Commit e72d2527 authored by Pavan Balaji's avatar Pavan Balaji
Browse files

[svn-r10816] 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.
parent f84a221c
......@@ -23,3 +23,4 @@ nestvec_CFLAGS = -O
nestvec2_CFLAGS = -O
indexperf_CFLAGS = -O
twovec_LDADD = -lm
......@@ -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"
/* Make sure datatype creation is independent of data size */
#define SKIP 4
#define NUM_SIZES 16
#define FRACTION 0.2
/* Don't make the number of loops too high; we create so many
* datatypes before trying to free them */
#define LOOPS 1024
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;
MPI_Init(&argc, &argv);
/* 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 */
tmean = 0;
size = 1;
for (i = 0; i < NUM_SIZES + SKIP; i++) {
nrows = ncols = 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);
ttmp = MPI_Wtime();
ttick = MPI_Wtick();
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]);
}
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 );
}
if (i >= SKIP) {
t[i - SKIP] = MPI_Wtime() - ttmp;
tmean += t[i - SKIP];
}
/* 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 */
}
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;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment