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