1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2003 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
10 int prodof(int ndims, const int dims[]);
11 int increasing(int ndims, const int dims[]);
13 int prodof(int ndims, const int dims[])
16 for (i = 0; i < ndims; i++)
21 int increasing(int ndims, const int dims[])
24 for (i = 1; i < ndims; i++) {
25 if (dims[i] > dims[i - 1]) {
26 printf("%d = dims[%d] > dims[%d] = %d\n", dims[i], i, i - 1, dims[i - 1]);
33 int main(int argc, char *argv[])
36 int dims[4], nnodes, ndims;
38 MTest_Init(&argc, &argv);
40 /* Test multiple dims create values. For each, make sure that the
41 * product of dims is the number of input nodes */
42 nnodes = 2 * 3 * 5 * 7 * 11;
44 dims[0] = dims[1] = 0;
45 MPI_Dims_create(nnodes, ndims, dims);
46 if (prodof(ndims, dims) != nnodes) {
48 printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
50 if (increasing(ndims, dims)) {
53 ("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n");
54 printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
57 /* Test multiple dims create values. For each, make sure that the
58 * product of dims is the number of input nodes */
61 dims[0] = dims[1] = 0;
62 MPI_Dims_create(nnodes, ndims, dims);
63 if (prodof(ndims, dims) != nnodes) {
65 printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
67 if (increasing(ndims, dims)) {
70 ("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n");
71 printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
74 nnodes = 2 * 2 * 3 * 3 * 5 * 7 * 11;
76 dims[0] = dims[1] = 0;
77 MPI_Dims_create(nnodes, ndims, dims);
78 if (prodof(ndims, dims) != nnodes) {
80 printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
82 if (increasing(ndims, dims)) {
85 ("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n");
86 printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
91 dims[0] = dims[1] = 0;
92 MPI_Dims_create(nnodes, ndims, dims);
93 if (prodof(ndims, dims) != nnodes) {
95 printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
97 if (increasing(ndims, dims)) {
100 ("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n");
101 printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
106 dims[0] = dims[1] = dims[2] = dims[3] = 0;
107 MPI_Dims_create(nnodes, ndims, dims);
108 if (prodof(ndims, dims) != nnodes) {
110 printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
112 if (increasing(ndims, dims)) {
115 ("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n");
116 printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
121 dims[0] = dims[1] = dims[2] = dims[3] = 0;
122 MPI_Dims_create(nnodes, ndims, dims);
123 if (prodof(ndims, dims) != nnodes) {
125 printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
127 if (increasing(ndims, dims)) {
130 ("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n");
131 printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
134 MTest_Finalize(errs);