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

Go to the source code of this file.

Macros

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

Functions

int main (int argc, char **argv)
 

Macro Definition Documentation

#define NUM_EVENTS   1
Author
Vince Weaver

test case for coretemp component

Definition at line 19 of file coretemp_basic.c.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 21 of file coretemp_basic.c.

22 {
23 
24  int retval,cid,numcmp,coretemp_cid=-1;
25  int EventSet = PAPI_NULL;
26  long long values[NUM_EVENTS];
27  int code;
29  int total_events=0;
30  int r;
31  const PAPI_component_info_t *cmpinfo = NULL;
32 
33  /* Set TESTS_QUIET variable */
34  tests_quiet( argc, argv );
35 
36  /* PAPI Initialization */
38  if ( retval != PAPI_VER_CURRENT ) {
39  test_fail(__FILE__, __LINE__,"PAPI_library_init failed\n",retval);
40  }
41 
42  if (!TESTS_QUIET) {
43  printf("Trying all coretemp events\n");
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__,
52  "PAPI_get_component_info failed\n", 0);
53  }
54 
55  if (strstr(cmpinfo->name,"coretemp")) {
56  coretemp_cid=cid;
57  if (!TESTS_QUIET) {
58  printf("Found coretemp component at cid %d\n", coretemp_cid);
59  }
60 
61  if (cmpinfo->disabled) {
62  if (!TESTS_QUIET) fprintf(stderr,"Coretemp component disabled: %s\n",
63  cmpinfo->disabled_reason);
64  test_skip(__FILE__, __LINE__,
65  "Component disabled\n", 0);
66  }
67  }
68  }
69 
70  if (coretemp_cid==-1) {
71  test_skip(__FILE__,__LINE__,"No coretemp component found",0);
72  }
73 
74 
75  code = PAPI_NATIVE_MASK;
76 
77  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, coretemp_cid );
78 
79  while ( r == PAPI_OK ) {
80  retval = PAPI_event_code_to_name( code, event_name );
81  if ( retval != PAPI_OK ) {
82  printf("Error translating %#x\n",code);
83  test_fail( __FILE__, __LINE__,
84  "PAPI_event_code_to_name", retval );
85  }
86 
87  if (!TESTS_QUIET) printf("%s ",event_name);
88 
89  EventSet = PAPI_NULL;
90 
91  retval = PAPI_create_eventset( &EventSet );
92  if (retval != PAPI_OK) {
93  test_fail(__FILE__, __LINE__,
94  "PAPI_create_eventset()",retval);
95  }
96 
97  retval = PAPI_add_event( EventSet, code );
98  if (retval != PAPI_OK) {
99  test_fail(__FILE__, __LINE__,
100  "PAPI_add_event()",retval);
101  }
102 
103  retval = PAPI_start( EventSet);
104  if (retval != PAPI_OK) {
105  test_fail(__FILE__, __LINE__, "PAPI_start()",retval);
106  }
107 
108  retval = PAPI_stop( EventSet, values);
109  if (retval != PAPI_OK) {
110  test_fail(__FILE__, __LINE__, "PAPI_start()",retval);
111  }
112 
113  if (!TESTS_QUIET) printf(" value: %lld\n",values[0]);
114 
115  retval = PAPI_cleanup_eventset( EventSet );
116  if (retval != PAPI_OK) {
117  test_fail(__FILE__, __LINE__,
118  "PAPI_cleanup_eventset()",retval);
119  }
120 
121  retval = PAPI_destroy_eventset( &EventSet );
122  if (retval != PAPI_OK) {
123  test_fail(__FILE__, __LINE__,
124  "PAPI_destroy_eventset()",retval);
125  }
126 
127  total_events++;
128  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, coretemp_cid );
129  }
130 
131  if (total_events==0) {
132  test_skip(__FILE__,__LINE__,"No coretemp events found",0);
133  }
134 
135  test_pass( __FILE__, NULL, 0 );
136 
137  return 0;
138 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:626
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2258
#define PAPI_NATIVE_MASK
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:807
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1622
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
#define PAPI_NULL
Definition: papi.h:290
int EventSet
Definition: data_range.c:25
int PAPI_num_components(void)
Definition: papi.c:4326
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
char disabled_reason[PAPI_MAX_STR_LEN]
Definition: papi.h:633
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:497
#define NUM_EVENTS
Tests basic coretemp functionality.
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
Definition: papi.c:1324
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2834
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1424
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:926
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1971
#define PAPI_MAX_STR_LEN
Definition: papi.h:463
int PAPI_start(int EventSet)
Definition: papi.c:2053
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:223

Here is the call graph for this function: