|
PAPI
5.0.1.0
|
00001 /****************************/ 00002 /* THIS IS OPEN SOURCE CODE */ 00003 /****************************/ 00004 00015 #include <stdio.h> 00016 #include <stdlib.h> 00017 #include "papi_test.h" 00018 00019 #define NUM_EVENTS 1 00020 00021 int main (int argc, char **argv) 00022 { 00023 00024 int retval,cid,numcmp; 00025 int EventSet = PAPI_NULL; 00026 long long values[NUM_EVENTS]; 00027 int code; 00028 char event_name[PAPI_MAX_STR_LEN]; 00029 int total_events=0; 00030 int r; 00031 const PAPI_component_info_t *cmpinfo = NULL; 00032 00033 /* Set TESTS_QUIET variable */ 00034 tests_quiet( argc, argv ); 00035 00036 /* PAPI Initialization */ 00037 retval = PAPI_library_init( PAPI_VER_CURRENT ); 00038 if ( retval != PAPI_VER_CURRENT ) { 00039 test_fail(__FILE__, __LINE__,"PAPI_library_init failed\n",retval); 00040 } 00041 00042 if (!TESTS_QUIET) { 00043 printf("Trying all hwmon* events\n"); 00044 } 00045 00046 numcmp = PAPI_num_components(); 00047 00048 for(cid=0; cid<numcmp; cid++) { 00049 00050 if (!TESTS_QUIET) { 00051 if ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) { 00052 test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n", 0); 00053 } 00054 printf("\tComponent %d - %s\n", cid, cmpinfo->name); 00055 } 00056 00057 code = PAPI_NATIVE_MASK; 00058 00059 r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid ); 00060 00061 while ( r == PAPI_OK ) { 00062 retval = PAPI_event_code_to_name( code, event_name ); 00063 if ( retval != PAPI_OK ) { 00064 printf("Error translating %x\n",code); 00065 test_fail( __FILE__, __LINE__, 00066 "PAPI_event_code_to_name", retval ); 00067 } 00068 00069 if (!strncmp(event_name,"hwmon",5)) { 00070 if (!TESTS_QUIET) printf("0x%x %s ",code,event_name); 00071 00072 EventSet = PAPI_NULL; 00073 00074 retval = PAPI_create_eventset( &EventSet ); 00075 if (retval != PAPI_OK) { 00076 test_fail(__FILE__, __LINE__, 00077 "PAPI_create_eventset()",retval); 00078 } 00079 00080 retval = PAPI_add_event( EventSet, code ); 00081 if (retval != PAPI_OK) { 00082 test_fail(__FILE__, __LINE__, 00083 "PAPI_add_event()",retval); 00084 } 00085 00086 retval = PAPI_start( EventSet); 00087 if (retval != PAPI_OK) { 00088 test_fail(__FILE__, __LINE__, "PAPI_start()",retval); 00089 } 00090 00091 retval = PAPI_stop( EventSet, values); 00092 if (retval != PAPI_OK) { 00093 test_fail(__FILE__, __LINE__, "PAPI_start()",retval); 00094 } 00095 00096 if (!TESTS_QUIET) printf(" value: %lld\n",values[0]); 00097 00098 retval = PAPI_cleanup_eventset( EventSet ); 00099 if (retval != PAPI_OK) { 00100 test_fail(__FILE__, __LINE__, 00101 "PAPI_cleanup_eventset()",retval); 00102 } 00103 00104 retval = PAPI_destroy_eventset( &EventSet ); 00105 if (retval != PAPI_OK) { 00106 test_fail(__FILE__, __LINE__, 00107 "PAPI_destroy_eventset()",retval); 00108 } 00109 00110 total_events++; 00111 } 00112 r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid ); 00113 } 00114 } 00115 00116 if (total_events==0) { 00117 00118 test_skip(__FILE__,__LINE__,"No coretemp events found",0); 00119 } 00120 00121 test_pass( __FILE__, NULL, 0 ); 00122 00123 return 0; 00124 } 00125