1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2004 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
13 static char MTEST_Descrip[] = "Test intercomm merge, including the choice of the high value";
16 int main( int argc, char *argv[] )
19 int rank, size, rsize;
23 MPI_Comm comm, comm1, comm2, comm3, comm4;
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 (MTestGetIntercomm( &comm, &isLeft, minsize )) {
32 if (comm == MPI_COMM_NULL) continue;
33 /* Determine the sender and receiver */
34 MPI_Comm_rank( comm, &rank );
35 MPI_Comm_remote_size( comm, &rsize );
36 MPI_Comm_size( comm, &size );
38 /* Try building intercomms */
39 MPI_Intercomm_merge( comm, isLeft, &comm1 );
40 /* Check the size and ranks */
41 MPI_Comm_size( comm1, &nsize );
42 MPI_Comm_rank( comm1, &nrank );
43 if (nsize != size + rsize) {
45 printf( "(1) Comm size is %d but should be %d\n", nsize,
48 /* The left processes should be high */
49 if (nrank != rsize + rank) {
51 printf( "(1) rank for high process is %d should be %d\n",
52 nrank, rsize + rank );
56 /* The right processes should be low */
59 printf( "(1) rank for low process is %d should be %d\n",
65 MPI_Intercomm_merge( comm, !isLeft, &comm2 );
66 /* Check the size and ranks */
67 MPI_Comm_size( comm1, &nsize );
68 MPI_Comm_rank( comm1, &nrank );
69 if (nsize != size + rsize) {
71 printf( "(2) Comm size is %d but should be %d\n", nsize,
74 /* The right processes should be high */
75 if (nrank != rsize + rank) {
77 printf( "(2) rank for high process is %d should be %d\n",
78 nrank, rsize + rank );
82 /* The left processes should be low */
85 printf( "(2) rank for low process is %d should be %d\n",
92 MPI_Intercomm_merge( comm, 0, &comm3 );
94 MPI_Intercomm_merge( comm, 1, &comm4 );
96 MPI_Comm_free( &comm1 );
97 MPI_Comm_free( &comm2 );
98 MPI_Comm_free( &comm3 );
99 MPI_Comm_free( &comm4 );
101 MTestFreeComm( &comm );
104 MTest_Finalize( errs );