1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2010 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
7 /* This is a very weak sanity test that all nonblocking collectives specified by
8 * MPI-3 are present in the library and take arguments as expected. This test
9 * does not check for progress, matching issues, or sensible output buffer
19 #define my_assert(cond_) \
22 fprintf(stderr, "assertion (%s) failed, aborting\n", #cond_); \
23 MPI_Abort(MPI_COMM_WORLD, 1); \
27 int main(int argc, char **argv)
42 /* intentionally not using MTest_Init/MTest_Finalize in order to make it
43 * easy to take this test and use it as an NBC sanity test outside of the
45 MPI_Init(&argc, &argv);
47 comm = MPI_COMM_WORLD;
49 MPI_Comm_size(comm, &size);
50 MPI_Comm_rank(comm, &rank);
52 MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
54 /* enough space for every process to contribute at least NUM_INTS ints to any
55 * collective operation */
56 sbuf = malloc(NUM_INTS*size*sizeof(int));
58 rbuf = malloc(NUM_INTS*size*sizeof(int));
60 scounts = malloc(size*sizeof(int));
62 rcounts = malloc(size*sizeof(int));
64 sdispls = malloc(size*sizeof(int));
66 rdispls = malloc(size*sizeof(int));
68 types = malloc(size*sizeof(int));
71 for (i = 0; i < size; ++i) {
76 scounts[i] = NUM_INTS;
77 rcounts[i] = NUM_INTS;
78 sdispls[i] = i * NUM_INTS;
79 rdispls[i] = i * NUM_INTS;
83 if (rank == 0 && MPI_SUCCESS ==
84 MPI_Igather(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm, &req))
87 if (rank == 0 && MPI_SUCCESS ==
88 MPI_Igatherv(sbuf, NUM_INTS, MPI_INT, sbuf, rcounts, rdispls, MPI_INT, 0, comm, &req))
91 if (rank == 0 && MPI_SUCCESS ==
92 MPI_Iscatter(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm, &req))
95 if (rank == 0 && MPI_SUCCESS ==
96 MPI_Iscatterv(sbuf, scounts, sdispls, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm, &req))
100 MPI_Iallgather(&sbuf[rank], 1, MPI_INT, sbuf, 1, MPI_INT, comm, &req))
104 MPI_Iallgatherv(&sbuf[rank * rcounts[rank]], rcounts[rank], MPI_INT, sbuf, rcounts, rdispls, MPI_INT, comm, &req))
108 MPI_Ialltoall(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, comm, &req))
112 MPI_Ialltoallv(sbuf, scounts, sdispls, MPI_INT, sbuf, scounts, sdispls, MPI_INT, comm, &req))
116 MPI_Ialltoallw(sbuf, scounts, sdispls, types, sbuf, scounts, sdispls, types, comm, &req))
119 if (rank == 0 && MPI_SUCCESS ==
120 MPI_Ireduce(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, 0, comm, &req))
124 MPI_Iallreduce(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req))
128 MPI_Ireduce_scatter(sbuf, sbuf, rcounts, MPI_INT, MPI_SUM, comm, &req))
132 MPI_Ireduce_scatter_block(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req))
136 MPI_Iscan(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req))
140 MPI_Iexscan(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req))
143 if (sbuf) free(sbuf);
144 if (rbuf) free(rbuf);
145 if (scounts) free(scounts);
146 if (rcounts) free(rcounts);
147 if (sdispls) free(sdispls);
148 if (rdispls) free(rdispls);
152 fprintf(stderr, "Found %d errors\n", errs);
154 printf(" No errors\n");