2 * Program to test that the "synchronous send" semantics
3 * of point to point communications in MPI is (probably) satisfied.
4 * Two messages are send in one order; the destination uses MPI_Iprobe
5 * to look for the SECOND message before doing a receive on the first.
6 * To give a finite-termination, a fixed amount of time is used for
9 * This program has been patterned off of "overtake.c"
20 /* Amount of time in seconds to wait for the receipt of the second Ssend
26 /* Prototypes for picky compilers */
27 void Generate_Data ( int *, int );
29 void Generate_Data( int *buffer, int buff_size)
33 for (i = 0; i < buff_size; i++)
37 int main( int argc, char **argv)
39 int rank; /* My Rank (0 or 1) */
41 int flag, np, rval, i;
44 char *Current_Test = NULL;
45 MPI_Status status, status1, status2;
49 MPI_Init(&argc, &argv);
50 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
51 MPI_Comm_size( MPI_COMM_WORLD, &np );
53 fprintf(stderr, "*** This program uses exactly 2 processes! ***\n");
54 MPI_Abort( MPI_COMM_WORLD, 1 );
61 /* for (i = 0; i < 4; i++ ) { */
62 for (i = 1; i < 2; i++ ) {
65 Generate_Data(buffer, SIZE);
66 MPI_Recv( buffer, 0, MPI_INT, dest, 0, MPI_COMM_WORLD, &status );
67 MPI_Send( buffer, 0, MPI_INT, dest, 0, MPI_COMM_WORLD );
68 MPI_Ssend( buffer, act_size, MPI_INT, dest, 1, MPI_COMM_WORLD );
69 MPI_Ssend( buffer, act_size, MPI_INT, dest, 2, MPI_COMM_WORLD );
71 } else if (rank == dest) {
72 Test_Init("ssendtest", rank);
74 Current_Test = (char*)"Ssend Test (Synchronous Send -> Normal Recieve)";
75 MPI_Send( buffer, 0, MPI_INT, src, 0, MPI_COMM_WORLD );
76 MPI_Recv( buffer, 0, MPI_INT, src, 0, MPI_COMM_WORLD, &status );
79 /* This test depends on a working wtime. Make a simple check */
80 if (t0 == 0 && MPI_Wtime() == 0) {
81 int loopcount = 1000000;
82 /* This test is too severe (systems with fast
83 processors and large MPI_Wtick values can
84 fail. Try harder to test MPI_Wtime */
85 while (loopcount-- && MPI_Wtime() == 0) ;
88 "MPI_WTIME is returning 0; a working value is needed\n\
90 Test_Failed(Current_Test);
91 MPI_Abort( MPI_COMM_WORLD, 1 );
95 while (MPI_Wtime() - t0 < MAX_TIME) {
96 MPI_Iprobe( src, 2, MPI_COMM_WORLD, &flag, &status );
98 Test_Failed(Current_Test);
103 Test_Passed(Current_Test);
104 MPI_Recv( buffer, act_size, MPI_INT, src, 1, MPI_COMM_WORLD,
106 MPI_Recv( buffer, act_size, MPI_INT, src, 2, MPI_COMM_WORLD,
109 MPI_Get_count( &status1, MPI_INT, &count1 );
110 MPI_Get_count( &status2, MPI_INT, &count2 );
111 if (count1 != act_size) {
113 "(1) Wrong count from recv of ssend: got %d (%d)\n",
116 if (status1.MPI_TAG != 1) {
117 fprintf( stdout, "(1) Wrong tag from recv of ssend: got %d\n",
120 if (count2 != act_size) {
122 "(2) Wrong count from recv of ssend: got %d (%d)\n",
125 if (status2.MPI_TAG != 2) {
126 fprintf( stdout, "(2) Wrong tag from recv of ssend: got %d\n",
136 rval = Summarize_Test_Results(); /* Returns number of tests;