PAPI  5.6.0.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 23 of file host_micpower_basic.c.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 25 of file host_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 ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) {
51  test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n", 0);
52  }
53  if (!TESTS_QUIET) {
54  printf("\tComponent %d - %s\n", cid, cmpinfo->name);
55  }
56 
57  if ( 0 != strncmp(cmpinfo->name,"host_micpower",13)) {
58  continue;
59  }
60 
61  code = PAPI_NATIVE_MASK;
62 
63  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
64 
65  while ( r == PAPI_OK ) {
66  retval = PAPI_event_code_to_name( code, event_name );
67  if ( retval != PAPI_OK ) {
68  printf("Error translating %#x\n",code);
69  test_fail( __FILE__, __LINE__,
70  "PAPI_event_code_to_name", retval );
71  }
72 
73  if (!TESTS_QUIET) printf("%#x %s ",code,event_name);
74 
75  EventSet = PAPI_NULL;
76 
77  retval = PAPI_create_eventset( &EventSet );
78  if (retval != PAPI_OK) {
79  test_fail(__FILE__, __LINE__,
80  "PAPI_create_eventset()",retval);
81  }
82 
83  retval = PAPI_add_event( EventSet, code );
84  if (retval != PAPI_OK) {
85  test_fail(__FILE__, __LINE__,
86  "PAPI_add_event()",retval);
87  }
88 
89  retval = PAPI_start( EventSet);
90  if (retval != PAPI_OK) {
91  test_fail(__FILE__, __LINE__, "PAPI_start()",retval);
92  }
93 
94  retval = PAPI_stop( EventSet, values);
95  if (retval != PAPI_OK) {
96  test_fail(__FILE__, __LINE__, "PAPI_stop()",retval);
97  }
98 
99  if (!TESTS_QUIET) printf(" value: %lld\n",values[0]);
100 
101  retval = PAPI_cleanup_eventset( EventSet );
102  if (retval != PAPI_OK) {
103  test_fail(__FILE__, __LINE__,
104  "PAPI_cleanup_eventset()",retval);
105  }
106 
107  retval = PAPI_destroy_eventset( &EventSet );
108  if (retval != PAPI_OK) {
109  test_fail(__FILE__, __LINE__,
110  "PAPI_destroy_eventset()",retval);
111  }
112 
113  total_events++;
114  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
115  }
116  }
117 
118  if (total_events==0) {
119 
120  test_skip(__FILE__,__LINE__,"No events from host_micpower found",0);
121  }
122 
123  test_pass( __FILE__ );
124 
125  return 0;
126 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:629
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
#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:796
void test_pass(const char *filename)
Definition: test_utils.c:432
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
#define PAPI_NULL
Definition: papi.h:292
int PAPI_num_components(void)
Definition: papi.c:4387
int EventSet
return PAPI_OK
Definition: linux-nvml.c:497
int int argc
Definition: iozone.c:1609
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:559
char ** argv
Definition: iozone.c:1610
int PAPI_library_init(int version)
Definition: papi.c:500
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
printf("\tTry: -i 0 -i 1 \n\n")
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
#define PAPI_MAX_STR_LEN
Definition: papi.h:465
int PAPI_start(int EventSet)
Definition: papi.c:2096
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:225

Here is the call graph for this function: