74 fprintf(
stderr,
"Unable to open output file, %s, output will not be saved.\n", fn);
77 fprintf(
fp,
"###%s\n#number of events\tmin cycles\tmax cycles\tmean cycles\t\
78std deviation\tsw min cycles\tsw max cycles\tsw avg cycles\tsw std dev\n", message);
84 fprintf(
fp,
"%20d\t%10lld\t%10lld\t%10lf\t%10lf", noc,
min, max, average, std);
87 fprintf(
fp,
"\t%10lld\t%10lld\t%10lf\t%10lf\n",
min, max, average, std);
93init_test(
int SoftwareMPX,
int KernelMPX,
int* Events)
101 fprintf(
stderr,
"Error! PAPI_assign_eventset_component\n");
107 fprintf(
stderr,
"Error! PAPI_assign_eventset_component\n");
113 fprintf(
stderr,
"Error! PAPI_set_multiplex\n");
119 memset(&option,0x0,
sizeof(option));
127 fprintf(
stderr,
"Error! PAPI_set_opt\n");
135 fprintf(
stderr,
"Error! PAPI_add_event\n");
143 fprintf(
stderr,
"Error! PAPI_add_event\n");
160 printf(
"Usage: papi_multiplex_cost [options]\n"
161 "\t-m num, number of events to count\n"
162 "\t-x num, number of events to count\n"
163 "\t-s, Do not run software multiplexing test.\n"
164 "\t-k, Do not attempt kernel multiplexed test.\n"
165 "\t-t THRESHOLD set the threshold for the number "
166 "of iterations. Default: 100,000\n" );
172 int retval, retval_start, retval_stop;
176 int number_of_counters;
179 int dont_loop_forever;
180 long long totcyc, *
values = NULL;
181 long long *
array = NULL;
193 while ( (
c=getopt(argc, argv,
"hm:x:skt:") ) != -1 ) {
217 printf(
"This utility benchmarks the overhead of PAPI multiplexing\n");
218 printf(
"Warning! This can take a long time (many minutes) to run\n");
219 printf(
"The output goes to multiple .dat files in the current directory\n\n");
222 fprintf(
stderr,
"Error! Min # of Events > Max # of Events");
228 Events = (
int* )malloc(
sizeof(
int) *
options.
max);
230 if (
values == NULL ||
array == NULL || Events == NULL ) {
231 fprintf(
stderr,
"Error allocating memory!\n");
237 fprintf(
stderr,
"Error! PAPI_library_init\n");
243 fprintf(
stderr,
"Error! PAPI_set_debug\n");
249 fprintf(
stderr,
"Error! PAPI_multiplex_init\n");
257 fprintf(
stderr,
"Error! Kernel multiplexing is "
258 "not supported on this platform, bailing!\n");
264 fprintf(
stderr,
"Error! PAPI_create_eventset\n");
270 fprintf(
stderr,
"PAPI_create_eventset");
276 fprintf(
stderr,
"PAPI_assign_eventset_component");
282 fprintf(
stderr,
"PAPI_set_multiplex");
288 fprintf(
stderr,
"PAPI_assign_eventset_component");
294 memset(&option,0x0,
sizeof(option));
302 fprintf(
stderr,
"PAPI_set_opt");
307 fprintf(
stderr,
"No tests to run.");
310 fprintf(
stderr,
"Running test[s]\n");
312 fprintf(
stderr,
"\tKernel multiplexing read\n");
314 fprintf(
stderr,
"\tSoftware Multiplexing read\n");
321 for (number_of_counters = 0; number_of_counters <
options.
max; number_of_counters++) {
322 dont_loop_forever = 0;
329 dont_loop_forever < 512);
335 dont_loop_forever < 512);
337 if ( dont_loop_forever == 512 )
340 Events[number_of_counters] = event;
347 init_test(SoftwareMPX, KernelMPX, Events);
349 for (number_of_counters =
options.
min; number_of_counters <
options.
max; number_of_counters++) {
353 fprintf(
stderr,
"PAPI_add_event");
358 fprintf(
stderr,
"PAPI_start");
362 fprintf(
stderr,
"PAPI_stop");
372 if (retval_start || retval_stop)
373 fprintf(
stderr,
"PAPI start/stop");
382 fprintf(
stderr,
"PAPI_add_event");
387 fprintf(
stderr,
"PAPI_start");
391 fprintf(
stderr,
"PAPI_stop");
401 if (retval_start || retval_stop)
402 fprintf(
stderr,
"PAPI start/stop");
409 do_output(
"papi_startstop.dat",
"Multiplexed PAPI_read()",
array, number_of_counters );
417 init_test(SoftwareMPX, KernelMPX, Events);
419 for (number_of_counters =
options.
min; number_of_counters <
options.
max; number_of_counters++) {
423 fprintf(
stderr,
"PAPI_add_event");
428 fprintf(
stderr,
"PAPI_start");
442 fprintf(
stderr,
"PAPI_stop");
449 fprintf(
stderr,
"PAPI_add_event");
454 fprintf(
stderr,
"PAPI_start");
468 fprintf(
stderr,
"PAPI_stop");
472 do_output(
"papi_read.dat",
"Multiplexed PAPI_read()",
array, number_of_counters );
482 init_test( SoftwareMPX, KernelMPX, Events);
484 for (number_of_counters =
options.
min; number_of_counters <
options.
max; number_of_counters++) {
488 fprintf(
stderr,
"PAPI_add_event");
493 fprintf(
stderr,
"PAPI_start");
511 fprintf(
stderr,
"PAPI_stop");
518 fprintf(
stderr,
"PAPI_add_event");
523 fprintf(
stderr,
"PAPI_start");
535 fprintf(
stderr,
"PAPI_stop");
546 do_output(
"papi_read_ts.dat",
"Multiplexed PAPI_read_ts()",
array, number_of_counters );
555 init_test(SoftwareMPX, KernelMPX, Events);
557 for (number_of_counters =
options.
min; number_of_counters <
options.
max; number_of_counters++) {
561 fprintf(
stderr,
"PAPI_add_event");
566 fprintf(
stderr,
"PAPI_start");
580 fprintf(
stderr,
"PAPI_stop");
588 fprintf(
stderr,
"PAPI_add_event");
593 fprintf(
stderr,
"PAPI_start");
607 fprintf(
stderr,
"PAPI_stop");
611 do_output(
"papi_accum.dat",
"Multiplexed PAPI_accum()",
array, number_of_counters );
619 init_test(SoftwareMPX, KernelMPX, Events);
621 for (number_of_counters =
options.
min; number_of_counters <
options.
max; number_of_counters++) {
625 fprintf(
stderr,
"PAPI_add_event");
630 fprintf(
stderr,
"PAPI_start");
644 fprintf(
stderr,
"PAPI_stop");
651 fprintf(
stderr,
"PAPI_add_event");
656 fprintf(
stderr,
"PAPI_start");
670 fprintf(
stderr,
"PAPI_stop");
675 do_output(
"papi_reset.dat",
"Multiplexed PAPI_reset()",
array, number_of_counters );
685 if ( Events != NULL ) free(Events);
695 if ( Events != NULL ) free(Events);
Accumulate and reset counters in an EventSet.
add PAPI preset or native hardware event to an event set
Assign a component index to an existing but empty EventSet.
Empty and destroy an EventSet.
Create a new empty PAPI EventSet.
Enumerate PAPI preset or native events.
get information about a specific software component
Get PAPI library or event set options.
get real time counter value in clock cycles Returns the total real time passed since some arbitrary s...
initialize the PAPI library.
Initialize multiplex support in the PAPI library.
Read hardware counters with a timestamp.
Read hardware counters from an event set.
Reset the hardware event counts in an event set.
Set the current debug level for error output from PAPI.
Convert a standard event set to a multiplexed event set.
Set PAPI library or event set options.
Finish using PAPI and free all related resources.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
double do_stats(long long *array, long long *min, long long *max, double *average)
#define PAPI_MULTIPLEX_FORCE_SW
static long long values[NUM_EVENTS]
static double c[MATRIX_SIZE][MATRIX_SIZE]
Return codes and api definitions.
int fclose(FILE *__stream)
static double array[ARRAYSIZE]
void do_output(char *fn, char *message, long long *array, int noc)
void init_test(int SoftwareMPX, int KernelMPX, int *Events)
unsigned int kernel_multiplex
A pointer to the following is passed to PAPI_set/get_opt()
PAPI_itimer_option_t itimer
PAPI_multiplex_option_t multiplex