Changeset 119
- Timestamp:
- 06/02/10 13:15:24 (3 years ago)
- File:
-
- 1 edited
-
trunk/bench/bench.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bench/bench.c
r118 r119 6 6 coming from a file" comment). 7 7 8 To compile using GCC, go to src/directory and do:8 To compile using GCC, stay in this directory and do: 9 9 10 10 gcc -O3 -msse2 -o bench bench.c \ … … 35 35 36 36 #define KB 1024 37 #define MB (1024*1024) 38 39 /* #define NCHUNKS (100) */ 40 /* #define NITER (10) /\* Number of iterations *\/ */ 41 #define NCHUNKS (128) 42 #define NITER (10) /* Number of iterations */ 43 37 #define MB (1024*KB) 38 #define GB (1024*MB) 39 40 #define WORKINGSET (256*MB) /* do not exceed this memory consumption */ 41 #define NCHUNKS (32*1024) /* maximum number of chunks */ 42 #define NITER 3 /* number of iterations */ 43 44 45 int nchunks = NCHUNKS; 46 int niter = NITER; 44 47 45 48 #if defined(_WIN32) && !defined(__MINGW32__) … … 100 103 sec = current.tv_sec - last.tv_sec; 101 104 usec = current.tv_usec - last.tv_usec; 102 return (float)(((double)sec + usec*1e-6)/((double) NITER*NCHUNKS)*1e6);105 return (float)(((double)sec + usec*1e-6)/((double)niter*nchunks)*1e6); 103 106 } 104 107 … … 154 157 init_buffer(src, size, rshift); 155 158 memcpy(srccpy, src, size); 156 for (j = 0; j < NCHUNKS; j++) {159 for (j = 0; j < nchunks; j++) { 157 160 dest[j] = malloc(size); 158 161 } 159 162 160 163 /* Warm destination memory (memcpy() will go a bit faster later on) */ 161 for (j = 0; j < NCHUNKS; j++) {164 for (j = 0; j < nchunks; j++) { 162 165 memcpy(dest[j], src, size); 163 166 } … … 168 171 printf("Using synthetic data with %d significant bits (out of 32)\n", rshift); 169 172 printf("Dataset size: %d bytes\tType size: %d bytes\n", size, elsize); 170 printf("Working set: %.1f MB\t\t", (size* NCHUNKS) / (float)MB);173 printf("Working set: %.1f MB\t\t", (size*nchunks) / (float)MB); 171 174 printf("Number of threads: %d\n", nthreads); 172 175 printf("********************** Running benchmarks *********************\n"); 173 176 174 177 gettimeofday(&last, NULL); 175 for (i = 0; i < NITER; i++) {176 for (j = 0; j < NCHUNKS; j++) {178 for (i = 0; i < niter; i++) { 179 for (j = 0; j < nchunks; j++) { 177 180 memcpy(dest[j], src, size); 178 181 } … … 184 187 185 188 gettimeofday(&last, NULL); 186 for (i = 0; i < NITER; i++) {187 for (j = 0; j < NCHUNKS; j++) {189 for (i = 0; i < niter; i++) { 190 for (j = 0; j < nchunks; j++) { 188 191 memcpy(dest2, dest[j], size); 189 192 } … … 199 202 200 203 gettimeofday(&last, NULL); 201 for (i = 0; i < NITER; i++) {202 for (j = 0; j < NCHUNKS; j++) {204 for (i = 0; i < niter; i++) { 205 for (j = 0; j < nchunks; j++) { 203 206 cbytes = blosc_compress(clevel, doshuffle, elsize, size, src, dest[j]); 204 207 } … … 216 219 /* Compressor was unable to compress. Copy the buffer manually. */ 217 220 if (cbytes == 0) { 218 for (j = 0; j < NCHUNKS; j++) {221 for (j = 0; j < nchunks; j++) { 219 222 memcpy(dest[j], src, size); 220 223 } … … 222 225 223 226 gettimeofday(&last, NULL); 224 for (i = 0; i < NITER; i++) {225 for (j = 0; j < NCHUNKS; j++) {227 for (i = 0; i < niter; i++) { 228 for (j = 0; j < nchunks; j++) { 226 229 if (cbytes == 0) { 227 230 memcpy(dest2, dest[j], size); … … 259 262 260 263 free(src); free(srccpy); free(dest2); 261 for (i = 0; i < NCHUNKS; i++) {264 for (i = 0; i < nchunks; i++) { 262 265 free(dest[i]); 263 266 } 264 267 268 } 269 270 271 /* Compute a sensible value for nchunks */ 272 int get_nchunks(unsigned int size_) { 273 int nchunks; 274 275 nchunks = WORKINGSET / size_; 276 if (nchunks > NCHUNKS) nchunks = NCHUNKS; 277 if (nchunks < 1) nchunks = 1; 278 return nchunks; 265 279 } 266 280 … … 269 283 int suite = 0; 270 284 int hard_suite = 0; 271 int nthreads = 1; /* The number of threads */ 272 unsigned int size = 2*1024*1024; /* Buffer size */ 273 unsigned int elsize = 8; /* Datatype size */ 274 int rshift = 19; /* Significant bits */ 285 int nloops = 0; 286 float totalsize; 287 int nthreads = 1; /* The number of threads */ 288 unsigned int size = 2*1024*1024; /* Buffer size */ 289 unsigned int elsize = 8; /* Datatype size */ 290 int rshift = 19; /* Significant bits */ 275 291 int j; 276 292 … … 293 309 if (argc >= 3) { 294 310 size = atoi(argv[2])*1024; 295 if (size > 2*1024*1024) {296 printf("The test is going to require more than 256 MB of RAM!\n");297 }298 311 } 299 312 if (argc >= 4) { … … 309 322 } 310 323 324 nchunks = get_nchunks(size); 325 311 326 if (hard_suite) { 312 for (j=1; j <= nthreads; j++) { 313 for (size=64*KB; size <= 8*MB; size *=2) { 314 for (elsize=1; elsize < 32; elsize *=2) { 315 for (rshift=0; rshift < 32; rshift +=5) { 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++) { 316 332 do_bench(j, size, elsize, rshift); 333 nloops++; 317 334 } 318 335 } 319 336 } 320 337 } 338 /* To compute the totalsize, we should take into account the 9 339 compression levels */ 340 totalsize = (1. * nloops * WORKINGSET * NITER * 9) / GB; 341 printf("Performed round-trip compr/decompr on %.1f GB", totalsize); 321 342 } 322 343 else if (suite) {
Note: See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/images/blosc-logo-small.png)