85{
86
87 int retval,cid,rapl_cid=-1,numcmp;
91 int code;
99 double elapsed_time;
100
101#ifdef WRAP_TEST
102
103 int do_wrap=0;
104
105 if ( argc > 1 ) {
106 if ( strstr( argv[1], "-w" ) ) {
107 do_wrap = 1;
108 }
109 }
110
111#endif
112
113
115
116
120 }
121
123 printf("Trying all RAPL events\n");
124 }
125
127
128 for(cid=0; cid<numcmp; cid++) {
129
131 test_fail(__FILE__, __LINE__,
"PAPI_get_component_info failed\n", 0);
132 }
133
134 if (strstr(cmpinfo->
name,
"rapl")) {
135
136 rapl_cid=cid;
137
139 printf("Found rapl component at cid %d\n",rapl_cid);
140 }
141
144 printf("RAPL component disabled: %s\n",
146 }
147 test_skip(__FILE__,__LINE__,
"RAPL component disabled",0);
148 }
149 break;
150 }
151 }
152
153
154 if (cid==numcmp) {
155 test_skip(__FILE__,__LINE__,
"No rapl component found\n",0);
156 }
157
158
162 "PAPI_create_eventset()",
retval);
163 }
164
165
166
168
170
172
175 printf("Error translating %#x\n",code);
177 "PAPI_event_code_to_name",
retval );
178 }
179
183 "Error getting event info\n",
retval);
184 }
185
187
189
191
194 break;
195 }
197
199 }
200
205 }
206
208 printf("\nStarting measurements...\n\n");
209 }
210
211
216 }
217
218
220
221
226 }
227
229
231 printf("\nStopping measurements, took %.3fs, gathering results...\n\n",
232 elapsed_time);
233
234 printf("Scaled energy measurements:\n");
235
237 if (strstr(
units[
i],
"nJ")) {
238
239 printf("%-40s%12.6f J\t(Average Power %.1fW)\n",
242 ((
double)
values[
i]/1.0e9)/elapsed_time);
243 }
244 }
245
246 printf("\n");
247 printf("Energy measurement counts:\n");
248
252 }
253 }
254
255 printf("\n");
256 printf("Scaled Fixed values:\n");
257
261
262 union {
263 long long ll;
266
269 }
270 }
271 }
272
273 printf("\n");
274 printf("Fixed value counts:\n");
275
280 }
281 }
282 }
283
284 }
285
286#ifdef WRAP_TEST
287 double max_time;
288 unsigned long long max_value = 0;
289 int repeat;
290
293 if (max_value < (
unsigned)
values[
i]) {
295 }
296 }
297 }
298 max_time = elapsed_time * ( (double)0xffffffff / (double)max_value );
299 printf("\n");
300 printf ("Approximate time to energy measurement wraparound: %.3f sec or %.3f min.\n",
301 max_time, max_time/60);
302
303 if (do_wrap) {
304 printf ("Beginning wraparound execution.");
305
310 }
311
312
313 repeat = (
int)(max_time/elapsed_time);
314 for (
i=0;
i< repeat;
i++) {
316 printf(
"."); fflush(
stdout);
317 }
318 printf("\n");
319
320
325 }
326
328 printf("\nStopping measurements, took %.3fs\n\n", elapsed_time);
329
330 printf("Scaled energy measurements:\n");
331
333 if (strstr(
units[
i],
"nJ")) {
334
335 printf("%-40s%12.6f J\t(Average Power %.1fW)\n",
338 ((
double)
values[
i]/1.0e9)/elapsed_time);
339 }
340 }
341 printf("\n");
342 printf("Energy measurement counts:\n");
343
347 }
348 }
349 }
350
351#endif
352
353
357 "PAPI_cleanup_eventset()",
retval);
358 }
359
363 "PAPI_destroy_eventset()",
retval);
364 }
365
367
368 return 0;
369}
static const char * event_names[2]
add PAPI preset or native hardware event to an event set
Empty and destroy an EventSet.
Create a new empty PAPI EventSet.
Empty and destroy an EventSet.
Enumerate PAPI preset or native events for a given component.
Convert a numeric hardware event code to a name.
get information about a specific software component
Get the event's name and description info.
Get real time counter value in nanoseconds.
initialize the PAPI library.
Get the number of components available on the system.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
#define PAPI_DATATYPE_FP64
#define PAPI_DATATYPE_UINT64
static long long values[NUM_EVENTS]
int tests_quiet(int argc, char **argv)
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
void PAPI_NORETURN test_pass(const char *filename)
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
int data_type[MAX_EVENTS]
char units[MAX_EVENTS][BUFSIZ]
#define MAX_RAPL_EVENTS
Tests basic functionality of RAPL component.
static long long after_time
static long long before_time
char name[PAPI_MAX_STR_LEN]
char disabled_reason[PAPI_HUGE_STR_LEN]
char units[PAPI_MIN_STR_LEN]