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
16 /* USE_STRICT_MPI may be defined in mpitestconf.h */
17 #include "mpitestconf.h"
21 #define my_assert(cond_) \
24 fprintf(stderr, "assertion (%s) failed, aborting\n", #cond_); \
25 MPI_Abort(MPI_COMM_WORLD, 1); \
29 int main(int argc, char **argv)
44 /* intentionally not using MTest_Init/MTest_Finalize in order to make it
45 * easy to take this test and use it as an NBC sanity test outside of the
47 MPI_Init(&argc, &argv);
49 comm = MPI_COMM_WORLD;
51 MPI_Comm_size(comm, &size);
52 MPI_Comm_rank(comm, &rank);
54 #if !defined(USE_STRICT_MPI) && defined(MPICH)
55 /* enough space for every process to contribute at least NUM_INTS ints to any
56 * collective operation */
57 sbuf = malloc(NUM_INTS*size*sizeof(int));
59 rbuf = malloc(NUM_INTS*size*sizeof(int));
61 scounts = malloc(size*sizeof(int));
63 rcounts = malloc(size*sizeof(int));
65 sdispls = malloc(size*sizeof(int));
67 rdispls = malloc(size*sizeof(int));
69 types = malloc(size*sizeof(int));
72 for (i = 0; i < size; ++i) {
77 scounts[i] = NUM_INTS;
78 rcounts[i] = NUM_INTS;
79 sdispls[i] = i * NUM_INTS;
80 rdispls[i] = i * NUM_INTS;
84 MPI_Ibarrier(comm, &req);
85 MPI_Wait(&req, MPI_STATUS_IGNORE);
87 MPI_Ibcast(sbuf, NUM_INTS, MPI_INT, 0, comm, &req);
88 MPI_Wait(&req, MPI_STATUS_IGNORE);
90 MPI_Igather(sbuf, NUM_INTS, MPI_INT, rbuf, NUM_INTS, MPI_INT, 0, comm, &req);
91 MPI_Wait(&req, MPI_STATUS_IGNORE);
93 MPI_Igatherv(sbuf, NUM_INTS, MPI_INT, rbuf, rcounts, rdispls, MPI_INT, 0, comm, &req);
94 MPI_Wait(&req, MPI_STATUS_IGNORE);
96 MPI_Iscatter(sbuf, NUM_INTS, MPI_INT, rbuf, NUM_INTS, MPI_INT, 0, comm, &req);
97 MPI_Wait(&req, MPI_STATUS_IGNORE);
99 MPI_Iscatterv(sbuf, scounts, sdispls, MPI_INT, rbuf, NUM_INTS, MPI_INT, 0, comm, &req);
100 MPI_Wait(&req, MPI_STATUS_IGNORE);
102 MPI_Iallgather(sbuf, NUM_INTS, MPI_INT, rbuf, NUM_INTS, MPI_INT, comm, &req);
103 MPI_Wait(&req, MPI_STATUS_IGNORE);
105 MPI_Iallgatherv(sbuf, NUM_INTS, MPI_INT, rbuf, rcounts, rdispls, MPI_INT, comm, &req);
106 MPI_Wait(&req, MPI_STATUS_IGNORE);
108 MPI_Ialltoall(sbuf, NUM_INTS, MPI_INT, rbuf, NUM_INTS, MPI_INT, comm, &req);
109 MPI_Wait(&req, MPI_STATUS_IGNORE);
111 MPI_Ialltoallv(sbuf, scounts, sdispls, MPI_INT, rbuf, rcounts, rdispls, MPI_INT, comm, &req);
112 MPI_Wait(&req, MPI_STATUS_IGNORE);
114 MPI_Ialltoallw(sbuf, scounts, sdispls, types, rbuf, rcounts, rdispls, types, comm, &req);
115 MPI_Wait(&req, MPI_STATUS_IGNORE);
117 MPI_Ireduce(sbuf, rbuf, NUM_INTS, MPI_INT, MPI_SUM, 0, comm, &req);
118 MPI_Wait(&req, MPI_STATUS_IGNORE);
120 MPI_Iallreduce(sbuf, rbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req);
121 MPI_Wait(&req, MPI_STATUS_IGNORE);
123 MPI_Ireduce_scatter(sbuf, rbuf, rcounts, MPI_INT, MPI_SUM, comm, &req);
124 MPI_Wait(&req, MPI_STATUS_IGNORE);
126 MPI_Ireduce_scatter_block(sbuf, rbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req);
127 MPI_Wait(&req, MPI_STATUS_IGNORE);
129 MPI_Iscan(sbuf, rbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req);
130 MPI_Wait(&req, MPI_STATUS_IGNORE);
132 MPI_Iexscan(sbuf, rbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req);
133 MPI_Wait(&req, MPI_STATUS_IGNORE);
137 if (sbuf) free(sbuf);
138 if (rbuf) free(rbuf);
139 if (scounts) free(scounts);
140 if (rcounts) free(rcounts);
141 if (sdispls) free(sdispls);
142 if (rdispls) free(rdispls);
146 fprintf(stderr, "Found %d errors\n", errs);
148 printf(" No errors\n");