[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patches] Re: Possible PowerPC LIBC optimization




Here is my corrected benchmark program
#include <stdio.h>
#include <memory.h>
#include <stdlib.h> #define NUM_OF_LINES 1024
/* for a 32k datacache */
int data_cache_flush_array[8193];

int thrash_the_cache(int up_down)
{
int i;
if (up_down) {
 i = 0;
 do{
   data_cache_flush_array[i*8] = data_cache_flush_array [(i+1)*8];
 }while (i++ < NUM_OF_LINES - 2);
} else {
i =  NUM_OF_LINES - 1;
 do{
   data_cache_flush_array[(i+1)*8] = data_cache_flush_array [i*8];
 }while (i-- > 0);
} return i; } int main(void){
int x,y,z;
char *mem;
int x1,y1,z1;
char *mem1;
int x2,y2,z2;
char *mem2;
int x3,y3,z3;
char *mem3;
z= 8192;
do{
data_cache_flush_array[z]=z;
}while(z--);

srandom(7);
x = 65535;
x1 = 512;
x2 = 4096;
x3 = 256; y = 1000; do {
  thrash_the_cache(1);
  z = random() % x;
  mem = malloc(z);
  if(z) mem[z-1] = 0x3f;
  y1 = 100;
  do {
 do {
    thrash_the_cache(0);
    z1 = random() % x1;
    mem1 = malloc(z1);
    if(z1) mem1[z1-1] = 0x3f;
    y2 = 100;
    do {
      thrash_the_cache(1);
      z2 = random() % x;
      mem2 = malloc(z2);
      if(z2) mem2[z2-1] = 0x3f;
      y3 = 100;
      do {
        thrash_the_cache(0);
        z3 = random() % x3;
        mem3 = malloc(z3);
        if(z3) mem3[z3-1] = 0x3f;
        thrash_the_cache(1);
        free(mem3);
}while( (--y3));
      thrash_the_cache(0);
      free(mem2);
}while( (--y2));
    thrash_the_cache(1);
    free(mem1);
}while( (--y1));

  thrash_the_cache(0);
  free(mem);
}while( (--y));

return 1;
}



Conn Clark writes:
There are some further optimizations I'm playing with. I have added one more dcbt to the public_free function. I am also playing around with reorganizing the mp_ data structure to take into account cache filling.


<SNIP>

Conn
---------------------------------------
Conn Clark
Electronic Systems Technology
415 N. Quay Street Building B1     (509)-735-9092 ext 117
Kennewick, WA. 99336
Observation: In formal computer science advances are made
by standing on the shoulders of giants. Linux has proved
that if there are enough of you, you can advance just as
far by standing on each others toes.



---------------------------------------
Conn Clark
Electronic Systems Technology
415 N. Quay Street Building B1     (509)-735-9092 ext 117
Kennewick, WA. 99336
Observation: In formal computer science advances are made
by standing on the shoulders of giants. Linux has proved
that if there are enough of you, you can advance just as
far by standing on each others toes.