PAPI  5.3.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
host_micpower_basic.c File Reference
Include dependency graph for host_micpower_basic.c:

Go to the source code of this file.

Macros

#define NUM_EVENTS   1
 Tests basic component functionality. More...
 

Functions

int main (int argc, char **argv)
 

Macro Definition 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.

23 {
24 
25  int retval,cid,numcmp;
26  int EventSet = PAPI_NULL;
27  long long values[NUM_EVENTS];
28  int code;
30  int total_events=0;
31  int r;
32  const PAPI_component_info_t *cmpinfo = NULL;
33 
34  /* Set TESTS_QUIET variable */
35  tests_quiet( argc, argv );
36 
37  /* PAPI Initialization */
39  if ( retval != PAPI_VER_CURRENT ) {
40  test_fail(__FILE__, __LINE__,"PAPI_library_init failed\n",retval);
41  }
42 
43  numcmp = PAPI_num_components();
44 
45  for(cid=0; cid<numcmp; cid++) {
46 
47  if ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) {
48  test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n", 0);
49  }
50  if (!TESTS_QUIET) {
51  printf("\tComponent %d - %s\n", cid, cmpinfo->name);
52  }
53 
54  if ( 0 != strncmp(cmpinfo->name,"host_micpower",13)) {
55  continue;
56  }
57 
58  code = PAPI_NATIVE_MASK;
59 
60  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
61 
62  while ( r == PAPI_OK ) {
63  retval = PAPI_event_code_to_name( code, event_name );
64  if ( retval != PAPI_OK ) {
65  printf("Error translating %#x\n",code);
66  test_fail( __FILE__, __LINE__,
67  "PAPI_event_code_to_name", retval );
68  }
69 
70  if (!TESTS_QUIET) printf("%#x %s ",code,event_name);
71 
72  EventSet = PAPI_NULL;
73 
74  retval = PAPI_create_eventset( &EventSet );
75  if (retval != PAPI_OK) {
76  test_fail(__FILE__, __LINE__,
77  "PAPI_create_eventset()",retval);
78  }
79 
80  retval = PAPI_add_event( EventSet, code );
81  if (retval != PAPI_OK) {
82  test_fail(__FILE__, __LINE__,
83  "PAPI_add_event()",retval);
84  }
85 
86  retval = PAPI_start( EventSet);
87  if (retval != PAPI_OK) {
88  test_fail(__FILE__, __LINE__, "PAPI_start()",retval);
89  }
90 
91  retval = PAPI_stop( EventSet, values);
92  if (retval != PAPI_OK) {
93  test_fail(__FILE__, __LINE__, "PAPI_stop()",retval);
94  }
95 
96  if (!TESTS_QUIET) printf(" value: %lld\n",values[0]);
97 
98  retval = PAPI_cleanup_eventset( EventSet );
99  if (retval != PAPI_OK) {
100  test_fail(__FILE__, __LINE__,
101  "PAPI_cleanup_eventset()",retval);
102  }
103 
104  retval = PAPI_destroy_eventset( &EventSet );
105  if (retval != PAPI_OK) {
106  test_fail(__FILE__, __LINE__,
107  "PAPI_destroy_eventset()",retval);
108  }
109 
110  total_events++;
111  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
112  }
113  }
114 
115  if (total_events==0) {
116 
117  test_skip(__FILE__,__LINE__,"No events from host_micpower found",0);
118  }
119 
120  test_pass( __FILE__, NULL, 0 );
121 
122  return 0;
123 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:625
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2232
#define PAPI_NATIVE_MASK
#define NUM_EVENTS
Tests basic component functionality.
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:805
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1604
#define PAPI_NULL
Definition: fpapi.h:13
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
int PAPI_num_components(void)
Definition: papi.c:4285
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
int TESTS_QUIET
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:495
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
Definition: papi.c:1311
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2805
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1406
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:924
int EventSet
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1944
int PAPI_start(int EventSet)
Definition: papi.c:2026
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function: