|
PAPI
5.3.0.0
|
00001 00033 /* Open Issues: 00034 * Selecting events to add is very primitive right now. 00035 * Output format, right now the format targets a gnuplot script I have, 00036 * We will probably end up generating a csv per test 00037 */ 00038 #include <stdio.h> 00039 #include <stdlib.h> 00040 #include <string.h> 00041 #include <unistd.h> 00042 00043 #include "papi_test.h" 00044 #include "cost_utils.h" 00045 00046 static int first_time = 1; 00047 static int skip = 0; 00048 static FILE* fp; 00049 00050 typedef struct { 00051 int first_time; 00052 int force_sw; 00053 int kernel_mpx; 00054 int min; 00055 int max; 00056 } options_t; 00057 00058 static options_t options; 00059 00060 void 00061 do_output( char *fn, char *message, long long* array, int noc ) 00062 { 00063 long long min, max; 00064 double average, std; 00065 00066 std = do_stats( array, &min, &max, &average ); 00067 00068 if ( first_time ) { 00069 skip = 0; 00070 00071 fp = fopen(fn, "w"); 00072 if (fp == NULL) { 00073 fprintf(stderr,"Unable to open output file, %s, output will not be saved.\n", fn); 00074 skip = 1; 00075 } else 00076 fprintf(fp, "###%s\n#number of events\tmin cycles\tmax cycles\tmean cycles\t\ 00077 std deviation\tsw min cycles\tsw max cycles\tsw avg cycles\tsw std dev\n", message); 00078 00079 first_time = 0; 00080 } 00081 00082 if ( !skip ) { 00083 fprintf(fp, "%20d\t%10lld\t%10lld\t%10lf\t%10lf", noc, min, max, average, std); 00084 00085 std = do_stats( array+num_iters, &min, &max, &average ); 00086 fprintf(fp, "\t%10lld\t%10lld\t%10lf\t%10lf\n", min, max, average, std); 00087 fflush(fp); 00088 } 00089 } 00090 00091 void 00092 init_test(int SoftwareMPX, int KernelMPX, int* Events) 00093 { 00094 int i; 00095 int retval; 00096 PAPI_option_t option, itimer; 00097 00098 if ( ( retval = PAPI_assign_eventset_component( SoftwareMPX, 0 ) ) != PAPI_OK ) 00099 test_fail( __FILE__, __LINE__, "PAPI_assign_eventset_component", retval); 00100 00101 if ( ( retval = PAPI_assign_eventset_component( KernelMPX, 0 ) ) != PAPI_OK ) 00102 test_fail( __FILE__, __LINE__, "PAPI_assign_eventset_component", retval); 00103 00104 if ( ( retval = PAPI_set_multiplex( KernelMPX ) ) != PAPI_OK ) 00105 test_fail( __FILE__, __LINE__, "PAPI_set_multiplex", retval ); 00106 00107 PAPI_get_opt(PAPI_DEF_ITIMER,&itimer); 00108 00109 memset(&option,0x0,sizeof(option)); 00110 00111 option.multiplex.flags = PAPI_MULTIPLEX_FORCE_SW; 00112 option.multiplex.eventset = SoftwareMPX; 00113 option.multiplex.ns = itimer.itimer.ns; 00114 00115 if ( (retval = PAPI_set_opt( PAPI_MULTIPLEX, &option )) != PAPI_OK ) 00116 test_fail( __FILE__, __LINE__, "PAPI_set_opt", retval); 00117 00118 for (i = 0; i < options.min - 1; i++) { 00119 if ( options.kernel_mpx ) { 00120 if ( ( retval = PAPI_add_event( KernelMPX, Events[i]) ) != PAPI_OK ) { 00121 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval ); 00122 } 00123 } 00124 00125 if ( options.force_sw ) { 00126 if ( ( retval = PAPI_add_event( SoftwareMPX, Events[i]) ) != PAPI_OK ) { 00127 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval ); 00128 } 00129 } 00130 } 00131 } 00132 00133 void 00134 finalize_test(void) 00135 { 00136 if (fp) 00137 fclose(fp); 00138 first_time = 1; 00139 } 00140 00141 static void 00142 usage(void) 00143 { 00144 printf( "Usage: papi_multiplex_cost [options]\n\ 00145 \t-m num, number of events to count\n\ 00146 \t-x num, number of events to count\n\ 00147 \t-s, Do not run software multiplexing test.\n\ 00148 \t-k, Do not attempt kernel multiplexed test.\n\ 00149 \t-t THREASHOLD set the threshold for the number of iterations. Default: 100,000\n" ); 00150 } 00151 00152 int 00153 main( int argc, char **argv ) 00154 { 00155 int retval, retval_start, retval_stop; 00156 int KernelMPX = PAPI_NULL; 00157 int SoftwareMPX = PAPI_NULL; 00158 int *Events = NULL; 00159 int number_of_counters; 00160 int i; 00161 int c; 00162 int dont_loop_forever; 00163 long long totcyc, *values = NULL; 00164 long long *array = NULL; 00165 int event; 00166 00167 PAPI_option_t option, itimer; 00168 const PAPI_component_info_t *info; 00169 00170 tests_quiet( argc, argv ); 00171 00172 PAPI_set_debug(PAPI_QUIET); 00173 options.min = 1; 00174 options.max = 10; 00175 options.force_sw = 1; 00176 options.kernel_mpx = 1; 00177 00178 while ( ( c=getopt(argc, argv, "hm:x:skt:") ) != -1 ) { 00179 switch (c) { 00180 case 'h': 00181 usage(); 00182 exit(0); 00183 case 'm': 00184 options.min = atoi(optarg); 00185 break; 00186 case 'x': 00187 options.max = atoi(optarg); 00188 break; 00189 case 's': 00190 options.force_sw = 0; 00191 break; 00192 case 'k': 00193 options.kernel_mpx = 0; 00194 break; 00195 case 't': 00196 num_iters = atoi(optarg); 00197 default: 00198 break; 00199 } 00200 } 00201 00202 if ( options.min > options.max ) { 00203 test_fail( __FILE__, __LINE__, "Min # of Events > Max # of Events", -1); 00204 goto cleanup; 00205 } 00206 00207 values = (long long*)malloc(sizeof(long long) * options.max); 00208 array = (long long *)malloc(sizeof(long long) * 2 * num_iters); 00209 Events = ( int* )malloc(sizeof(int) * options.max); 00210 00211 if ( ( retval = 00212 PAPI_library_init( PAPI_VER_CURRENT ) ) != PAPI_VER_CURRENT ) 00213 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval ); 00214 if ( ( retval = PAPI_set_debug( PAPI_QUIET ) ) != PAPI_OK ) 00215 test_fail( __FILE__, __LINE__, "PAPI_set_debug", retval ); 00216 00217 if ( ( retval = PAPI_multiplex_init( ) ) != PAPI_OK ) 00218 test_fail( __FILE__, __LINE__, "PAPI_multiplex_init", retval ); 00219 00220 00221 info = PAPI_get_component_info(0); 00222 options.kernel_mpx &= info->kernel_multiplex; 00223 00224 if ( options.kernel_mpx && !info->kernel_multiplex ) { 00225 test_fail( __FILE__, __LINE__, "Kernel multiplexing is not supported on this platform, bailing!\n", PAPI_EINVAL ); 00226 exit(1); 00227 } 00228 00229 00230 if ( ( retval = PAPI_create_eventset( &SoftwareMPX ) ) != PAPI_OK ) 00231 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval ); 00232 00233 if ( ( retval = PAPI_create_eventset( &KernelMPX ) ) != PAPI_OK ) 00234 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval ); 00235 00236 if ( ( retval = PAPI_assign_eventset_component( KernelMPX, 0 ) ) != PAPI_OK ) 00237 test_fail( __FILE__, __LINE__, "PAPI_assign_eventset_component", retval); 00238 00239 if ( ( retval = PAPI_set_multiplex( KernelMPX ) ) != PAPI_OK ) 00240 test_fail( __FILE__, __LINE__, "PAPI_set_multiplex", retval ); 00241 00242 if ( ( retval = PAPI_assign_eventset_component( SoftwareMPX, 0 ) ) != PAPI_OK ) 00243 test_fail( __FILE__, __LINE__, "PAPI_assign_eventset_component", retval); 00244 00245 PAPI_get_opt(PAPI_DEF_ITIMER,&itimer); 00246 00247 memset(&option,0x0,sizeof(option)); 00248 00249 option.multiplex.flags = PAPI_MULTIPLEX_FORCE_SW; 00250 option.multiplex.eventset = SoftwareMPX; 00251 option.multiplex.ns = itimer.itimer.ns; 00252 00253 if ( PAPI_OK != (retval = PAPI_set_opt( PAPI_MULTIPLEX, &option ))) 00254 test_fail( __FILE__, __LINE__, "PAPI_set_opt", retval); 00255 00256 if ( !options.kernel_mpx && !options.force_sw ) { 00257 test_fail(__FILE__, __LINE__, "No tests to run.", -1); 00258 goto cleanup; 00259 } else { 00260 fprintf(stderr,"Running test[s]\n"); 00261 if (options.kernel_mpx) 00262 fprintf(stderr,"\tKernel multiplexing read\n"); 00263 if (options.force_sw) 00264 fprintf(stderr,"\tSoftware Multiplexing read\n"); 00265 } 00266 00267 event = 0 | PAPI_NATIVE_MASK; 00268 PAPI_enum_event( &event, PAPI_ENUM_FIRST ); 00269 00270 /* Find some events to run the tests with. */ 00271 for (number_of_counters = 0; number_of_counters < options.max; number_of_counters++) { 00272 dont_loop_forever = 0; 00273 00274 if ( options.kernel_mpx ) { 00275 do { 00276 PAPI_enum_event( &event, PAPI_ENUM_EVENTS ); 00277 dont_loop_forever++; 00278 } while ( ( retval = PAPI_add_event( KernelMPX, event ) ) != PAPI_OK && 00279 dont_loop_forever < 512); 00280 } else { 00281 do { 00282 PAPI_enum_event( &event, PAPI_ENUM_EVENTS ); 00283 dont_loop_forever++; 00284 } while ( ( retval = PAPI_add_event( SoftwareMPX, event) ) != PAPI_OK && 00285 dont_loop_forever < 512); 00286 } 00287 if ( dont_loop_forever == 512 ) 00288 test_fail( __FILE__, __LINE__, "I can't find %d events to count at once.", options.max); 00289 00290 Events[number_of_counters] = event; 00291 } 00292 00293 PAPI_cleanup_eventset( KernelMPX ); 00294 PAPI_cleanup_eventset( SoftwareMPX ); 00295 00296 /* Start/Stop test */ 00297 init_test(SoftwareMPX, KernelMPX, Events); 00298 00299 for (number_of_counters = options.min; number_of_counters < options.max; number_of_counters++) { 00300 00301 if ( options.kernel_mpx ) { 00302 if ( ( retval = PAPI_add_event( KernelMPX, Events[number_of_counters - options.min] ) ) != PAPI_OK ) { 00303 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval); 00304 goto cleanup; 00305 } 00306 00307 if ( ( retval = PAPI_start( KernelMPX ) ) != PAPI_OK ) 00308 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00309 if ( ( retval = PAPI_stop( KernelMPX, values ) ) != PAPI_OK ) 00310 test_fail( __FILE__, __LINE__, "PAPI_stop", retval ); 00311 00312 /* KernelMPX Timing loop */ 00313 for ( i = 0; i < num_iters; i++ ) { 00314 totcyc = PAPI_get_real_cyc(); 00315 retval_start=PAPI_start( KernelMPX ); 00316 retval_stop=PAPI_stop( KernelMPX, values ); 00317 array[i] = PAPI_get_real_cyc() - totcyc; 00318 if (retval_start || retval_stop) 00319 test_fail( __FILE__, __LINE__, "PAPI start/stop", retval_start ); 00320 } /* End 1 timing run */ 00321 00322 } else 00323 memset(array, 0, sizeof(long long) * num_iters ); 00324 00325 /* Also test software multiplexing */ 00326 if ( options.force_sw ) { 00327 if ( ( retval = PAPI_add_event( SoftwareMPX, Events[number_of_counters - options.min] ) ) != PAPI_OK ) { 00328 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval); 00329 goto cleanup; 00330 } 00331 00332 if ( ( retval = PAPI_start( SoftwareMPX ) ) != PAPI_OK ) 00333 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00334 if ( ( retval = PAPI_stop( SoftwareMPX, values ) ) != PAPI_OK ) 00335 test_fail( __FILE__, __LINE__, "PAPI_stop", retval); 00336 00337 /* SoftwareMPX Timing Loop */ 00338 for ( i = num_iters; i < 2*num_iters; i++ ) { 00339 totcyc = PAPI_get_real_cyc(); 00340 retval_start=PAPI_start( SoftwareMPX ); 00341 retval_stop=PAPI_stop( SoftwareMPX, values ); 00342 array[i] = PAPI_get_real_cyc() - totcyc; 00343 if (retval_start || retval_stop) 00344 test_fail( __FILE__, __LINE__, "PAPI start/stop", retval_start ); 00345 } /* End 2 timing run */ 00346 00347 } else 00348 memset(array+num_iters, 0, sizeof(long long) * num_iters ); 00349 00350 do_output( "papi_startstop.dat", "Multiplexed PAPI_read()", array, number_of_counters ); 00351 00352 } /* End counter loop */ 00353 PAPI_cleanup_eventset( SoftwareMPX ); 00354 PAPI_cleanup_eventset( KernelMPX ); 00355 finalize_test(); 00356 00357 /* PAPI_read() test */ 00358 init_test(SoftwareMPX, KernelMPX, Events); 00359 00360 for (number_of_counters = options.min; number_of_counters < options.max; number_of_counters++) { 00361 00362 if ( options.kernel_mpx ) { 00363 if ( ( retval = PAPI_add_event( KernelMPX, Events[number_of_counters - options.min] ) ) != PAPI_OK ) { 00364 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval); 00365 goto cleanup; 00366 } 00367 00368 if ( ( retval = PAPI_start( KernelMPX ) ) != PAPI_OK ) 00369 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00370 PAPI_read( KernelMPX, values ); 00371 00372 /* KernelMPX Timing loop */ 00373 for ( i = 0; i < num_iters; i++ ) { 00374 totcyc = PAPI_get_real_cyc(); 00375 retval = PAPI_read( KernelMPX, values ); 00376 array[i] = PAPI_get_real_cyc() - totcyc; 00377 } /* End 1 timing run */ 00378 00379 retval_stop=PAPI_stop( KernelMPX, values ); 00380 if (retval_stop!=PAPI_OK) 00381 test_fail( __FILE__, __LINE__, "PAPI_stop", retval_stop ); 00382 } else 00383 memset(array, 0, sizeof(long long) * num_iters ); 00384 00385 /* Also test software multiplexing */ 00386 if ( options.force_sw ) { 00387 if ( ( retval = PAPI_add_event( SoftwareMPX, Events[number_of_counters - options.min] ) ) != PAPI_OK ) { 00388 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval); 00389 goto cleanup; 00390 } 00391 00392 if ( ( retval = PAPI_start( SoftwareMPX ) ) != PAPI_OK ) 00393 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00394 PAPI_read( SoftwareMPX, values ); 00395 00396 /* SoftwareMPX Timing Loop */ 00397 for ( i = num_iters; i < 2*num_iters; i++ ) { 00398 totcyc = PAPI_get_real_cyc(); 00399 retval = PAPI_read( SoftwareMPX, values ); 00400 array[i] = PAPI_get_real_cyc() - totcyc; 00401 } /* End 2 timing run */ 00402 00403 retval_stop=PAPI_stop( SoftwareMPX, values ); 00404 if (retval_stop!=PAPI_OK) 00405 test_fail( __FILE__, __LINE__, "PAPI_stop", retval_stop ); 00406 } else 00407 memset(array+num_iters, 0, sizeof(long long) * num_iters ); 00408 00409 do_output( "papi_read.dat", "Multiplexed PAPI_read()", array, number_of_counters ); 00410 00411 } /* End counter loop */ 00412 PAPI_cleanup_eventset( SoftwareMPX ); 00413 PAPI_cleanup_eventset( KernelMPX ); 00414 finalize_test(); 00415 00416 00417 00418 /* PAPI_read_ts() test */ 00419 init_test( SoftwareMPX, KernelMPX, Events); 00420 00421 for (number_of_counters = options.min; number_of_counters < options.max; number_of_counters++) { 00422 00423 if ( options.kernel_mpx ) { 00424 if ( (retval = PAPI_add_event( KernelMPX, Events[number_of_counters - options.min] ) ) != PAPI_OK ) { 00425 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval); 00426 goto cleanup; 00427 } 00428 00429 if ( ( retval = PAPI_start( KernelMPX ) ) != PAPI_OK ) 00430 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00431 PAPI_read_ts( KernelMPX, values, &totcyc ); 00432 00433 /* KernelMPX Timing loop */ 00434 for ( i = 0; i < num_iters; i++ ) { 00435 retval = PAPI_read_ts( KernelMPX, values, &array[i] ); 00436 } /* End 1 timing run */ 00437 00438 /* post-process the timing array */ 00439 for ( i = num_iters - 1; i > 0; i-- ) { 00440 array[i] -= array[i - 1]; 00441 } 00442 array[0] -= totcyc; 00443 00444 retval_stop=PAPI_stop( KernelMPX, values ); 00445 if (retval_stop!=PAPI_OK) 00446 test_fail( __FILE__, __LINE__, "PAPI_stop", retval_stop ); 00447 } else 00448 memset(array, 0, sizeof(long long) * num_iters ); 00449 00450 /* Also test software multiplexing */ 00451 if ( options.force_sw ) { 00452 if ( ( retval = PAPI_add_event( SoftwareMPX, Events[number_of_counters - options.min] ) ) != PAPI_OK ) { 00453 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval); 00454 goto cleanup; 00455 } 00456 00457 if ( ( retval = PAPI_start( SoftwareMPX ) ) != PAPI_OK ) 00458 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00459 PAPI_read_ts( SoftwareMPX, values, &totcyc); 00460 00461 /* SoftwareMPX Timing Loop */ 00462 for ( i = num_iters; i < 2*num_iters; i++ ) { 00463 retval = PAPI_read_ts( SoftwareMPX, values, &array[i]); 00464 } /* End 2 timing run */ 00465 00466 retval_stop=PAPI_stop( SoftwareMPX, values ); 00467 if (retval_stop!=PAPI_OK) 00468 test_fail( __FILE__, __LINE__, "PAPI_stop", retval_stop ); 00469 00470 /* post-process the timing array */ 00471 for ( i = 2*num_iters - 1; i > num_iters; i-- ) { 00472 array[i] -= array[i - 1]; 00473 } 00474 array[num_iters] -= totcyc; 00475 00476 } else 00477 memset(array+num_iters, 0, sizeof(long long) * num_iters ); 00478 00479 do_output( "papi_read_ts.dat", "Multiplexed PAPI_read_ts()", array, number_of_counters ); 00480 00481 } /* End counter loop */ 00482 PAPI_cleanup_eventset( SoftwareMPX ); 00483 PAPI_cleanup_eventset( KernelMPX ); 00484 finalize_test(); 00485 00486 00487 /* PAPI_accum() test */ 00488 init_test(SoftwareMPX, KernelMPX, Events); 00489 00490 for (number_of_counters = options.min; number_of_counters < options.max; number_of_counters++) { 00491 00492 if ( options.kernel_mpx ) { 00493 if ( ( retval = PAPI_add_event( KernelMPX, Events[number_of_counters - options.min] ) ) != PAPI_OK ) { 00494 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval); 00495 goto cleanup; 00496 } 00497 00498 if ( ( retval = PAPI_start( KernelMPX ) ) != PAPI_OK ) 00499 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00500 PAPI_read( KernelMPX, values ); 00501 00502 /* KernelMPX Timing loop */ 00503 for ( i = 0; i < num_iters; i++ ) { 00504 totcyc = PAPI_get_real_cyc(); 00505 retval = PAPI_accum( KernelMPX, values ); 00506 array[i] = PAPI_get_real_cyc() - totcyc; 00507 } /* End 1 timing run */ 00508 00509 retval_stop=PAPI_stop( KernelMPX, values ); 00510 if (retval_stop!=PAPI_OK) 00511 test_fail( __FILE__, __LINE__, "PAPI_stop", retval_stop ); 00512 } else 00513 memset(array, 0, sizeof(long long) * num_iters ); 00514 00515 /* Also test software multiplexing */ 00516 if ( options.force_sw ) { 00517 if ( ( retval = PAPI_add_event( SoftwareMPX, Events[number_of_counters - options.min] ) ) != PAPI_OK ) { 00518 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval); 00519 goto cleanup; 00520 } 00521 00522 if ( ( retval = PAPI_start( SoftwareMPX ) ) != PAPI_OK ) 00523 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00524 PAPI_read( SoftwareMPX, values ); 00525 00526 /* SoftwareMPX Timing Loop */ 00527 for ( i = num_iters; i < 2*num_iters; i++ ) { 00528 totcyc = PAPI_get_real_cyc(); 00529 retval = PAPI_accum( SoftwareMPX, values ); 00530 array[i] = PAPI_get_real_cyc() - totcyc; 00531 } /* End 2 timing run */ 00532 00533 retval_stop=PAPI_stop( SoftwareMPX, values ); 00534 if (retval_stop!=PAPI_OK) 00535 test_fail( __FILE__, __LINE__, "PAPI_stop", retval_stop ); 00536 } else 00537 memset(array+num_iters, 0, sizeof(long long) * num_iters ); 00538 00539 do_output( "papi_accum.dat", "Multiplexed PAPI_accum()", array, number_of_counters ); 00540 00541 } /* End counter loop */ 00542 PAPI_cleanup_eventset( SoftwareMPX ); 00543 PAPI_cleanup_eventset( KernelMPX ); 00544 finalize_test(); 00545 00546 /* PAPI_reset() test */ 00547 init_test(SoftwareMPX, KernelMPX, Events); 00548 00549 for (number_of_counters = options.min; number_of_counters < options.max; number_of_counters++) { 00550 00551 if ( options.kernel_mpx ) { 00552 if ( ( retval = PAPI_add_event( KernelMPX, Events[number_of_counters - options.min] ) ) != PAPI_OK ) { 00553 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval); 00554 goto cleanup; 00555 } 00556 00557 if ( ( retval = PAPI_start( KernelMPX ) ) != PAPI_OK ) 00558 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00559 PAPI_read( KernelMPX, values ); 00560 00561 /* KernelMPX Timing loop */ 00562 for ( i = 0; i < num_iters; i++ ) { 00563 totcyc = PAPI_get_real_cyc(); 00564 retval = PAPI_reset( KernelMPX ); 00565 array[i] = PAPI_get_real_cyc() - totcyc; 00566 } /* End 1 timing run */ 00567 00568 retval_stop=PAPI_stop( KernelMPX, values ); 00569 if (retval_stop!=PAPI_OK) 00570 test_fail( __FILE__, __LINE__, "PAPI_stop", retval_stop ); 00571 } else 00572 memset(array, 0, sizeof(long long) * num_iters ); 00573 00574 /* Also test software multiplexing */ 00575 if ( options.force_sw ) { 00576 if ( ( retval = PAPI_add_event( SoftwareMPX, Events[number_of_counters - options.min] ) ) != PAPI_OK ) { 00577 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval); 00578 goto cleanup; 00579 } 00580 00581 if ( ( retval = PAPI_start( SoftwareMPX ) ) != PAPI_OK ) 00582 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00583 PAPI_read( SoftwareMPX, values ); 00584 00585 /* SoftwareMPX Timing Loop */ 00586 for ( i = num_iters; i < 2*num_iters; i++ ) { 00587 totcyc = PAPI_get_real_cyc(); 00588 retval = PAPI_reset( SoftwareMPX ); 00589 array[i] = PAPI_get_real_cyc() - totcyc; 00590 } /* End 2 timing run */ 00591 00592 retval_stop=PAPI_stop( SoftwareMPX, values ); 00593 if (retval_stop!=PAPI_OK) 00594 test_fail( __FILE__, __LINE__, "PAPI_stop", retval_stop ); 00595 } else 00596 memset(array+num_iters, 0, sizeof(long long) * num_iters ); 00597 00598 do_output( "papi_reset.dat", "Multiplexed PAPI_reset()", array, number_of_counters ); 00599 00600 } /* End counter loop */ 00601 PAPI_cleanup_eventset( SoftwareMPX ); 00602 PAPI_cleanup_eventset( KernelMPX ); 00603 finalize_test(); 00604 00605 00606 test_pass( __FILE__, NULL, 0 ); 00607 cleanup: 00608 if ( KernelMPX != PAPI_NULL) 00609 PAPI_cleanup_eventset( KernelMPX ); 00610 if ( SoftwareMPX != PAPI_NULL ) 00611 PAPI_cleanup_eventset( KernelMPX ); 00612 00613 if ( values != NULL ) 00614 free(values); 00615 if ( array != NULL ) 00616 free(array); 00617 if ( Events != NULL ) 00618 free(Events); 00619 00620 PAPI_shutdown(); 00621 exit( 1 ); 00622 }