PAPI 7.1.0.0
Loading...
Searching...
No Matches
perf_event_system_wide.c File Reference
Include dependency graph for perf_event_system_wide.c:

Go to the source code of this file.

Macros

#define __USE_GNU
 

Functions

int main (int argc, char **argv)
 

Macro Definition Documentation

◆ __USE_GNU

#define __USE_GNU

Definition at line 15 of file perf_event_system_wide.c.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 22 of file perf_event_system_wide.c.

22 {
23
24 int retval;
25 int EventSetDefault = PAPI_NULL;
26 int EventSetUser = PAPI_NULL;
27 int EventSetKernel = PAPI_NULL;
28 int EventSetUserKernel = PAPI_NULL;
29 int EventSetAll = PAPI_NULL;
30 int EventSet4 = PAPI_NULL;
31 int EventSet5 = PAPI_NULL;
32 int EventSet6 = PAPI_NULL;
33 int EventSet7 = PAPI_NULL;
34 int EventSet8 = PAPI_NULL;
35 int EventSet9 = PAPI_NULL;
36 int EventSet10 = PAPI_NULL;
37
38 int quiet=0;
39
40 PAPI_domain_option_t domain_opt;
42 PAPI_cpu_option_t cpu_opt;
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 /* Set TESTS_QUIET variable */
67 quiet=tests_quiet( argc, argv );
68
69 /* Init the PAPI library */
71 if ( retval != PAPI_VER_CURRENT ) {
72 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
73 }
74
75 if (!quiet) {
76 printf("\nTrying PAPI_TOT_INS with different domains:\n");
77 }
78
79 /***************************/
80 /***************************/
81 /* Default */
82 /***************************/
83 /***************************/
84
85 retval = PAPI_create_eventset(&EventSetDefault);
86 if (retval != PAPI_OK) {
87 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval);
88 }
89
90 retval = PAPI_add_named_event(EventSetDefault, "PAPI_TOT_INS");
91 if (retval != PAPI_OK) {
92 if ( !quiet ) {
93 fprintf(stderr,"Error trying to add PAPI_TOT_INS\n");
94 }
95 test_skip(__FILE__, __LINE__, "adding PAPI_TOT_INS ",retval);
96 }
97
98 if (!quiet) {
99 printf("\tDefault:\t\t\t");
100 }
101
102 retval = PAPI_start( EventSetDefault );
103 if ( retval != PAPI_OK ) {
104 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
105 }
106
108
109 retval = PAPI_stop( EventSetDefault, dom_default_values );
110 if ( retval != PAPI_OK ) {
111 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
112 }
113
114 if ( !quiet ) {
115 printf("%lld\n",dom_default_values[0]);
116 }
117
118 /***************************/
119 /***************************/
120 /* user events */
121 /***************************/
122 /***************************/
123
124 retval = PAPI_create_eventset(&EventSetUser);
125 if (retval != PAPI_OK) {
126 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval);
127 }
128
129 retval = PAPI_assign_eventset_component(EventSetUser, 0);
130
131 /* we need to set domain to be as inclusive as possible */
132 domain_opt.def_cidx=0;
133 domain_opt.eventset=EventSetUser;
134 domain_opt.domain=PAPI_DOM_USER;
135
137 if (retval != PAPI_OK) {
138 if (retval==PAPI_EPERM) {
139 test_skip( __FILE__, __LINE__,
140 "this test; trying to set PAPI_DOM_ALL; need to run as root",
141 retval);
142 }
143 else {
144 test_fail(__FILE__, __LINE__, "setting PAPI_DOM_KERNEL",retval);
145 }
146 }
147
148 retval = PAPI_add_named_event(EventSetUser, "PAPI_TOT_INS");
149 if (retval != PAPI_OK) {
150 if ( !quiet ) {
151 fprintf(stderr,"Error trying to add PAPI_TOT_INS\n");
152 }
153 test_skip(__FILE__, __LINE__, "adding PAPI_TOT_INS ",retval);
154 }
155
156 if (!quiet) {
157 printf("\tPAPI_DOM_USER:\t\t\t");
158 }
159
160 retval = PAPI_start( EventSetUser );
161 if ( retval != PAPI_OK ) {
162 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
163 }
164
166
167 retval = PAPI_stop( EventSetUser, dom_user_values );
168 if ( retval != PAPI_OK ) {
169 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
170 }
171
172 if ( !quiet ) {
173 printf("%lld\n",dom_user_values[0]);
174 }
175
176
177 /***************************/
178 /***************************/
179 /* kernel events */
180 /***************************/
181 /***************************/
182
183 retval = PAPI_create_eventset(&EventSetKernel);
184 if (retval != PAPI_OK) {
185 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval);
186 }
187
188 retval = PAPI_assign_eventset_component(EventSetKernel, 0);
189
190 /* we need to set domain to be as inclusive as possible */
191 domain_opt.def_cidx=0;
192 domain_opt.eventset=EventSetKernel;
193 domain_opt.domain=PAPI_DOM_KERNEL;
194
196 if (retval != PAPI_OK) {
197 if (retval==PAPI_EPERM) {
198 test_skip( __FILE__, __LINE__,
199 "this test; trying to set PAPI_DOM_ALL; need to run as root",
200 retval);
201 }
202 else {
203 test_fail(__FILE__, __LINE__, "setting PAPI_DOM_KERNEL",retval);
204 }
205 }
206
207 retval = PAPI_add_named_event(EventSetKernel, "PAPI_TOT_INS");
208 if (retval != PAPI_OK) {
209 if ( !quiet ) {
210 fprintf(stderr,"Error trying to add PAPI_TOT_INS\n");
211 }
212 test_skip(__FILE__, __LINE__, "adding PAPI_TOT_INS ",retval);
213 }
214
215 if (!quiet) {
216 printf("\tPAPI_DOM_KERNEL:\t\t");
217 }
218
219 retval = PAPI_start( EventSetKernel );
220 if ( retval != PAPI_OK ) {
221 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
222 }
223
225
226 retval = PAPI_stop( EventSetKernel, dom_kernel_values );
227 if ( retval != PAPI_OK ) {
228 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
229 }
230
231 if ( !quiet ) {
232 printf("%lld\n",dom_kernel_values[0]);
233 }
234
235
236 /***************************/
237 /***************************/
238 /* User+Kernel events */
239 /***************************/
240 /***************************/
241
242 if (!quiet) {
243 printf("\tPAPI_DOM_USER|PAPI_DOM_KERNEL:\t");
244 }
245
246 retval = PAPI_create_eventset(&EventSetUserKernel);
247 if (retval != PAPI_OK) {
248 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval);
249 }
250
251 retval = PAPI_assign_eventset_component(EventSetUserKernel, 0);
252
253 /* we need to set domain to be as inclusive as possible */
254
255 domain_opt.def_cidx=0;
256 domain_opt.eventset=EventSetUserKernel;
258
260 if (retval != PAPI_OK) {
261
262 if (retval==PAPI_EPERM) {
263 test_skip( __FILE__, __LINE__,
264 "this test; trying to set PAPI_DOM_ALL; need to run as root",
265 retval);
266 }
267 else {
268 test_fail(__FILE__, __LINE__, "setting PAPI_DOM_ALL",retval);
269 }
270 }
271
272
273 retval = PAPI_add_named_event(EventSetUserKernel, "PAPI_TOT_INS");
274 if (retval != PAPI_OK) {
275 if ( !quiet ) {
276 fprintf(stderr,"Error trying to add PAPI_TOT_INS\n");
277 }
278 test_fail(__FILE__, __LINE__, "adding PAPI_TOT_INS ",retval);
279 }
280
281 retval = PAPI_start( EventSetUserKernel );
282 if ( retval != PAPI_OK ) {
283 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
284 }
285
287
288 retval = PAPI_stop( EventSetUserKernel, dom_userkernel_values );
289 if ( retval != PAPI_OK ) {
290 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
291 }
292
293 if ( !quiet ) {
294 printf("%lld\n",dom_userkernel_values[0]);
295 }
296
297 /***************************/
298 /***************************/
299 /* DOMAIN_ALL events */
300 /***************************/
301 /***************************/
302
303 if (!quiet) {
304 printf("\tPAPI_DOM_ALL:\t\t\t");
305 }
306
307 retval = PAPI_create_eventset(&EventSetAll);
308 if (retval != PAPI_OK) {
309 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval);
310 }
311
312 retval = PAPI_assign_eventset_component(EventSetAll, 0);
313
314 /* we need to set domain to be as inclusive as possible */
315
316 domain_opt.def_cidx=0;
317 domain_opt.eventset=EventSetAll;
318 domain_opt.domain=PAPI_DOM_ALL;
319
321 if (retval != PAPI_OK) {
322
323 if (retval==PAPI_EPERM) {
324 test_skip( __FILE__, __LINE__,
325 "this test; trying to set PAPI_DOM_ALL; need to run as root",
326 retval);
327 }
328 else {
329 test_fail(__FILE__, __LINE__, "setting PAPI_DOM_ALL",retval);
330 }
331 }
332
333
334 retval = PAPI_add_named_event(EventSetAll, "PAPI_TOT_INS");
335 if (retval != PAPI_OK) {
336 if ( !quiet ) {
337 fprintf(stderr,"Error trying to add PAPI_TOT_INS\n");
338 }
339 test_fail(__FILE__, __LINE__, "adding PAPI_TOT_INS ",retval);
340 }
341
342 retval = PAPI_start( EventSetAll );
343 if ( retval != PAPI_OK ) {
344 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
345 }
346
348
349 retval = PAPI_stop( EventSetAll, dom_all_values );
350 if ( retval != PAPI_OK ) {
351 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
352 }
353
354 if ( !quiet ) {
355 printf("%lld\n",dom_all_values[0]);
356 }
357
358
359 /***************************/
360 /***************************/
361 /* PAPI_GRN_THR events */
362 /***************************/
363 /***************************/
364
365 if ( !quiet ) {
366 printf("\nTrying different granularities:\n");
367 }
368
369 if ( !quiet ) {
370 printf("\tPAPI_GRN_THR:\t\t\t");
371 }
372
373 retval = PAPI_create_eventset(&EventSet4);
374 if (retval != PAPI_OK) {
375 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval);
376 }
377
379
380 /* Set the granularity to individual thread */
381
382 gran_opt.def_cidx=0;
383 gran_opt.eventset=EventSet4;
384 gran_opt.granularity=PAPI_GRN_THR;
385
387 if (retval != PAPI_OK) {
388 test_skip( __FILE__, __LINE__,
389 "this test; trying to set PAPI_GRN_THR",
390 retval);
391 }
392
393
394 retval = PAPI_add_named_event(EventSet4, "PAPI_TOT_INS");
395 if (retval != PAPI_OK) {
396 if ( !quiet ) {
397 fprintf(stderr,"Error trying to add PAPI_TOT_INS\n");
398 }
399 test_fail(__FILE__, __LINE__, "adding PAPI_TOT_INS ",retval);
400 }
401
402 retval = PAPI_start( EventSet4 );
403 if ( retval != PAPI_OK ) {
404 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
405 }
406
408
409 retval = PAPI_stop( EventSet4, grn_thr_values );
410 if ( retval != PAPI_OK ) {
411 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
412 }
413
414 if ( !quiet ) {
415 printf("%lld\n",grn_thr_values[0]);
416 }
417
418
419 /***************************/
420 /***************************/
421 /* PAPI_GRN_PROC events */
422 /***************************/
423 /***************************/
424
425 if ( !quiet ) {
426 printf("\tPAPI_GRN_PROC:\t\t\t");
427 }
428
429 retval = PAPI_create_eventset(&EventSet5);
430 if (retval != PAPI_OK) {
431 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval);
432 }
433
435
436 /* Set the granularity to process */
437
438 gran_opt.def_cidx=0;
439 gran_opt.eventset=EventSet5;
440 gran_opt.granularity=PAPI_GRN_PROC;
441
443 if (retval != PAPI_OK) {
444 if (!quiet) {
445 printf("Unable to set PAPI_GRN_PROC\n");
446 }
447 }
448 else {
449 retval = PAPI_add_named_event(EventSet5, "PAPI_TOT_INS");
450 if (retval != PAPI_OK) {
451 if ( !quiet ) {
452 printf("Error trying to add PAPI_TOT_INS\n");
453 }
454 test_fail(__FILE__, __LINE__, "adding PAPI_TOT_INS ",retval);
455 }
456
457 retval = PAPI_start( EventSet5 );
458 if ( retval != PAPI_OK ) {
459 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
460 }
461
463
464 retval = PAPI_stop( EventSet5, grn_proc_values );
465 if ( retval != PAPI_OK ) {
466 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
467 }
468
469 if ( !quiet ) {
470 printf("%lld\n",grn_proc_values[0]);
471 }
472 }
473
474
475
476 /***************************/
477 /***************************/
478 /* PAPI_GRN_SYS events */
479 /***************************/
480 /***************************/
481
482 if ( !quiet ) {
483 printf("\tPAPI_GRN_SYS:\t\t\t");
484 }
485
486 retval = PAPI_create_eventset(&EventSet6);
487 if (retval != PAPI_OK) {
488 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval);
489 }
490
492
493 /* Set the granularity to current cpu */
494
495 gran_opt.def_cidx=0;
496 gran_opt.eventset=EventSet6;
497 gran_opt.granularity=PAPI_GRN_SYS;
498
500 if (retval != PAPI_OK) {
501 if (!quiet) {
502 printf("Unable to set PAPI_GRN_SYS\n");
503 }
504 }
505 else {
506
507 retval = PAPI_add_named_event(EventSet6, "PAPI_TOT_INS");
508 if (retval != PAPI_OK) {
509
510 if (retval == PAPI_EPERM) {
511 /* FIXME: read perf_event_paranoid and see */
512 if (!quiet) printf("SYS granularity not allowed, probably perf_event_paranoid permissions\n");
513 }
514 else {
515 if ( !quiet ) {
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
522 retval = PAPI_start( EventSet6 );
523 if ( retval != PAPI_OK ) {
524 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
525 }
526
528
529 retval = PAPI_stop( EventSet6, grn_sys_values );
530 if ( retval != PAPI_OK ) {
531 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
532 }
533
534 if ( !quiet ) {
535 printf("%lld\n",grn_sys_values[0]);
536 }
537 }
538
539 }
540
541
542 /****************************/
543 /****************************/
544 /* PAPI_GRN_SYS_CPU events */
545 /****************************/
546 /****************************/
547
548 if ( !quiet ) {
549 printf("\tPAPI_GRN_SYS_CPU:\t\t");
550 }
551
552 retval = PAPI_create_eventset(&EventSet7);
553 if (retval != PAPI_OK) {
554 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval);
555 }
556
558
559 /* Set the granularity to all cpus */
560
561 gran_opt.def_cidx=0;
562 gran_opt.eventset=EventSet7;
564
566 if (retval != PAPI_OK) {
567 if (!quiet) {
568 printf("Unable to set PAPI_GRN_SYS_CPU\n");
569 }
570 }
571 else {
572 retval = PAPI_add_named_event(EventSet7, "PAPI_TOT_INS");
573 if (retval != PAPI_OK) {
574 if ( !quiet ) {
575 printf("Error trying to add PAPI_TOT_INS\n");
576 }
577 test_fail(__FILE__, __LINE__, "adding PAPI_TOT_INS ",retval);
578 }
579
580 retval = PAPI_start( EventSet7 );
581 if ( retval != PAPI_OK ) {
582 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
583 }
584
586
587 retval = PAPI_stop( EventSet7, grn_sys_cpu_values );
588 if ( retval != PAPI_OK ) {
589 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
590 }
591
592 if ( !quiet ) {
593 printf("%lld\n",grn_sys_cpu_values[0]);
594 }
595 }
596
597
598 /***************************/
599 /***************************/
600 /* SYS and ATTACH events */
601 /***************************/
602 /***************************/
603
604 if ( !quiet ) {
605 printf("\nPAPI_GRN_SYS plus CPU attach:\n");
606 }
607
608 if ( !quiet ) {
609 printf("\tGRN_SYS, DOM_USER, CPU 0 attach:\t");
610 }
611
612 retval = PAPI_create_eventset(&EventSet8);
613 if (retval != PAPI_OK) {
614 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval);
615 }
616
618
619 /* Set the granularity to system-wide */
620
621 gran_opt.def_cidx=0;
622 gran_opt.eventset=EventSet8;
623 gran_opt.granularity=PAPI_GRN_SYS;
624
626 if (retval != PAPI_OK) {
627 if (!quiet) {
628 printf("Unable to set PAPI_GRN_SYS\n");
629 }
630 }
631 else {
632 /* we need to set to a certain cpu */
633
634 cpu_opt.eventset=EventSet8;
635 cpu_opt.cpu_num=0;
636
638 if (retval != PAPI_OK) {
639 if (retval==PAPI_EPERM) {
640 if (!quiet) {
641 printf("Permission error trying to CPU_ATTACH; need to run as root\n");
642 }
643 test_skip( __FILE__, __LINE__,
644 "this test; trying to CPU_ATTACH; need to run as root",
645 retval);
646 }
647
648 test_fail(__FILE__, __LINE__, "PAPI_CPU_ATTACH",retval);
649 }
650
651 retval = PAPI_add_named_event(EventSet8, "PAPI_TOT_INS");
652 if (retval != PAPI_OK) {
653 if ( !quiet ) {
654 printf("Error trying to add PAPI_TOT_INS\n");
655 }
656 test_fail(__FILE__, __LINE__, "adding PAPI_TOT_INS ",retval);
657 }
658
659 retval = PAPI_start( EventSet8 );
660 if ( retval != PAPI_OK ) {
661 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
662 }
663
665
666 retval = PAPI_stop( EventSet8, total_values );
667 if ( retval != PAPI_OK ) {
668 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
669 }
670
671 if ( !quiet ) {
672 printf("%lld\n",total_values[0]);
673 }
674 }
675
676
677 /***************************/
678 /***************************/
679 /* SYS and ATTACH, bind CPU events */
680 /***************************/
681 /***************************/
682
683 if ( !quiet ) {
684 printf("\tGRN_SYS, DOM_USER, CPU 0 affinity:\t");
685 }
686
687 /* Set affinity to CPU 0 */
688 CPU_ZERO(&mask);
689 CPU_SET(0,&mask);
690 retval=sched_setaffinity(0, sizeof(mask), &mask);
691
692 if (retval<0) {
693 if (!quiet) {
694 printf("Setting affinity failed: %s\n",strerror(errno));
695 }
696 } else {
697
698 retval = PAPI_create_eventset(&EventSet9);
699 if (retval != PAPI_OK) {
700 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval);
701 }
702
704
705 /* Set the granularity to system-wide */
706
707 gran_opt.def_cidx=0;
708 gran_opt.eventset=EventSet9;
709 gran_opt.granularity=PAPI_GRN_SYS;
710
712 if (retval != PAPI_OK) {
713 if (!quiet) {
714 printf("Unable to set PAPI_GRN_SYS\n");
715 }
716 }
717 else {
718 /* we need to set to a certain cpu for uncore to work */
719
720 cpu_opt.eventset=EventSet9;
721 cpu_opt.cpu_num=0;
722
724 if (retval != PAPI_OK) {
725 test_fail(__FILE__, __LINE__, "PAPI_CPU_ATTACH",retval);
726 }
727
728 retval = PAPI_add_named_event(EventSet9, "PAPI_TOT_INS");
729 if (retval != PAPI_OK) {
730 if ( !quiet ) {
731 printf("Error trying to add PAPI_TOT_INS\n");
732 }
733 test_fail(__FILE__, __LINE__, "adding PAPI_TOT_INS ",retval);
734 }
735
736 retval = PAPI_start( EventSet9 );
737 if ( retval != PAPI_OK ) {
738 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
739 }
740
742
743 retval = PAPI_stop( EventSet9, total_affinity_values );
744 if ( retval != PAPI_OK ) {
745 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
746 }
747
748 if ( !quiet ) {
749 printf("%lld\n",total_affinity_values[0]);
750 }
751 }
752 }
753
754 /***************************/
755 /***************************/
756 /* SYS and ATTACH, bind CPU events */
757 /***************************/
758 /***************************/
759
760 if ( !quiet ) {
761 printf("\tGRN_SYS, DOM_ALL, CPU 0 affinity:\t");
762 }
763
764
765
766 /* Set affinity to CPU 0 */
767 CPU_ZERO(&mask);
768 CPU_SET(0,&mask);
769 retval=sched_setaffinity(0, sizeof(mask), &mask);
770
771 if (retval<0) {
772 if (!quiet) {
773 printf("Setting affinity failed: %s\n",strerror(errno));
774 }
775 } else {
776
777 retval = PAPI_create_eventset(&EventSet10);
778 if (retval != PAPI_OK) {
779 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval);
780 }
781
782 retval = PAPI_assign_eventset_component(EventSet10, 0);
783
784 /* Set DOM_ALL */
785 domain_opt.def_cidx=0;
786 domain_opt.eventset=EventSet10;
787 domain_opt.domain=PAPI_DOM_ALL;
788
790 if (retval != PAPI_OK) {
791
792 if (retval==PAPI_EPERM) {
793 test_skip( __FILE__, __LINE__,
794 "this test; trying to set PAPI_DOM_ALL; need to run as root",
795 retval);
796 }
797 else {
798 test_fail(__FILE__, __LINE__, "setting PAPI_DOM_ALL",retval);
799 }
800 }
801
802 /* Set the granularity to system-wide */
803
804 gran_opt.def_cidx=0;
805 gran_opt.eventset=EventSet10;
806 gran_opt.granularity=PAPI_GRN_SYS;
807
809 if (retval != PAPI_OK) {
810 if (!quiet) {
811 printf("Unable to set PAPI_GRN_SYS\n");
812 }
813 }
814 else {
815 /* we need to set to a certain cpu for uncore to work */
816
817 cpu_opt.eventset=EventSet10;
818 cpu_opt.cpu_num=0;
819
821 if (retval != PAPI_OK) {
822 test_fail(__FILE__, __LINE__, "PAPI_CPU_ATTACH",retval);
823 }
824
825 retval = PAPI_add_named_event(EventSet10, "PAPI_TOT_INS");
826 if (retval != PAPI_OK) {
827 if ( !quiet ) {
828 printf("Error trying to add PAPI_TOT_INS\n");
829 }
830 test_fail(__FILE__, __LINE__, "adding PAPI_TOT_INS ",retval);
831 }
832
833 retval = PAPI_start( EventSet10 );
834 if ( retval != PAPI_OK ) {
835 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
836 }
837
839
840 retval = PAPI_stop( EventSet10, total_all_values );
841 if ( retval != PAPI_OK ) {
842 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
843 }
844
845 if ( !quiet ) {
846 printf("%lld\n",total_all_values[0]);
847 }
848 }
849 }
850
851 /**************/
852 /* Validation */
853 /**************/
854
855 if ( !quiet ) {
856 printf("\n");
857 }
858
859 if ( !quiet ) {
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
868 if ( !quiet ) {
869 printf("\n");
870 }
871
872 test_pass( __FILE__ );
873
874 return 0;
875}
int errno
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.
#define PAPI_CPU_ATTACH
Definition: f90papi.h:19
#define PAPI_DOM_USER
Definition: f90papi.h:174
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
#define PAPI_GRANUL
Definition: f90papi.h:179
#define PAPI_DOM_KERNEL
Definition: f90papi.h:254
#define PAPI_EPERM
Definition: f90papi.h:112
#define PAPI_DOMAIN
Definition: f90papi.h:159
#define PAPI_GRN_SYS
Definition: f90papi.h:43
#define PAPI_GRN_SYS_CPU
Definition: f90papi.h:100
#define PAPI_GRN_PROC
Definition: f90papi.h:266
#define PAPI_GRN_THR
Definition: f90papi.h:265
#define PAPI_DOM_ALL
Definition: f90papi.h:261
void do_flops(int n)
Definition: multiplex.c:23
FILE * stderr
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:584
int quiet
Definition: rapl_overflow.c:19
#define NUM_FLOPS
Definition: sdsc-mpx.c:24
unsigned int cpu_num
Definition: papi.h:818
A pointer to the following is passed to PAPI_set/get_opt()
Definition: papi.h:843
int retval
Definition: zero_fork.c:53
Here is the call graph for this function: