2 * Program to test that the "synchronous send" semantics
3 * of point to point communications in MPI is (probably) satisfied.
4 * This uses tests on the completions of the SENDS (unlike the MPI_Ssend
5 * test) since the Issends return "immediately" but can not complete
6 * until the matching receive begins.
8 * This program has been patterned off of "overtake.c"
19 /* Amount of time in seconds to wait for the receipt of the second Ssend
25 /* Prototypes for picky compilers */
26 void Generate_Data ( int *, int );
28 void Generate_Data( int *buffer, int buff_size)
32 for (i = 0; i < buff_size; i++)
36 int main( int argc, char **argv)
38 int rank; /* My Rank (0 or 1) */
43 char *Current_Test = NULL;
47 MPI_Init(&argc, &argv);
48 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
50 /* This test depends on a working wtime. Make a simple check */
51 Current_Test = (char*)"Testing timer";
53 if (t0 == 0 && MPI_Wtime() == 0) {
54 int loopcount = 1000000;
55 /* This test is too severe (systems with fast
56 processors and large MPI_Wtick values can
57 fail. Try harder to test MPI_Wtime */
58 while (loopcount-- && MPI_Wtime() == 0) ;
61 "MPI_WTIME is returning 0; a working value is needed\n\
63 Test_Failed(Current_Test);
64 MPI_Abort( MPI_COMM_WORLD, 1 );
68 /* Test that the timer increases */
69 /* Current_Test = (char*)"Testing timer increases";*/
70 /* for (flag=0; flag<1000000; flag++) {*/
71 /* if (MPI_Wtime() > t0) break;*/
73 /* if (flag >= 1000000) {*/
74 /* fprintf( stderr, "MPI_WTIME is not returning increasing values!\n" );*/
75 /* Test_Failed(Current_Test);*/
76 /* MPI_Abort( MPI_COMM_WORLD, 1 );*/
79 Current_Test = (char*)"Issend waits for recv";
81 Test_Init("issendtest", rank);
82 Generate_Data(buffer, SIZE);
83 MPI_Recv( buffer, 0, MPI_INT, dest, 0, MPI_COMM_WORLD, &status );
84 MPI_Send( buffer, 0, MPI_INT, dest, 0, MPI_COMM_WORLD );
85 MPI_Issend( buffer, act_size, MPI_INT, dest, 1, MPI_COMM_WORLD, &r1 );
86 MPI_Issend( buffer, act_size, MPI_INT, dest, 2, MPI_COMM_WORLD, &r2 );
89 /* while ( (MPI_Wtime() - t0) < MAX_TIME) {*/
90 /* MPI_Test( &r1, &flag, &status );*/
92 /* Test_Failed(Current_Test);*/
97 /* Test_Passed(Current_Test);*/
98 MPI_Wait( &r2, &status );
99 MPI_Sendrecv( MPI_BOTTOM, 0, MPI_INT, dest, 13,
100 MPI_BOTTOM, 0, MPI_INT, dest, 13,
101 MPI_COMM_WORLD, &status );
102 MPI_Wait( &r1, &status );
105 int rval = Summarize_Test_Results(); /* Returns number of tests;
112 } else if (rank == dest) {
114 MPI_Send( buffer, 0, MPI_INT, src, 0, MPI_COMM_WORLD );
115 MPI_Recv( buffer, 0, MPI_INT, src, 0, MPI_COMM_WORLD, &status );
116 MPI_Recv( buffer, act_size, MPI_INT, src, 2, MPI_COMM_WORLD, &status );
117 MPI_Sendrecv( MPI_BOTTOM, 0, MPI_INT, src, 13,
118 MPI_BOTTOM, 0, MPI_INT, src, 13,
119 MPI_COMM_WORLD, &status );
120 MPI_Recv( buffer, act_size, MPI_INT, src, 1, MPI_COMM_WORLD, &status );
126 fprintf(stderr, "*** This program uses exactly 2 processes! ***\n");
127 MPI_Abort( MPI_COMM_WORLD, 1 );