2 * This file tests to see if short,eager,and rndv messages can all be
3 * successfully cancelled. If they cannot be cancelled, then the
4 * program still must successfully complete.
10 #if defined(NEEDS_STDLIB_PROTOTYPES)
14 int main( int argc, char *argv[] )
28 MPI_Init( &argc, &argv );
29 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
30 MPI_Comm_size( MPI_COMM_WORLD, &size );
33 printf( "Cancel test requires at least 2 processes\n" );
34 MPI_Abort( MPI_COMM_WORLD, 1 );
37 /* Short Message Test */
40 if (rank == 1) { /* begin if rank = 1 */
41 MPI_Isend( sbuf, n, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD, &req );
43 MPI_Wait(&req, &status);
44 MPI_Test_cancelled(&status, &flag);
47 printf( "Cancelling a short message failed where it should succeed.\n" );
51 printf("Cancelling a short message succeeded.\n");
53 } /* end if rank == 1 */
56 /* Note that MPI-2 specifies that status.MPI_ERROR is only set by
57 multiple completion (e.g., MPI_Waitsome) and not by test_cancelled.
59 MPI_Barrier(MPI_COMM_WORLD);
61 if (rank == 0) { /* begin if rank == 0 */
62 MPI_Recv( rbuf, n, MPI_DOUBLE, 1, 1, MPI_COMM_WORLD, &status);
63 } /* end if rank = 0 */
64 else if (rank == 1) { /* begin if rank = 1 */
65 MPI_Isend( sbuf, n, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD, &req );
67 MPI_Wait(&req, &status);
68 MPI_Test_cancelled(&status, &flag);
69 if (!flag && status.MPI_ERROR != MPI_SUCCESS) {
71 printf( "Cancel of a send returned an error in the status field.\n" );
73 /* end if status.MPI_ERROR */
74 } /* end if rank == 1 */
77 MPI_Barrier(MPI_COMM_WORLD);
79 /* Eager Message Test */
82 if (rank == 1) { /* begin if rank = 1 */
83 MPI_Isend( sbuf, n, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD, &req );
85 MPI_Wait(&req, &status);
86 MPI_Test_cancelled(&status, &flag);
89 printf( "Cancelling an eager message (3000 doubles) failed where it should succeed.\n" );
93 printf("Cancelling an eager message (3000 doubles) succeeded.\n");
95 } /* end if rank == 1 */
98 MPI_Barrier(MPI_COMM_WORLD);
100 if (rank == 0) { /* begin if rank == 0 */
101 MPI_Irecv(rbuf, n, MPI_DOUBLE, 1, 1, MPI_COMM_WORLD, &req );
102 MPI_Wait( &req, &status);
103 } /* end if rank = 0 */
104 else if (rank == 1) { /* begin if rank = 1 */
105 MPI_Isend( sbuf, n, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD, &req );
107 MPI_Wait(&req, &status);
108 MPI_Test_cancelled(&status, &flag);
109 if (!flag && status.MPI_ERROR != MPI_SUCCESS) {
111 printf( "Cancel of a send returned an error in the status field.\n" );
113 /* end if status.MPI_ERROR */
114 } /* end if rank == 1 */
117 MPI_Barrier(MPI_COMM_WORLD);
119 /* Rndv Message Test */
122 if (rank == 1) { /* begin if rank = 1 */
123 MPI_Isend( sbuf, n, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD, &req );
125 MPI_Wait(&req, &status);
126 MPI_Test_cancelled(&status, &flag);
129 printf( "Cancelling a rendezvous message failed (20000 doubles) where it should succeed.\n" );
133 printf("Cancelling an rendezvous message (20000 doubles) succeeded.\n");
135 } /* end if rank == 1 */
138 MPI_Barrier(MPI_COMM_WORLD);
140 if (rank == 0) { /* begin if rank == 0 */
141 MPI_Irecv(rbuf, n, MPI_DOUBLE, 1, 1, MPI_COMM_WORLD, &req );
142 MPI_Wait( &req, &status);
143 } /* end if rank = 0 */
144 else if (rank == 1) { /* begin if rank = 1 */
145 MPI_Isend( sbuf, n, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD, &req );
147 MPI_Wait(&req, &status);
148 MPI_Test_cancelled(&status, &flag);
149 if (!flag && status.MPI_ERROR != MPI_SUCCESS) {
151 printf( "Cancel of a send returned an error in the status field.\n" );
153 /* end if status.MPI_ERROR */
154 } /* end if rank == 1 */
157 MPI_Barrier(MPI_COMM_WORLD);
159 if (rank == 1) { /* begin if rank = 1 */
161 printf( "Test failed with %d errors.\n", err );
164 printf( " No Errors\n" );