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 40000000
16 #define MAX_COUNT 4000
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) continue;
33 /* Determine the sender and receiver */
34 MPI_Comm_rank( comm, &rank );
35 MPI_Comm_size( comm, &size );
39 /* To improve reporting of problems about operations, we
40 change the error handler to errors return */
41 MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
43 for (count = 1; count < MAX_COUNT; count = count * 2) {
44 while (MTestGetDatatypes( &sendtype, &recvtype, count )) {
46 MPI_Type_size( sendtype.datatype, &nbytes );
48 /* We may want to limit the total message size sent */
49 if (nbytes > MAX_MSG_SIZE) {
50 /* We do not need to free, as we haven't
51 initialized any of the buffers (?) */
54 maxmsg = MAX_COUNT - count;
55 MTestPrintfMsg( 1, "Sending count = %d of sendtype %s of total size %d bytes\n",
56 count, MTestGetDatatypeName( &sendtype ),
58 /* Make sure that everyone has a recv buffer */
59 recvtype.InitBuf( &recvtype );
62 sendtype.InitBuf( &sendtype );
64 for (nmsg=1; nmsg<maxmsg; nmsg++) {
65 err = MPI_Send( sendtype.buf, sendtype.count,
66 sendtype.datatype, dest, 0, comm);
70 MTestPrintError( err );
75 else if (rank == dest) {
76 for (nmsg=1; nmsg<maxmsg; nmsg++) {
77 err = MPI_Recv( recvtype.buf, recvtype.count,
78 recvtype.datatype, source, 0,
79 comm, MPI_STATUS_IGNORE);
83 MTestPrintError( err );
87 err = MTestCheckRecv( 0, &recvtype );
90 printf( "Data in target buffer did not match for destination datatype %s and source datatype %s, count = %d, message iteration %d of %d\n",
91 MTestGetDatatypeName( &recvtype ),
92 MTestGetDatatypeName( &sendtype ),
93 count, nmsg, maxmsg );
94 recvtype.printErrors = 1;
95 (void)MTestCheckRecv( 0, &recvtype );
101 MTestFreeDatatype( &recvtype );
102 MTestFreeDatatype( &sendtype );
105 MTestFreeComm( &comm );
108 MTest_Finalize( errs );