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;
35 double tMeanLower, tMeanHigher;
37 int i, j, errs = 0, nrows, ncols;
39 MPI_Init(&argc, &argv);
42 for (i = -SKIP; i < NUM_SIZES; i++) {
47 for (j = 0; j < LOOPS; j++) {
48 MPI_Type_vector(nrows, 1, ncols, MPI_INT, &column[j]);
49 MPI_Type_hvector(ncols, 1, sizeof(int), column[j], &xpose[j]);
50 MPI_Type_commit(&xpose[j]);
54 t[i] = MPI_Wtime() - ttmp;
55 if (t[i] < 100 * MPI_Wtick()) {
56 /* Time is too inaccurate to use. Set to zero.
57 * Consider increasing the LOOPS value to make this
58 * time large enough */
63 for (j = 0; j < LOOPS; j++) {
64 MPI_Type_free(&xpose[j]);
65 MPI_Type_free(&column[j]);
72 /* Now, analyze the times to see that they do not grow too fast
73 * as a function of size. As that is a vague criteria, we do the
74 * following as a simple test:
75 * Compute the mean of the first half and the second half of the
77 * Compare the two means
78 * If the mean of the second half is more than FRACTION times the
79 * mean of the first half, then the time may be growing too fast.
81 tMeanLower = tMeanHigher = 0;
82 for (i = 0; i < NUM_SIZES / 2; i++)
84 tMeanLower /= (NUM_SIZES / 2);
85 for (i = NUM_SIZES / 2; i < NUM_SIZES; i++)
87 tMeanHigher /= (NUM_SIZES - NUM_SIZES / 2);
88 /* A large value (even 1 or greater) is a good choice for
89 * FRACTION here - the goal is to detect significant growth in
90 * execution time as the size increases, and there is no MPI
91 * standard requirement here to meet.
93 * If the times were too small, then the test also passes - the
94 * goal is to find implementation problems that lead to excessive
95 * time in these routines.
97 if (tMeanLower > 0 && tMeanHigher > (1 + FRACTION) * tMeanLower)
101 fprintf(stderr, "too much difference in performance: ");
102 for (i = 0; i < NUM_SIZES; i++)
103 fprintf(stderr, "%.3f ", t[i] * 1e6);
104 fprintf(stderr, "\n");
107 printf(" No Errors\n");