1 /*
2 * Copyright (C) by Argonne National Laboratory
3 * See COPYRIGHT in top-level directory
4 */
5
6 /* regression test for ticket #1574
7 *
8 * Based on test code from N. Radclif @ Cray. */
9
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <mpi.h>
13 #include "mpitest.h"
14
main(int argc,char ** argv)15 int main(int argc, char **argv)
16 {
17 MPI_Comm c0, c1, ic;
18 MPI_Group g0, g1, gworld;
19 int a, b, c, d;
20 int rank, size, remote_leader, tag;
21 int ranks[2];
22 int errs = 0;
23
24 tag = 5;
25 c0 = c1 = ic = MPI_COMM_NULL;
26 g0 = g1 = gworld = MPI_GROUP_NULL;
27
28 MTest_Init(&argc, &argv);
29
30 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
31 MPI_Comm_size(MPI_COMM_WORLD, &size);
32
33 if (size < 33) {
34 printf("ERROR: this test requires at least 33 processes\n");
35 MPI_Abort(MPI_COMM_WORLD, 1);
36 return 1;
37 }
38
39 /* group of c0
40 * NOTE: a>=32 is essential for exercising the loop bounds bug from tt#1574 */
41 a = 32;
42 b = 24;
43
44 /* group of c1 */
45 c = 25;
46 d = 26;
47
48 MPI_Comm_group(MPI_COMM_WORLD, &gworld);
49
50 ranks[0] = a;
51 ranks[1] = b;
52 MPI_Group_incl(gworld, 2, ranks, &g0);
53 MPI_Comm_create(MPI_COMM_WORLD, g0, &c0);
54
55 ranks[0] = c;
56 ranks[1] = d;
57 MPI_Group_incl(gworld, 2, ranks, &g1);
58 MPI_Comm_create(MPI_COMM_WORLD, g1, &c1);
59
60 if (rank == a || rank == b) {
61 remote_leader = c;
62 MPI_Intercomm_create(c0, 0, MPI_COMM_WORLD, remote_leader, tag, &ic);
63 } else if (rank == c || rank == d) {
64 remote_leader = a;
65 MPI_Intercomm_create(c1, 0, MPI_COMM_WORLD, remote_leader, tag, &ic);
66 }
67
68 MPI_Group_free(&g0);
69 MPI_Group_free(&g1);
70 MPI_Group_free(&gworld);
71
72 if (c0 != MPI_COMM_NULL)
73 MPI_Comm_free(&c0);
74 if (c1 != MPI_COMM_NULL)
75 MPI_Comm_free(&c1);
76 if (ic != MPI_COMM_NULL)
77 MPI_Comm_free(&ic);
78
79 MTest_Finalize(errs);
80
81 return MTestReturnValue(errs);
82 }
83