1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2012 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
8 /* regression test for ticket #1574
10 * Based on test code from N. Radclif @ Cray. */
16 int main(int argc, char **argv)
19 MPI_Group g0, g1, gworld;
21 int rank, size, remote_leader, tag;
26 c0 = c1 = ic = MPI_COMM_NULL;
27 g0 = g1 = gworld = MPI_GROUP_NULL;
29 MPI_Init(&argc, &argv);
31 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
32 MPI_Comm_size(MPI_COMM_WORLD, &size);
35 printf("ERROR: this test requires at least 33 processes\n");
36 MPI_Abort(MPI_COMM_WORLD, 1);
41 * NOTE: a>=32 is essential for exercising the loop bounds bug from tt#1574 */
49 MPI_Comm_group(MPI_COMM_WORLD, &gworld);
53 MPI_Group_incl(gworld, 2, ranks, &g0);
54 MPI_Comm_create(MPI_COMM_WORLD, g0, &c0);
58 MPI_Group_incl(gworld, 2, ranks, &g1);
59 MPI_Comm_create(MPI_COMM_WORLD, g1, &c1);
61 if (rank == a || rank == b) {
63 MPI_Intercomm_create(c0, 0, MPI_COMM_WORLD, remote_leader, tag, &ic);
65 else if (rank == c || rank == d) {
67 MPI_Intercomm_create(c1, 0, MPI_COMM_WORLD, remote_leader, tag, &ic);
72 MPI_Group_free(&gworld);
74 if (c0 != MPI_COMM_NULL)
76 if (c1 != MPI_COMM_NULL)
78 if (ic != MPI_COMM_NULL)
82 MPI_Reduce((rank == 0 ? MPI_IN_PLACE : &errs), &errs, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
85 printf("found %d errors\n", errs);
88 printf(" No errors\n");