1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2006 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
12 static char MTEST_Descrip[] = "Test of sending to self (with a preposted receive)";
15 int main( int argc, char *argv[] )
22 MTestDatatype sendtype, recvtype;
24 MTest_Init( &argc, &argv );
26 comm = MPI_COMM_WORLD;
27 MPI_Comm_rank( comm, &rank );
28 MPI_Comm_size( comm, &size );
30 /* To improve reporting of problems about operations, we
31 change the error handler to errors return */
32 MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
34 for (count = 1; count < 65000; count = count * 2) {
35 while (MTestGetDatatypes( &sendtype, &recvtype, count )) {
37 sendtype.InitBuf( &sendtype );
38 recvtype.InitBuf( &recvtype );
40 err = MPI_Irecv( recvtype.buf, recvtype.count,
41 recvtype.datatype, rank, 0, comm, &req );
45 MTestPrintError( err );
49 err = MPI_Send( sendtype.buf, sendtype.count,
50 sendtype.datatype, rank, 0, comm);
54 MTestPrintError( err );
57 err = MPI_Wait( &req, MPI_STATUS_IGNORE );
58 err = MTestCheckRecv( 0, &recvtype );
61 printf( "Data in target buffer did not match for destination datatype %s and source datatype %s, count = %d\n",
62 MTestGetDatatypeName( &recvtype ),
63 MTestGetDatatypeName( &sendtype ),
65 recvtype.printErrors = 1;
66 (void)MTestCheckRecv( 0, &recvtype );
71 err = MPI_Irecv( recvtype.buf, recvtype.count,
72 recvtype.datatype, rank, 0, comm, &req );
76 MTestPrintError( err );
80 err = MPI_Ssend( sendtype.buf, sendtype.count,
81 sendtype.datatype, rank, 0, comm);
85 MTestPrintError( err );
88 err = MPI_Wait( &req, MPI_STATUS_IGNORE );
89 err = MTestCheckRecv( 0, &recvtype );
92 printf( "Data in target buffer did not match for destination datatype %s and source datatype %s, count = %d\n",
93 MTestGetDatatypeName( &recvtype ),
94 MTestGetDatatypeName( &sendtype ),
96 recvtype.printErrors = 1;
97 (void)MTestCheckRecv( 0, &recvtype );
102 err = MPI_Irecv( recvtype.buf, recvtype.count,
103 recvtype.datatype, rank, 0, comm, &req );
107 MTestPrintError( err );
111 err = MPI_Rsend( sendtype.buf, sendtype.count,
112 sendtype.datatype, rank, 0, comm);
116 MTestPrintError( err );
119 err = MPI_Wait( &req, MPI_STATUS_IGNORE );
120 err = MTestCheckRecv( 0, &recvtype );
123 printf( "Data in target buffer did not match for destination datatype %s and source datatype %s, count = %d\n",
124 MTestGetDatatypeName( &recvtype ),
125 MTestGetDatatypeName( &sendtype ),
127 recvtype.printErrors = 1;
128 (void)MTestCheckRecv( 0, &recvtype );
133 MTestFreeDatatype( &sendtype );
134 MTestFreeDatatype( &recvtype );
138 MTest_Finalize( errs );