1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2001 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
12 /* Make sure datatype creation is independent of data size
13 Note, however, that there is no guarantee or expectation
14 that the time would be constant. In particular, some
15 optimizations might take more time than others.
17 The real goal of this is to ensure that the time to create
18 a datatype doesn't increase strongly with the number of elements
19 within the datatype, particularly for these datatypes that are
20 quite simple patterns.
27 /* Don't make the number of loops too high; we create so many
28 * datatypes before trying to free them */
31 int main(int argc, char *argv[])
33 MPI_Datatype column[LOOPS], xpose[LOOPS];
34 double t[NUM_SIZES], ttmp, tmean;
35 double tMeanLower, tMeanHigher;
37 int i, j, errs = 0, nrows, ncols;
39 MPI_Init(&argc, &argv);
43 for (i = -SKIP; i < NUM_SIZES; i++) {
48 for (j = 0; j < LOOPS; j++) {
49 MPI_Type_vector(nrows, 1, ncols, MPI_INT, &column[j]);
50 MPI_Type_hvector(ncols, 1, sizeof(int), column[j], &xpose[j]);
51 MPI_Type_commit(&xpose[j]);
55 t[i] = MPI_Wtime() - ttmp;
56 if (t[i] < 100 * MPI_Wtick()) {
57 /* Time is too inaccurate to use. Set to zero.
58 Consider increasing the LOOPS value to make this
65 for (j = 0; j < LOOPS; j++) {
66 MPI_Type_free(&xpose[j]);
67 MPI_Type_free(&column[j]);
75 /* Now, analyze the times to see that they do not grow too fast
76 as a function of size. As that is a vague criteria, we do the
77 following as a simple test:
78 Compute the mean of the first half and the second half of the
81 If the mean of the second half is more than FRACTION times the
82 mean of the first half, then the time may be growing too fast.
84 tMeanLower = tMeanHigher = 0;
85 for (i=0; i<NUM_SIZES/2; i++)
87 tMeanLower /= (NUM_SIZES/2);
88 for (i=NUM_SIZES/2; i<NUM_SIZES; i++)
90 tMeanHigher /= (NUM_SIZES - NUM_SIZES/2);
91 /* A large value (even 1 or greater) is a good choice for
92 FRACTION here - the goal is to detect significant growth in
93 execution time as the size increases, and there is no MPI
94 standard requirement here to meet.
96 If the times were too small, then the test also passes - the
97 goal is to find implementation problems that lead to excessive
98 time in these routines.
100 if (tMeanLower > 0 && tMeanHigher > (1 + FRACTION) * tMeanLower) errs++;
103 fprintf(stderr, "too much difference in performance: ");
104 for (i = 0; i < NUM_SIZES; i++)
105 fprintf(stderr, "%.3f ", t[i] * 1e6);
106 fprintf(stderr, "\n");
109 printf(" No Errors\n");