1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2003 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
12 static char MTEST_Descrip[] = "Test of various receive cancel calls, with multiple requests to cancel";
15 int main( int argc, char *argv[] )
18 int rank, size, source, dest;
22 static int bufsizes[4] = { 1, 100, 10000, 1000000 };
26 MTest_Init( &argc, &argv );
28 comm = MPI_COMM_WORLD;
29 MPI_Comm_rank( comm, &rank );
30 MPI_Comm_size( comm, &size );
36 MPI_Send( MPI_BOTTOM, 0, MPI_CHAR, dest, 1, MPI_COMM_WORLD );
38 else if (rank == dest) {
39 /* Create 3 requests to cancel, plus one to use.
40 Then receive one message and exit */
42 bufs[i] = (char *) malloc( bufsizes[i] );
43 MPI_Irecv( bufs[i], bufsizes[i], MPI_CHAR, source,
44 i, MPI_COMM_WORLD, &req[i] );
46 /* Now, cancel them in a more interesting order, to ensure that the
47 queue operation work properly */
48 MPI_Cancel( &req[2] );
49 MPI_Wait( &req[2], &status );
50 MTestPrintfMsg( 1, "Completed wait on irecv[2]\n" );
51 MPI_Test_cancelled( &status, &flag );
54 printf( "Failed to cancel a Irecv[2] request\n" );
57 MPI_Cancel( &req[3] );
58 MPI_Wait( &req[3], &status );
59 MTestPrintfMsg( 1, "Completed wait on irecv[3]\n" );
60 MPI_Test_cancelled( &status, &flag );
63 printf( "Failed to cancel a Irecv[3] request\n" );
66 MPI_Cancel( &req[0] );
67 MPI_Wait( &req[0], &status );
68 MTestPrintfMsg( 1, "Completed wait on irecv[0]\n" );
69 MPI_Test_cancelled( &status, &flag );
72 printf( "Failed to cancel a Irecv[0] request\n" );
75 MPI_Wait( &req[1], &status );
76 MPI_Test_cancelled( &status, &flag );
79 printf( "Incorrectly cancelled Irecv[1]\n" ); fflush(stdout);
83 MTest_Finalize( errs );