|
PAPI
5.3.0.0
|
00001 /* 00002 * This tests the use of offcore_response events 00003 */ 00004 00005 #include "papi_test.h" 00006 00007 #include "event_name_lib.h" 00008 00009 int main( int argc, char **argv ) { 00010 00011 00012 char *offcore_event=NULL; 00013 char event_name[BUFSIZ]; 00014 00015 int retval; 00016 int EventSet1 = PAPI_NULL; 00017 00018 long long total_values[1]; 00019 00020 /* Set TESTS_QUIET variable */ 00021 tests_quiet( argc, argv ); 00022 00023 /* Init the PAPI library */ 00024 retval = PAPI_library_init( PAPI_VER_CURRENT ); 00025 if ( retval != PAPI_VER_CURRENT ) { 00026 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval ); 00027 } 00028 00029 retval = PAPI_create_eventset(&EventSet1); 00030 if (retval != PAPI_OK) { 00031 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval); 00032 } 00033 00034 /* Get a relevant event name */ 00035 offcore_event=get_offcore_event(event_name, BUFSIZ); 00036 if (offcore_event==NULL) { 00037 test_skip( __FILE__, __LINE__, 00038 "PAPI does not support offcore on this processor", PAPI_ENOSUPP ); 00039 } 00040 00041 retval = PAPI_add_named_event(EventSet1, offcore_event); 00042 if (retval != PAPI_OK) { 00043 if ( !TESTS_QUIET ) { 00044 fprintf(stderr,"Error trying to add %s\n",offcore_event); 00045 } 00046 test_fail(__FILE__, __LINE__, "adding offcore event ",retval); 00047 } 00048 00049 retval = PAPI_start( EventSet1 ); 00050 if ( retval != PAPI_OK ) { 00051 test_fail( __FILE__, __LINE__, "PAPI_start", retval ); 00052 } 00053 00054 do_flops( NUM_FLOPS ); 00055 00056 retval = PAPI_stop( EventSet1, total_values ); 00057 if ( retval != PAPI_OK ) { 00058 test_fail( __FILE__, __LINE__, "PAPI_stop", retval ); 00059 } 00060 00061 if ( !TESTS_QUIET ) { 00062 printf("\t%s count = %lld\n",offcore_event,total_values[0]); 00063 } 00064 00065 test_pass( __FILE__, NULL, 0 ); 00066 00067 return 0; 00068 }