22#define REPEATS (MAXEVENTS * 4)
24#define MINCOUNTS 100000
25#define MPX_TOLERANCE 0.20
26#define NUM_FLOPS 20000000
29main(
int argc,
char **argv )
35 double x = 1.1,
y, dtmp;
58 if ( !strcmp( argv[1],
"quiet" ) ) {
61 sleep_time = atoi( argv[1] );
62 if ( sleep_time <= 0 )
85 printf(
"\nFunctional check of multiplexing routines.\n" );
86 printf(
"Adding and removing events from an event set.\n\n" );
116 test_fail( __FILE__, __LINE__,
"PAPI_assign_eventset_component",
121 test_skip(__FILE__, __LINE__,
"Multiplex not supported", 1);
129 for (
i = 0;
i < nevents;
i++ ) {
142 test_skip( __FILE__, __LINE__,
"Not enough events left...", 0 );
152 t2 = 10000 * 20 * nevents;
155 "This test takes too much time",
retval );
165 iters = iters * (
int ) (
t2 /
t1 );
168 else if (
t1 > 30e6 ) {
170 "This test takes too much time",
retval );
175 for (
i = 1;
i < nevents;
i =
i + 2 )
177 for (
i = 0;
i < nevents;
i =
i + 2 )
182 for (
i = 0;
i < nevents;
i++ )
189 printf(
"\nReference run:\n" );
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" );
209 for ( j = 0; j < nevents; j++ ) {
212 printf(
"%20s = %16lld %-15s %-15s %s\n",
215 strcmp( info.
symbol,name2 ) ?
216 "*** MISMATCH ***" :
"" );
224 repeats = nevents * 4;
228 for (
i = 0;
i < repeats;
i++ ) {
236 if ( (
i % nevents ) + 1 == nevents )
continue;
239 printf(
"\nTest %d (of %d):\n",
240 i + 1 - (
i / nevents), repeats - 4 );
253 j = eventidx[
i % nevents];
254 if ( (
i / nevents ) % 2 == 0 ) {
259 printf(
"Removing event[%d]: %s\n",
266 "PAPI_remove_event",
retval );
271 for ( idx = 0; eventmap[idx] != j; idx++ );
272 for ( j = idx; j < nev1; j++ )
273 eventmap[j] = eventmap[j + 1];
279 printf(
"Adding event[%d]: %s\n",
285 "PAPI_add_event",
retval );
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 ) ) );
322 printf(
"%20s %16s %-15s %-15s\n",
326 "PAPI_list_events" );
331 for ( j = 0; j < nev1; j++ ) {
336 printf(
"%20s = %16lld %-15s %-15s %s\n",
339 strcmp( info.
symbol, name2 ) ?
340 "*** MISMATCH ***" :
"" );
346 for ( j = 0; j < nev1; j++ ) {
348 dtmp = ( double )
values[j];
350 valsample[idx][nsamples[idx]] = dtmp;
361 printf(
"\n\nEstimated variance relative "
362 "to average counts:\n" );
363 for ( j = 0; j < nev1; j++ ) {
364 printf(
" Event %.2d", j );
382 for ( j = 0; j < nev1; j++ ) {
384 avg[j] = valsum[j] / nsamples[j];
386 for (
i = 0;
i < nsamples[j]; ++
i ) {
387 double diff = ( valsample[j][
i] - avg[j] );
388 spread[j] += diff * diff;
390 spread[j] = sqrt( spread[j] / nsamples[j] ) / avg[j];
392 printf(
"%9.2g ", spread[j] );
396 for ( j = 0; j < nev1; j++ ) {
400 if (!
quiet) printf(
"Event %d tolerance good\n",j);
405 if (!
quiet) printf(
"Event %d too small to fail\n",j);
409 if (!
quiet) printf(
"Event %d failed!\n",j);
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],
426 test_fail( __FILE__, __LINE__,
"Values differ from reference", fails );
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]
Return codes and api definitions.
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]