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