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 send cancel (failure) calls";
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 );
35 MTestPrintfMsg( 1, "Starting scancel test\n" );
37 for (cs=0; cs<4; cs++) {
39 buf = (char *)malloc( n );
41 fprintf( stderr, "Unable to allocate %d bytes\n", n );
42 MPI_Abort( MPI_COMM_WORLD, 1 );
47 MTestPrintfMsg( 1, "(%d) About to create isend and cancel\n",cs );
48 MPI_Isend( buf, n, MPI_CHAR, dest, cs+n+1, comm, &req );
51 MPI_Wait( &req, &status );
52 MTestPrintfMsg( 1, "Completed wait on isend\n" );
53 MPI_Test_cancelled( &status, &flag );
56 printf( "Cancelled a matched Isend request (msg size = %d)!\n",
64 /* Send the size, zero for not cancelled (success) */
65 MPI_Send( &n, 1, MPI_INT, dest, 123, comm );
67 else if (rank == dest)
69 MPI_Recv( buf, n, MPI_CHAR, source, cs+n+1, comm, &status );
71 MPI_Recv( &n, 1, MPI_INT, source, 123, comm, &status );
81 MTest_Finalize( errs );