|
PAPI
5.3.0.0
|
00001 /* 00002 * This tests the measuring of events using a system-wide granularity 00003 */ 00004 00005 #include "papi_test.h" 00006 00007 #ifndef __USE_GNU 00008 #define __USE_GNU 00009 #endif 00010 00011 /* For sched_setaffinity() */ 00012 #include <sched.h> 00013 00014 00015 int main( int argc, char **argv ) { 00016 00017 int retval; 00018 int EventSet1 = PAPI_NULL; 00019 int EventSet2 = PAPI_NULL; 00020 int EventSet3 = PAPI_NULL; 00021 int EventSet4 = PAPI_NULL; 00022 int EventSet5 = PAPI_NULL; 00023 int EventSet6 = PAPI_NULL; 00024 int EventSet7 = PAPI_NULL; 00025 int EventSet8 = PAPI_NULL; 00026 int EventSet9 = PAPI_NULL; 00027 int EventSet10 = PAPI_NULL; 00028 00029 PAPI_domain_option_t domain_opt; 00030 PAPI_granularity_option_t gran_opt; 00031 PAPI_cpu_option_t cpu_opt; 00032 cpu_set_t mask; 00033 00034 long long dom_user_values[1],dom_userkernel_values[1],dom_all_values[1]; 00035 long long grn_thr_values[1],grn_proc_values[1]; 00036 long long grn_sys_values[1],grn_sys_cpu_values[1]; 00037 long long total_values[1],total_affinity_values[1]; 00038 long long total_all_values[1]; 00039 00040 dom_user_values[0]=0; 00041 dom_userkernel_values[0]=0; 00042 dom_all_values[0]=0; 00043 grn_thr_values[0]=0; 00044 grn_proc_values[0]=0; 00045 grn_sys_values[0]=0; 00046 grn_sys_cpu_values[0]=0; 00047 total_values[0]=0; 00048 total_affinity_values[0]=0; 00049 total_all_values[0]=0; 00050 00051 /* Set TESTS_QUIET variable */ 00052 tests_quiet( argc, argv ); 00053 00054 /* Init the PAPI library */ 00055 retval = PAPI_library_init( PAPI_VER_CURRENT ); 00056 if ( retval != PAPI_VER_CURRENT ) { 00057 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval ); 00058 } 00059 00060 /***************************/ 00061 /***************************/ 00062 /* Default, user events */ 00063 /***************************/ 00064 /***************************/ 00065 00066 if (!TESTS_QUIET) { 00067 printf("\nTrying PAPI_TOT_CYC with different domains:\n"); 00068 } 00069 00070 if (!TESTS_QUIET) { 00071 printf("\tPAPI_DOM_USER:\t\t\t"); 00072 } 00073 00074 retval = PAPI_create_eventset(&EventSet1); 00075 if (retval != PAPI_OK) { 00076 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval); 00077 } 00078 00079 retval = PAPI_add_named_event(EventSet1, "PAPI_TOT_CYC"); 00080 if (retval != PAPI_OK) { 00081 if ( !TESTS_QUIET ) { 00082 fprintf(stderr,"Error trying to add PAPI_TOT_CYC\n"); 00083 } 00084 test_fail(__FILE__, __LINE__, "adding PAPI_TOT_CYC ",retval); 00085 } 00086 00087 retval = PAPI_start( EventSet1 ); 00088 if ( retval != PAPI_OK ) { 00089 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00090 } 00091 00092 do_flops( NUM_FLOPS ); 00093 00094 retval = PAPI_stop( EventSet1, dom_user_values ); 00095 if ( retval != PAPI_OK ) { 00096 test_fail( __FILE__, __LINE__, "PAPI_stop", retval ); 00097 } 00098 00099 if ( !TESTS_QUIET ) { 00100 printf("%lld\n",dom_user_values[0]); 00101 } 00102 00103 00104 /***************************/ 00105 /***************************/ 00106 /* User+Kernel events */ 00107 /***************************/ 00108 /***************************/ 00109 00110 if (!TESTS_QUIET) { 00111 printf("\tPAPI_DOM_USER|PAPI_DOM_KERNEL:\t"); 00112 } 00113 00114 retval = PAPI_create_eventset(&EventSet2); 00115 if (retval != PAPI_OK) { 00116 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval); 00117 } 00118 00119 retval = PAPI_assign_eventset_component(EventSet2, 0); 00120 00121 /* we need to set domain to be as inclusive as possible */ 00122 00123 domain_opt.def_cidx=0; 00124 domain_opt.eventset=EventSet2; 00125 domain_opt.domain=PAPI_DOM_USER|PAPI_DOM_KERNEL; 00126 00127 retval = PAPI_set_opt(PAPI_DOMAIN,(PAPI_option_t*)&domain_opt); 00128 if (retval != PAPI_OK) { 00129 00130 if (retval==PAPI_EPERM) { 00131 test_skip( __FILE__, __LINE__, 00132 "this test; trying to set PAPI_DOM_ALL; need to run as root", 00133 retval); 00134 } 00135 else { 00136 test_fail(__FILE__, __LINE__, "setting PAPI_DOM_ALL",retval); 00137 } 00138 } 00139 00140 00141 retval = PAPI_add_named_event(EventSet2, "PAPI_TOT_CYC"); 00142 if (retval != PAPI_OK) { 00143 if ( !TESTS_QUIET ) { 00144 fprintf(stderr,"Error trying to add PAPI_TOT_CYC\n"); 00145 } 00146 test_fail(__FILE__, __LINE__, "adding PAPI_TOT_CYC ",retval); 00147 } 00148 00149 retval = PAPI_start( EventSet2 ); 00150 if ( retval != PAPI_OK ) { 00151 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00152 } 00153 00154 do_flops( NUM_FLOPS ); 00155 00156 retval = PAPI_stop( EventSet2, dom_userkernel_values ); 00157 if ( retval != PAPI_OK ) { 00158 test_fail( __FILE__, __LINE__, "PAPI_stop", retval ); 00159 } 00160 00161 if ( !TESTS_QUIET ) { 00162 printf("%lld\n",dom_userkernel_values[0]); 00163 } 00164 00165 /***************************/ 00166 /***************************/ 00167 /* DOMAIN_ALL events */ 00168 /***************************/ 00169 /***************************/ 00170 00171 if (!TESTS_QUIET) { 00172 printf("\tPAPI_DOM_ALL:\t\t\t"); 00173 } 00174 00175 retval = PAPI_create_eventset(&EventSet3); 00176 if (retval != PAPI_OK) { 00177 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval); 00178 } 00179 00180 retval = PAPI_assign_eventset_component(EventSet3, 0); 00181 00182 /* we need to set domain to be as inclusive as possible */ 00183 00184 domain_opt.def_cidx=0; 00185 domain_opt.eventset=EventSet3; 00186 domain_opt.domain=PAPI_DOM_ALL; 00187 00188 retval = PAPI_set_opt(PAPI_DOMAIN,(PAPI_option_t*)&domain_opt); 00189 if (retval != PAPI_OK) { 00190 00191 if (retval==PAPI_EPERM) { 00192 test_skip( __FILE__, __LINE__, 00193 "this test; trying to set PAPI_DOM_ALL; need to run as root", 00194 retval); 00195 } 00196 else { 00197 test_fail(__FILE__, __LINE__, "setting PAPI_DOM_ALL",retval); 00198 } 00199 } 00200 00201 00202 retval = PAPI_add_named_event(EventSet3, "PAPI_TOT_CYC"); 00203 if (retval != PAPI_OK) { 00204 if ( !TESTS_QUIET ) { 00205 fprintf(stderr,"Error trying to add PAPI_TOT_CYC\n"); 00206 } 00207 test_fail(__FILE__, __LINE__, "adding PAPI_TOT_CYC ",retval); 00208 } 00209 00210 retval = PAPI_start( EventSet3 ); 00211 if ( retval != PAPI_OK ) { 00212 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00213 } 00214 00215 do_flops( NUM_FLOPS ); 00216 00217 retval = PAPI_stop( EventSet3, dom_all_values ); 00218 if ( retval != PAPI_OK ) { 00219 test_fail( __FILE__, __LINE__, "PAPI_stop", retval ); 00220 } 00221 00222 if ( !TESTS_QUIET ) { 00223 printf("%lld\n",dom_all_values[0]); 00224 } 00225 00226 00227 /***************************/ 00228 /***************************/ 00229 /* PAPI_GRN_THR events */ 00230 /***************************/ 00231 /***************************/ 00232 00233 if ( !TESTS_QUIET ) { 00234 printf("\nTrying different granularities:\n"); 00235 } 00236 00237 if ( !TESTS_QUIET ) { 00238 printf("\tPAPI_GRN_THR:\t\t\t"); 00239 } 00240 00241 retval = PAPI_create_eventset(&EventSet4); 00242 if (retval != PAPI_OK) { 00243 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval); 00244 } 00245 00246 retval = PAPI_assign_eventset_component(EventSet4, 0); 00247 00248 /* Set the granularity to system-wide */ 00249 00250 gran_opt.def_cidx=0; 00251 gran_opt.eventset=EventSet4; 00252 gran_opt.granularity=PAPI_GRN_THR; 00253 00254 retval = PAPI_set_opt(PAPI_GRANUL,(PAPI_option_t*)&gran_opt); 00255 if (retval != PAPI_OK) { 00256 test_skip( __FILE__, __LINE__, 00257 "this test; trying to set PAPI_GRN_THR", 00258 retval); 00259 } 00260 00261 00262 retval = PAPI_add_named_event(EventSet4, "PAPI_TOT_CYC"); 00263 if (retval != PAPI_OK) { 00264 if ( !TESTS_QUIET ) { 00265 fprintf(stderr,"Error trying to add PAPI_TOT_CYC\n"); 00266 } 00267 test_fail(__FILE__, __LINE__, "adding PAPI_TOT_CYC ",retval); 00268 } 00269 00270 retval = PAPI_start( EventSet4 ); 00271 if ( retval != PAPI_OK ) { 00272 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00273 } 00274 00275 do_flops( NUM_FLOPS ); 00276 00277 retval = PAPI_stop( EventSet4, grn_thr_values ); 00278 if ( retval != PAPI_OK ) { 00279 test_fail( __FILE__, __LINE__, "PAPI_stop", retval ); 00280 } 00281 00282 if ( !TESTS_QUIET ) { 00283 printf("%lld\n",grn_thr_values[0]); 00284 } 00285 00286 00287 /***************************/ 00288 /***************************/ 00289 /* PAPI_GRN_PROC events */ 00290 /***************************/ 00291 /***************************/ 00292 00293 if ( !TESTS_QUIET ) { 00294 printf("\tPAPI_GRN_PROC:\t\t\t"); 00295 } 00296 00297 retval = PAPI_create_eventset(&EventSet5); 00298 if (retval != PAPI_OK) { 00299 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval); 00300 } 00301 00302 retval = PAPI_assign_eventset_component(EventSet5, 0); 00303 00304 /* Set the granularity to system-wide */ 00305 00306 gran_opt.def_cidx=0; 00307 gran_opt.eventset=EventSet5; 00308 gran_opt.granularity=PAPI_GRN_PROC; 00309 00310 retval = PAPI_set_opt(PAPI_GRANUL,(PAPI_option_t*)&gran_opt); 00311 if (retval != PAPI_OK) { 00312 if (!TESTS_QUIET) { 00313 printf("Unable to set PAPI_GRN_PROC\n"); 00314 } 00315 } 00316 else { 00317 retval = PAPI_add_named_event(EventSet5, "PAPI_TOT_CYC"); 00318 if (retval != PAPI_OK) { 00319 if ( !TESTS_QUIET ) { 00320 printf("Error trying to add PAPI_TOT_CYC\n"); 00321 } 00322 test_fail(__FILE__, __LINE__, "adding PAPI_TOT_CYC ",retval); 00323 } 00324 00325 retval = PAPI_start( EventSet5 ); 00326 if ( retval != PAPI_OK ) { 00327 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00328 } 00329 00330 do_flops( NUM_FLOPS ); 00331 00332 retval = PAPI_stop( EventSet5, grn_proc_values ); 00333 if ( retval != PAPI_OK ) { 00334 test_fail( __FILE__, __LINE__, "PAPI_stop", retval ); 00335 } 00336 00337 if ( !TESTS_QUIET ) { 00338 printf("%lld\n",grn_proc_values[0]); 00339 } 00340 } 00341 00342 00343 00344 /***************************/ 00345 /***************************/ 00346 /* PAPI_GRN_SYS events */ 00347 /***************************/ 00348 /***************************/ 00349 00350 if ( !TESTS_QUIET ) { 00351 printf("\tPAPI_GRN_SYS:\t\t\t"); 00352 } 00353 00354 retval = PAPI_create_eventset(&EventSet6); 00355 if (retval != PAPI_OK) { 00356 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval); 00357 } 00358 00359 retval = PAPI_assign_eventset_component(EventSet6, 0); 00360 00361 /* Set the granularity to system-wide */ 00362 00363 gran_opt.def_cidx=0; 00364 gran_opt.eventset=EventSet6; 00365 gran_opt.granularity=PAPI_GRN_SYS; 00366 00367 retval = PAPI_set_opt(PAPI_GRANUL,(PAPI_option_t*)&gran_opt); 00368 if (retval != PAPI_OK) { 00369 if (!TESTS_QUIET) { 00370 printf("Unable to set PAPI_GRN_SYS\n"); 00371 } 00372 } 00373 else { 00374 retval = PAPI_add_named_event(EventSet6, "PAPI_TOT_CYC"); 00375 if (retval != PAPI_OK) { 00376 if ( !TESTS_QUIET ) { 00377 printf("Error trying to add PAPI_TOT_CYC\n"); 00378 } 00379 } else { 00380 00381 retval = PAPI_start( EventSet6 ); 00382 if ( retval != PAPI_OK ) { 00383 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00384 } 00385 00386 do_flops( NUM_FLOPS ); 00387 00388 retval = PAPI_stop( EventSet6, grn_sys_values ); 00389 if ( retval != PAPI_OK ) { 00390 test_fail( __FILE__, __LINE__, "PAPI_stop", retval ); 00391 } 00392 00393 if ( !TESTS_QUIET ) { 00394 printf("GRN_SYS PAPI_TOT_CYC: %lld\n",grn_sys_values[0]); 00395 } 00396 } 00397 00398 } 00399 00400 00401 /****************************/ 00402 /****************************/ 00403 /* PAPI_GRN_SYS_CPU events */ 00404 /****************************/ 00405 /****************************/ 00406 00407 if ( !TESTS_QUIET ) { 00408 printf("\tPAPI_GRN_SYS_CPU:\t\t"); 00409 } 00410 00411 retval = PAPI_create_eventset(&EventSet7); 00412 if (retval != PAPI_OK) { 00413 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval); 00414 } 00415 00416 retval = PAPI_assign_eventset_component(EventSet7, 0); 00417 00418 /* Set the granularity to system-wide */ 00419 00420 gran_opt.def_cidx=0; 00421 gran_opt.eventset=EventSet7; 00422 gran_opt.granularity=PAPI_GRN_SYS_CPU; 00423 00424 retval = PAPI_set_opt(PAPI_GRANUL,(PAPI_option_t*)&gran_opt); 00425 if (retval != PAPI_OK) { 00426 if (!TESTS_QUIET) { 00427 printf("Unable to set PAPI_GRN_SYS_CPU\n"); 00428 } 00429 } 00430 else { 00431 retval = PAPI_add_named_event(EventSet7, "PAPI_TOT_CYC"); 00432 if (retval != PAPI_OK) { 00433 if ( !TESTS_QUIET ) { 00434 printf("Error trying to add PAPI_TOT_CYC\n"); 00435 } 00436 test_fail(__FILE__, __LINE__, "adding PAPI_TOT_CYC ",retval); 00437 } 00438 00439 retval = PAPI_start( EventSet7 ); 00440 if ( retval != PAPI_OK ) { 00441 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00442 } 00443 00444 do_flops( NUM_FLOPS ); 00445 00446 retval = PAPI_stop( EventSet7, grn_sys_cpu_values ); 00447 if ( retval != PAPI_OK ) { 00448 test_fail( __FILE__, __LINE__, "PAPI_stop", retval ); 00449 } 00450 00451 if ( !TESTS_QUIET ) { 00452 printf("%lld\n",grn_sys_cpu_values[0]); 00453 } 00454 } 00455 00456 00457 /***************************/ 00458 /***************************/ 00459 /* SYS and ATTACH events */ 00460 /***************************/ 00461 /***************************/ 00462 00463 if ( !TESTS_QUIET ) { 00464 printf("\nPAPI_GRN_SYS plus CPU attach:\n"); 00465 } 00466 00467 if ( !TESTS_QUIET ) { 00468 printf("\tGRN_SYS, DOM_USER, CPU 0 attach:\t"); 00469 } 00470 00471 retval = PAPI_create_eventset(&EventSet8); 00472 if (retval != PAPI_OK) { 00473 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval); 00474 } 00475 00476 retval = PAPI_assign_eventset_component(EventSet8, 0); 00477 00478 /* Set the granularity to system-wide */ 00479 00480 gran_opt.def_cidx=0; 00481 gran_opt.eventset=EventSet8; 00482 gran_opt.granularity=PAPI_GRN_SYS; 00483 00484 retval = PAPI_set_opt(PAPI_GRANUL,(PAPI_option_t*)&gran_opt); 00485 if (retval != PAPI_OK) { 00486 if (!TESTS_QUIET) { 00487 printf("Unable to set PAPI_GRN_SYS\n"); 00488 } 00489 } 00490 else { 00491 /* we need to set to a certain cpu */ 00492 00493 cpu_opt.eventset=EventSet8; 00494 cpu_opt.cpu_num=0; 00495 00496 retval = PAPI_set_opt(PAPI_CPU_ATTACH,(PAPI_option_t*)&cpu_opt); 00497 if (retval != PAPI_OK) { 00498 if (retval==PAPI_EPERM) { 00499 test_skip( __FILE__, __LINE__, 00500 "this test; trying to CPU_ATTACH; need to run as root", 00501 retval); 00502 } 00503 00504 test_fail(__FILE__, __LINE__, "PAPI_CPU_ATTACH",retval); 00505 } 00506 00507 retval = PAPI_add_named_event(EventSet8, "PAPI_TOT_CYC"); 00508 if (retval != PAPI_OK) { 00509 if ( !TESTS_QUIET ) { 00510 printf("Error trying to add PAPI_TOT_CYC\n"); 00511 } 00512 test_fail(__FILE__, __LINE__, "adding PAPI_TOT_CYC ",retval); 00513 } 00514 00515 retval = PAPI_start( EventSet8 ); 00516 if ( retval != PAPI_OK ) { 00517 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00518 } 00519 00520 do_flops( NUM_FLOPS ); 00521 00522 retval = PAPI_stop( EventSet8, total_values ); 00523 if ( retval != PAPI_OK ) { 00524 test_fail( __FILE__, __LINE__, "PAPI_stop", retval ); 00525 } 00526 00527 if ( !TESTS_QUIET ) { 00528 printf("%lld\n",total_values[0]); 00529 } 00530 } 00531 00532 00533 /***************************/ 00534 /***************************/ 00535 /* SYS and ATTACH, bind CPU events */ 00536 /***************************/ 00537 /***************************/ 00538 00539 if ( !TESTS_QUIET ) { 00540 printf("\tGRN_SYS, DOM_USER, CPU 0 affinity:\t"); 00541 } 00542 00543 /* Set affinity to CPU 0 */ 00544 CPU_ZERO(&mask); 00545 CPU_SET(0,&mask); 00546 retval=sched_setaffinity(0, sizeof(mask), &mask); 00547 00548 if (retval<0) { 00549 if (!TESTS_QUIET) { 00550 printf("Setting affinity failed: %s\n",strerror(errno)); 00551 } 00552 } else { 00553 00554 retval = PAPI_create_eventset(&EventSet9); 00555 if (retval != PAPI_OK) { 00556 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval); 00557 } 00558 00559 retval = PAPI_assign_eventset_component(EventSet9, 0); 00560 00561 /* Set the granularity to system-wide */ 00562 00563 gran_opt.def_cidx=0; 00564 gran_opt.eventset=EventSet9; 00565 gran_opt.granularity=PAPI_GRN_SYS; 00566 00567 retval = PAPI_set_opt(PAPI_GRANUL,(PAPI_option_t*)&gran_opt); 00568 if (retval != PAPI_OK) { 00569 if (!TESTS_QUIET) { 00570 printf("Unable to set PAPI_GRN_SYS\n"); 00571 } 00572 } 00573 else { 00574 /* we need to set to a certain cpu for uncore to work */ 00575 00576 cpu_opt.eventset=EventSet9; 00577 cpu_opt.cpu_num=0; 00578 00579 retval = PAPI_set_opt(PAPI_CPU_ATTACH,(PAPI_option_t*)&cpu_opt); 00580 if (retval != PAPI_OK) { 00581 test_fail(__FILE__, __LINE__, "PAPI_CPU_ATTACH",retval); 00582 } 00583 00584 retval = PAPI_add_named_event(EventSet9, "PAPI_TOT_CYC"); 00585 if (retval != PAPI_OK) { 00586 if ( !TESTS_QUIET ) { 00587 printf("Error trying to add PAPI_TOT_CYC\n"); 00588 } 00589 test_fail(__FILE__, __LINE__, "adding PAPI_TOT_CYC ",retval); 00590 } 00591 00592 retval = PAPI_start( EventSet9 ); 00593 if ( retval != PAPI_OK ) { 00594 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00595 } 00596 00597 do_flops( NUM_FLOPS ); 00598 00599 retval = PAPI_stop( EventSet9, total_affinity_values ); 00600 if ( retval != PAPI_OK ) { 00601 test_fail( __FILE__, __LINE__, "PAPI_stop", retval ); 00602 } 00603 00604 if ( !TESTS_QUIET ) { 00605 printf("%lld\n",total_affinity_values[0]); 00606 } 00607 } 00608 } 00609 00610 /***************************/ 00611 /***************************/ 00612 /* SYS and ATTACH, bind CPU events */ 00613 /***************************/ 00614 /***************************/ 00615 00616 if ( !TESTS_QUIET ) { 00617 printf("\tGRN_SYS, DOM_ALL, CPU 0 affinity:\t"); 00618 } 00619 00620 00621 00622 /* Set affinity to CPU 0 */ 00623 CPU_ZERO(&mask); 00624 CPU_SET(0,&mask); 00625 retval=sched_setaffinity(0, sizeof(mask), &mask); 00626 00627 if (retval<0) { 00628 if (!TESTS_QUIET) { 00629 printf("Setting affinity failed: %s\n",strerror(errno)); 00630 } 00631 } else { 00632 00633 retval = PAPI_create_eventset(&EventSet10); 00634 if (retval != PAPI_OK) { 00635 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval); 00636 } 00637 00638 retval = PAPI_assign_eventset_component(EventSet10, 0); 00639 00640 /* Set DOM_ALL */ 00641 domain_opt.def_cidx=0; 00642 domain_opt.eventset=EventSet10; 00643 domain_opt.domain=PAPI_DOM_ALL; 00644 00645 retval = PAPI_set_opt(PAPI_DOMAIN,(PAPI_option_t*)&domain_opt); 00646 if (retval != PAPI_OK) { 00647 00648 if (retval==PAPI_EPERM) { 00649 test_skip( __FILE__, __LINE__, 00650 "this test; trying to set PAPI_DOM_ALL; need to run as root", 00651 retval); 00652 } 00653 else { 00654 test_fail(__FILE__, __LINE__, "setting PAPI_DOM_ALL",retval); 00655 } 00656 } 00657 00658 /* Set the granularity to system-wide */ 00659 00660 gran_opt.def_cidx=0; 00661 gran_opt.eventset=EventSet10; 00662 gran_opt.granularity=PAPI_GRN_SYS; 00663 00664 retval = PAPI_set_opt(PAPI_GRANUL,(PAPI_option_t*)&gran_opt); 00665 if (retval != PAPI_OK) { 00666 if (!TESTS_QUIET) { 00667 printf("Unable to set PAPI_GRN_SYS\n"); 00668 } 00669 } 00670 else { 00671 /* we need to set to a certain cpu for uncore to work */ 00672 00673 cpu_opt.eventset=EventSet10; 00674 cpu_opt.cpu_num=0; 00675 00676 retval = PAPI_set_opt(PAPI_CPU_ATTACH,(PAPI_option_t*)&cpu_opt); 00677 if (retval != PAPI_OK) { 00678 test_fail(__FILE__, __LINE__, "PAPI_CPU_ATTACH",retval); 00679 } 00680 00681 retval = PAPI_add_named_event(EventSet10, "PAPI_TOT_CYC"); 00682 if (retval != PAPI_OK) { 00683 if ( !TESTS_QUIET ) { 00684 printf("Error trying to add PAPI_TOT_CYC\n"); 00685 } 00686 test_fail(__FILE__, __LINE__, "adding PAPI_TOT_CYC ",retval); 00687 } 00688 00689 retval = PAPI_start( EventSet10 ); 00690 if ( retval != PAPI_OK ) { 00691 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00692 } 00693 00694 do_flops( NUM_FLOPS ); 00695 00696 retval = PAPI_stop( EventSet10, total_all_values ); 00697 if ( retval != PAPI_OK ) { 00698 test_fail( __FILE__, __LINE__, "PAPI_stop", retval ); 00699 } 00700 00701 if ( !TESTS_QUIET ) { 00702 printf("%lld\n",total_all_values[0]); 00703 } 00704 } 00705 } 00706 00707 /**************/ 00708 /* Validation */ 00709 /**************/ 00710 00711 if ( !TESTS_QUIET ) { 00712 printf("\n"); 00713 } 00714 00715 if ( !TESTS_QUIET ) { 00716 printf("Validating:\n"); 00717 printf("\tDOM_USER|DOM_KERNEL (%lld) > DOM_USER (%lld)\n", 00718 dom_userkernel_values[0],dom_user_values[0]); 00719 } 00720 if (dom_user_values[0] > dom_userkernel_values[0]) { 00721 test_fail( __FILE__, __LINE__, "DOM_USER too high", 0 ); 00722 } 00723 00724 if ( !TESTS_QUIET ) { 00725 printf("\n"); 00726 } 00727 00728 test_pass( __FILE__, NULL, 0 ); 00729 00730 return 0; 00731 }