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 main(int argc, char *argv[])
55 MTest_Init(&argc, &argv);
57 MPI_Comm_size(MPI_COMM_WORLD, &size);
58 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
60 /* Create a persistent send request */
61 MPI_Send_init(buf, 10, MPI_INT, dest, tag, MPI_COMM_WORLD, &r);
66 MPI_Test(&r, &flag, &s);
69 printf("Flag not true after MPI_Test (send)\n");
70 printf("Aborting further tests to avoid hanging in MPI_Wait\n");
75 if (!StatusEmpty(&s)) {
77 printf("Status not empty after MPI_Test (send)\n");
83 if (!StatusEmpty(&s)) {
85 printf("Status not empty after MPI_Wait (send)\n");
88 /* Now try to use that request, then check again */
91 MPI_Request *rr = (MPI_Request *) malloc(size * sizeof(MPI_Request));
92 for (i = 0; i < size; i++) {
93 MPI_Irecv(rbuf, 10, MPI_INT, i, tag, MPI_COMM_WORLD, &rr[i]);
97 MPI_Waitall(size, rr, MPI_STATUSES_IGNORE);
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);
117 if (!StatusEmpty(&s)) {
119 printf("Status not empty after MPI_Test (send)\n");
125 if (!StatusEmpty(&s)) {
127 printf("Status not empty after MPI_Wait (send)\n");
132 MPI_Request_free(&r);
134 /* Create a persistent receive request */
135 MPI_Recv_init(buf, 10, MPI_INT, dest, tag, MPI_COMM_WORLD, &r);
140 MPI_Test(&r, &flag, &s);
143 printf("Flag not true after MPI_Test (recv)\n");
144 printf("Aborting further tests to avoid hanging in MPI_Wait\n");
145 MTest_Finalize(errs);
149 if (!StatusEmpty(&s)) {
151 printf("Status not empty after MPI_Test (recv)\n");
157 if (!StatusEmpty(&s)) {
159 printf("Status not empty after MPI_Wait (recv)\n");
162 MPI_Request_free(&r);
164 MTest_Finalize(errs);