host_micpower_basic.c File Reference

Include dependency graph for host_micpower_basic.c:

Go to the source code of this file.

Defines

#define NUM_EVENTS   1
 Tests basic component functionality.

Functions

int main (int argc, char **argv)

Define Documentation

#define NUM_EVENTS   1
Author:
Vince Weaver

test case for micpower component Based on coretemp test code by Vince Weaver

Definition at line 20 of file host_micpower_basic.c.


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 22 of file host_micpower_basic.c.

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 ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) {
00048                     test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n", 0);
00049             }
00050             if (!TESTS_QUIET) {
00051                     printf("\tComponent %d - %s\n", cid, cmpinfo->name);
00052             }
00053 
00054             if ( 0 != strncmp(cmpinfo->name,"host_micpower",13)) {
00055                     continue;
00056             }
00057 
00058             code = PAPI_NATIVE_MASK;
00059 
00060             r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
00061 
00062             while ( r == PAPI_OK ) {
00063                     retval = PAPI_event_code_to_name( code, event_name );
00064                     if ( retval != PAPI_OK ) {
00065                             printf("Error translating %#x\n",code);
00066                             test_fail( __FILE__, __LINE__, 
00067                                             "PAPI_event_code_to_name", retval );
00068                     }
00069 
00070                     if (!TESTS_QUIET) printf("%#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_stop()",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                     r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
00112             }
00113     }
00114 
00115     if (total_events==0) {
00116 
00117        test_skip(__FILE__,__LINE__,"No events from host_micpower found",0);
00118     }
00119 
00120     test_pass( __FILE__, NULL, 0 );
00121         
00122     return 0;
00123 }

Here is the call graph for this function:


Generated on 8 Sep 2016 for PAPI by  doxygen 1.6.1