4 int main( int argc, char *argv[] )
13 MPI_Init( &argc, &argv );
14 MPI_Comm_size( MPI_COMM_WORLD, &size );
16 fprintf( stderr, "Need at least 3 processors\n" );
17 MPI_Abort( MPI_COMM_WORLD, 1 );
20 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
21 MPI_Comm_split( MPI_COMM_WORLD, rank < 2, rank, &local_comm );
23 MPI_Barrier( MPI_COMM_WORLD );
25 /* First, ensure ssend works */
27 MPI_Ssend( MPI_BOTTOM, 0, MPI_INT, 1, 1, MPI_COMM_WORLD );
28 t0 = MPI_Wtime() - t0;
30 fprintf( stderr, "Ssend does not wait for recv!\n" );
32 MPI_Abort( MPI_COMM_WORLD, 1 );
34 MPI_Barrier( MPI_COMM_WORLD );
35 /* Start the ssend after process 1 is well into its barrier */
37 while (MPI_Wtime() - t0 < 1.0) ;
38 MPI_Ssend( MPI_BOTTOM, 0, MPI_INT, 1, 0, MPI_COMM_WORLD );
39 MPI_Barrier( local_comm );
40 /* Send process 2 an alls well */
41 MPI_Send( MPI_BOTTOM, 0, MPI_INT, 2, 0, MPI_COMM_WORLD );
45 while (MPI_Wtime() - t0 < 2.0) ;
46 MPI_Recv( MPI_BOTTOM, 0, MPI_INT, 0, 1, MPI_COMM_WORLD, &status );
47 MPI_Barrier( MPI_COMM_WORLD );
48 MPI_Irecv( MPI_BOTTOM, 0, MPI_INT, 0, 0, MPI_COMM_WORLD, &r );
49 MPI_Barrier( local_comm );
50 MPI_Wait( &r, &status );
55 MPI_Barrier( MPI_COMM_WORLD );
56 MPI_Irecv( MPI_BOTTOM, 0, MPI_INT, 0, 0, MPI_COMM_WORLD, &r );
58 while (MPI_Wtime() - t0 < 3.0) ;
59 MPI_Test( &r, &flag, &status );
61 fprintf( stderr, "Test failed!\n" );
63 MPI_Abort( MPI_COMM_WORLD, 1 );
66 fprintf( stderr, "Test succeeded\n" );
69 MPI_Barrier( MPI_COMM_WORLD );
72 MPI_Comm_free( &local_comm );