22 {
23
37
39
43 cpu_set_t mask;
44
45 long long dom_default_values[1],
46 dom_user_values[1],
47 dom_kernel_values[1],
48 dom_userkernel_values[1],
49 dom_all_values[1];
50 long long grn_thr_values[1],grn_proc_values[1];
51 long long grn_sys_values[1],grn_sys_cpu_values[1];
52 long long total_values[1],total_affinity_values[1];
53 long long total_all_values[1];
54
55 dom_user_values[0]=0;
56 dom_userkernel_values[0]=0;
57 dom_all_values[0]=0;
58 grn_thr_values[0]=0;
59 grn_proc_values[0]=0;
60 grn_sys_values[0]=0;
61 grn_sys_cpu_values[0]=0;
62 total_values[0]=0;
63 total_affinity_values[0]=0;
64 total_all_values[0]=0;
65
66
68
69
73 }
74
76 printf("\nTrying PAPI_TOT_INS with different domains:\n");
77 }
78
79
80
81
82
83
84
88 }
89
93 fprintf(
stderr,
"Error trying to add PAPI_TOT_INS\n");
94 }
96 }
97
99 printf("\tDefault:\t\t\t");
100 }
101
105 }
106
108
112 }
113
115 printf("%lld\n",dom_default_values[0]);
116 }
117
118
119
120
121
122
123
127 }
128
130
131
135
140 "this test; trying to set PAPI_DOM_ALL; need to run as root",
142 }
143 else {
145 }
146 }
147
151 fprintf(
stderr,
"Error trying to add PAPI_TOT_INS\n");
152 }
154 }
155
157 printf("\tPAPI_DOM_USER:\t\t\t");
158 }
159
163 }
164
166
170 }
171
173 printf("%lld\n",dom_user_values[0]);
174 }
175
176
177
178
179
180
181
182
186 }
187
189
190
194
199 "this test; trying to set PAPI_DOM_ALL; need to run as root",
201 }
202 else {
204 }
205 }
206
210 fprintf(
stderr,
"Error trying to add PAPI_TOT_INS\n");
211 }
213 }
214
216 printf("\tPAPI_DOM_KERNEL:\t\t");
217 }
218
222 }
223
225
229 }
230
232 printf("%lld\n",dom_kernel_values[0]);
233 }
234
235
236
237
238
239
240
241
243 printf("\tPAPI_DOM_USER|PAPI_DOM_KERNEL:\t");
244 }
245
249 }
250
252
253
254
256 domain_opt.
eventset=EventSetUserKernel;
258
261
264 "this test; trying to set PAPI_DOM_ALL; need to run as root",
266 }
267 else {
269 }
270 }
271
272
276 fprintf(
stderr,
"Error trying to add PAPI_TOT_INS\n");
277 }
279 }
280
284 }
285
287
291 }
292
294 printf("%lld\n",dom_userkernel_values[0]);
295 }
296
297
298
299
300
301
302
304 printf("\tPAPI_DOM_ALL:\t\t\t");
305 }
306
310 }
311
313
314
315
319
322
325 "this test; trying to set PAPI_DOM_ALL; need to run as root",
327 }
328 else {
330 }
331 }
332
333
337 fprintf(
stderr,
"Error trying to add PAPI_TOT_INS\n");
338 }
340 }
341
345 }
346
348
352 }
353
355 printf("%lld\n",dom_all_values[0]);
356 }
357
358
359
360
361
362
363
364
366 printf("\nTrying different granularities:\n");
367 }
368
370 printf("\tPAPI_GRN_THR:\t\t\t");
371 }
372
376 }
377
379
380
381
385
389 "this test; trying to set PAPI_GRN_THR",
391 }
392
393
397 fprintf(
stderr,
"Error trying to add PAPI_TOT_INS\n");
398 }
400 }
401
405 }
406
408
412 }
413
415 printf("%lld\n",grn_thr_values[0]);
416 }
417
418
419
420
421
422
423
424
426 printf("\tPAPI_GRN_PROC:\t\t\t");
427 }
428
432 }
433
435
436
437
441
445 printf("Unable to set PAPI_GRN_PROC\n");
446 }
447 }
448 else {
452 printf("Error trying to add PAPI_TOT_INS\n");
453 }
455 }
456
460 }
461
463
467 }
468
470 printf("%lld\n",grn_proc_values[0]);
471 }
472 }
473
474
475
476
477
478
479
480
481
483 printf("\tPAPI_GRN_SYS:\t\t\t");
484 }
485
489 }
490
492
493
494
498
502 printf("Unable to set PAPI_GRN_SYS\n");
503 }
504 }
505 else {
506
509
511
512 if (!
quiet) printf(
"SYS granularity not allowed, probably perf_event_paranoid permissions\n");
513 }
514 else {
516 printf("Error adding PAPI_TOT_INS with system granularity\n");
517 }
518 test_fail(__FILE__, __LINE__,
"adding PAPI_TOT_INS with system granularity",
retval);
519 }
520 } else {
521
525 }
526
528
532 }
533
535 printf("%lld\n",grn_sys_values[0]);
536 }
537 }
538
539 }
540
541
542
543
544
545
546
547
549 printf("\tPAPI_GRN_SYS_CPU:\t\t");
550 }
551
555 }
556
558
559
560
564
568 printf("Unable to set PAPI_GRN_SYS_CPU\n");
569 }
570 }
571 else {
575 printf("Error trying to add PAPI_TOT_INS\n");
576 }
578 }
579
583 }
584
586
590 }
591
593 printf("%lld\n",grn_sys_cpu_values[0]);
594 }
595 }
596
597
598
599
600
601
602
603
605 printf("\nPAPI_GRN_SYS plus CPU attach:\n");
606 }
607
609 printf("\tGRN_SYS, DOM_USER, CPU 0 attach:\t");
610 }
611
615 }
616
618
619
620
624
628 printf("Unable to set PAPI_GRN_SYS\n");
629 }
630 }
631 else {
632
633
636
641 printf("Permission error trying to CPU_ATTACH; need to run as root\n");
642 }
644 "this test; trying to CPU_ATTACH; need to run as root",
646 }
647
649 }
650
654 printf("Error trying to add PAPI_TOT_INS\n");
655 }
657 }
658
662 }
663
665
669 }
670
672 printf("%lld\n",total_values[0]);
673 }
674 }
675
676
677
678
679
680
681
682
684 printf("\tGRN_SYS, DOM_USER, CPU 0 affinity:\t");
685 }
686
687
688 CPU_ZERO(&mask);
689 CPU_SET(0,&mask);
690 retval=sched_setaffinity(0,
sizeof(mask), &mask);
691
694 printf(
"Setting affinity failed: %s\n",strerror(
errno));
695 }
696 } else {
697
701 }
702
704
705
706
710
714 printf("Unable to set PAPI_GRN_SYS\n");
715 }
716 }
717 else {
718
719
722
726 }
727
731 printf("Error trying to add PAPI_TOT_INS\n");
732 }
734 }
735
739 }
740
742
746 }
747
749 printf("%lld\n",total_affinity_values[0]);
750 }
751 }
752 }
753
754
755
756
757
758
759
761 printf("\tGRN_SYS, DOM_ALL, CPU 0 affinity:\t");
762 }
763
764
765
766
767 CPU_ZERO(&mask);
768 CPU_SET(0,&mask);
769 retval=sched_setaffinity(0,
sizeof(mask), &mask);
770
773 printf(
"Setting affinity failed: %s\n",strerror(
errno));
774 }
775 } else {
776
780 }
781
783
784
788
791
794 "this test; trying to set PAPI_DOM_ALL; need to run as root",
796 }
797 else {
799 }
800 }
801
802
803
807
811 printf("Unable to set PAPI_GRN_SYS\n");
812 }
813 }
814 else {
815
816
819
823 }
824
828 printf("Error trying to add PAPI_TOT_INS\n");
829 }
831 }
832
836 }
837
839
843 }
844
846 printf("%lld\n",total_all_values[0]);
847 }
848 }
849 }
850
851
852
853
854
856 printf("\n");
857 }
858
860 printf("Validating:\n");
861 printf("\tDOM_USER|DOM_KERNEL (%lld) > DOM_USER (%lld)\n",
862 dom_userkernel_values[0],dom_user_values[0]);
863 }
864 if (dom_user_values[0] > dom_userkernel_values[0]) {
865 test_fail( __FILE__, __LINE__,
"DOM_USER too high", 0 );
866 }
867
869 printf("\n");
870 }
871
873
874 return 0;
875}
add PAPI preset or native hardware event by name to an EventSet
Assign a component index to an existing but empty EventSet.
Create a new empty PAPI EventSet.
initialize the PAPI library.
Set PAPI library or event set options.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
int tests_quiet(int argc, char **argv)
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
void PAPI_NORETURN test_pass(const char *filename)
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
A pointer to the following is passed to PAPI_set/get_opt()