30{
35 double x = 1.1,
y, dtmp;
39#ifdef STARTSTOP
41#endif
52 int fails;
54
56
57 if ( argc > 1 ) {
58 if ( !strcmp( argv[1], "quiet" ) ) {
59 }
60 else {
61 sleep_time = atoi( argv[1] );
62 if ( sleep_time <= 0 )
64 }
65 }
66
76
81 }
82
83
85 printf( "\nFunctional check of multiplexing routines.\n" );
86 printf( "Adding and removing events from an event set.\n\n" );
87 }
88
89
93 }
94
95
96#ifdef MPX
100 }
101#endif
102
103
106 }
107
108
109#ifdef MPX
110
111
112
113
116 test_fail( __FILE__, __LINE__,
"PAPI_assign_eventset_component",
118
121 test_skip(__FILE__, __LINE__,
"Multiplex not supported", 1);
122 }
124 }
125#endif
126
127
129 for (
i = 0;
i < nevents;
i++ ) {
133 nevents--;
135 }
136 }
137
138
139
140
141 if ( nevents < 3 ) {
142 test_skip( __FILE__, __LINE__,
"Not enough events left...", 0 );
143 }
144
145
146
147
148
149
150
151
152 t2 = 10000 * 20 * nevents;
155 "This test takes too much time",
retval );
156 }
157
158
162
163
165 iters = iters * (
int ) (
t2 /
t1 );
166 }
167
168 else if (
t1 > 30e6 ) {
170 "This test takes too much time",
retval );
171 }
172
173
174 j = nevents;
175 for (
i = 1;
i < nevents;
i =
i + 2 )
177 for (
i = 0;
i < nevents;
i =
i + 2 )
179 assert( j == 0 );
180
181
182 for (
i = 0;
i < nevents;
i++ )
184
186
187
189 printf( "\nReference run:\n" );
190 }
191
195 }
199
200
201 ntrue = nevents;
204 printf(
"\tOperations= %.1f Mflop",
y * 1e-6 );
205 printf(
"\t(%g Mflop/s)\n\n", (
y / (
double ) (
t2 -
t1 ) ) );
206 printf( "%20s %16s %-15s %-15s\n", "PAPI measurement:",
207 "Acquired count", "Expected event", "PAPI_list_events" );
208
209 for ( j = 0; j < nevents; j++ ) {
212 printf( "%20s = %16lld %-15s %-15s %s\n",
215 strcmp( info.
symbol,name2 ) ?
216 "*** MISMATCH ***" : "" );
217 }
218 printf( "\n" );
219 }
220
221
222
223 nev1 = nevents;
224 repeats = nevents * 4;
225
226
227
228 for (
i = 0;
i < repeats;
i++ ) {
229
230
231
232
233
234
235
236 if ( (
i % nevents ) + 1 == nevents )
continue;
237
239 printf( "\nTest %d (of %d):\n",
240 i + 1 - (
i / nevents), repeats - 4 );
241 }
242
243
246 }
247
248
249
250
251
252
253 j = eventidx[
i % nevents];
254 if ( (
i / nevents ) % 2 == 0 ) {
255
256
259 printf( "Removing event[%d]: %s\n",
261 }
262
266 "PAPI_remove_event",
retval );
267 }
268
269
270 nev1--;
271 for ( idx = 0; eventmap[idx] != j; idx++ );
272 for ( j = idx; j < nev1; j++ )
273 eventmap[j] = eventmap[j + 1];
274 } else {
275
276
279 printf( "Adding event[%d]: %s\n",
281 }
285 "PAPI_add_event",
retval );
286 }
287
288 eventmap[nev1] = j;
289 nev1++;
290 }
291
294 }
295
297
298
299#ifndef STARTSTOP
302#else
307#endif
308
309
314
315
317 printf( "\n(calculated independent of PAPI)\n" );
318 printf(
"\tOperations= %.1f Mflop",
y * 1e-6 );
319 printf( "\t(%g Mflop/s)\n\n",
320 (
y / (
double ) (
t2 -
t1 ) ) );
321
322 printf( "%20s %16s %-15s %-15s\n",
323 "PAPI measurement:",
324 "Acquired count",
325 "Expected event",
326 "PAPI_list_events" );
327
328
329 ntrue = nev1;
331 for ( j = 0; j < nev1; j++ ) {
332 idx = eventmap[j];
333
336 printf( "%20s = %16lld %-15s %-15s %s\n",
339 strcmp( info.
symbol, name2 ) ?
340 "*** MISMATCH ***" : "" );
341 }
342 printf( "\n" );
343 }
344
345
346 for ( j = 0; j < nev1; j++ ) {
347 idx = eventmap[j];
348 dtmp = ( double )
values[j];
349 valsum[idx] += dtmp;
350 valsample[idx][nsamples[idx]] = dtmp;
351 nsamples[idx]++;
352 }
353 }
354
355
358 }
359
361 printf( "\n\nEstimated variance relative "
362 "to average counts:\n" );
363 for ( j = 0; j < nev1; j++ ) {
364 printf( " Event %.2d", j );
365 }
366 printf( "\n" );
367 }
368
369 fails = nevents;
370
371
372
373
374
375
376
377
378
379
380
381
382 for ( j = 0; j < nev1; j++ ) {
383
384 avg[j] = valsum[j] / nsamples[j];
385 spread[j] = 0;
386 for (
i = 0;
i < nsamples[j]; ++
i ) {
387 double diff = ( valsample[j][
i] - avg[j] );
388 spread[j] += diff * diff;
389 }
390 spread[j] = sqrt( spread[j] / nsamples[j] ) / avg[j];
392 printf( "%9.2g ", spread[j] );
393 }
394 }
395
396 for ( j = 0; j < nev1; j++ ) {
397
398
400 if (!
quiet) printf(
"Event %d tolerance good\n",j);
401 fails--;
402 }
403
405 if (!
quiet) printf(
"Event %d too small to fail\n",j);
406 fails--;
407 }
408 else {
409 if (!
quiet) printf(
"Event %d failed!\n",j);
410 }
411 }
412
414 printf( "\n\n" );
415 for ( j = 0; j < nev1; j++ ) {
417 printf( "Event %.2d: mean=%10.0f, "
418 "sdev/mean=%7.2g nrpt=%2d -- %s\n",
419 j, avg[j], spread[j],
421 }
422 printf( "\n\n" );
423 }
424
425 if ( fails ) {
426 test_fail( __FILE__, __LINE__,
"Values differ from reference", fails );
427 }
428
430
431 return 0;
432}
static struct timeval t1 t2
add PAPI preset or native hardware event to an event set
Assign a component index to an existing but empty EventSet.
Create a new empty PAPI EventSet.
Convert a numeric hardware event code to a name.
Get the event's name and description info.
get real time counter value in microseconds
initialize the PAPI library.
list the events in an event set
Initialize multiplex support in the PAPI library.
Read hardware counters from an event set.
removes a hardware event from a PAPI event set.
Reset the hardware event counts in an event set.
Convert a standard event set to a multiplexed event set.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
double do_flops3(double x, int iters, int quiet)
char events[MAX_EVENTS][BUFSIZ]
static long long values[NUM_EVENTS]
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 short_descr[PAPI_MIN_STR_LEN]
char symbol[PAPI_HUGE_STR_LEN]