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 MTEST_DATATYPE_FOR_EACH_COUNT(count) {
35 while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
37 sendtype.InitBuf(&sendtype);
38 recvtype.InitBuf(&recvtype);
40 err = MPI_Irecv(recvtype.buf, recvtype.count, recvtype.datatype, rank, 0, comm, &req);
48 err = MPI_Send(sendtype.buf, sendtype.count, sendtype.datatype, rank, 0, comm);
55 err = MPI_Wait(&req, MPI_STATUS_IGNORE);
56 err = MTestCheckRecv(0, &recvtype);
60 ("Data in target buffer did not match for destination datatype %s and source datatype %s, count = %d\n",
61 MTestGetDatatypeName(&recvtype), MTestGetDatatypeName(&sendtype), count);
62 recvtype.printErrors = 1;
63 (void) MTestCheckRecv(0, &recvtype);
68 err = MPI_Irecv(recvtype.buf, recvtype.count, recvtype.datatype, rank, 0, comm, &req);
76 err = MPI_Ssend(sendtype.buf, sendtype.count, sendtype.datatype, rank, 0, comm);
83 err = MPI_Wait(&req, MPI_STATUS_IGNORE);
84 err = MTestCheckRecv(0, &recvtype);
88 ("Data in target buffer did not match for destination datatype %s and source datatype %s, count = %d\n",
89 MTestGetDatatypeName(&recvtype), MTestGetDatatypeName(&sendtype), count);
90 recvtype.printErrors = 1;
91 (void) MTestCheckRecv(0, &recvtype);
96 err = MPI_Irecv(recvtype.buf, recvtype.count, recvtype.datatype, rank, 0, comm, &req);
100 MTestPrintError(err);
104 err = MPI_Rsend(sendtype.buf, sendtype.count, sendtype.datatype, rank, 0, comm);
108 MTestPrintError(err);
111 err = MPI_Wait(&req, MPI_STATUS_IGNORE);
112 err = MTestCheckRecv(0, &recvtype);
116 ("Data in target buffer did not match for destination datatype %s and source datatype %s, count = %d\n",
117 MTestGetDatatypeName(&recvtype), MTestGetDatatypeName(&sendtype), count);
118 recvtype.printErrors = 1;
119 (void) MTestCheckRecv(0, &recvtype);
124 MTestFreeDatatype(&sendtype);
125 MTestFreeDatatype(&recvtype);
129 MTest_Finalize(errs);