perf_event_system_wide.c File Reference

Include dependency graph for perf_event_system_wide.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 15 of file perf_event_system_wide.c.

00015                                   {
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 individual thread */
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 process */
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 current cpu */
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          test_fail(__FILE__, __LINE__, "adding PAPI_TOT_CYC ",retval);
00380       } else {
00381 
00382          retval = PAPI_start( EventSet6 );
00383          if ( retval != PAPI_OK ) {
00384             test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00385          }
00386 
00387          do_flops( NUM_FLOPS );
00388 
00389          retval = PAPI_stop( EventSet6, grn_sys_values );
00390          if ( retval != PAPI_OK ) {
00391             test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00392          }
00393 
00394          if ( !TESTS_QUIET ) {
00395             printf("%lld\n",grn_sys_values[0]);
00396          }
00397       }
00398 
00399    }
00400 
00401 
00402    /****************************/
00403    /****************************/
00404    /* PAPI_GRN_SYS_CPU  events */
00405    /****************************/
00406    /****************************/
00407 
00408    if ( !TESTS_QUIET ) {
00409       printf("\tPAPI_GRN_SYS_CPU:\t\t");
00410    }
00411 
00412    retval = PAPI_create_eventset(&EventSet7);
00413    if (retval != PAPI_OK) {
00414       test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval);
00415    }
00416 
00417    retval = PAPI_assign_eventset_component(EventSet7, 0);
00418 
00419    /* Set the granularity to all cpus */
00420 
00421    gran_opt.def_cidx=0;
00422    gran_opt.eventset=EventSet7;
00423    gran_opt.granularity=PAPI_GRN_SYS_CPU;
00424 
00425    retval = PAPI_set_opt(PAPI_GRANUL,(PAPI_option_t*)&gran_opt);
00426    if (retval != PAPI_OK) {
00427       if (!TESTS_QUIET) {
00428          printf("Unable to set PAPI_GRN_SYS_CPU\n");
00429       }
00430    }
00431    else {
00432       retval = PAPI_add_named_event(EventSet7, "PAPI_TOT_CYC");
00433       if (retval != PAPI_OK) {
00434          if ( !TESTS_QUIET ) {
00435             printf("Error trying to add PAPI_TOT_CYC\n");
00436          }
00437          test_fail(__FILE__, __LINE__, "adding PAPI_TOT_CYC ",retval);
00438       }
00439 
00440       retval = PAPI_start( EventSet7 );
00441       if ( retval != PAPI_OK ) {
00442          test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00443       }
00444 
00445       do_flops( NUM_FLOPS );
00446 
00447       retval = PAPI_stop( EventSet7, grn_sys_cpu_values );
00448       if ( retval != PAPI_OK ) {
00449          test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00450       }
00451 
00452       if ( !TESTS_QUIET ) {
00453          printf("%lld\n",grn_sys_cpu_values[0]);
00454       }
00455    }
00456 
00457 
00458    /***************************/
00459    /***************************/
00460    /* SYS and ATTACH  events  */
00461    /***************************/
00462    /***************************/
00463 
00464    if ( !TESTS_QUIET ) {
00465       printf("\nPAPI_GRN_SYS plus CPU attach:\n");
00466    }
00467 
00468    if ( !TESTS_QUIET ) {
00469       printf("\tGRN_SYS, DOM_USER, CPU 0 attach:\t");
00470    }
00471 
00472    retval = PAPI_create_eventset(&EventSet8);
00473    if (retval != PAPI_OK) {
00474       test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval);
00475    }
00476 
00477    retval = PAPI_assign_eventset_component(EventSet8, 0);
00478 
00479    /* Set the granularity to system-wide */
00480 
00481    gran_opt.def_cidx=0;
00482    gran_opt.eventset=EventSet8;
00483    gran_opt.granularity=PAPI_GRN_SYS;
00484 
00485    retval = PAPI_set_opt(PAPI_GRANUL,(PAPI_option_t*)&gran_opt);
00486    if (retval != PAPI_OK) {
00487       if (!TESTS_QUIET) {
00488          printf("Unable to set PAPI_GRN_SYS\n");
00489       }
00490    }
00491    else {
00492       /* we need to set to a certain cpu */
00493 
00494       cpu_opt.eventset=EventSet8;
00495       cpu_opt.cpu_num=0;
00496 
00497       retval = PAPI_set_opt(PAPI_CPU_ATTACH,(PAPI_option_t*)&cpu_opt);
00498       if (retval != PAPI_OK) {
00499      if (retval==PAPI_EPERM) {
00500             test_skip( __FILE__, __LINE__,
00501             "this test; trying to CPU_ATTACH; need to run as root",
00502             retval);
00503      }
00504 
00505          test_fail(__FILE__, __LINE__, "PAPI_CPU_ATTACH",retval);
00506       }
00507 
00508       retval = PAPI_add_named_event(EventSet8, "PAPI_TOT_CYC");
00509       if (retval != PAPI_OK) {
00510          if ( !TESTS_QUIET ) {
00511             printf("Error trying to add PAPI_TOT_CYC\n");
00512          }
00513          test_fail(__FILE__, __LINE__, "adding PAPI_TOT_CYC ",retval);
00514       }
00515 
00516       retval = PAPI_start( EventSet8 );
00517       if ( retval != PAPI_OK ) {
00518          test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00519       }
00520 
00521       do_flops( NUM_FLOPS );
00522 
00523       retval = PAPI_stop( EventSet8, total_values );
00524       if ( retval != PAPI_OK ) {
00525          test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00526       }
00527 
00528       if ( !TESTS_QUIET ) {
00529          printf("%lld\n",total_values[0]);
00530       }
00531    }
00532 
00533 
00534    /***************************/
00535    /***************************/
00536    /* SYS and ATTACH, bind CPU  events  */
00537    /***************************/
00538    /***************************/
00539 
00540    if ( !TESTS_QUIET ) {
00541       printf("\tGRN_SYS, DOM_USER, CPU 0 affinity:\t");
00542    }
00543 
00544    /* Set affinity to CPU 0 */
00545    CPU_ZERO(&mask);
00546    CPU_SET(0,&mask);
00547    retval=sched_setaffinity(0, sizeof(mask), &mask);
00548 
00549    if (retval<0) {
00550      if (!TESTS_QUIET) {
00551         printf("Setting affinity failed: %s\n",strerror(errno));
00552      }
00553    } else {
00554    
00555       retval = PAPI_create_eventset(&EventSet9);
00556       if (retval != PAPI_OK) {
00557          test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval);
00558       }
00559 
00560       retval = PAPI_assign_eventset_component(EventSet9, 0);
00561 
00562       /* Set the granularity to system-wide */
00563 
00564       gran_opt.def_cidx=0;
00565       gran_opt.eventset=EventSet9;
00566       gran_opt.granularity=PAPI_GRN_SYS;
00567 
00568       retval = PAPI_set_opt(PAPI_GRANUL,(PAPI_option_t*)&gran_opt);
00569       if (retval != PAPI_OK) {
00570          if (!TESTS_QUIET) {
00571             printf("Unable to set PAPI_GRN_SYS\n");
00572          }
00573       }
00574       else {
00575          /* we need to set to a certain cpu for uncore to work */
00576       
00577          cpu_opt.eventset=EventSet9;
00578          cpu_opt.cpu_num=0;
00579 
00580          retval = PAPI_set_opt(PAPI_CPU_ATTACH,(PAPI_option_t*)&cpu_opt);
00581          if (retval != PAPI_OK) {
00582             test_fail(__FILE__, __LINE__, "PAPI_CPU_ATTACH",retval);
00583          }
00584 
00585          retval = PAPI_add_named_event(EventSet9, "PAPI_TOT_CYC");
00586          if (retval != PAPI_OK) {
00587             if ( !TESTS_QUIET ) {
00588                printf("Error trying to add PAPI_TOT_CYC\n");
00589             }
00590             test_fail(__FILE__, __LINE__, "adding PAPI_TOT_CYC ",retval);
00591          }
00592 
00593          retval = PAPI_start( EventSet9 );
00594          if ( retval != PAPI_OK ) {
00595             test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00596          }
00597 
00598          do_flops( NUM_FLOPS );
00599 
00600          retval = PAPI_stop( EventSet9, total_affinity_values );
00601          if ( retval != PAPI_OK ) {
00602             test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00603          }
00604 
00605          if ( !TESTS_QUIET ) {
00606             printf("%lld\n",total_affinity_values[0]);
00607          }
00608       }
00609    }
00610 
00611    /***************************/
00612    /***************************/
00613    /* SYS and ATTACH, bind CPU  events  */
00614    /***************************/
00615    /***************************/
00616 
00617    if ( !TESTS_QUIET ) {
00618       printf("\tGRN_SYS, DOM_ALL, CPU 0 affinity:\t");
00619    }
00620 
00621 
00622 
00623    /* Set affinity to CPU 0 */
00624    CPU_ZERO(&mask);
00625    CPU_SET(0,&mask);
00626    retval=sched_setaffinity(0, sizeof(mask), &mask);
00627 
00628    if (retval<0) {
00629      if (!TESTS_QUIET) {
00630         printf("Setting affinity failed: %s\n",strerror(errno));
00631      }
00632    } else {
00633    
00634       retval = PAPI_create_eventset(&EventSet10);
00635       if (retval != PAPI_OK) {
00636          test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval);
00637       }
00638 
00639       retval = PAPI_assign_eventset_component(EventSet10, 0);
00640 
00641       /* Set DOM_ALL */
00642       domain_opt.def_cidx=0;
00643       domain_opt.eventset=EventSet10;
00644       domain_opt.domain=PAPI_DOM_ALL;
00645 
00646       retval = PAPI_set_opt(PAPI_DOMAIN,(PAPI_option_t*)&domain_opt);
00647       if (retval != PAPI_OK) {
00648 
00649          if (retval==PAPI_EPERM) {
00650             test_skip( __FILE__, __LINE__,
00651             "this test; trying to set PAPI_DOM_ALL; need to run as root",
00652             retval);
00653          }
00654          else {
00655             test_fail(__FILE__, __LINE__, "setting PAPI_DOM_ALL",retval);
00656          }
00657       }
00658 
00659       /* Set the granularity to system-wide */
00660 
00661       gran_opt.def_cidx=0;
00662       gran_opt.eventset=EventSet10;
00663       gran_opt.granularity=PAPI_GRN_SYS;
00664 
00665       retval = PAPI_set_opt(PAPI_GRANUL,(PAPI_option_t*)&gran_opt);
00666       if (retval != PAPI_OK) {
00667          if (!TESTS_QUIET) {
00668             printf("Unable to set PAPI_GRN_SYS\n");
00669          }
00670       }
00671       else {
00672          /* we need to set to a certain cpu for uncore to work */
00673       
00674          cpu_opt.eventset=EventSet10;
00675          cpu_opt.cpu_num=0;
00676 
00677          retval = PAPI_set_opt(PAPI_CPU_ATTACH,(PAPI_option_t*)&cpu_opt);
00678          if (retval != PAPI_OK) {
00679             test_fail(__FILE__, __LINE__, "PAPI_CPU_ATTACH",retval);
00680          }
00681 
00682          retval = PAPI_add_named_event(EventSet10, "PAPI_TOT_CYC");
00683          if (retval != PAPI_OK) {
00684             if ( !TESTS_QUIET ) {
00685                printf("Error trying to add PAPI_TOT_CYC\n");
00686             }
00687             test_fail(__FILE__, __LINE__, "adding PAPI_TOT_CYC ",retval);
00688          }
00689 
00690          retval = PAPI_start( EventSet10 );
00691          if ( retval != PAPI_OK ) {
00692             test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00693          }
00694 
00695          do_flops( NUM_FLOPS );
00696 
00697          retval = PAPI_stop( EventSet10, total_all_values );
00698          if ( retval != PAPI_OK ) {
00699             test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00700          }
00701 
00702          if ( !TESTS_QUIET ) {
00703             printf("%lld\n",total_all_values[0]);
00704          }
00705       }
00706    }
00707 
00708    /**************/
00709    /* Validation */
00710    /**************/
00711 
00712    if ( !TESTS_QUIET ) {
00713       printf("\n");
00714    }
00715 
00716    if ( !TESTS_QUIET ) {
00717       printf("Validating:\n");
00718       printf("\tDOM_USER|DOM_KERNEL (%lld) > DOM_USER (%lld)\n",
00719              dom_userkernel_values[0],dom_user_values[0]);
00720    }
00721    if (dom_user_values[0] > dom_userkernel_values[0]) {
00722       test_fail( __FILE__, __LINE__, "DOM_USER too high", 0 );
00723    }
00724 
00725    if ( !TESTS_QUIET ) {
00726       printf("\n");
00727    }
00728 
00729    test_pass( __FILE__, NULL, 0 );
00730 
00731    return 0;
00732 }

Here is the call graph for this function:


Generated on 8 Sep 2016 for PAPI by  doxygen 1.6.1