171{
172 int retval, retval_start, retval_stop;
175 int *Events = NULL;
176 int number_of_counters;
179 int dont_loop_forever;
180 long long totcyc, *
values = NULL;
181 long long *
array = NULL;
182 int event;
183
186
192
193 while ( (
c=getopt(argc, argv,
"hm:x:skt:") ) != -1 ) {
195 case 'h':
197 exit(0);
198 case 'm':
200 break;
201 case 'x':
203 break;
204 case 's':
206 break;
207 case 'k':
209 break;
210 case 't':
212 default:
213 break;
214 }
215 }
216
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");
220
222 fprintf(
stderr,
"Error! Min # of Events > Max # of Events");
223 goto cleanup;
224 }
225
228 Events = (
int* )malloc(
sizeof(
int) *
options.
max);
229
230 if (
values == NULL ||
array == NULL || Events == NULL ) {
231 fprintf(
stderr,
"Error allocating memory!\n");
232 exit(1);
233 }
234
237 fprintf(
stderr,
"Error! PAPI_library_init\n");
239 }
240
243 fprintf(
stderr,
"Error! PAPI_set_debug\n");
245 }
246
249 fprintf(
stderr,
"Error! PAPI_multiplex_init\n");
251 }
252
255
257 fprintf(
stderr,
"Error! Kernel multiplexing is "
258 "not supported on this platform, bailing!\n");
259 exit(1);
260 }
261
264 fprintf(
stderr,
"Error! PAPI_create_eventset\n");
266 }
267
270 fprintf(
stderr,
"PAPI_create_eventset");
272 }
273
276 fprintf(
stderr,
"PAPI_assign_eventset_component");
278 }
279
282 fprintf(
stderr,
"PAPI_set_multiplex");
284 }
285
288 fprintf(
stderr,
"PAPI_assign_eventset_component");
290 }
291
293
294 memset(&option,0x0,sizeof(option));
295
299
302 fprintf(
stderr,
"PAPI_set_opt");
304 }
305
307 fprintf(
stderr,
"No tests to run.");
308 goto cleanup;
309 } else {
310 fprintf(
stderr,
"Running test[s]\n");
312 fprintf(
stderr,
"\tKernel multiplexing read\n");
314 fprintf(
stderr,
"\tSoftware Multiplexing read\n");
315 }
316
319
320
321 for (number_of_counters = 0; number_of_counters <
options.
max; number_of_counters++) {
322 dont_loop_forever = 0;
323
325 do {
327 dont_loop_forever++;
329 dont_loop_forever < 512);
330 } else {
331 do {
333 dont_loop_forever++;
335 dont_loop_forever < 512);
336 }
337 if ( dont_loop_forever == 512 )
339
340 Events[number_of_counters] = event;
341 }
342
345
346
347 init_test(SoftwareMPX, KernelMPX, Events);
348
349 for (number_of_counters =
options.
min; number_of_counters <
options.
max; number_of_counters++) {
350
353 fprintf(
stderr,
"PAPI_add_event");
354 goto cleanup;
355 }
356
358 fprintf(
stderr,
"PAPI_start");
360 }
362 fprintf(
stderr,
"PAPI_stop");
364 }
365
366
372 if (retval_start || retval_stop)
373 fprintf(
stderr,
"PAPI start/stop");
374 }
375
376 } else
378
379
382 fprintf(
stderr,
"PAPI_add_event");
383 goto cleanup;
384 }
385
387 fprintf(
stderr,
"PAPI_start");
389 }
391 fprintf(
stderr,
"PAPI_stop");
393 }
394
395
401 if (retval_start || retval_stop)
402 fprintf(
stderr,
"PAPI start/stop");
403 }
404
405 } else {
407 }
408
409 do_output(
"papi_startstop.dat",
"Multiplexed PAPI_read()",
array, number_of_counters );
410
411 }
415
416
417 init_test(SoftwareMPX, KernelMPX, Events);
418
419 for (number_of_counters =
options.
min; number_of_counters <
options.
max; number_of_counters++) {
420
423 fprintf(
stderr,
"PAPI_add_event");
424 goto cleanup;
425 }
426
428 fprintf(
stderr,
"PAPI_start");
430 }
432
433
438 }
439
442 fprintf(
stderr,
"PAPI_stop");
443 } else
445
446
449 fprintf(
stderr,
"PAPI_add_event");
450 goto cleanup;
451 }
452
454 fprintf(
stderr,
"PAPI_start");
456 }
458
459
464 }
465
468 fprintf(
stderr,
"PAPI_stop");
469 } else
471
472 do_output(
"papi_read.dat",
"Multiplexed PAPI_read()",
array, number_of_counters );
473
474 }
478
479
480
481
482 init_test( SoftwareMPX, KernelMPX, Events);
483
484 for (number_of_counters =
options.
min; number_of_counters <
options.
max; number_of_counters++) {
485
488 fprintf(
stderr,
"PAPI_add_event");
489 goto cleanup;
490 }
491
493 fprintf(
stderr,
"PAPI_start");
495 }
497
498
501 }
502
503
506 }
508
511 fprintf(
stderr,
"PAPI_stop");
512 } else
514
515
518 fprintf(
stderr,
"PAPI_add_event");
519 goto cleanup;
520 }
521
523 fprintf(
stderr,
"PAPI_start");
525 }
527
528
531 }
532
535 fprintf(
stderr,
"PAPI_stop");
536
537
540 }
542
543 } else
545
546 do_output(
"papi_read_ts.dat",
"Multiplexed PAPI_read_ts()",
array, number_of_counters );
547
548 }
552
553
554
555 init_test(SoftwareMPX, KernelMPX, Events);
556
557 for (number_of_counters =
options.
min; number_of_counters <
options.
max; number_of_counters++) {
558
561 fprintf(
stderr,
"PAPI_add_event");
562 goto cleanup;
563 }
564
566 fprintf(
stderr,
"PAPI_start");
568 }
570
571
576 }
577
580 fprintf(
stderr,
"PAPI_stop");
581 } else {
583 }
584
585
588 fprintf(
stderr,
"PAPI_add_event");
589 goto cleanup;
590 }
591
593 fprintf(
stderr,
"PAPI_start");
595 }
597
598
603 }
604
607 fprintf(
stderr,
"PAPI_stop");
608 } else {
610 }
611 do_output(
"papi_accum.dat",
"Multiplexed PAPI_accum()",
array, number_of_counters );
612
613 }
617
618
619 init_test(SoftwareMPX, KernelMPX, Events);
620
621 for (number_of_counters =
options.
min; number_of_counters <
options.
max; number_of_counters++) {
622
625 fprintf(
stderr,
"PAPI_add_event");
626 goto cleanup;
627 }
628
630 fprintf(
stderr,
"PAPI_start");
632 }
634
635
640 }
641
644 fprintf(
stderr,
"PAPI_stop");
645 } else
647
648
651 fprintf(
stderr,
"PAPI_add_event");
652 goto cleanup;
653 }
654
656 fprintf(
stderr,
"PAPI_start");
658 }
660
661
666 }
667
670 fprintf(
stderr,
"PAPI_stop");
671 } else {
673 }
674
675 do_output(
"papi_reset.dat",
"Multiplexed PAPI_reset()",
array, number_of_counters );
676
677 }
678
682
685 if ( Events != NULL ) free(Events);
686
687 return 0;
688
689cleanup:
692
695 if ( Events != NULL ) free(Events);
696
698 return 1;
699
700}
Accumulate and reset counters in an 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 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.
Finish using PAPI and free all related resources.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
static long long values[NUM_EVENTS]
static double c[MATRIX_SIZE][MATRIX_SIZE]
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