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)
33 #if defined BCAST_COMM_WORLD_ONLY
34 if (comm != MPI_COMM_WORLD) {
38 #endif /* BCAST_COMM_WORLD_ONLY */
40 /* Determine the sender and receiver */
41 MPI_Comm_rank(comm, &rank);
42 MPI_Comm_size(comm, &size);
44 /* To improve reporting of problems about operations, we
45 * change the error handler to errors return */
46 MPI_Errhandler_set(comm, MPI_ERRORS_RETURN);
48 MTEST_DATATYPE_FOR_EACH_COUNT(count) {
50 /* To shorten test time, only run the default version of datatype tests
51 * for comm world and run the minimum version for other communicators. */
52 #if defined BCAST_MIN_DATATYPES_ONLY
53 MTestInitMinDatatypes();
54 #endif /* BCAST_MIN_DATATYPES_ONLY */
56 while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
57 for (root = 0; root < size; root+=2) {
59 sendtype.InitBuf(&sendtype);
60 err = MPI_Bcast(sendtype.buf, sendtype.count,
61 sendtype.datatype, root, comm);
68 recvtype.InitBuf(&recvtype);
69 err = MPI_Bcast(recvtype.buf, recvtype.count,
70 recvtype.datatype, root, comm);
73 fprintf(stderr, "Error with communicator %s and datatype %s\n",
74 MTestGetIntracommName(), MTestGetDatatypeName(&recvtype));
77 err = MTestCheckRecv(0, &recvtype);
83 MTestFreeDatatype(&recvtype);
84 MTestFreeDatatype(&sendtype);