PAPI  5.3.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
micpower_basic.c File Reference
Include dependency graph for 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 micpower_basic.c.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 22 of file 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 (!TESTS_QUIET) {
48  if ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) {
49  test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n", 0);
50  }
51  printf("\tComponent %d - %s\n", cid, cmpinfo->name);
52  }
53 
54  code = PAPI_NATIVE_MASK;
55 
56  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
57 
58  while ( r == PAPI_OK ) {
59  retval = PAPI_event_code_to_name( code, event_name );
60  if ( retval != PAPI_OK ) {
61  printf("Error translating %#x\n",code);
62  test_fail( __FILE__, __LINE__,
63  "PAPI_event_code_to_name", retval );
64  }
65 
66  if (!strncmp(event_name,"micpower",8)) {
67  if (!TESTS_QUIET) printf("%#x %s ",code,event_name);
68 
69  EventSet = PAPI_NULL;
70 
71  retval = PAPI_create_eventset( &EventSet );
72  if (retval != PAPI_OK) {
73  test_fail(__FILE__, __LINE__,
74  "PAPI_create_eventset()",retval);
75  }
76 
77  retval = PAPI_add_event( EventSet, code );
78  if (retval != PAPI_OK) {
79  test_fail(__FILE__, __LINE__,
80  "PAPI_add_event()",retval);
81  }
82 
83  retval = PAPI_start( EventSet);
84  if (retval != PAPI_OK) {
85  test_fail(__FILE__, __LINE__, "PAPI_start()",retval);
86  }
87 
88  retval = PAPI_stop( EventSet, values);
89  if (retval != PAPI_OK) {
90  test_fail(__FILE__, __LINE__, "PAPI_start()",retval);
91  }
92 
93  if (!TESTS_QUIET) printf(" value: %lld\n",values[0]);
94 
95  retval = PAPI_cleanup_eventset( EventSet );
96  if (retval != PAPI_OK) {
97  test_fail(__FILE__, __LINE__,
98  "PAPI_cleanup_eventset()",retval);
99  }
100 
101  retval = PAPI_destroy_eventset( &EventSet );
102  if (retval != PAPI_OK) {
103  test_fail(__FILE__, __LINE__,
104  "PAPI_destroy_eventset()",retval);
105  }
106 
107  total_events++;
108  }
109  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
110  }
111  }
112 
113  if (total_events==0) {
114 
115  test_skip(__FILE__,__LINE__,"No coretemp events found",0);
116  }
117 
118  test_pass( __FILE__, NULL, 0 );
119 
120  return 0;
121 }
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:2225
#define PAPI_NATIVE_MASK
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:803
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1597
#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:4272
#define NUM_EVENTS
Tests basic component functionality.
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:1305
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2795
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1399
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:920
int EventSet
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1937
int PAPI_start(int EventSet)
Definition: papi.c:2019
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: