2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) */
4 /* type-no-error-exhaustive.c -- use all group constructors correctly */
8 "$Header: /usr/gapps/asde/cvs-vault/umpire/tests/group-no-error-exhaustive.c,v 1.2 2002/07/30 21:34:42 bronis Exp $";
16 #define GROUP_CONSTRUCTOR_COUNT 8
17 #define INTERCOMM_CREATE_TAG 666
21 main (int argc, char **argv)
25 int comm = MPI_COMM_WORLD;
26 char processor_name[128];
29 int ranks[2], ranges[1][3];
30 MPI_Group newgroup[GROUP_CONSTRUCTOR_COUNT];
31 MPI_Group newgroup2[GROUP_CONSTRUCTOR_COUNT];
33 MPI_Comm intercomm = MPI_COMM_NULL;
36 MPI_Init (&argc, &argv);
37 MPI_Comm_size (comm, &nprocs);
38 MPI_Comm_rank (comm, &rank);
39 MPI_Get_processor_name (processor_name, &namelen);
40 printf ("(%d) is alive on %s\n", rank, processor_name);
53 printf ("requires at least 3 tasks\n");
56 /* create the groups */
57 if (GROUP_CONSTRUCTOR_COUNT > 0)
58 MPI_Comm_group (MPI_COMM_WORLD, &newgroup[0]);
60 if (GROUP_CONSTRUCTOR_COUNT > 1)
61 MPI_Group_incl (newgroup[0], 2, ranks, &newgroup[1]);
63 if (GROUP_CONSTRUCTOR_COUNT > 2)
64 MPI_Group_excl (newgroup[0], 2, ranks, &newgroup[2]);
66 if (GROUP_CONSTRUCTOR_COUNT > 3)
67 MPI_Group_range_incl (newgroup[0], 1, ranges, &newgroup[3]);
69 if (GROUP_CONSTRUCTOR_COUNT > 4)
70 MPI_Group_range_excl (newgroup[0], 1, ranges, &newgroup[4]);
72 if (GROUP_CONSTRUCTOR_COUNT > 5)
73 MPI_Group_union (newgroup[1], newgroup[3], &newgroup[5]);
75 if (GROUP_CONSTRUCTOR_COUNT > 6)
76 MPI_Group_intersection (newgroup[5], newgroup[2], &newgroup[6]);
78 if (GROUP_CONSTRUCTOR_COUNT > 7)
79 MPI_Group_difference (newgroup[5], newgroup[2], &newgroup[7]);
81 if (GROUP_CONSTRUCTOR_COUNT > 8) {
82 /* need lots of stuff for this constructor... */
83 MPI_Comm_split (MPI_COMM_WORLD, rank % 3, nprocs - rank, &temp);
86 MPI_Intercomm_create (temp, 0, MPI_COMM_WORLD,
87 (((nprocs % 3) == 2) && ((rank % 3) == 2)) ?
88 nprocs - 1 : nprocs - (rank % 3) - (nprocs % 3),
89 INTERCOMM_CREATE_TAG, &intercomm);
91 MPI_Comm_remote_group (intercomm, &newgroup[8]);
93 MPI_Comm_free (&intercomm);
96 MPI_Comm_group (temp, &newgroup[8]);
99 MPI_Comm_free (&temp);
102 for (i = 0; i < GROUP_CONSTRUCTOR_COUNT; i++)
103 MPI_Group_free (&newgroup[i]);
107 /* create the groups again and free with an alias... */
108 if (GROUP_CONSTRUCTOR_COUNT > 0)
109 MPI_Comm_group (MPI_COMM_WORLD, &newgroup[0]);
111 if (GROUP_CONSTRUCTOR_COUNT > 1)
112 MPI_Group_incl (newgroup[0], 2, ranks, &newgroup[1]);
114 if (GROUP_CONSTRUCTOR_COUNT > 2)
115 MPI_Group_excl (newgroup[0], 2, ranks, &newgroup[2]);
117 if (GROUP_CONSTRUCTOR_COUNT > 3)
118 MPI_Group_range_incl (newgroup[0], 1, ranges, &newgroup[3]);
120 if (GROUP_CONSTRUCTOR_COUNT > 4)
121 MPI_Group_range_excl (newgroup[0], 1, ranges, &newgroup[4]);
123 if (GROUP_CONSTRUCTOR_COUNT > 5)
124 MPI_Group_union (newgroup[1], newgroup[3], &newgroup[5]);
126 if (GROUP_CONSTRUCTOR_COUNT > 6)
127 MPI_Group_intersection (newgroup[5], newgroup[2], &newgroup[6]);
129 if (GROUP_CONSTRUCTOR_COUNT > 7)
130 MPI_Group_difference (newgroup[5], newgroup[2], &newgroup[7]);
132 if (GROUP_CONSTRUCTOR_COUNT > 8) {
133 /* need lots of stuff for this constructor... */
134 MPI_Comm_split (MPI_COMM_WORLD, rank % 3, nprocs - rank, &temp);
137 MPI_Intercomm_create (temp, 0, MPI_COMM_WORLD,
138 (((nprocs % 3) == 2) && ((rank % 3) == 2)) ?
139 nprocs - 1 : nprocs - (rank % 3) - (nprocs % 3),
140 INTERCOMM_CREATE_TAG, &intercomm);
142 MPI_Comm_remote_group (intercomm, &newgroup[8]);
144 MPI_Comm_free (&intercomm);
147 MPI_Comm_group (temp, &newgroup[8]);
150 MPI_Comm_free (&temp);
153 for (i = 0; i < GROUP_CONSTRUCTOR_COUNT; i++) {
154 newgroup2[i] = newgroup[i];
155 MPI_Group_free (&newgroup2[i]);
161 printf ("(%d) Finished normally\n", rank);