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[] = "Test of broadcast with various roots and datatypes";
15 int main( int argc, char *argv[] )
19 int minsize = 2, count;
21 MTestDatatype sendtype, recvtype;
23 MTest_Init( &argc, &argv );
25 /* The following illustrates the use of the routines to
26 run through a selection of communicators and datatypes.
27 Use subsets of these for tests that do not involve combinations
28 of communicators, datatypes, and counts of datatypes */
29 while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
30 if (comm == MPI_COMM_NULL) continue;
32 /* Determine the sender and receiver */
33 MPI_Comm_rank( comm, &rank );
34 MPI_Comm_size( comm, &size );
36 /* To improve reporting of problems about operations, we
37 change the error handler to errors return */
38 MPI_Errhandler_set( comm, MPI_ERRORS_RETURN );
40 /* The max value of count must be very large to ensure that we
41 reach the long message algorithms */
42 for (count = 1; count < 2800; count = count * 4) {
43 while (MTestGetDatatypes( &sendtype, &recvtype, count )) {
44 for (root=0; root<size; root++) {
46 sendtype.InitBuf( &sendtype );
47 err = MPI_Bcast( sendtype.buf, sendtype.count,
48 sendtype.datatype, root, comm );
51 MTestPrintError( err );
55 recvtype.InitBuf( &recvtype );
56 err = MPI_Bcast( recvtype.buf, recvtype.count,
57 recvtype.datatype, root, comm );
60 fprintf( stderr, "Error with communicator %s and datatype %s\n",
61 MTestGetIntracommName(),
62 MTestGetDatatypeName( &recvtype ) );
63 MTestPrintError( err );
65 err = MTestCheckRecv( 0, &recvtype );
71 MTestFreeDatatype( &recvtype );
72 MTestFreeDatatype( &sendtype );
75 MTestFreeComm( &comm );
78 MTest_Finalize( errs );