31 {
33 int eventSetCount, ret;
35 int cid=-1;
38 char errMsg[1024];
40 int firstTime = 1;
41 int retlen;
42
43 gettimeofday(&
t1, NULL);
45 gettimeofday(&
t2, NULL);
47
49 test_fail(__FILE__, __LINE__,
"PAPI_library_init failed\n", ret);
50 }
51
52
54 fprintf(
stderr,
"Testing PCP Component with PAPI %d.%d.%d\n",
58 }
59
60
61
62
63
64
65
66
67
70 for (
i=0;
i<k && cid<0;
i++) {
72 if (aComponent == NULL) {
73 sprintf(errMsg, "PAPI_get_component_info(%i) failed, "
74 "returned NULL. %i components reported.\n",
i,k);
76
77 }
78
79 if (strcmp(
"pcp", aComponent->
name) == 0) cid=
i;
80 }
81
82 if (cid < 0) {
83 sprintf(errMsg, "Failed to find pcp component among %i "
84 "reported components.\n", k);
86 }
87
89 fprintf(
stderr,
"Found PCP Component at id %d\n",cid);
90 }
91
92
94 test_skip(__FILE__,__LINE__,
"Component pcp is disabled", 0);
96 return 0;
97 }
98
99
100
101
102
103
104
108
109
110
115 test_fail(__FILE__, __LINE__,
"PAPI_enum_cmp_event failed.\n",
116 ret);
117 }
118
119
120
121
123 if (!
quiet) printf(
"Component Idx, Symbol, Units, Description, HexCode (this run only), Time Scope, PAPI_TYPE, Sample Value\n");
124
125 do{
127 k=m;
128
129
130
131
132
133 do{
136 sprintf(errMsg, "PAPI_get_event_info(%i) failed.\n", k);
137 test_fail(__FILE__, __LINE__, errMsg, ret);
138 }
139
140
143 test_fail(__FILE__, __LINE__,
"PAPI_enum_create_eventset failed.\n", ret);
144 }
145
146
151 continue;
152 test_fail( __FILE__, __LINE__, errMsg, ret);
153 }
154
155
156
157 if (firstTime) {
161 test_fail(__FILE__, __LINE__,
"PAPI_set_opt failed.\n",
162 ret);
163 }
164 }
165
170 continue;
171 test_fail( __FILE__, __LINE__, errMsg, ret);
172 }
173
174
179 continue;
180 test_fail( __FILE__, __LINE__, errMsg, ret);
181 }
182
183
184
185 if (code != k && code != (k+1)) {
186 retlen = snprintf(errMsg,
PAPI_MAX_STR_LEN,
"PAPI_event_name_to_code('%s') "
187 "returned code 0x%08X, expected 0x%08X. failure.\n",
190 continue;
191 test_fail( __FILE__, __LINE__, errMsg, 0);
192 }
193
194
198 retlen = snprintf(errMsg,
PAPI_MAX_STR_LEN,
"PAPI_event_code_to_name(('0x%08X') failed.\n", code);
200 continue;
201 test_fail( __FILE__, __LINE__, errMsg, ret);
202 }
203
204 if (strcmp(info.
symbol, testName) != 0) {
205 retlen = snprintf(errMsg,
PAPI_MAX_STR_LEN,
"PAPI_event_code_to_name(('0x%08X') "
206 "returned name=\"'%s'\", expected \"%s\". failure.\n",
207 code, testName, info.
symbol);
209 continue;
210 test_fail( __FILE__, __LINE__, errMsg, 0);
211 }
212
215 sprintf(errMsg, "PAPI_add_event('0x%08X') failed.\n", code);
216 test_fail( __FILE__, __LINE__, errMsg, ret);
217 }
218
221 sprintf(errMsg, "PAPI_start_event('0x%08X') failed.\n", code);
222 test_fail( __FILE__, __LINE__, errMsg, ret);
223 }
224
226
228 if (eventSetCount < 1) {
229 test_fail( __FILE__, __LINE__,
"PAPI_num_events(EventSet) failed.\n", ret);
230 }
231
232 values = calloc(eventSetCount,
sizeof(
long long));
233
237 test_fail( __FILE__, __LINE__,
"PAPI_read(EventSet) failed.\n", ret);
238 }
239
240
243 printf("%i, %s, %s, %s, 0x%08x,",
248
250 printf("SINCE START,");
251 } else {
252 printf("POINT,");
253 }
254
257 printf(
"INT64, %lli", cvt.
ll);
258 break;
259
261 printf(
"UINT64, %llu", cvt.
ull);
262 break;
263
265 printf(
"FP64, %f", cvt.
d);
266 break;
267
268 default:
269 printf(
"UNKNOWN TYPE, %p", cvt.
vp);
270 break;
271 }
272
273 printf("\n");
274 }
275
279 test_fail( __FILE__, __LINE__,
"PAPI_reset_event() failed\n", ret);
280 }
281
285 test_fail( __FILE__, __LINE__,
"PAPI_stop_event(EventSet, values) failed.\n", ret);
286 }
287
290
293 test_fail( __FILE__, __LINE__,
"PAPI_cleanup_eventset(EventSet) failed.\n", ret);
294 }
295
298 test_fail( __FILE__, __LINE__,
"PAPI_destroy_eventset(EventSet) failed.\n", ret);
299 }
300
301 firstTime = 0;
302
305
306
307
308
311 test_fail(__FILE__, __LINE__,
"PAPI_enum_create_eventset failed.\n", ret);
312 }
313
317 test_fail(__FILE__, __LINE__,
"PAPI_enum_cmp_event failed.\n",
318 ret);
319 }
320
322 do{
326 retlen = snprintf(errMsg,
PAPI_MAX_STR_LEN,
"PAPI_get_event_info(%i) failed.\n", k);
328 continue;
329 test_fail(__FILE__, __LINE__, errMsg, ret);
330 }
331
332
337 continue;
338 test_fail( __FILE__, __LINE__, errMsg, ret);
339 } else {
341 }
343
344
346 sprintf(errMsg,
"Test should have been able to add all %i events; failed after %i.\n",
count,
i);
347 test_fail(__FILE__, __LINE__, errMsg, 0);
348 }
349
352 test_fail( __FILE__, __LINE__,
"PAPI_cleanup_eventset(EventSet) failed.\n", ret);
353 }
354
357 test_fail( __FILE__, __LINE__,
"PAPI_destroy_eventset(EventSet) failed.\n", ret);
358 }
359
360 if (!
quiet) fprintf(
stderr,
"PCP discovered %i events; added "
363 if (!
quiet) fprintf(
stderr,
"Shutdown completed.\n");
365 return 0;
366}
add PAPI preset or native hardware event to an event set
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.
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.
Return the number of events in an event set.
Read hardware counters from an event set.
removes a named hardware event from a PAPI event set.
Reset the hardware event counts in an event set.
Set PAPI library or event set options.
Finish using PAPI and free all related resources.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
Returns a string describing the PAPI error code.
#define PAPI_DATATYPE_FP64
#define PAPI_DATATYPE_UINT64
#define PAPI_NTV_ENUM_UMASKS
#define PAPI_TIMESCOPE_SINCE_START
#define PAPI_DATATYPE_INT64
static long long values[NUM_EVENTS]
#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]
char units[PAPI_MIN_STR_LEN]
char symbol[PAPI_HUGE_STR_LEN]
char long_descr[PAPI_HUGE_STR_LEN]
#define mConvertUsec(timeval_)
static struct timeval t1 t2
A pointer to the following is passed to PAPI_set/get_opt()
PAPI_domain_option_t domain