1 /****************************************************************************
3 MESSAGE PASSING INTERFACE TEST CASE SUITE
5 Copyright IBM Corp. 1995
7 IBM Corp. hereby grants a non-exclusive license to use, copy, modify, and
8 distribute this software for any purpose and without fee provided that the
9 above copyright notice and the following paragraphs appear in all copies.
11 IBM Corp. makes no representation that the test cases comprising this
12 suite are correct or are an accurate representation of any standard.
14 In no event shall IBM be liable to any party for direct, indirect, special
15 incidental, or consequential damage arising out of the use of this software
16 even if IBM Corp. has been advised of the possibility of such damage.
18 IBM CORP. SPECIFICALLY DISCLAIMS ANY WARRANTIES INCLUDING, BUT NOT LIMITED
19 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS AND IBM
21 CORP. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
22 ENHANCEMENTS, OR MODIFICATIONS.
24 ****************************************************************************
26 These test cases reflect an interpretation of the MPI Standard. They are
27 are, in most cases, unit tests of specific MPI behaviors. If a user of any
28 test case from this set believes that the MPI Standard requires behavior
29 different than that implied by the test case we would appreciate feedback.
31 Comments may be sent to:
35 ****************************************************************************
40 int main(int argc, char *argv[])
42 int me, tasks, data, flag;
49 MPI_Init(&argc,&argv);
50 MPI_Comm_rank(MPI_COMM_WORLD,&me);
51 MPI_Comm_size(MPI_COMM_WORLD,&tasks);
54 printf( "Cancel test requires at least 2 processes\n" );
55 MPI_Abort( MPI_COMM_WORLD, 1 );
58 { int data[100000]; if (me == 0)
60 MPI_Irecv(data, 1, MPI_INT, 1, 1, MPI_COMM_WORLD,&request);
62 MPI_Wait(&request,&status);
63 MPI_Test_cancelled(&status,&flag);
66 printf("task %d ERROR: Receive request not cancelled!\n", me);
69 MPI_Issend(data, 100000, MPI_INT, 1, 1, MPI_COMM_WORLD,&request);
73 MPI_Test(&request,&flag,&status);
77 MPI_Test_cancelled(&status,&flag);
80 printf("task %d ERROR: Send request not cancelled! (1)\n", me);
87 MPI_Isend(&data, 1, MPI_INT, 1, 1, MPI_COMM_WORLD,&request);
89 MPI_Wait(&request,&status);
90 MPI_Test_cancelled(&status,&flag);
93 printf("task %d ERROR: Send request not cancelled! (2)\n", me);
95 MPI_Barrier(MPI_COMM_WORLD);
96 status.MPI_TAG=MPI_SUCCESS;
98 MPI_Send(&data, 1, MPI_INT, 1, 5, MPI_COMM_WORLD);
101 MPI_Isend(&data, 1, MPI_INT, 1, 1, MPI_COMM_WORLD,&request);
102 MPI_Barrier(MPI_COMM_WORLD);
103 MPI_Cancel(&request);
104 MPI_Wait(&request,&status);
105 MPI_Test_cancelled(&status,&flag);
108 printf("task %d ERROR: Send request cancelled!\n", me);
113 MPI_Barrier(MPI_COMM_WORLD);
115 MPI_Recv(&data, 1, MPI_INT, 0, 1, MPI_COMM_WORLD,&status);
118 printf("task %d ERROR: Send request not cancelled!\n", me);
121 MPI_Recv(&data, 1, MPI_INT, 0, 5, MPI_COMM_WORLD,&status);
124 printf("task %d ERROR: Send request not cancelled!\n", me);
126 MPI_Barrier(MPI_COMM_WORLD);
129 /* These are needed when the size of MPI_COMM_WORLD > 2 */
130 MPI_Barrier( MPI_COMM_WORLD );
131 MPI_Barrier( MPI_COMM_WORLD );
135 MPI_Reduce( &errs, &toterrs, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD );
138 printf( "Test failed with %d errors.\n", errs );
140 if (me == 0 && toterrs == 0) {
141 printf( " No Errors\n" );