1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2005 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
11 /* This test program checks that the point-to-point completion routines
12 can be applied to an inactive persistent request, as required by the
13 MPI-1 standard. See section 3.7.3, for example,
15 One is allowed to call MPI TEST with a null or inactive request argument.
16 In such a case the operation returns with flag = true and empty status.
20 int StatusEmpty(MPI_Status * s);
21 int StatusEmpty(MPI_Status * s)
26 if (s->MPI_TAG != MPI_ANY_TAG) {
28 printf("MPI_TAG not MPI_ANY_TAG in status\n");
30 if (s->MPI_SOURCE != MPI_ANY_SOURCE) {
32 printf("MPI_SOURCE not MPI_ANY_SOURCE in status\n");
34 MPI_Get_count(s, MPI_INT, &count);
37 printf("count in status is not 0\n");
39 /* Return true only if status passed all tests */
43 int test_recv_init(int src_rank, const char *test_name);
44 int test_recv_init(int src_rank, const char *test_name)
53 MPI_Recv_init(buf, 10, MPI_INT, src_rank, tag, MPI_COMM_WORLD, &r);
58 MPI_Test(&r, &flag, &s);
61 printf("Flag not true after MPI_Test (%s)\n", test_name);
62 printf("Aborting further tests to avoid hanging in MPI_Wait\n");
65 if (!StatusEmpty(&s)) {
67 printf("Status not empty after MPI_Test (%s)\n", test_name);
73 if (!StatusEmpty(&s)) {
75 printf("Status not empty after MPI_Wait (%s)\n", test_name);
83 int main(int argc, char *argv[])
95 MTest_Init(&argc, &argv);
97 MPI_Comm_size(MPI_COMM_WORLD, &size);
98 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
101 MTestPrintfMsg(1, "Create a persistent send request\n");
103 MPI_Send_init(buf, 10, MPI_INT, dest, tag, MPI_COMM_WORLD, &r);
108 MPI_Test(&r, &flag, &s);
111 printf("Flag not true after MPI_Test (send)\n");
112 printf("Aborting further tests to avoid hanging in MPI_Wait\n");
113 MTest_Finalize(errs);
114 return MTestReturnValue(errs);
116 if (!StatusEmpty(&s)) {
118 printf("Status not empty after MPI_Test (send)\n");
124 if (!StatusEmpty(&s)) {
126 printf("Status not empty after MPI_Wait (send)\n");
129 /* Now try to use that request, then check again */
132 MPI_Request *rr = (MPI_Request *) malloc(size * sizeof(MPI_Request));
133 for (i = 0; i < size; i++) {
134 MPI_Irecv(rbuf, 10, MPI_INT, i, tag, MPI_COMM_WORLD, &rr[i]);
138 MPI_Waitall(size, rr, MPI_STATUSES_IGNORE);
148 MPI_Test(&r, &flag, &s);
151 printf("Flag not true after MPI_Test (send)\n");
152 printf("Aborting further tests to avoid hanging in MPI_Wait\n");
153 MTest_Finalize(errs);
154 return MTestReturnValue(errs);
156 if (!StatusEmpty(&s)) {
158 printf("Status not empty after MPI_Test (send)\n");
164 if (!StatusEmpty(&s)) {
166 printf("Status not empty after MPI_Wait (send)\n");
171 MPI_Request_free(&r);
174 MTestPrintfMsg(1, "Create a persistent receive request\n");
176 e = test_recv_init(dest, "recv");
182 MTestPrintfMsg(1, "Create a persistent receive (ANY_SOURCE) request\n");
184 errs += test_recv_init(MPI_ANY_SOURCE, "recv-anysource");
187 MTest_Finalize(errs);
188 return MTestReturnValue(errs);