30 int 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");
char event_name[2][PAPI_MAX_STR_LEN]
int PAPI_stop(int EventSet, long long *values)
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
void test_pass(const char *filename)
int PAPI_add_event(int EventSet, int EventCode)
int PAPI_reset(int EventSet)
int PAPI_write(int EventSet, long long *values)
int PAPI_num_components(void)
int PAPI_event_name_to_code(const char *in, int *out)
Return codes and api definitions.
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
void test_skip(const char *file, int line, const char *call, int retval)
static struct counter_info * event_info
int PAPI_library_init(int version)
#define PAPI_VERSION_MAJOR(x)
#define PAPI_VERSION_REVISION(x)
char name[PAPI_MAX_STR_LEN]
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
#define PAPI_VERSION_MINOR(x)
int PAPI_cleanup_eventset(int EventSet)
int PAPI_create_eventset(int *EventSet)
int PAPI_event_code_to_name(int EventCode, char *out)
int tests_quiet(int argc, char **argv)
void test_fail(const char *file, int line, const char *call, int retval)
int main(int argc, char **argv)
int PAPI_destroy_eventset(int *EventSet)
int PAPI_read(int EventSet, long long *values)
int PAPI_start(int EventSet)
static long long values[NUM_EVENTS]