1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2008 by University of Illinois
4 * See COPYRIGHT in top-level directory.
8 * This code is intended to test the trace overhead when using an
9 * MPI tracing package. To perform the test, follow these steps:
11 * 1) Run with the versbose mode selected to determine the delay argument
12 * to use in subsequent tests:
13 * mpiexec -n 4096 allredtrace -v
14 * Assume that the computed delay count is 6237; that value is used in
17 * 2) Run with an explicit delay count, without tracing enabled:
18 * mpiexec -n 4096 allredtrace -delaycount 6237
20 * 3) Build allredtrace with tracing enabled, then run:
21 * mpiexec -n 4096 allredtrace -delaycount 6237
23 * Compare the total times. The tracing version should take slightly
24 * longer but no more than, for example, 15%.
31 static int verbose = 0;
32 static int lCount = 0;
34 void SetupDelay( double );
36 int main( int argc, char *argv[] )
38 double usecPerCall = 100;
43 MPI_Init( &argc, &argv );
44 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
46 /* Process arguments. We allow the delay count to be set from the
47 command line to ensure reproducibility*/
48 for (i=1; i<argc; i++) {
49 if (strcmp( argv[i], "-delaycount" ) == 0) {
51 lCount = atoi( argv[i] );
53 else if (strcmp( argv[i], "-v" ) == 0) {
57 fprintf( stderr, "Unrecognized argument %s\n", argv[i] );
63 SetupDelay( usecPerCall );
66 MPI_Barrier( MPI_COMM_WORLD );
69 for (i=0; i<nLoop; i++) {
70 MPI_Allreduce( &t1, &tsum, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD );
74 MPI_Barrier( MPI_COMM_WORLD );
76 printf( "For delay count %d, time is %e\n", lCount, t );
79 MPI_Barrier( MPI_COMM_WORLD );
86 void SetupDelay( double usec )
89 double sec = 1.0e-6 * usec;
90 int nLoop, i, direction;
93 /* Compute the number of times to run the tests to get an accurate
94 number given the timer resolution. */
96 tick = 100 * MPI_Wtick();
100 for (i=0; i<nLoop; i++) {
105 while ( t < tick && nLoop < 100000 );
107 if (verbose) printf( "nLoop = %d\n", nLoop );
109 /* Start with an estimated count */
114 for (i=0; i<nLoop; i++) {
119 if (verbose) printf( "lCount = %d, time = %e\n", lCount, t );
120 if (t > 10 * tick) nLoop = nLoop / 2;
122 /* Compare measured delay */
125 if (direction == 1) break;
128 else if (t < sec / 2) {
130 if (direction == -1) break;
134 /* sec/2 <= t < sec , so estimate the lCount to hit sec */
135 lCount = (sec/t) * lCount;
141 if (verbose) printf( "lCount = %d, t = %e\n", lCount, t );
143 /* Should coordinate with the other processes - take the max? */
146 double delayCounter = 0;
147 void Delay( int count )
152 for (i=0; i<count; i++) {
153 delayCounter += 2.73;