1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2015 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
7 /* This test tests overlapping of Comm_idups with other comm. generations calls */
17 int main(int argc, char **argv)
25 MPI_Group world_group, high_group, even_group;
26 MPI_Comm local_comm, inter_comm, test_comm, outcomm;
27 MPI_Comm idupcomms[NUM_IDUPS];
28 MPI_Request reqs[NUM_IDUPS];
30 MTest_Init(&argc, &argv);
31 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
32 MPI_Comm_size(MPI_COMM_WORLD, &size);
33 MPI_Comm_group(MPI_COMM_WORLD, &world_group);
36 printf("this test requires at least 2 processes\n");
37 MPI_Abort(MPI_COMM_WORLD, 1);
40 /* Idup MPI_COMM_WORLD multiple times */
41 for (i = 0; i < NUM_IDUPS; i++) {
42 MPI_Comm_idup(MPI_COMM_WORLD, &idupcomms[i], &reqs[i]);
45 /* Overlap pending idups with various comm generation functions */
48 MPI_Comm_dup(MPI_COMM_WORLD, &outcomm);
49 errs += MTestTestComm(outcomm);
50 MTestFreeComm(&outcomm);
53 MPI_Comm_split(MPI_COMM_WORLD, rank % 2, size - rank, &outcomm);
54 errs += MTestTestComm(outcomm);
55 MTestFreeComm(&outcomm);
57 /* Comm_create, high half of MPI_COMM_WORLD */
58 ranges[0][0] = size / 2;
59 ranges[0][1] = size - 1;
61 MPI_Group_range_incl(world_group, 1, ranges, &high_group);
62 MPI_Comm_create(MPI_COMM_WORLD, high_group, &outcomm);
63 MPI_Group_free(&high_group);
64 errs += MTestTestComm(outcomm);
65 MTestFreeComm(&outcomm);
67 /* Comm_create_group, even ranks of MPI_COMM_WORLD */
68 /* exclude the odd ranks */
69 excl = malloc((size / 2) * sizeof(int));
70 for (i = 0; i < size / 2; i++)
71 excl[i] = (2 * i) + 1;
73 MPI_Group_excl(world_group, size / 2, excl, &even_group);
77 MPI_Comm_create_group(MPI_COMM_WORLD, even_group, 0, &outcomm);
80 outcomm = MPI_COMM_NULL;
82 MPI_Group_free(&even_group);
84 errs += MTestTestComm(outcomm);
85 MTestFreeComm(&outcomm);
87 /* Intercomm_create & Intercomm_merge */
88 MPI_Comm_split(MPI_COMM_WORLD, (rank < size / 2), rank, &local_comm);
93 else if (rank == size / 2) {
99 isLeft = rank < size / 2;
101 MPI_Intercomm_create(local_comm, 0, MPI_COMM_WORLD, rleader, 99, &inter_comm);
102 MPI_Intercomm_merge(inter_comm, isLeft, &outcomm);
103 MPI_Comm_free(&local_comm);
105 errs += MTestTestComm(inter_comm);
106 MTestFreeComm(&inter_comm);
108 errs += MTestTestComm(outcomm);
109 MTestFreeComm(&outcomm);
111 MPI_Waitall(NUM_IDUPS, reqs, MPI_STATUSES_IGNORE);
112 for (i = 0; i < NUM_IDUPS; i++) {
113 errs += MTestTestComm(idupcomms[i]);
114 MPI_Comm_free(&idupcomms[i]);
117 MPI_Group_free(&world_group);
119 MTest_Finalize(errs);