30int main (
int argc,
char **argv)
37 int numcmp,cid,example_cid=-1;
38 int code,maximum_code=0;
53 printf(
"Testing example component with PAPI %d.%d.%d\n",
62 for( cid=0; cid<numcmp; cid++) {
65 "PAPI_get_component_info failed\n", 0);
68 printf(
"\tComponent %d - %d events - %s\n", cid,
72 if (strstr(cmpinfo->
name,
"example")) {
81 "Example component not found\n", 0);
85 printf(
"\nFound Example Component at id %d\n",example_cid);
86 printf(
"\nListing all events in this component:\n");
99 printf(
"Error translating %#x\n",code);
101 "PAPI_event_code_to_name",
retval );
105 printf(
"Error getting info for event %#x\n",code);
107 "PAPI_get_event_info()",
retval );
111 printf(
"\tEvent %#x: %s -- %s\n",
120 if (!
quiet) printf(
"\n");
129 "Failed to return PAPI_ENOEVNT on invalid event",
retval );
139 "PAPI_create_eventset() failed\n",
retval );
145 "EXAMPLE_ZERO not found\n",
retval );
151 "PAPI_add_events failed\n",
retval );
157 "PAPI_start failed\n",
retval );
165 if (!
quiet) printf(
"Testing EXAMPLE_ZERO: %lld\n",
values[0]);
168 test_fail( __FILE__, __LINE__,
"Result should be 0!\n", 0);
191 "PAPI_create_eventset() failed\n",
retval );
197 "EXAMPLE_CONSTANT not found\n",
retval );
203 "PAPI_add_events failed\n",
retval );
209 "PAPI_start failed\n",
retval );
217 if (!
quiet) printf(
"Testing EXAMPLE_CONSTANT: %lld\n",
values[0]);
220 test_fail( __FILE__, __LINE__,
"Result should be 42!\n", 0);
244 "PAPI_create_eventset() failed\n",
retval );
250 "EXAMPLE_AUTOINC not found\n",
retval );
256 "PAPI_add_events failed\n",
retval );
259 if (!
quiet) printf(
"Testing EXAMPLE_AUTOINC: ");
266 "PAPI_start failed\n",
retval );
277 test_fail( __FILE__, __LINE__,
"Result wrong!\n", 0);
281 if (!
quiet) printf(
"\n");
291 "PAPI_start failed\n",
retval );
320 "PAPI_reset() failed\n",
retval );
326 "PAPI_start failed\n",
retval );
332 "PAPI_reset() failed\n",
retval );
341 if (!
quiet) printf(
"Testing EXAMPLE_AUTOINC after PAPI_reset(): %lld\n",
345 test_fail( __FILE__, __LINE__,
"Result not zero!\n", 0);
365 if (!
quiet) printf(
"Testing Multiple Events: ");
370 "PAPI_create_eventset() failed\n",
retval );
376 "EXAMPLE_CONSTANT not found\n",
retval );
382 "PAPI_add_events failed\n",
retval );
388 "EXAMPLE_GLOBAL_AUTOINC not found\n",
retval );
394 "PAPI_add_events failed\n",
retval );
400 "EXAMPLE_ZERO not found\n",
retval );
406 "PAPI_add_events failed\n",
retval );
413 "PAPI_start failed\n",
retval );
429 test_fail( __FILE__, __LINE__,
"Result should be 42!\n", 0);
433 test_fail( __FILE__, __LINE__,
"Result should be 0!\n", 0);
452 if (!
quiet) printf(
"Testing Write\n");
457 "PAPI_create_eventset() failed\n",
retval );
463 "EXAMPLE_CONSTANT not found\n",
retval );
469 "PAPI_add_events failed\n",
retval );
475 "EXAMPLE_GLOBAL_AUTOINC not found\n",
retval );
481 "PAPI_add_events failed\n",
retval );
487 "EXAMPLE_ZERO not found\n",
retval );
493 "PAPI_add_events failed\n",
retval );
500 "PAPI_start failed\n",
retval );
506 "PAPI_read failed\n",
retval );
510 printf(
"Before values: ");
524 "PAPI_write failed\n",
retval );
533 printf(
"After values: ");
542 test_fail( __FILE__, __LINE__,
"Result should be 42!\n", 0);
546 test_fail( __FILE__, __LINE__,
"Result should be 200!\n", 0);
550 test_fail( __FILE__, __LINE__,
"Result should be 0!\n", 0);
570 if (!
quiet) printf(
"\n");
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
Return codes and api definitions.
#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]