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.
13 static char MTEST_Descrip[] = "Simple intercomm broadcast test";
16 int main( int argc, char *argv[] )
20 int leftGroup, i, count, rank;
22 MPI_Datatype datatype;
24 MTest_Init( &argc, &argv );
27 /* Get an intercommunicator */
28 while (MTestGetIntercomm( &comm, &leftGroup, 4 )) {
29 if (comm == MPI_COMM_NULL)
32 MPI_Comm_rank( comm, &rank );
34 /* To improve reporting of problems about operations, we
35 change the error handler to errors return */
36 MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
38 for (count = 1; count < 65000; count = 2 * count) {
39 buf = (int *)malloc( count * sizeof(int) );
42 for (i=0; i<count; i++) buf[i] = i;
45 for (i=0; i<count; i++) buf[i] = -1;
47 err = MPI_Bcast( buf, count, datatype,
48 (rank == 0) ? MPI_ROOT : MPI_PROC_NULL,
52 MTestPrintError( err );
54 /* Test that no other process in this group received the
57 for (i=0; i<count; i++) {
65 /* In the right group */
66 for (i=0; i<count; i++) buf[i] = -1;
67 err = MPI_Bcast( buf, count, datatype, 0, comm );
70 MTestPrintError( err );
72 /* Check that we have received the correct data */
73 for (i=0; i<count; i++) {
81 MTestFreeComm( &comm );
84 MTest_Finalize( errs );