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); \
26 int main(int argc, char **argv)
37 MPI_Datatype *types = NULL;
41 /* intentionally not using MTest_Init/MTest_Finalize in order to make it
42 * easy to take this test and use it as an NBC sanity test outside of the
44 MPI_Init(&argc, &argv);
46 comm = MPI_COMM_WORLD;
48 MPI_Comm_size(comm, &size);
49 MPI_Comm_rank(comm, &rank);
51 /* enough space for every process to contribute at least NUM_INTS ints to any
52 * collective operation */
53 sbuf = malloc(NUM_INTS * size * sizeof(int));
55 rbuf = malloc(NUM_INTS * size * sizeof(int));
57 scounts = malloc(size * sizeof(int));
59 rcounts = malloc(size * sizeof(int));
61 sdispls = malloc(size * sizeof(int));
63 rdispls = malloc(size * sizeof(int));
65 types = malloc(size * sizeof(MPI_Datatype));
68 for (i = 0; i < size; ++i) {
73 scounts[i] = NUM_INTS;
74 rcounts[i] = NUM_INTS;
75 sdispls[i] = i * NUM_INTS;
76 rdispls[i] = i * NUM_INTS;
80 MPI_Ibarrier(comm, &req);
81 MPI_Wait(&req, MPI_STATUS_IGNORE);
83 MPI_Ibcast(sbuf, NUM_INTS, MPI_INT, 0, comm, &req);
84 MPI_Wait(&req, MPI_STATUS_IGNORE);
86 MPI_Igather(sbuf, NUM_INTS, MPI_INT, rbuf, NUM_INTS, MPI_INT, 0, comm, &req);
87 MPI_Wait(&req, MPI_STATUS_IGNORE);
90 MPI_Igather(MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, rbuf, NUM_INTS, MPI_INT, 0, comm, &req);
92 MPI_Igather(sbuf, NUM_INTS, MPI_INT, rbuf, NUM_INTS, MPI_INT, 0, comm, &req);
93 MPI_Wait(&req, MPI_STATUS_IGNORE);
95 MPI_Igatherv(sbuf, NUM_INTS, MPI_INT, rbuf, rcounts, rdispls, MPI_INT, 0, comm, &req);
96 MPI_Wait(&req, MPI_STATUS_IGNORE);
99 MPI_Igatherv(MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, rbuf, rcounts, rdispls, MPI_INT, 0, comm,
102 MPI_Igatherv(sbuf, NUM_INTS, MPI_INT, rbuf, rcounts, rdispls, MPI_INT, 0, comm, &req);
103 MPI_Wait(&req, MPI_STATUS_IGNORE);
105 MPI_Iscatter(sbuf, NUM_INTS, MPI_INT, rbuf, NUM_INTS, MPI_INT, 0, comm, &req);
106 MPI_Wait(&req, MPI_STATUS_IGNORE);
109 MPI_Iscatter(sbuf, NUM_INTS, MPI_INT, MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, 0, comm, &req);
111 MPI_Iscatter(sbuf, NUM_INTS, MPI_INT, rbuf, NUM_INTS, MPI_INT, 0, comm, &req);
112 MPI_Wait(&req, MPI_STATUS_IGNORE);
114 MPI_Iscatterv(sbuf, scounts, sdispls, MPI_INT, rbuf, NUM_INTS, MPI_INT, 0, comm, &req);
115 MPI_Wait(&req, MPI_STATUS_IGNORE);
118 MPI_Iscatterv(sbuf, scounts, sdispls, MPI_INT, MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, 0, comm,
121 MPI_Iscatterv(sbuf, scounts, sdispls, MPI_INT, rbuf, NUM_INTS, MPI_INT, 0, comm, &req);
122 MPI_Wait(&req, MPI_STATUS_IGNORE);
124 MPI_Iallgather(sbuf, NUM_INTS, MPI_INT, rbuf, NUM_INTS, MPI_INT, comm, &req);
125 MPI_Wait(&req, MPI_STATUS_IGNORE);
127 MPI_Iallgather(MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, rbuf, NUM_INTS, MPI_INT, comm, &req);
128 MPI_Wait(&req, MPI_STATUS_IGNORE);
130 MPI_Iallgatherv(sbuf, NUM_INTS, MPI_INT, rbuf, rcounts, rdispls, MPI_INT, comm, &req);
131 MPI_Wait(&req, MPI_STATUS_IGNORE);
133 MPI_Iallgatherv(MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, rbuf, rcounts, rdispls, MPI_INT, comm,
135 MPI_Wait(&req, MPI_STATUS_IGNORE);
137 MPI_Ialltoall(sbuf, NUM_INTS, MPI_INT, rbuf, NUM_INTS, MPI_INT, comm, &req);
138 MPI_Wait(&req, MPI_STATUS_IGNORE);
140 MPI_Ialltoall(MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, rbuf, NUM_INTS, MPI_INT, comm, &req);
141 MPI_Wait(&req, MPI_STATUS_IGNORE);
143 MPI_Ialltoallv(sbuf, scounts, sdispls, MPI_INT, rbuf, rcounts, rdispls, MPI_INT, comm, &req);
144 MPI_Wait(&req, MPI_STATUS_IGNORE);
146 MPI_Ialltoallv(MPI_IN_PLACE, NULL, NULL, MPI_DATATYPE_NULL, rbuf, rcounts, rdispls, MPI_INT,
148 MPI_Wait(&req, MPI_STATUS_IGNORE);
150 MPI_Ialltoallw(sbuf, scounts, sdispls, types, rbuf, rcounts, rdispls, types, comm, &req);
151 MPI_Wait(&req, MPI_STATUS_IGNORE);
153 MPI_Ialltoallw(MPI_IN_PLACE, NULL, NULL, NULL, rbuf, rcounts, rdispls, types, comm, &req);
154 MPI_Wait(&req, MPI_STATUS_IGNORE);
156 MPI_Ireduce(sbuf, rbuf, NUM_INTS, MPI_INT, MPI_SUM, 0, comm, &req);
157 MPI_Wait(&req, MPI_STATUS_IGNORE);
160 MPI_Ireduce(MPI_IN_PLACE, rbuf, NUM_INTS, MPI_INT, MPI_SUM, 0, comm, &req);
162 MPI_Ireduce(sbuf, rbuf, NUM_INTS, MPI_INT, MPI_SUM, 0, comm, &req);
163 MPI_Wait(&req, MPI_STATUS_IGNORE);
165 MPI_Iallreduce(sbuf, rbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req);
166 MPI_Wait(&req, MPI_STATUS_IGNORE);
168 MPI_Iallreduce(MPI_IN_PLACE, rbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req);
169 MPI_Wait(&req, MPI_STATUS_IGNORE);
171 MPI_Ireduce_scatter(sbuf, rbuf, rcounts, MPI_INT, MPI_SUM, comm, &req);
172 MPI_Wait(&req, MPI_STATUS_IGNORE);
174 MPI_Ireduce_scatter(MPI_IN_PLACE, rbuf, rcounts, MPI_INT, MPI_SUM, comm, &req);
175 MPI_Wait(&req, MPI_STATUS_IGNORE);
177 MPI_Ireduce_scatter_block(sbuf, rbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req);
178 MPI_Wait(&req, MPI_STATUS_IGNORE);
180 MPI_Ireduce_scatter_block(MPI_IN_PLACE, rbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req);
181 MPI_Wait(&req, MPI_STATUS_IGNORE);
183 MPI_Iscan(sbuf, rbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req);
184 MPI_Wait(&req, MPI_STATUS_IGNORE);
186 MPI_Iscan(MPI_IN_PLACE, rbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req);
187 MPI_Wait(&req, MPI_STATUS_IGNORE);
189 MPI_Iexscan(sbuf, rbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req);
190 MPI_Wait(&req, MPI_STATUS_IGNORE);
192 MPI_Iexscan(MPI_IN_PLACE, rbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req);
193 MPI_Wait(&req, MPI_STATUS_IGNORE);
212 fprintf(stderr, "Found %d errors\n", errs);
214 printf(" No errors\n");