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)
52 MPI_Recv_init(buf, 10, MPI_INT, src_rank, tag, MPI_COMM_WORLD, &r);
57 MPI_Test(&r, &flag, &s);
60 printf("Flag not true after MPI_Test (%s)\n", test_name);
61 printf("Aborting further tests to avoid hanging in MPI_Wait\n");
64 if (!StatusEmpty(&s)) {
66 printf("Status not empty after MPI_Test (%s)\n", test_name);
72 if (!StatusEmpty(&s)) {
74 printf("Status not empty after MPI_Wait (%s)\n", test_name);
82 int main(int argc, char *argv[])
94 MTest_Init(&argc, &argv);
96 MPI_Comm_size(MPI_COMM_WORLD, &size);
97 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
100 MTestPrintfMsg(1, "Create a persistent send request\n");
102 MPI_Send_init(buf, 10, MPI_INT, dest, tag, MPI_COMM_WORLD, &r);
107 MPI_Test(&r, &flag, &s);
110 printf("Flag not true after MPI_Test (send)\n");
111 printf("Aborting further tests to avoid hanging in MPI_Wait\n");
112 MTest_Finalize(errs);
113 return MTestReturnValue(errs);
115 if (!StatusEmpty(&s)) {
117 printf("Status not empty after MPI_Test (send)\n");
123 if (!StatusEmpty(&s)) {
125 printf("Status not empty after MPI_Wait (send)\n");
128 /* Now try to use that request, then check again */
131 MPI_Request *rr = (MPI_Request *) malloc(size * sizeof(MPI_Request));
132 for (i = 0; i < size; i++) {
133 MPI_Irecv(rbuf, 10, MPI_INT, i, tag, MPI_COMM_WORLD, &rr[i]);
137 MPI_Waitall(size, rr, MPI_STATUSES_IGNORE);
147 MPI_Test(&r, &flag, &s);
150 printf("Flag not true after MPI_Test (send)\n");
151 printf("Aborting further tests to avoid hanging in MPI_Wait\n");
152 MTest_Finalize(errs);
153 return MTestReturnValue(errs);
155 if (!StatusEmpty(&s)) {
157 printf("Status not empty after MPI_Test (send)\n");
163 if (!StatusEmpty(&s)) {
165 printf("Status not empty after MPI_Wait (send)\n");
170 MPI_Request_free(&r);
173 MTestPrintfMsg(1, "Create a persistent receive request\n");
175 e = test_recv_init(dest, "recv");
181 MTestPrintfMsg(1, "Create a persistent receive (ANY_SOURCE) request\n");
183 errs += test_recv_init(MPI_ANY_SOURCE, "recv-anysource");
186 MTest_Finalize(errs);
187 return MTestReturnValue(errs);