[mpich-commits] r10816 - mpich2/trunk/test/mpi/perf

balaji at mcs.anl.gov balaji at mcs.anl.gov
Thu Jan 3 12:17:31 CST 2013


Author: balaji
Date: 2013-01-03 12:17:31 -0600 (Thu, 03 Jan 2013)
New Revision: 10816

Modified:
   mpich2/trunk/test/mpi/perf/Makefile.am
   mpich2/trunk/test/mpi/perf/twovec.c
Log:
Redo the twovec test to get rid of the MPI_Wtick() test which makes no
sense.  Also improve the code to make sure the datatype creation time
does not depend on the data size.

Reviewed by goodell.

Modified: mpich2/trunk/test/mpi/perf/Makefile.am
===================================================================
--- mpich2/trunk/test/mpi/perf/Makefile.am	2013-01-03 16:41:30 UTC (rev 10815)
+++ mpich2/trunk/test/mpi/perf/Makefile.am	2013-01-03 18:17:31 UTC (rev 10816)
@@ -23,3 +23,4 @@
 nestvec2_CFLAGS  = -O
 indexperf_CFLAGS = -O
 
+twovec_LDADD = -lm

Modified: mpich2/trunk/test/mpi/perf/twovec.c
===================================================================
--- mpich2/trunk/test/mpi/perf/twovec.c	2013-01-03 16:41:30 UTC (rev 10815)
+++ mpich2/trunk/test/mpi/perf/twovec.c	2013-01-03 18:17:31 UTC (rev 10816)
@@ -3,84 +3,77 @@
  *  (C) 2001 by Argonne National Laboratory.
  *      See COPYRIGHT in top-level directory.
  */
-#include "mpi.h" 
+
 #include <stdio.h>
 #include <stdlib.h>
+#include <math.h>
+#include "mpi.h"
 
-/* FIXME: This comment is wrong - the test appears to only create a datatype */
-/* This does a transpose with a get operation, fence, and derived
-   datatypes. Uses vector and hvector (Example 3.32 from MPI 1.1
-   Standard). Run on 2 processes */
+/* Make sure datatype creation is independent of data size */
 
-int main(int argc, char *argv[]) 
-{ 
-    MPI_Datatype column, xpose;
-    double t[5], ttmp, tmin, tmax, ttick;
-    static int sizes[5] = { 10, 100, 1000, 10000, 20000 };
-    int i, isMonotone, errs=0, nrows, ncols, isvalid;
- 
-    MPI_Init(&argc,&argv); 
+#define SKIP 4
+#define NUM_SIZES 16
+#define FRACTION 0.2
 
-    ttick = MPI_Wtick();
+/* Don't make the number of loops too high; we create so many
+ * datatypes before trying to free them */
+#define LOOPS 1024
 
-    for (i=0; i<5; i++) {
-         nrows = ncols = sizes[i];
-         ttmp = MPI_Wtime();
-         /* create datatype for one column */
-         MPI_Type_vector(nrows, 1, ncols, MPI_INT, &column);
-         /* create datatype for matrix in column-major order */
-         MPI_Type_hvector(ncols, 1, sizeof(int), column, &xpose);
-         MPI_Type_commit(&xpose);
-         t[i] = MPI_Wtime() - ttmp;
-         MPI_Type_free( &xpose );
-         MPI_Type_free( &column );
-     }
+int main(int argc, char *argv[])
+{
+    MPI_Datatype column[LOOPS], xpose[LOOPS];
+    double t[NUM_SIZES], ttmp, tmin, tmax, tmean, tdiff;
+    int size;
+    int i, j, isMonotone, errs = 0, nrows, ncols, isvalid;
 
-     /* Now, analyze the times to see that they are (a) small and (b)
-        nearly independent of size */
-     tmin = 10000;
-     tmax = 0;
-     isvalid = 1;
-     for (i=0; i<5; i++) {
-	 if (t[i] < 10*ttick) {
-	     /* Timing is invalid - resolution is too low */
-	     isvalid = 0;
-	 }
-	 else {
-	     if (t[i] < tmin) tmin = t[i];
-	     if (t[i] > tmax) tmax = t[i];
-	 }
-     }
-     if (isvalid) {
-	 /* Monotone times are a warning */
-	 isMonotone = 1;
-	 for (i=1; i<5; i++) {
-	     if (t[i] < t[i-1]) isMonotone = 0;
-	 }
-	 if (tmax > 100 * tmin) {
-	     errs++;
-	     fprintf( stderr, "Range of times appears too large\n" );
-	     if (isMonotone) {
-		 fprintf( stderr, "Vector types may use processing proportion to count\n" );
-	     }
-	     for (i=0; i<5; i++) {
-		 fprintf( stderr, "n = %d, time = %f\n", sizes[i], t[i] );
-	     }
-	     fflush(stderr);
-	 }
-     }
-     else {
-	 fprintf( stderr, "Timing failed - recorded times are too small relative to MPI_Wtick\n" );
-	 /* Note that this is not an error in the MPI implementation - it is a 
-	    failure in the test */
-     }
+    MPI_Init(&argc, &argv);
 
+    tmean = 0;
+    size = 1;
+    for (i = 0; i < NUM_SIZES + SKIP; i++) {
+        nrows = ncols = size;
+
+        ttmp = MPI_Wtime();
+
+        for (j = 0; j < LOOPS; j++) {
+            MPI_Type_vector(nrows, 1, ncols, MPI_INT, &column[j]);
+            MPI_Type_hvector(ncols, 1, sizeof(int), column[j], &xpose[j]);
+            MPI_Type_commit(&xpose[j]);
+        }
+
+        if (i >= SKIP) {
+            t[i - SKIP] = MPI_Wtime() - ttmp;
+            tmean += t[i - SKIP];
+        }
+
+        for (j = 0; j < LOOPS; j++) {
+            MPI_Type_free(&xpose[j]);
+            MPI_Type_free(&column[j]);
+        }
+
+        if (i >= SKIP)
+            size *= 2;
+    }
+    tmean /= NUM_SIZES;
+
+    /* Now, analyze the times to see that they are nearly independent
+     * of size */
+    for (i = 0; i < NUM_SIZES; i++) {
+        /* The difference between the value and the mean is more than
+         * a "FRACTION" of mean. */
+        if (fabs(t[i] - tmean) > (FRACTION * tmean))
+            errs++;
+    }
+
     if (errs) {
-        printf( " Found %d errors\n", errs );
+        fprintf(stderr, "too much difference in performance: ");
+        for (i = 0; i < NUM_SIZES; i++)
+            fprintf(stderr, "%.3f ", t[i] * 1e6);
+        fprintf(stderr, "\n");
     }
-    else {
-        printf( " No Errors\n" );
-    } 
-    MPI_Finalize(); 
-    return 0; 
-} 
+    else
+        printf(" No Errors\n");
+
+    MPI_Finalize();
+    return 0;
+}



More information about the commits mailing list