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 gather test";
16 int main( int argc, char *argv[] )
20 int leftGroup, i, count, rank, rsize, size;
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) continue;
30 MPI_Comm_rank( comm, &rank );
31 MPI_Comm_remote_size( comm, &rsize );
32 MPI_Comm_size( comm, &size );
33 /* To improve reporting of problems about operations, we
34 change the error handler to errors return */
35 MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
36 for (count = 1; count < 65000; count = 2 * count) {
38 buf = (int *)malloc( count * rsize * sizeof(int) );
39 for (i=0; i<count*rsize; i++) buf[i] = -1;
41 err = MPI_Gather( NULL, 0, datatype,
43 (rank == 0) ? MPI_ROOT : MPI_PROC_NULL,
47 MTestPrintError( err );
49 /* Test that no other process in this group received the
52 for (i=0; i<count; i++) {
59 /* Check for the correct data */
60 for (i=0; i<count*rsize; i++) {
68 /* In the right group */
69 buf = (int *)malloc( count * sizeof(int) );
70 for (i=0; i<count; i++) buf[i] = rank * count + i;
71 err = MPI_Gather( buf, count, datatype,
72 NULL, 0, datatype, 0, comm );
75 MTestPrintError( err );
80 MTestFreeComm( &comm );
83 MTest_Finalize( errs );