31{
32
37 int numcmp,cid,example_cid=-1;
38 int code,maximum_code=0;
42
43
45
46
50 }
51
53 printf( "Testing example component with PAPI %d.%d.%d\n",
57 }
58
59
60
62 for( cid=0; cid<numcmp; cid++) {
65 "PAPI_get_component_info failed\n", 0);
66 }
68 printf("\tComponent %d - %d events - %s\n", cid,
71 }
72 if (strstr(cmpinfo->
name,
"example")) {
73
74 example_cid=cid;
75 }
76 }
77
78
79 if (example_cid<0) {
81 "Example component not found\n", 0);
82 }
83
85 printf("\nFound Example Component at id %d\n",example_cid);
86 printf("\nListing all events in this component:\n");
87 }
88
89
90
91
92
94
96
99 printf("Error translating %#x\n",code);
101 "PAPI_event_code_to_name",
retval );
102 }
103
105 printf("Error getting info for event %#x\n",code);
107 "PAPI_get_event_info()",
retval );
108 }
109
111 printf("\tEvent %#x: %s -- %s\n",
113 }
114
115 maximum_code=code;
116
118
119 }
120 if (!
quiet) printf(
"\n");
121
122
123
124
125
129 "Failed to return PAPI_ENOEVNT on invalid event",
retval );
130 }
131
132
133
134
135
139 "PAPI_create_eventset() failed\n",
retval );
140 }
141
145 "EXAMPLE_ZERO not found\n",
retval );
146 }
147
151 "PAPI_add_events failed\n",
retval );
152 }
153
157 "PAPI_start failed\n",
retval );
158 }
159
163 }
164
165 if (!
quiet) printf(
"Testing EXAMPLE_ZERO: %lld\n",
values[0]);
166
168 test_fail( __FILE__, __LINE__,
"Result should be 0!\n", 0);
169 }
170
174 }
175
179 }
180
182
183
184
185
186
187
191 "PAPI_create_eventset() failed\n",
retval );
192 }
193
197 "EXAMPLE_CONSTANT not found\n",
retval );
198 }
199
203 "PAPI_add_events failed\n",
retval );
204 }
205
209 "PAPI_start failed\n",
retval );
210 }
211
215 }
216
217 if (!
quiet) printf(
"Testing EXAMPLE_CONSTANT: %lld\n",
values[0]);
218
220 test_fail( __FILE__, __LINE__,
"Result should be 42!\n", 0);
221 }
222
226 }
227
231 }
232
234
235
236
237
238
239
240
244 "PAPI_create_eventset() failed\n",
retval );
245 }
246
250 "EXAMPLE_AUTOINC not found\n",
retval );
251 }
252
256 "PAPI_add_events failed\n",
retval );
257 }
258
259 if (!
quiet) printf(
"Testing EXAMPLE_AUTOINC: ");
260
262
266 "PAPI_start failed\n",
retval );
267 }
268
272 }
273
275
277 test_fail( __FILE__, __LINE__,
"Result wrong!\n", 0);
278 }
279 }
280
281 if (!
quiet) printf(
"\n");
282
283
284
285
286
287
291 "PAPI_start failed\n",
retval );
292 }
293
295
299 }
301 }
302
306 }
308
309
310
311
312
313
314
315
316
320 "PAPI_reset() failed\n",
retval );
321 }
322
326 "PAPI_start failed\n",
retval );
327 }
328
332 "PAPI_reset() failed\n",
retval );
333 }
334
338 }
339
340
341 if (!
quiet) printf(
"Testing EXAMPLE_AUTOINC after PAPI_reset(): %lld\n",
343
345 test_fail( __FILE__, __LINE__,
"Result not zero!\n", 0);
346 }
347
351 }
352
356 }
357
359
360
361
362
363
364
365 if (!
quiet) printf(
"Testing Multiple Events: ");
366
370 "PAPI_create_eventset() failed\n",
retval );
371 }
372
376 "EXAMPLE_CONSTANT not found\n",
retval );
377 }
378
382 "PAPI_add_events failed\n",
retval );
383 }
384
388 "EXAMPLE_GLOBAL_AUTOINC not found\n",
retval );
389 }
390
394 "PAPI_add_events failed\n",
retval );
395 }
396
400 "EXAMPLE_ZERO not found\n",
retval );
401 }
402
406 "PAPI_add_events failed\n",
retval );
407 }
408
409
413 "PAPI_start failed\n",
retval );
414 }
415
419 }
420
424 }
425 printf("\n");
426 }
427
429 test_fail( __FILE__, __LINE__,
"Result should be 42!\n", 0);
430 }
431
433 test_fail( __FILE__, __LINE__,
"Result should be 0!\n", 0);
434 }
435
439 }
440
444 }
445
447
448
449
450
451
452 if (!
quiet) printf(
"Testing Write\n");
453
457 "PAPI_create_eventset() failed\n",
retval );
458 }
459
463 "EXAMPLE_CONSTANT not found\n",
retval );
464 }
465
469 "PAPI_add_events failed\n",
retval );
470 }
471
475 "EXAMPLE_GLOBAL_AUTOINC not found\n",
retval );
476 }
477
481 "PAPI_add_events failed\n",
retval );
482 }
483
487 "EXAMPLE_ZERO not found\n",
retval );
488 }
489
493 "PAPI_add_events failed\n",
retval );
494 }
495
496
500 "PAPI_start failed\n",
retval );
501 }
502
506 "PAPI_read failed\n",
retval );
507 }
508
510 printf("Before values: ");
513 }
514 printf("\n");
515 }
516
520
524 "PAPI_write failed\n",
retval );
525 }
526
530 }
531
533 printf("After values: ");
536 }
537 printf("\n");
538 }
539
540
542 test_fail( __FILE__, __LINE__,
"Result should be 42!\n", 0);
543 }
544
546 test_fail( __FILE__, __LINE__,
"Result should be 200!\n", 0);
547 }
548
550 test_fail( __FILE__, __LINE__,
"Result should be 0!\n", 0);
551 }
552
556 }
557
561 }
562
564
565
566
567
568
569
570 if (!
quiet) printf(
"\n");
571
573
574 return 0;
575}
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.
Convert a name to a numeric hardware event code.
get information about a specific software component
Get the event's name and description info.
initialize the PAPI library.
Get the number of components available on the system.
Read hardware counters from an event set.
Reset the hardware event counts in an event set.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
Write counter values into counters.
char event_name[2][PAPI_MAX_STR_LEN]
static long long values[NUM_EVENTS]
static struct counter_info * event_info
#define PAPI_VERSION_REVISION(x)
#define PAPI_VERSION_MAJOR(x)
#define PAPI_VERSION_MINOR(x)
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)
char name[PAPI_MAX_STR_LEN]