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
18 #define my_assert(cond_) \
21 fprintf(stderr, "assertion (%s) failed, aborting\n", #cond_); \
22 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 /* enough space for every process to contribute at least NUM_INTS ints to any
53 * collective operation */
54 sbuf = malloc(NUM_INTS*size*sizeof(int));
56 rbuf = malloc(NUM_INTS*size*sizeof(int));
58 scounts = malloc(size*sizeof(int));
60 rcounts = malloc(size*sizeof(int));
62 sdispls = malloc(size*sizeof(int));
64 rdispls = malloc(size*sizeof(int));
66 types = malloc(size*sizeof(int));
69 for (i = 0; i < size; ++i) {
74 scounts[i] = NUM_INTS;
75 rcounts[i] = NUM_INTS;
76 sdispls[i] = i * NUM_INTS;
77 rdispls[i] = i * NUM_INTS;
81 MPI_Ibarrier(comm, &req);
82 MPI_Wait(&req, MPI_STATUS_IGNORE);
84 MPI_Ibcast(sbuf, NUM_INTS, MPI_INT, 0, comm, &req);
85 MPI_Wait(&req, MPI_STATUS_IGNORE);
87 MPI_Igather(sbuf, NUM_INTS, MPI_INT, rbuf, NUM_INTS, MPI_INT, 0, comm, &req);
88 MPI_Wait(&req, MPI_STATUS_IGNORE);
90 MPI_Igatherv(sbuf, NUM_INTS, MPI_INT, rbuf, rcounts, rdispls, MPI_INT, 0, comm, &req);
91 MPI_Wait(&req, MPI_STATUS_IGNORE);
93 MPI_Iscatter(sbuf, NUM_INTS, MPI_INT, rbuf, NUM_INTS, MPI_INT, 0, comm, &req);
94 MPI_Wait(&req, MPI_STATUS_IGNORE);
96 MPI_Iscatterv(sbuf, scounts, sdispls, MPI_INT, rbuf, NUM_INTS, MPI_INT, 0, comm, &req);
97 MPI_Wait(&req, MPI_STATUS_IGNORE);
99 MPI_Iallgather(sbuf, NUM_INTS, MPI_INT, rbuf, NUM_INTS, MPI_INT, comm, &req);
100 MPI_Wait(&req, MPI_STATUS_IGNORE);
102 MPI_Iallgatherv(sbuf, NUM_INTS, MPI_INT, rbuf, rcounts, rdispls, MPI_INT, comm, &req);
103 MPI_Wait(&req, MPI_STATUS_IGNORE);
105 MPI_Ialltoall(sbuf, NUM_INTS, MPI_INT, rbuf, NUM_INTS, MPI_INT, comm, &req);
106 MPI_Wait(&req, MPI_STATUS_IGNORE);
108 MPI_Ialltoallv(sbuf, scounts, sdispls, MPI_INT, rbuf, rcounts, rdispls, MPI_INT, comm, &req);
109 MPI_Wait(&req, MPI_STATUS_IGNORE);
111 MPI_Ialltoallw(sbuf, scounts, sdispls, types, rbuf, rcounts, rdispls, types, comm, &req);
112 MPI_Wait(&req, MPI_STATUS_IGNORE);
114 MPI_Ireduce(sbuf, rbuf, NUM_INTS, MPI_INT, MPI_SUM, 0, comm, &req);
115 MPI_Wait(&req, MPI_STATUS_IGNORE);
117 MPI_Iallreduce(sbuf, rbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req);
118 MPI_Wait(&req, MPI_STATUS_IGNORE);
120 MPI_Ireduce_scatter(sbuf, rbuf, rcounts, MPI_INT, MPI_SUM, comm, &req);
121 MPI_Wait(&req, MPI_STATUS_IGNORE);
123 MPI_Ireduce_scatter_block(sbuf, rbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req);
124 MPI_Wait(&req, MPI_STATUS_IGNORE);
126 MPI_Iscan(sbuf, rbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req);
127 MPI_Wait(&req, MPI_STATUS_IGNORE);
129 MPI_Iexscan(sbuf, rbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req);
130 MPI_Wait(&req, MPI_STATUS_IGNORE);
132 if (sbuf) free(sbuf);
133 if (rbuf) free(rbuf);
134 if (scounts) free(scounts);
135 if (rcounts) free(rcounts);
136 if (sdispls) free(sdispls);
137 if (rdispls) free(rdispls);
141 fprintf(stderr, "Found %d errors\n", errs);
143 printf(" No errors\n");