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