47 {
50 char errMsg[1024];
51 char *pcpName;
52 if (argc == 1) {
53 printf("Initialize, Event Read Avg uS\n");
54 return 0;
55 }
56
57 if (argc != 3) {
58 fprintf(
stderr,
"%s:%i ERROR Invalid number of arguments; must be 0 or 2.\n", __FILE__, __LINE__);
59 fprintf(
stderr,
"%s readsToAvg Event-Name\n", argv[0]);
60 exit(-1);
61 }
62
63
66 fprintf(
stderr,
"%s:%i ERROR readsToAvg must be > 0.\n", __FILE__, __LINE__);
67 fprintf(
stderr,
"%s readsToAvg Event-Name\n", argv[0]);
68 exit(-1);
69 }
70
71 pcpName = argv[2];
72
73 gettimeofday(&
t1, NULL);
75 gettimeofday(&
t2, NULL);
76
78 printf("ERROR PAPI library init failed.\n");
79 test_fail(__FILE__, __LINE__,
"PAPI_library_init failed\n", ret);
80 }
81
83
84
85
86
87
88
89
92 fprintf(
stderr,
"ERROR PAPI_create_eventset failed.\n");
93 test_fail(__FILE__, __LINE__,
"PAPI_create_eventset failed.\n", ret);
94 }
95
98 sprintf(errMsg, "PAPI_add_named_event('%s') failed.\n", pcpName);
99 printf("ERROR %s\n", errMsg);
100 test_fail( __FILE__, __LINE__, errMsg, ret);
101 }
102
103
104
105
106
107
108 long long pcpValue;
109
110
113 printf("ERROR PAPI_start EventSet failed.\n");
114 test_fail( __FILE__, __LINE__,
"PAPI_start_event(EventSet) failed.\n", ret);
115 }
116
117 gettimeofday(&
t1, NULL);
121 printf("ERROR PAPI_read EventSet failed.\n");
122 test_fail( __FILE__, __LINE__,
"PAPI_read(EventSet) failed.\n", ret);
123 }
124 }
125 gettimeofday(&
t2, NULL);
126
129 printf("ERROR PAPI_stop EventSet failed.\n");
130 test_fail( __FILE__, __LINE__,
"PAPI_stop_event(PAPIEventSet, &papiValues[FINAL]) failed.\n", ret);
131 }
132
134
137 printf("ERROR PAPI_cleanup_eventset failed.\n");
138 test_fail( __FILE__, __LINE__,
"PAPI_cleanup_eventset(EventSet) failed.\n", ret);
139 }
140
143 printf("ERROR PAPI_destroy_eventset failed.\n");
144 test_fail( __FILE__, __LINE__,
"PAPI_destroy_eventset(EventSet) failed.\n", ret);
145 }
146
147
148
149
151
152
153 return 0;
154}
#define mConvertUsec(timeval_)
static struct timeval t1 t2
add PAPI preset or native hardware event by name to an EventSet
Empty and destroy an EventSet.
Create a new empty PAPI EventSet.
Empty and destroy an EventSet.
initialize the PAPI library.
Read hardware counters from an event set.
Finish using PAPI and free all related resources.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)