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" );
71 MTest_Finalize( errs );
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 );
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 );
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" );
131 MPI_Request_free( &r );
133 /* Create a persistent receive request */
134 MPI_Recv_init( buf, 10, MPI_INT, dest, tag, MPI_COMM_WORLD, &r );
139 MPI_Test( &r, &flag, &s );
142 printf( "Flag not true after MPI_Test (recv)\n" );
143 printf( "Aborting further tests to avoid hanging in MPI_Wait\n" );
144 MTest_Finalize( errs );
148 if (!StatusEmpty( &s )) {
150 printf( "Status not empty after MPI_Test (recv)\n" );
156 if (!StatusEmpty( &s )) {
158 printf( "Status not empty after MPI_Wait (recv)\n" );
161 MPI_Request_free( &r );
163 MTest_Finalize( errs );