1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2003 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
12 static char MTEST_Descrip[] = "Send flood test";
15 #define MAX_MSG_SIZE 40000
17 int main(int argc, char *argv[])
20 int rank, size, source, dest;
21 int minsize = 2, count, nmsg, maxmsg;
23 MTestDatatype sendtype, recvtype;
25 MTest_Init(&argc, &argv);
27 /* The following illustrates the use of the routines to
28 * run through a selection of communicators and datatypes.
29 * Use subsets of these for tests that do not involve combinations
30 * of communicators, datatypes, and counts of datatypes */
31 while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
32 if (comm == MPI_COMM_NULL)
34 /* Determine the sender and receiver */
35 MPI_Comm_rank(comm, &rank);
36 MPI_Comm_size(comm, &size);
40 /* To improve reporting of problems about operations, we
41 * change the error handler to errors return */
42 MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
44 for (count = 1; count < MAX_COUNT; count = count * 2) {
46 /* To shorten test time, only run the default version of datatype tests
47 * for comm world and run the minimum version for other communicators. */
48 if (comm != MPI_COMM_WORLD) {
49 MTestInitMinDatatypes();
52 while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
54 MPI_Type_size(sendtype.datatype, &nbytes);
56 /* We may want to limit the total message size sent */
57 if (nbytes > MAX_MSG_SIZE) {
58 /* We do not need to free, as we haven't
59 * initialized any of the buffers (?) */
62 maxmsg = MAX_COUNT - count;
63 MTestPrintfMsg(1, "Sending count = %d of sendtype %s of total size %d bytes\n",
64 count, MTestGetDatatypeName(&sendtype), nbytes * count);
65 /* Make sure that everyone has a recv buffer */
66 recvtype.InitBuf(&recvtype);
69 sendtype.InitBuf(&sendtype);
71 for (nmsg = 1; nmsg < maxmsg; nmsg++) {
72 err = MPI_Send(sendtype.buf, sendtype.count,
73 sendtype.datatype, dest, 0, comm);
82 else if (rank == dest) {
83 for (nmsg = 1; nmsg < maxmsg; nmsg++) {
84 err = MPI_Recv(recvtype.buf, recvtype.count,
85 recvtype.datatype, source, 0, comm, MPI_STATUS_IGNORE);
93 err = MTestCheckRecv(0, &recvtype);
97 ("Data in target buffer did not match for destination datatype %s and source datatype %s, count = %d, message iteration %d of %d\n",
98 MTestGetDatatypeName(&recvtype),
99 MTestGetDatatypeName(&sendtype), count, nmsg, maxmsg);
100 recvtype.printErrors = 1;
101 (void) MTestCheckRecv(0, &recvtype);
107 MTestFreeDatatype(&recvtype);
108 MTestFreeDatatype(&sendtype);
111 MTestFreeComm(&comm);
114 MTest_Finalize(errs);