Changeset 122


Ignore:
Timestamp:
06/03/10 05:04:09 (3 years ago)
Author:
faltet
Message:

The hardsuite has been heavily modified in order to run in acceptable times.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bench/bench.c

    r119 r122  
    3838#define GB  (1024*MB) 
    3939 
    40 #define WORKINGSET (256*MB)     /* do not exceed this memory consumption */ 
     40#define WORKINGSET (256*MB)     /* working set for normal operation */ 
     41#define WORKINGSET_H (64*MB)    /* working set for hardsuite operation */ 
    4142#define NCHUNKS (32*1024)       /* maximum number of chunks */ 
    42 #define NITER  3                /* number of iterations */ 
     43#define NITER  3                /* number of iterations for normal operation */ 
    4344 
    4445 
     
    103104  sec = current.tv_sec - last.tv_sec; 
    104105  usec = current.tv_usec - last.tv_usec; 
    105   return (float)(((double)sec + usec*1e-6)/((double)niter*nchunks)*1e6); 
     106  return (float)(((double)sec + usec*1e-6)); 
     107} 
     108 
     109/* Given two timeval stamps, return the time per chunk in usec */ 
     110float get_usec_chunk(struct timeval last, struct timeval current) { 
     111  return (float)(getseconds(last, current)/(niter*nchunks)*1e6); 
    106112} 
    107113 
     
    182188  } 
    183189  gettimeofday(&current, NULL); 
    184   tmemcpy = getseconds(last, current); 
     190  tmemcpy = get_usec_chunk(last, current); 
    185191  printf("memcpy(write):\t\t %6.1f us, %.1f MB/s\n", 
    186192         tmemcpy, size/(tmemcpy*MB/1e6)); 
     
    193199  } 
    194200  gettimeofday(&current, NULL); 
    195   tmemcpy = getseconds(last, current); 
     201  tmemcpy = get_usec_chunk(last, current); 
    196202  printf("memcpy(read):\t\t %6.1f us, %.1f MB/s\n", 
    197203         tmemcpy, size/(tmemcpy*MB/1e6)); 
     
    208214    } 
    209215    gettimeofday(&current, NULL); 
    210     tshuf = getseconds(last, current); 
     216    tshuf = get_usec_chunk(last, current); 
    211217    printf("comp(write):\t %6.1f us, %.1f MB/s\t  ", 
    212218           tshuf, size/(tshuf*MB/1e6)); 
     
    237243    } 
    238244    gettimeofday(&current, NULL); 
    239     tunshuf = getseconds(last, current); 
     245    tunshuf = get_usec_chunk(last, current); 
    240246    printf("decomp(read):\t %6.1f us, %.1f MB/s\t  ", 
    241247           tunshuf, nbytes/(tunshuf*MB/1e6)); 
     
    270276 
    271277/* Compute a sensible value for nchunks */ 
    272 int get_nchunks(unsigned int size_) { 
     278int get_nchunks(int size_, int ws) { 
    273279  int nchunks; 
    274280 
    275   nchunks = WORKINGSET / size_; 
     281  nchunks = ws / size_; 
    276282  if (nchunks > NCHUNKS) nchunks = NCHUNKS; 
    277283  if (nchunks < 1) nchunks = 1; 
     
    286292  float totalsize; 
    287293  int nthreads = 1;                    /* The number of threads */ 
    288   unsigned int size = 2*1024*1024;     /* Buffer size */ 
    289   unsigned int elsize = 8;             /* Datatype size */ 
     294  int size = 2*1024*1024;              /* Buffer size */ 
     295  int elsize = 8;                      /* Datatype size */ 
    290296  int rshift = 19;                     /* Significant bits */ 
    291   int j; 
     297  int i, j; 
     298  struct timeval last, current; 
     299  float totaltime; 
    292300 
    293301  if ((argc >= 2) && (strcmp(argv[1], "suite") == 0)) { 
     
    297305    } 
    298306  } 
    299   else if ((argc >= 2) && (strcmp(argv[1], "hard_suite") == 0)) { 
     307  else if ((argc >= 2) && (strcmp(argv[1], "hardsuite") == 0)) { 
    300308    hard_suite = 1; 
    301309    if (argc == 3) { 
     
    317325    } 
    318326    if (argc >= 6) { 
    319       printf("Usage: bench 'suite' [nthreads] | 'hard_suite' [nthreads] | [nthreads [bufsize(KB) [typesize [sbits ]]]]\n"); 
     327      printf("Usage: bench 'suite' [nthreads] | 'hardsuite' [nthreads] | [nthreads [bufsize(KB) [typesize [sbits ]]]]\n"); 
    320328      exit(1); 
    321329    } 
    322330  } 
    323331 
    324   nchunks = get_nchunks(size); 
     332  nchunks = get_nchunks(size, WORKINGSET); 
    325333 
    326334  if (hard_suite) { 
    327     for (rshift=0; rshift < 32; rshift +=5) { 
    328       for (elsize=1; elsize <= 32; elsize *=2) { 
    329         for (size=32*KB; size <= 8*MB; size *=2) { 
    330           nchunks = get_nchunks(size); 
    331           for (j=1; j <= nthreads; j++) { 
    332             do_bench(j, size, elsize, rshift); 
    333             nloops++; 
     335    gettimeofday(&last, NULL); 
     336    for (rshift = 0; rshift < 32; rshift += 5) { 
     337      for (elsize = 1; elsize <= 32; elsize *= 2) { 
     338        /* The next loop is for getting sizes that are not power of 2 */ 
     339        for (i = -elsize; i <= elsize; i += elsize) { 
     340          for (size = 32*KB; size <= 8*MB; size *= 2) { 
     341            nchunks = get_nchunks(size+i, WORKINGSET_H); 
     342            niter = 1; 
     343            for (j=1; j <= nthreads; j++) { 
     344              do_bench(j, size+i, elsize, rshift); 
     345              nloops++; 
     346            } 
    334347          } 
    335348        } 
     
    338351    /* To compute the totalsize, we should take into account the 9 
    339352       compression levels */ 
    340     totalsize = (1. * nloops * WORKINGSET * NITER * 9) / GB; 
    341     printf("Performed round-trip compr/decompr on %.1f GB", totalsize); 
     353    gettimeofday(&current, NULL); 
     354    totalsize = (1. * nloops * (WORKINGSET_H) * NITER * 9) / GB; 
     355    printf("\nRound-trip compr/decompr on %.1f GB\n", totalsize); 
     356    totaltime = getseconds(last, current); 
     357    printf("Elapsed time:\t %6.1f s, %.1f MB/s\n", 
     358           totaltime, totalsize*KB/totaltime); 
    342359  } 
    343360  else if (suite) { 
Note: See TracChangeset for help on using the changeset viewer.