PAPI  5.6.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 22 of file coretemp_basic.c.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 24 of file coretemp_basic.c.

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