PAPI  5.7.0.0
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

◆ NUM_EVENTS

#define NUM_EVENTS   1
Author
Vince Weaver

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

Definition at line 23 of file micpower_basic.c.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 25 of file micpower_basic.c.

26 {
27 
28  int retval,cid,numcmp;
29  int EventSet = PAPI_NULL;
30  long long values[NUM_EVENTS];
31  int code;
33  int total_events=0;
34  int r;
35  const PAPI_component_info_t *cmpinfo = NULL;
36 
37  /* Set TESTS_QUIET variable */
38  tests_quiet( argc, argv );
39 
40  /* PAPI Initialization */
42  if ( retval != PAPI_VER_CURRENT ) {
43  test_fail(__FILE__, __LINE__,"PAPI_library_init failed\n",retval);
44  }
45 
46  numcmp = PAPI_num_components();
47 
48  for(cid=0; cid<numcmp; cid++) {
49 
50  if (!TESTS_QUIET) {
51  if ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) {
52  test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n", 0);
53  }
54  printf("\tComponent %d - %s\n", cid, cmpinfo->name);
55  }
56 
57  code = PAPI_NATIVE_MASK;
58 
59  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
60 
61  while ( r == PAPI_OK ) {
63  if ( retval != PAPI_OK ) {
64  printf("Error translating %#x\n",code);
65  test_fail( __FILE__, __LINE__,
66  "PAPI_event_code_to_name", retval );
67  }
68 
69  if (!strncmp(event_name,"micpower",8)) {
70  if (!TESTS_QUIET) printf("%#x %s ",code,event_name);
71 
73 
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 
87  if (retval != PAPI_OK) {
88  test_fail(__FILE__, __LINE__, "PAPI_start()",retval);
89  }
90 
92  if (retval != PAPI_OK) {
93  test_fail(__FILE__, __LINE__, "PAPI_start()",retval);
94  }
95 
96  if (!TESTS_QUIET) printf(" value: %lld\n",values[0]);
97 
99  if (retval != PAPI_OK) {
100  test_fail(__FILE__, __LINE__,
101  "PAPI_cleanup_eventset()",retval);
102  }
103 
105  if (retval != PAPI_OK) {
106  test_fail(__FILE__, __LINE__,
107  "PAPI_destroy_eventset()",retval);
108  }
109 
110  total_events++;
111  }
112  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
113  }
114  }
115 
116  if (total_events==0) {
117 
118  test_skip(__FILE__,__LINE__,"No coretemp events found",0);
119  }
120 
121  test_pass( __FILE__ );
122 
123  return 0;
124 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
#define PAPI_OK
Definition: fpapi.h:105
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
#define PAPI_NATIVE_MASK
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:796
void test_pass(const char *filename)
Definition: test_utils.c:432
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
int PAPI_num_components(void)
Definition: papi.c:4387
#define NUM_EVENTS
Tests basic component functionality.
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
int EventSet
int retval
Definition: zero_fork.c:53
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:561
int PAPI_library_init(int version)
Definition: papi.c:500
#define PAPI_NULL
Definition: fpapi.h:13
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:630
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
Definition: papi.c:1357
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2890
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:915
int TESTS_QUIET
Definition: test_utils.c:18
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:2014
int PAPI_start(int EventSet)
Definition: papi.c:2096
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
Here is the call graph for this function: