From 7842bd614301712801b9f2b4a117824333cd3e16 Mon Sep 17 00:00:00 2001 From: degomme Date: Sat, 11 Feb 2017 14:30:36 +0100 Subject: [PATCH] Update mpich comm tests --- .../smpi/mpich3-test/comm/CMakeLists.txt | 3 +- teshsuite/smpi/mpich3-test/comm/cmfree.c | 146 +++++----- teshsuite/smpi/mpich3-test/comm/cmsplit.c | 46 ++-- teshsuite/smpi/mpich3-test/comm/cmsplit2.c | 10 +- .../smpi/mpich3-test/comm/cmsplit_type.c | 72 ++++- .../smpi/mpich3-test/comm/comm_create_group.c | 7 +- .../mpich3-test/comm/comm_create_group_idup.c | 54 ++++ .../smpi/mpich3-test/comm/comm_group_half.c | 7 +- .../smpi/mpich3-test/comm/comm_group_rand.c | 11 +- teshsuite/smpi/mpich3-test/comm/comm_idup.c | 17 +- .../smpi/mpich3-test/comm/comm_idup_comm.c | 122 +++++++++ .../smpi/mpich3-test/comm/comm_idup_comm2.c | 124 +++++++++ .../mpich3-test/comm/comm_idup_iallreduce.c | 218 +++++++++++++++ .../smpi/mpich3-test/comm/comm_idup_isend.c | 109 ++++++++ .../smpi/mpich3-test/comm/comm_idup_mul.c | 2 +- .../smpi/mpich3-test/comm/comm_idup_nb.c | 184 +++++++++++++ teshsuite/smpi/mpich3-test/comm/comm_info.c | 7 +- teshsuite/smpi/mpich3-test/comm/commcreate1.c | 159 ++++++----- teshsuite/smpi/mpich3-test/comm/commname.c | 54 ++-- teshsuite/smpi/mpich3-test/comm/ctxalloc.c | 64 ++--- teshsuite/smpi/mpich3-test/comm/ctxsplit.c | 115 ++++---- teshsuite/smpi/mpich3-test/comm/dup.c | 88 +++--- .../smpi/mpich3-test/comm/dup_with_info.c | 2 +- teshsuite/smpi/mpich3-test/comm/dupic.c | 138 +++++----- teshsuite/smpi/mpich3-test/comm/ic1.c | 53 ++-- teshsuite/smpi/mpich3-test/comm/ic2.c | 6 +- teshsuite/smpi/mpich3-test/comm/iccreate.c | 255 +++++++----------- teshsuite/smpi/mpich3-test/comm/icgroup.c | 59 ++-- teshsuite/smpi/mpich3-test/comm/icm.c | 147 +++++----- teshsuite/smpi/mpich3-test/comm/icsplit.c | 247 ++++++----------- .../smpi/mpich3-test/comm/probe-intercomm.c | 31 +-- 31 files changed, 1616 insertions(+), 941 deletions(-) create mode 100644 teshsuite/smpi/mpich3-test/comm/comm_create_group_idup.c create mode 100644 teshsuite/smpi/mpich3-test/comm/comm_idup_comm.c create mode 100644 teshsuite/smpi/mpich3-test/comm/comm_idup_comm2.c create mode 100644 teshsuite/smpi/mpich3-test/comm/comm_idup_iallreduce.c create mode 100644 teshsuite/smpi/mpich3-test/comm/comm_idup_isend.c create mode 100644 teshsuite/smpi/mpich3-test/comm/comm_idup_nb.c diff --git a/teshsuite/smpi/mpich3-test/comm/CMakeLists.txt b/teshsuite/smpi/mpich3-test/comm/CMakeLists.txt index 87bcb97ffe..8d7f6043dc 100644 --- a/teshsuite/smpi/mpich3-test/comm/CMakeLists.txt +++ b/teshsuite/smpi/mpich3-test/comm/CMakeLists.txt @@ -25,7 +25,8 @@ endif() foreach(file cmfree cmsplit2 cmsplit cmsplit_type commcreate1 comm_create_group comm_group_half comm_group_rand comm_idup comm_idup_overlap comm_idup_mul comm_info commname ctxalloc ctxsplit dup dupic dup_with_info ic1 ic2 - iccreate icgroup icm icsplit probe-intercomm) + iccreate icgroup icm icsplit probe-intercomm comm_create_group_idup.c comm_idup_comm.c comm_idup_mul.c comm_idup.c comm_idup_iallreduce.c comm_idup_nb.c comm_idup_comm2.c comm_idup_isend.c comm_idup_overlap.c +) set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${file}.c) endforeach() diff --git a/teshsuite/smpi/mpich3-test/comm/cmfree.c b/teshsuite/smpi/mpich3-test/comm/cmfree.c index 2274df8617..304401925d 100644 --- a/teshsuite/smpi/mpich3-test/comm/cmfree.c +++ b/teshsuite/smpi/mpich3-test/comm/cmfree.c @@ -16,104 +16,104 @@ static char MTEST_Descrip[] = "Test that communicators have reference count sema #define NELM 128 #define NCOMM 1020 -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rank, size, source, dest, i; - MPI_Comm comm; - MPI_Comm tmpComm[NCOMM]; - MPI_Status status; - MPI_Request req; - int *buf=0; + MPI_Comm comm; + MPI_Comm tmpComm[NCOMM]; + MPI_Status status; + MPI_Request req; + int *buf = 0; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - MPI_Comm_dup( MPI_COMM_WORLD, &comm ); + MPI_Comm_dup(MPI_COMM_WORLD, &comm); /* This is similar to the datatype test, except that we post - an irecv on a simple data buffer but use a rank-reordered communicator. - In this case, an error in handling the reference count will most - likely cause the program to hang, so this should be run only - if (a) you are confident that the code is correct or (b) - a timeout is set for mpiexec - */ + * an irecv on a simple data buffer but use a rank-reordered communicator. + * In this case, an error in handling the reference count will most + * likely cause the program to hang, so this should be run only + * if (a) you are confident that the code is correct or (b) + * a timeout is set for mpiexec + */ - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); if (size < 2) { - fprintf( stderr, "This test requires at least two processes." ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); + fprintf(stderr, "This test requires at least two processes."); + MPI_Abort(MPI_COMM_WORLD, 1); } - source = 0; - dest = size - 1; + source = 0; + dest = size - 1; if (rank == dest) { - buf = (int *)malloc( NELM * sizeof(int) ); - for (i=0; i #include @@ -15,7 +14,7 @@ int main(int argc, char *argv[]) { int size, rank, i, *excl; MPI_Group world_group, even_group; - MPI_Comm __attribute__((unused)) even_comm; + MPI_Comm even_comm; MPI_Init(&argc, &argv); @@ -25,7 +24,6 @@ int main(int argc, char *argv[]) if (size % 2) { fprintf(stderr, "this program requires a multiple of 2 number of processes\n"); MPI_Abort(MPI_COMM_WORLD, 1); - exit(1); } excl = malloc((size / 2) * sizeof(int)); @@ -40,14 +38,12 @@ int main(int argc, char *argv[]) MPI_Group_excl(world_group, size / 2, excl, &even_group); MPI_Group_free(&world_group); -#if !defined(USE_STRICT_MPI) && defined(MPICH) if (rank % 2 == 0) { /* Even processes create a group for themselves */ MPI_Comm_create_group(MPI_COMM_WORLD, even_group, 0, &even_comm); MPI_Barrier(even_comm); MPI_Comm_free(&even_comm); } -#endif /* USE_STRICT_MPI */ MPI_Group_free(&even_group); MPI_Barrier(MPI_COMM_WORLD); @@ -55,6 +51,7 @@ int main(int argc, char *argv[]) if (rank == 0) printf(" No errors\n"); + free(excl); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/comm/comm_create_group_idup.c b/teshsuite/smpi/mpich3-test/comm/comm_create_group_idup.c new file mode 100644 index 0000000000..91de325ab8 --- /dev/null +++ b/teshsuite/smpi/mpich3-test/comm/comm_create_group_idup.c @@ -0,0 +1,54 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2015 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ +#include "mpi.h" +#include "mpitestconf.h" +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + int size, rank; + MPI_Group world_group; + MPI_Comm group_comm, idup_comm; + MPI_Request req; + MPI_Init(&argc, &argv); + + MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + + if (size % 2) { + fprintf(stderr, "this program requires even number of processes\n"); + MPI_Abort(MPI_COMM_WORLD, 1); + } + + /* Create some groups */ + MPI_Comm_group(MPI_COMM_WORLD, &world_group); + + if (rank % 2 == 0) { + MPI_Comm_create_group(MPI_COMM_WORLD, world_group, 0, &group_comm); + MPI_Comm_idup(MPI_COMM_WORLD, &idup_comm, &req); + } + else { + MPI_Comm_idup(MPI_COMM_WORLD, &idup_comm, &req); + MPI_Comm_create_group(MPI_COMM_WORLD, world_group, 0, &group_comm); + } + + MPI_Wait(&req, MPI_STATUSES_IGNORE); + /*Test new comm with a barrier */ + MPI_Barrier(idup_comm); + MPI_Barrier(group_comm); + + MPI_Group_free(&world_group); + MPI_Comm_free(&idup_comm); + MPI_Comm_free(&group_comm); + if (rank == 0) + printf(" No errors\n"); + + MPI_Finalize(); + return 0; +} diff --git a/teshsuite/smpi/mpich3-test/comm/comm_group_half.c b/teshsuite/smpi/mpich3-test/comm/comm_group_half.c index 8302b58df7..bd98ab31e7 100644 --- a/teshsuite/smpi/mpich3-test/comm/comm_group_half.c +++ b/teshsuite/smpi/mpich3-test/comm/comm_group_half.c @@ -6,15 +6,14 @@ #include #include -/* USE_STRICT_MPI may be defined in mpitestconf.h */ #include "mpitestconf.h" int main(int argc, char **argv) { - int rank, size; + int rank, size, i; MPI_Group full_group, half_group; int range[1][3]; - MPI_Comm __attribute__((unused)) comm; + MPI_Comm comm; MPI_Init(NULL, NULL); MPI_Comm_rank(MPI_COMM_WORLD, &rank); @@ -26,13 +25,11 @@ int main(int argc, char **argv) range[0][2] = 1; MPI_Group_range_incl(full_group, 1, range, &half_group); -#if !defined(USE_STRICT_MPI) && defined(MPICH) if (rank <= size / 2) { MPI_Comm_create_group(MPI_COMM_WORLD, half_group, 0, &comm); MPI_Barrier(comm); MPI_Comm_free(&comm); } -#endif /* USE_STRICT_MPI */ MPI_Group_free(&half_group); MPI_Group_free(&full_group); diff --git a/teshsuite/smpi/mpich3-test/comm/comm_group_rand.c b/teshsuite/smpi/mpich3-test/comm/comm_group_rand.c index 22b7fdc8ca..90d143afd0 100644 --- a/teshsuite/smpi/mpich3-test/comm/comm_group_rand.c +++ b/teshsuite/smpi/mpich3-test/comm/comm_group_rand.c @@ -7,7 +7,6 @@ #include #include #include -/* USE_STRICT_MPI may be defined in mpitestconf.h */ #include "mpitestconf.h" #define LOOPS 100 @@ -17,7 +16,7 @@ int main(int argc, char **argv) int rank, size, i, j, count; MPI_Group full_group, sub_group; int *included, *ranks; - MPI_Comm __attribute__((unused)) comm; + MPI_Comm comm; MPI_Init(NULL, NULL); MPI_Comm_rank(MPI_COMM_WORLD, &rank); @@ -28,11 +27,11 @@ int main(int argc, char **argv) MPI_Comm_group(MPI_COMM_WORLD, &full_group); for (j = 0; j < LOOPS; j++) { - srand(j); /* Deterministic seed */ + srand(j); /* Deterministic seed */ count = 0; for (i = 0; i < size; i++) { - if (rand() % 2) { /* randomly include a rank */ + if (rand() % 2) { /* randomly include a rank */ included[i] = 1; ranks[count++] = i; } @@ -42,13 +41,11 @@ int main(int argc, char **argv) MPI_Group_incl(full_group, count, ranks, &sub_group); -#if !defined(USE_STRICT_MPI) && defined(MPICH) if (included[rank]) { MPI_Comm_create_group(MPI_COMM_WORLD, sub_group, 0, &comm); MPI_Barrier(comm); MPI_Comm_free(&comm); } -#endif /* USE_STRICT_MPI */ MPI_Group_free(&sub_group); } @@ -58,6 +55,8 @@ int main(int argc, char **argv) if (rank == 0) printf(" No Errors\n"); + free(ranks); + free(included); MPI_Finalize(); return 0; diff --git a/teshsuite/smpi/mpich3-test/comm/comm_idup.c b/teshsuite/smpi/mpich3-test/comm/comm_idup.c index 1a56bd6108..7958012b78 100644 --- a/teshsuite/smpi/mpich3-test/comm/comm_idup.c +++ b/teshsuite/smpi/mpich3-test/comm/comm_idup.c @@ -10,13 +10,6 @@ #include "mpi.h" #include "mpitest.h" -/* This is a temporary #ifdef to control whether we test this functionality. A - * configure-test or similar would be better. Eventually the MPI-3 standard - * will be released and this can be gated on a MPI_VERSION check */ -#if !defined(USE_STRICT_MPI) && defined(MPICH) -#define TEST_IDUP 1 -#endif - /* assert-like macro that bumps the err count and emits a message */ #define check(x_) \ do { \ @@ -45,11 +38,8 @@ int main(int argc, char **argv) if (size < 2) { printf("this test requires at least 2 processes\n"); MPI_Abort(MPI_COMM_WORLD, 1); - exit(1); } -#ifdef TEST_IDUP - /* test plan: make rank 0 wait in a blocking recv until all other processes * have posted their MPI_Comm_idup ops, then post last. Should ensure that * idup doesn't block on the non-zero ranks, otherwise we'll get a deadlock. @@ -76,7 +66,7 @@ int main(int argc, char **argv) buf[0] = rank; buf[1] = 0xfeedface; MPI_Allreduce(&buf[0], &buf[1], 1, MPI_INT, MPI_SUM, newcomm); - check(buf[1] == (size * (size-1) / 2)); + check(buf[1] == (size * (size - 1) / 2)); MPI_Comm_free(&newcomm); @@ -119,7 +109,7 @@ int main(int argc, char **argv) buf[0] = lrank; buf[1] = 0xfeedface; MPI_Allreduce(&buf[0], &buf[1], 1, MPI_INT, MPI_SUM, newcomm); - check(buf[1] == (rsize * (rsize-1) / 2)); + check(buf[1] == (rsize * (rsize - 1) / 2)); /* free this down here, not before idup, otherwise it will undo our * stagger_comm work */ @@ -131,8 +121,6 @@ int main(int argc, char **argv) MPI_Comm_free(&newcomm); MPI_Comm_free(&ic); -#endif /* TEST_IDUP */ - MPI_Reduce((rank == 0 ? MPI_IN_PLACE : &errs), &errs, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); if (rank == 0) { if (errs) { @@ -147,4 +135,3 @@ int main(int argc, char **argv) return 0; } - diff --git a/teshsuite/smpi/mpich3-test/comm/comm_idup_comm.c b/teshsuite/smpi/mpich3-test/comm/comm_idup_comm.c new file mode 100644 index 0000000000..0ac260e7f2 --- /dev/null +++ b/teshsuite/smpi/mpich3-test/comm/comm_idup_comm.c @@ -0,0 +1,122 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2015 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ + +/* This test tests overlapping of Comm_idups with other comm. generations calls */ + +#include +#include +#include +#include "mpi.h" +#include "mpitest.h" + +#define NUM_IDUPS 5 + +int main(int argc, char **argv) +{ + int errs = 0; + int i; + int rank, size; + int *excl; + int ranges[1][3]; + int isLeft, rleader; + MPI_Group world_group, high_group, even_group; + MPI_Comm local_comm, inter_comm, test_comm, outcomm; + MPI_Comm idupcomms[NUM_IDUPS]; + MPI_Request reqs[NUM_IDUPS]; + + MTest_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Comm_group(MPI_COMM_WORLD, &world_group); + + if (size < 2) { + printf("this test requires at least 2 processes\n"); + MPI_Abort(MPI_COMM_WORLD, 1); + } + + /* Idup MPI_COMM_WORLD multiple times */ + for (i = 0; i < NUM_IDUPS; i++) { + MPI_Comm_idup(MPI_COMM_WORLD, &idupcomms[i], &reqs[i]); + } + + /* Overlap pending idups with various comm generation functions */ + + /* Comm_dup */ + MPI_Comm_dup(MPI_COMM_WORLD, &outcomm); + errs += MTestTestComm(outcomm); + MTestFreeComm(&outcomm); + + /* Comm_split */ + MPI_Comm_split(MPI_COMM_WORLD, rank % 2, size - rank, &outcomm); + errs += MTestTestComm(outcomm); + MTestFreeComm(&outcomm); + + /* Comm_create, high half of MPI_COMM_WORLD */ + ranges[0][0] = size / 2; + ranges[0][1] = size - 1; + ranges[0][2] = 1; + MPI_Group_range_incl(world_group, 1, ranges, &high_group); + MPI_Comm_create(MPI_COMM_WORLD, high_group, &outcomm); + MPI_Group_free(&high_group); + errs += MTestTestComm(outcomm); + MTestFreeComm(&outcomm); + + /* Comm_create_group, even ranks of MPI_COMM_WORLD */ + /* exclude the odd ranks */ + excl = malloc((size / 2) * sizeof(int)); + for (i = 0; i < size / 2; i++) + excl[i] = (2 * i) + 1; + + MPI_Group_excl(world_group, size / 2, excl, &even_group); + free(excl); + + if (rank % 2 == 0) { + MPI_Comm_create_group(MPI_COMM_WORLD, even_group, 0, &outcomm); + } + else { + outcomm = MPI_COMM_NULL; + } + MPI_Group_free(&even_group); + + errs += MTestTestComm(outcomm); + MTestFreeComm(&outcomm); + + /* Intercomm_create & Intercomm_merge */ + MPI_Comm_split(MPI_COMM_WORLD, (rank < size / 2), rank, &local_comm); + + if (rank == 0) { + rleader = size / 2; + } + else if (rank == size / 2) { + rleader = 0; + } + else { + rleader = -1; + } + isLeft = rank < size / 2; + + MPI_Intercomm_create(local_comm, 0, MPI_COMM_WORLD, rleader, 99, &inter_comm); + MPI_Intercomm_merge(inter_comm, isLeft, &outcomm); + MPI_Comm_free(&local_comm); + + errs += MTestTestComm(inter_comm); + MTestFreeComm(&inter_comm); + + errs += MTestTestComm(outcomm); + MTestFreeComm(&outcomm); + + MPI_Waitall(NUM_IDUPS, reqs, MPI_STATUSES_IGNORE); + for (i = 0; i < NUM_IDUPS; i++) { + errs += MTestTestComm(idupcomms[i]); + MPI_Comm_free(&idupcomms[i]); + } + + MPI_Group_free(&world_group); + + MTest_Finalize(errs); + MPI_Finalize(); + return 0; +} diff --git a/teshsuite/smpi/mpich3-test/comm/comm_idup_comm2.c b/teshsuite/smpi/mpich3-test/comm/comm_idup_comm2.c new file mode 100644 index 0000000000..bf70824bab --- /dev/null +++ b/teshsuite/smpi/mpich3-test/comm/comm_idup_comm2.c @@ -0,0 +1,124 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2015 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ + +/* This test tests overlapping of Comm_idups with other comm. generations calls */ + +#include +#include +#include +#include "mpi.h" +#include "mpitest.h" + +#define NUM_IDUPS 5 + +int main(int argc, char **argv) +{ + int errs = 0; + int i; + int rank, size; + int *excl; + int ranges[1][3]; + int isLeft, rleader; + MPI_Group dup_group, high_group, even_group; + MPI_Comm local_comm, inter_comm, test_comm, outcomm, dupcomm; + MPI_Comm idupcomms[NUM_IDUPS]; + MPI_Request reqs[NUM_IDUPS]; + + MTest_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Comm_dup(MPI_COMM_WORLD, &dupcomm); + MPI_Comm_group(dupcomm, &dup_group); + + if (size < 2) { + printf("this test requires at least 2 processes\n"); + MPI_Abort(MPI_COMM_WORLD, 1); + } + + /* Idup MPI_COMM_WORLD multiple times */ + for (i = 0; i < NUM_IDUPS; i++) { + MPI_Comm_idup(MPI_COMM_WORLD, &idupcomms[i], &reqs[i]); + } + + /* Overlap pending idups with various comm generation functions */ + + /* Comm_dup */ + MPI_Comm_dup(dupcomm, &outcomm); + errs += MTestTestComm(outcomm); + MTestFreeComm(&outcomm); + + /* Comm_split */ + MPI_Comm_split(dupcomm, rank % 2, size - rank, &outcomm); + errs += MTestTestComm(outcomm); + MTestFreeComm(&outcomm); + + /* Comm_create, high half of dupcomm */ + ranges[0][0] = size / 2; + ranges[0][1] = size - 1; + ranges[0][2] = 1; + MPI_Group_range_incl(dup_group, 1, ranges, &high_group); + MPI_Comm_create(dupcomm, high_group, &outcomm); + MPI_Group_free(&high_group); + errs += MTestTestComm(outcomm); + MTestFreeComm(&outcomm); + + /* Comm_create_group, even ranks of dupcomm */ + /* exclude the odd ranks */ + excl = malloc((size / 2) * sizeof(int)); + for (i = 0; i < size / 2; i++) + excl[i] = (2 * i) + 1; + + MPI_Group_excl(dup_group, size / 2, excl, &even_group); + free(excl); + + if (rank % 2 == 0) { + MPI_Comm_create_group(dupcomm, even_group, 0, &outcomm); + } + else { + outcomm = MPI_COMM_NULL; + } + MPI_Group_free(&even_group); + + errs += MTestTestComm(outcomm); + MTestFreeComm(&outcomm); + + /* Intercomm_create & Intercomm_merge */ + MPI_Comm_split(dupcomm, (rank < size / 2), rank, &local_comm); + + if (rank == 0) { + rleader = size / 2; + } + else if (rank == size / 2) { + rleader = 0; + } + else { + rleader = -1; + } + isLeft = rank < size / 2; + + MPI_Intercomm_create(local_comm, 0, dupcomm, rleader, 99, &inter_comm); + MPI_Intercomm_merge(inter_comm, isLeft, &outcomm); + MPI_Comm_free(&local_comm); + + errs += MTestTestComm(inter_comm); + MTestFreeComm(&inter_comm); + + errs += MTestTestComm(outcomm); + MTestFreeComm(&outcomm); + + MPI_Waitall(NUM_IDUPS, reqs, MPI_STATUSES_IGNORE); + for (i = 0; i < NUM_IDUPS; i++) { + errs += MTestTestComm(idupcomms[i]); + MPI_Comm_free(&idupcomms[i]); + } + + MPI_Group_free(&dup_group); + MPI_Comm_free(&dupcomm); + + MTest_Finalize(errs); + MPI_Finalize(); + return 0; +} diff --git a/teshsuite/smpi/mpich3-test/comm/comm_idup_iallreduce.c b/teshsuite/smpi/mpich3-test/comm/comm_idup_iallreduce.c new file mode 100644 index 0000000000..46be1e945d --- /dev/null +++ b/teshsuite/smpi/mpich3-test/comm/comm_idup_iallreduce.c @@ -0,0 +1,218 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2015 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ + +#include +#include +#include +#include "mpi.h" +#include "mpitest.h" + +#define ITERS 10 + +/* This test uses several scenarios to overlap iallreduce and comm_idup + * 1.) Use comm_idup dublicate the COMM_WORLD and do iallreduce + * on the COMM_WORLD + * 2.) Do the above test in a loop + * 3.) Dublicate COMM_WORLD, overalp iallreduce on one + * communicator with comm_idup on the nother communicator + * 4.) Split MPI_COMM_WORLD, communicate on the split communicator + while dublicating COMM_WORLD + * 5.) Duplicate the split communicators with comm_idup + * while communicating onCOMM_WORLD + * 6.) Ceate an inter-communicator and duplicate it with comm_idup while + * communicating on the inter-communicator + * 7.) Dublicate the inter-communicator whil communicate on COMM_WORLD + * 8.) Merge the inter-communicator to an intra-communicator and idup it, + * overlapping with communication on MPI_COMM_WORLD + * 9.) Communicate on the merge communicator, while duplicating COMM_WORLD +*/ + +int main(int argc, char **argv) +{ + int errs = 0; + int i; + int rank, size, lrank, lsize, rsize, isize; + int in, out, sol; + + MPI_Comm newcomm, newcomm_v[ITERS], dup_comm, split, ic, merge; + MPI_Request sreq[ITERS * 2]; + + MTest_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + + if (size < 2) { + printf("this test requires at least 2 processes\n"); + MPI_Abort(MPI_COMM_WORLD, 1); + } + + /* set input buffer and compare buffer */ + in = 1; + sol = size; + MPI_Comm_idup(MPI_COMM_WORLD, &newcomm, &sreq[0]); + MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[1]); + + MPI_Waitall(2, sreq, MPI_STATUS_IGNORE); + /* Test results of overlapping allreduce */ + if (sol != out) + errs++; + /*Test new communicator */ + errs += MTestTestComm(newcomm); + MPI_Comm_free(&newcomm); + + for (i = 0; i < ITERS; i++) { + MPI_Comm_idup(MPI_COMM_WORLD, &newcomm_v[i], &sreq[i]); + MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[i + ITERS]); + } + MPI_Waitall(ITERS * 2, sreq, MPI_STATUS_IGNORE); + + for (i = 0; i < ITERS; i++) { + errs += MTestTestComm(newcomm_v[i]); + MPI_Comm_free(&newcomm_v[i]); + } + + MPI_Comm_dup(MPI_COMM_WORLD, &dup_comm); + + if (rank == 0) { + MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[0]); + MPI_Comm_idup(dup_comm, &newcomm, &sreq[1]); + MPI_Waitall(2, sreq, MPI_STATUS_IGNORE); + } + else { + MPI_Comm_idup(dup_comm, &newcomm, &sreq[1]); + MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[0]); + MPI_Waitall(2, sreq, MPI_STATUS_IGNORE); + } + /* Test Iallreduce */ + if (sol != out) + errs++; + + /*Test new communicator */ + errs += MTestTestComm(newcomm); + + MPI_Comm_free(&newcomm); + MPI_Comm_free(&dup_comm); + + MPI_Comm_split(MPI_COMM_WORLD, rank % 2, rank, &split); + MPI_Comm_rank(split, &lrank); + MPI_Comm_size(split, &lsize); + + sol = lsize; + if (lrank == 0) { + MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, split, &sreq[0]); + MPI_Comm_idup(MPI_COMM_WORLD, &newcomm, &sreq[1]); + MPI_Waitall(2, sreq, MPI_STATUS_IGNORE); + } + else { + MPI_Comm_idup(MPI_COMM_WORLD, &newcomm, &sreq[1]); + MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, split, &sreq[0]); + MPI_Waitall(2, sreq, MPI_STATUS_IGNORE); + } + /* Test Iallreduce */ + if (sol != out) + errs++;; + + /* Test new communicator */ + errs += MTestTestComm(newcomm); + MPI_Comm_free(&newcomm); + sol = size; + + if (lrank == 0) { + MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[0]); + MPI_Comm_idup(split, &newcomm, &sreq[1]); + MPI_Waitall(2, sreq, MPI_STATUS_IGNORE); + } + else { + MPI_Comm_idup(split, &newcomm, &sreq[1]); + MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[0]); + MPI_Waitall(2, sreq, MPI_STATUS_IGNORE); + } + /* Test Iallreduce */ + if (sol != out) + errs++;; + + /* Test new communicator */ + errs += MTestTestComm(newcomm); + MPI_Comm_free(&newcomm); + + MPI_Intercomm_create(split, 0, MPI_COMM_WORLD, (rank == 0 ? 1 : 0), 1234, &ic); + MPI_Comm_remote_size(ic, &rsize); + + sol = rsize; + + MPI_Comm_idup(ic, &newcomm, &sreq[1]); + MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, ic, &sreq[0]); + MPI_Waitall(2, sreq, MPI_STATUS_IGNORE); + + + if (sol != out) + errs++;; + /* Test new inter communicator */ + errs += MTestTestComm(newcomm); + MPI_Comm_free(&newcomm); + + sol = lsize; + if (lrank == 0) { + MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, split, &sreq[0]); + MPI_Comm_idup(ic, &newcomm, &sreq[1]); + MPI_Waitall(2, sreq, MPI_STATUS_IGNORE); + } + else { + MPI_Comm_idup(ic, &newcomm, &sreq[1]); + MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, split, &sreq[0]); + MPI_Waitall(2, sreq, MPI_STATUS_IGNORE); + } + /* Test Iallreduce resutls for split-communicator */ + if (sol != out) + errs++;; + /* Test new inter-communicator */ + + errs += MTestTestComm(newcomm); + MPI_Comm_free(&newcomm); + + MPI_Intercomm_merge(ic, rank % 2, &merge); + MPI_Comm_size(merge, &isize); + + sol = size; + if (rank == 0) { + MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[0]); + MPI_Comm_idup(merge, &newcomm, &sreq[1]); + MPI_Waitall(2, sreq, MPI_STATUS_IGNORE); + } + else { + MPI_Comm_idup(merge, &newcomm, &sreq[1]); + MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[0]); + MPI_Waitall(2, sreq, MPI_STATUS_IGNORE); + } + + + if (sol != out) + errs++;; + /* Test new communicator */ + errs += MTestTestComm(newcomm); + MPI_Comm_free(&newcomm); + sol = isize; + + if (rank == 0) { + MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, merge, &sreq[0]); + MPI_Comm_idup(MPI_COMM_WORLD, &newcomm, &sreq[1]); + MPI_Waitall(2, sreq, MPI_STATUS_IGNORE); + } + else { + MPI_Comm_idup(MPI_COMM_WORLD, &newcomm, &sreq[1]); + MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, merge, &sreq[0]); + MPI_Waitall(2, sreq, MPI_STATUS_IGNORE); + } + + MPI_Comm_free(&merge); + MPI_Comm_free(&newcomm); + MPI_Comm_free(&split); + MPI_Comm_free(&ic); + + MTest_Finalize(errs); + MPI_Finalize(); + return 0; +} diff --git a/teshsuite/smpi/mpich3-test/comm/comm_idup_isend.c b/teshsuite/smpi/mpich3-test/comm/comm_idup_isend.c new file mode 100644 index 0000000000..38b3b736bf --- /dev/null +++ b/teshsuite/smpi/mpich3-test/comm/comm_idup_isend.c @@ -0,0 +1,109 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2015 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ + +#include +#include +#include +#include "mpi.h" +#include "mpitest.h" + +#define ITERS 4 + +int main(int argc, char **argv) +{ + int errs = 0; + int i, j; + int rank, size, rsize; + int in[ITERS], out[ITERS], sol[ITERS], cnt; + int isLeft; + MPI_Comm newcomm[ITERS], testcomm; + MPI_Request *sreq; + + MTest_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + if (size < 2) { + printf("this test requires at least 2 processes\n"); + MPI_Abort(MPI_COMM_WORLD, 1); + } + + sreq = (MPI_Request *) malloc(sizeof(MPI_Request) * (size + 1) * ITERS); + + while (MTestGetIntracommGeneral(&testcomm, 1, 1)) { + if (testcomm == MPI_COMM_NULL) + continue; + + MPI_Comm_rank(testcomm, &rank); + MPI_Comm_size(testcomm, &size); + cnt = 0; + for (j = 0; j < ITERS; j++) { + if (rank == 0) { + out[j] = 815; + in[j] = 815; + sol[j] = 815; + for (i = 1; i < size; i++) + MPI_Isend(&out[j], 1, MPI_INT, i, 0, testcomm, &sreq[cnt++]); + MPI_Comm_idup(testcomm, &newcomm[j], &sreq[cnt++]); + } + else { + out[j] = 0; + in[j] = 0; + sol[j] = 815; + MPI_Comm_idup(testcomm, &newcomm[j], &sreq[cnt++]); + MPI_Irecv(&in[j], 1, MPI_INT, 0, 0, testcomm, &sreq[cnt++]); + } + } + MPI_Waitall(cnt, sreq, MPI_STATUS_IGNORE); + + for (j = 0; j < ITERS; j++) { + if (sol[j] != in[j]) + errs++; + errs += MTestTestComm(newcomm[j]); + MPI_Comm_free(&newcomm[j]); + } + MTestFreeComm(&testcomm); + } + while (MTestGetIntercomm(&testcomm, &isLeft, 1)) { + if (testcomm == MPI_COMM_NULL) + continue; + + MPI_Comm_rank(testcomm, &rank); + MPI_Comm_size(testcomm, &size); + MPI_Comm_remote_size(testcomm, &rsize); + cnt = 0; + for (j = 0; j < ITERS; j++) { + if (rank == 0) { + out[j] = 815; + in[j] = 815; + sol[j] = 815; + for (i = 1; i < rsize; i++) + MPI_Isend(&out[j], 1, MPI_INT, i, 0, testcomm, &sreq[cnt++]); + MPI_Comm_idup(testcomm, &newcomm[j], &sreq[cnt++]); + } + else { + out[j] = 0; + in[j] = 0; + sol[j] = 815; + MPI_Comm_idup(testcomm, &newcomm[j], &sreq[cnt++]); + MPI_Irecv(&in[j], 1, MPI_INT, 0, 0, testcomm, &sreq[cnt++]); + } + } + MPI_Waitall(cnt, sreq, MPI_STATUS_IGNORE); + + for (j = 0; j < ITERS; j++) { + if (sol[j] != in[j]) + errs++; + errs += MTestTestComm(newcomm[j]); + MPI_Comm_free(&newcomm[j]); + } + MTestFreeComm(&testcomm); + } + + free(sreq); + MTest_Finalize(errs); + MPI_Finalize(); + return 0; +} diff --git a/teshsuite/smpi/mpich3-test/comm/comm_idup_mul.c b/teshsuite/smpi/mpich3-test/comm/comm_idup_mul.c index 2830f021bd..a5f8242795 100644 --- a/teshsuite/smpi/mpich3-test/comm/comm_idup_mul.c +++ b/teshsuite/smpi/mpich3-test/comm/comm_idup_mul.c @@ -11,7 +11,7 @@ #include #include -#define NUM_ITER 2 +#define NUM_ITER 10 int main(int argc, char **argv) { diff --git a/teshsuite/smpi/mpich3-test/comm/comm_idup_nb.c b/teshsuite/smpi/mpich3-test/comm/comm_idup_nb.c new file mode 100644 index 0000000000..8344fc63a0 --- /dev/null +++ b/teshsuite/smpi/mpich3-test/comm/comm_idup_nb.c @@ -0,0 +1,184 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2015 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ + +#include +#include +#include +#include "mpi.h" +#include "mpitest.h" + +#define ITERS 5 + +int main(int argc, char **argv) +{ + int errs = 0; + int i, isleft; + MPI_Comm test_comm, new_comm[ITERS]; + int in[ITERS], out[ITERS], sol; + int rank, size, rsize, rrank; + MPI_Request sreq[ITERS * 2]; + int root; + + MTest_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + + if (size < 2) { + printf("this test requires at least 2 processes\n"); + MPI_Abort(MPI_COMM_WORLD, 1); + } + + while (MTestGetIntracommGeneral(&test_comm, 1, 1)) { + if (test_comm == MPI_COMM_NULL) + continue; + MPI_Comm_size(test_comm, &size); + MPI_Comm_rank(test_comm, &rank); + + /* Ibarrier */ + for (i = 0; i < ITERS; i++) { + MPI_Ibarrier(test_comm, &sreq[i]); + MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i + ITERS]); + } + MPI_Waitall(ITERS * 2, sreq, MPI_STATUS_IGNORE); + + for (i = 0; i < ITERS; i++) { + errs += MTestTestComm(new_comm[i]); + MPI_Comm_free(&new_comm[i]); + } + /*Ibcast */ + for (i = 0; i < ITERS; i++) { + if (rank == 0) + in[i] = 815; + else + in[i] = 10; + MPI_Ibcast(&in[i], 1, MPI_INT, 0, test_comm, &sreq[i]); + MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i + ITERS]); + } + sol = 815; + MPI_Waitall(ITERS * 2, sreq, MPI_STATUS_IGNORE); + + for (i = 0; i < ITERS; i++) { + if (in[i] != sol) + errs++; + errs += MTestTestComm(new_comm[i]); + MPI_Comm_free(&new_comm[i]); + } + /* Iallreduce */ + for (i = 0; i < ITERS; i++) { + in[i] = 1; + MPI_Iallreduce(&in[i], &out[i], 1, MPI_INT, MPI_SUM, test_comm, &sreq[i]); + MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i + ITERS]); + } + sol = size; + MPI_Waitall(ITERS * 2, sreq, MPI_STATUS_IGNORE); + + for (i = 0; i < ITERS; i++) { + if (out[i] != sol) + errs++; + errs += MTestTestComm(new_comm[i]); + MPI_Comm_free(&new_comm[i]); + } + /* Isann */ + for (i = 0; i < ITERS; i++) { + MPI_Iscan(&rank, &out[i], 1, MPI_INT, MPI_SUM, test_comm, &sreq[i]); + MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i + ITERS]); + } + sol = rank * (rank + 1) / 2; + MPI_Waitall(ITERS * 2, sreq, MPI_STATUS_IGNORE); + + for (i = 0; i < ITERS; i++) { + if (out[i] != sol) + errs++; + errs += MTestTestComm(new_comm[i]); + MPI_Comm_free(&new_comm[i]); + } + /*Ibcast */ + for (i = 0; i < ITERS; i++) { + if (rank == 0) + in[i] = 815; + else + in[i] = 10; + MPI_Ibcast(&in[i], 1, MPI_INT, 0, test_comm, &sreq[i]); + MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i + ITERS]); + } + MPI_Waitall(ITERS * 2, sreq, MPI_STATUS_IGNORE); + sol = 815; + for (i = 0; i < ITERS; i++) { + if (in[i] != sol) + errs++; + errs += MTestTestComm(new_comm[i]); + MPI_Comm_free(&new_comm[i]); + } + MTestFreeComm(&test_comm); + } +/* Now the test for inter-communicators */ + while (MTestGetIntercomm(&test_comm, &isleft, 1)) { + if (test_comm == MPI_COMM_NULL) + continue; + + MPI_Comm_size(test_comm, &size); + MPI_Comm_rank(test_comm, &rank); + + MPI_Comm_remote_size(test_comm, &rsize); + /* Ibarrier */ + for (i = 0; i < ITERS; i++) { + MPI_Ibarrier(test_comm, &sreq[i]); + MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i + ITERS]); + } + MPI_Waitall(ITERS * 2, sreq, MPI_STATUS_IGNORE); + for (i = 0; i < ITERS; i++) { + errs += MTestTestComm(new_comm[i]); + MPI_Comm_free(&new_comm[i]); + } + /*Ibcast */ + for (i = 0; i < ITERS; i++) { + if (isleft) { + if (rank == 0) { + root = MPI_ROOT; + in[i] = 815; + } + else { + root = MPI_PROC_NULL; + in[i] = 815; /* not needed, just to make correctness checking easier */ + } + } + else { + root = 0; + in[i] = 213; /* garbage value */ + } + MPI_Ibcast(&in[i], 1, MPI_INT, root, test_comm, &sreq[i]); + MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i + ITERS]); + } + sol = 815; + MPI_Waitall(ITERS * 2, sreq, MPI_STATUS_IGNORE); + + for (i = 0; i < ITERS; i++) { + if (in[i] != sol) + errs++; + errs += MTestTestComm(new_comm[i]); + MPI_Comm_free(&new_comm[i]); + } + /* Iallreduce */ + for (i = 0; i < ITERS; i++) { + in[i] = 1; + MPI_Iallreduce(&in[i], &out[i], 1, MPI_INT, MPI_SUM, test_comm, &sreq[i]); + MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i + ITERS]); + } + sol = rsize; + MPI_Waitall(ITERS * 2, sreq, MPI_STATUS_IGNORE); + + for (i = 0; i < ITERS; i++) { + if (out[i] != sol) + errs++; + errs += MTestTestComm(new_comm[i]); + MPI_Comm_free(&new_comm[i]); + } + MTestFreeComm(&test_comm); + } + MTest_Finalize(errs); + MPI_Finalize(); + return 0; +} diff --git a/teshsuite/smpi/mpich3-test/comm/comm_info.c b/teshsuite/smpi/mpich3-test/comm/comm_info.c index d2044d4a97..716c97046f 100644 --- a/teshsuite/smpi/mpich3-test/comm/comm_info.c +++ b/teshsuite/smpi/mpich3-test/comm/comm_info.c @@ -13,11 +13,12 @@ int main(int argc, char **argv) { - int rank; + int i, j, rank; MPI_Info info_in, info_out; int errors = 0, all_errors = 0; MPI_Comm comm; - char __attribute__((unused)) invalid_key[] = "invalid_test_key"; + void *base; + char invalid_key[] = "invalid_test_key"; char buf[MPI_MAX_INFO_VAL]; int flag; @@ -26,7 +27,7 @@ int main(int argc, char **argv) MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Info_create(&info_in); - MPI_Info_set(info_in, invalid_key, (char *) "true"); + MPI_Info_set(info_in, invalid_key, "true"); MPI_Comm_dup(MPI_COMM_WORLD, &comm); diff --git a/teshsuite/smpi/mpich3-test/comm/commcreate1.c b/teshsuite/smpi/mpich3-test/comm/commcreate1.c index e93f914e39..514dc6d0ea 100644 --- a/teshsuite/smpi/mpich3-test/comm/commcreate1.c +++ b/teshsuite/smpi/mpich3-test/comm/commcreate1.c @@ -12,129 +12,128 @@ processes in the communicator. */ -void abortMsg( const char *, int ); -int BuildComm( MPI_Comm, MPI_Group, const char [] ); +void abortMsg(const char *, int); +int BuildComm(MPI_Comm, MPI_Group, const char[]); -void abortMsg( const char *str, int code ) +void abortMsg(const char *str, int code) { char msg[MPI_MAX_ERROR_STRING]; int class, resultLen; - MPI_Error_class( code, &class ); - MPI_Error_string( code, msg, &resultLen ); - fprintf( stderr, "%s: errcode = %d, class = %d, msg = %s\n", - str, code, class, msg ); - MPI_Abort( MPI_COMM_WORLD, code ); - exit(code); + MPI_Error_class(code, &class); + MPI_Error_string(code, msg, &resultLen); + fprintf(stderr, "%s: errcode = %d, class = %d, msg = %s\n", str, code, class, msg); + MPI_Abort(MPI_COMM_WORLD, code); } -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { - MPI_Comm dupWorld; - int wrank, wsize, gsize, err, errs = 0; - int ranges[1][3]; + MPI_Comm dupWorld; + int wrank, wsize, gsize, err, errs = 0; + int ranges[1][3]; MPI_Group wGroup, godd, ghigh, geven; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - MPI_Comm_size( MPI_COMM_WORLD, &wsize ); - MPI_Comm_rank( MPI_COMM_WORLD, &wrank ); + MPI_Comm_size(MPI_COMM_WORLD, &wsize); + MPI_Comm_rank(MPI_COMM_WORLD, &wrank); /* Create some groups */ - MPI_Comm_group( MPI_COMM_WORLD, &wGroup ); + MPI_Comm_group(MPI_COMM_WORLD, &wGroup); - MTestPrintfMsg( 2, "Creating groups\n" ); - ranges[0][0] = 2*(wsize/2)-1; + MTestPrintfMsg(2, "Creating groups\n"); + ranges[0][0] = 2 * (wsize / 2) - 1; ranges[0][1] = 1; ranges[0][2] = -2; - err = MPI_Group_range_incl( wGroup, 1, ranges, &godd ); - if (err) abortMsg( "Failed to create odd group: ", err ); - err = MPI_Group_size( godd, &gsize ); - if (err) abortMsg( "Failed to get size of odd group: ", err ); - if (gsize != wsize/2) { - fprintf( stderr, "Group godd size is %d should be %d\n", gsize, - wsize/2 ); - errs++; + err = MPI_Group_range_incl(wGroup, 1, ranges, &godd); + if (err) + abortMsg("Failed to create odd group: ", err); + err = MPI_Group_size(godd, &gsize); + if (err) + abortMsg("Failed to get size of odd group: ", err); + if (gsize != wsize / 2) { + fprintf(stderr, "Group godd size is %d should be %d\n", gsize, wsize / 2); + errs++; } - ranges[0][0] = wsize/2+1; - ranges[0][1] = wsize-1; + ranges[0][0] = wsize / 2 + 1; + ranges[0][1] = wsize - 1; ranges[0][2] = 1; - err = MPI_Group_range_incl( wGroup, 1, ranges, &ghigh ); - if (err) abortMsg( "Failed to create high group\n", err ); + err = MPI_Group_range_incl(wGroup, 1, ranges, &ghigh); + if (err) + abortMsg("Failed to create high group\n", err); ranges[0][0] = 0; - ranges[0][1] = wsize-1; + ranges[0][1] = wsize - 1; ranges[0][2] = 2; - err = MPI_Group_range_incl( wGroup, 1, ranges, &geven ); - if (err) abortMsg( "Failed to create even group:", err ); + err = MPI_Group_range_incl(wGroup, 1, ranges, &geven); + if (err) + abortMsg("Failed to create even group:", err); - MPI_Comm_dup( MPI_COMM_WORLD, &dupWorld ); - MPI_Comm_set_name( dupWorld, (char*)"Dup of world" ); + MPI_Comm_dup(MPI_COMM_WORLD, &dupWorld); + MPI_Comm_set_name(dupWorld, (char *) "Dup of world"); /* First, use the groups to create communicators from world and a dup - of world */ - errs += BuildComm( MPI_COMM_WORLD, ghigh, "ghigh" ); - errs += BuildComm( MPI_COMM_WORLD, godd, "godd" ); - errs += BuildComm( MPI_COMM_WORLD, geven, "geven" ); - errs += BuildComm( dupWorld, ghigh, "ghigh" ); - errs += BuildComm( dupWorld, godd, "godd" ); - errs += BuildComm( dupWorld, geven, "geven" ); + * of world */ + errs += BuildComm(MPI_COMM_WORLD, ghigh, "ghigh"); + errs += BuildComm(MPI_COMM_WORLD, godd, "godd"); + errs += BuildComm(MPI_COMM_WORLD, geven, "geven"); + errs += BuildComm(dupWorld, ghigh, "ghigh"); + errs += BuildComm(dupWorld, godd, "godd"); + errs += BuildComm(dupWorld, geven, "geven"); #if MTEST_HAVE_MIN_MPI_VERSION(2,2) /* check that we can create multiple communicators from a single collective * call to MPI_Comm_create as long as the groups are all disjoint */ - errs += BuildComm( MPI_COMM_WORLD, (wrank % 2 ? godd : geven), "godd+geven" ); - errs += BuildComm( dupWorld, (wrank % 2 ? godd : geven), "godd+geven" ); - errs += BuildComm( MPI_COMM_WORLD, MPI_GROUP_EMPTY, "MPI_GROUP_EMPTY" ); - errs += BuildComm( dupWorld, MPI_GROUP_EMPTY, "MPI_GROUP_EMPTY" ); + errs += BuildComm(MPI_COMM_WORLD, (wrank % 2 ? godd : geven), "godd+geven"); + errs += BuildComm(dupWorld, (wrank % 2 ? godd : geven), "godd+geven"); + errs += BuildComm(MPI_COMM_WORLD, MPI_GROUP_EMPTY, "MPI_GROUP_EMPTY"); + errs += BuildComm(dupWorld, MPI_GROUP_EMPTY, "MPI_GROUP_EMPTY"); #endif - MPI_Comm_free( &dupWorld ); - MPI_Group_free( &ghigh ); - MPI_Group_free( &godd ); - MPI_Group_free( &geven ); - MPI_Group_free( &wGroup ); + MPI_Comm_free(&dupWorld); + MPI_Group_free(&ghigh); + MPI_Group_free(&godd); + MPI_Group_free(&geven); + MPI_Group_free(&wGroup); - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } -int BuildComm( MPI_Comm oldcomm, MPI_Group group, const char gname[] ) +int BuildComm(MPI_Comm oldcomm, MPI_Group group, const char gname[]) { MPI_Comm newcomm; int grank, gsize, rank, size, errs = 0; - char cname[MPI_MAX_OBJECT_NAME+1]; - int cnamelen; - - MPI_Group_rank( group, &grank ); - MPI_Group_size( group, &gsize ); - MPI_Comm_get_name( oldcomm, cname, &cnamelen ); - MTestPrintfMsg( 2, "Testing comm %s from %s\n", cname, gname ); - MPI_Comm_create( oldcomm, group, &newcomm ); + char cname[MPI_MAX_OBJECT_NAME + 1]; + int cnamelen; + + MPI_Group_rank(group, &grank); + MPI_Group_size(group, &gsize); + MPI_Comm_get_name(oldcomm, cname, &cnamelen); + MTestPrintfMsg(2, "Testing comm %s from %s\n", cname, gname); + MPI_Comm_create(oldcomm, group, &newcomm); if (newcomm == MPI_COMM_NULL && grank != MPI_UNDEFINED) { - errs ++; - fprintf( stderr, "newcomm is null but process is in group\n" ); + errs++; + fprintf(stderr, "newcomm is null but process is in group\n"); } if (newcomm != MPI_COMM_NULL && grank == MPI_UNDEFINED) { - errs ++; - fprintf( stderr, "newcomm is not null but process is not in group\n" ); + errs++; + fprintf(stderr, "newcomm is not null but process is not in group\n"); } if (newcomm != MPI_COMM_NULL && grank != MPI_UNDEFINED) { - MPI_Comm_rank( newcomm, &rank ); - if (rank != grank) { - errs ++; - fprintf( stderr, "Rank is %d should be %d in comm from %s\n", - rank, grank, gname ); - } - MPI_Comm_size( newcomm, &size ); - if (size != gsize) { - errs++; - fprintf( stderr, "Size is %d should be %d in comm from %s\n", - size, gsize, gname ); - } - MPI_Comm_free( &newcomm ); - MTestPrintfMsg( 2, "Done testing comm %s from %s\n", cname, gname ); + MPI_Comm_rank(newcomm, &rank); + if (rank != grank) { + errs++; + fprintf(stderr, "Rank is %d should be %d in comm from %s\n", rank, grank, gname); + } + MPI_Comm_size(newcomm, &size); + if (size != gsize) { + errs++; + fprintf(stderr, "Size is %d should be %d in comm from %s\n", size, gsize, gname); + } + MPI_Comm_free(&newcomm); + MTestPrintfMsg(2, "Done testing comm %s from %s\n", cname, gname); } return errs; } diff --git a/teshsuite/smpi/mpich3-test/comm/commname.c b/teshsuite/smpi/mpich3-test/comm/commname.c index 6a7a736d71..ed52049f48 100644 --- a/teshsuite/smpi/mpich3-test/comm/commname.c +++ b/teshsuite/smpi/mpich3-test/comm/commname.c @@ -14,51 +14,49 @@ #include #endif -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; MPI_Comm comm; int cnt, rlen; char name[MPI_MAX_OBJECT_NAME], nameout[MPI_MAX_OBJECT_NAME]; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); /* Check world and self firt */ nameout[0] = 0; - MPI_Comm_get_name( MPI_COMM_WORLD, nameout, &rlen ); - if (strcmp(nameout,"MPI_COMM_WORLD")) { - errs++; - printf( "Name of comm world is %s, should be MPI_COMM_WORLD\n", - nameout ); + MPI_Comm_get_name(MPI_COMM_WORLD, nameout, &rlen); + if (strcmp(nameout, "MPI_COMM_WORLD")) { + errs++; + printf("Name of comm world is %s, should be MPI_COMM_WORLD\n", nameout); } nameout[0] = 0; - MPI_Comm_get_name( MPI_COMM_SELF, nameout, &rlen ); - if (strcmp(nameout,"MPI_COMM_SELF")) { - errs++; - printf( "Name of comm self is %s, should be MPI_COMM_SELF\n", - nameout ); + MPI_Comm_get_name(MPI_COMM_SELF, nameout, &rlen); + if (strcmp(nameout, "MPI_COMM_SELF")) { + errs++; + printf("Name of comm self is %s, should be MPI_COMM_SELF\n", nameout); } /* Now, handle other communicators, including world/self */ cnt = 0; - while (MTestGetComm( &comm, 1 )) { - if (comm == MPI_COMM_NULL) continue; - - sprintf( name, "comm-%d", cnt ); - cnt++; - MPI_Comm_set_name( comm, name ); - nameout[0] = 0; - MPI_Comm_get_name( comm, nameout, &rlen ); - if (strcmp( name, nameout )) { - errs++; - printf( "Unexpected name, was %s but should be %s\n", - nameout, name ); - } - - MTestFreeComm( &comm ); + while (MTestGetComm(&comm, 1)) { + if (comm == MPI_COMM_NULL) + continue; + + sprintf(name, "comm-%d", cnt); + cnt++; + MPI_Comm_set_name(comm, name); + nameout[0] = 0; + MPI_Comm_get_name(comm, nameout, &rlen); + if (strcmp(name, nameout)) { + errs++; + printf("Unexpected name, was %s but should be %s\n", nameout, name); + } + + MTestFreeComm(&comm); } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/comm/ctxalloc.c b/teshsuite/smpi/mpich3-test/comm/ctxalloc.c index ef66be3bf9..97c84660df 100644 --- a/teshsuite/smpi/mpich3-test/comm/ctxalloc.c +++ b/teshsuite/smpi/mpich3-test/comm/ctxalloc.c @@ -10,51 +10,51 @@ /* * This program tests the allocation (and deallocation) of contexts. - * + * */ -int main( int argc, char **argv ) +int main(int argc, char **argv) { int errs = 0; int i, j, err; MPI_Comm newcomm1, newcomm2[200]; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); /* Get a separate communicator to duplicate */ - MPI_Comm_dup( MPI_COMM_WORLD, &newcomm1 ); + MPI_Comm_dup(MPI_COMM_WORLD, &newcomm1); - MPI_Errhandler_set( newcomm1, MPI_ERRORS_RETURN ); + MPI_Errhandler_set(newcomm1, MPI_ERRORS_RETURN); /* Allocate many communicators in batches, then free them */ - for (i=0; i<1000; i++) { - for (j=0; j<200; j++) { - err = MPI_Comm_dup( newcomm1, &newcomm2[j] ); - if (err) { - errs++; - if (errs < 10) { - fprintf( stderr, "Failed to duplicate communicator for (%d,%d)\n", i, j ); - MTestPrintError( err ); - } - } - } - for (j=0; j<200; j++) { - err = MPI_Comm_free( &newcomm2[j] ); - if (err) { - errs++; - if (errs < 10) { - fprintf( stderr, "Failed to free %d,%d\n", i, j ); - MTestPrintError( err ); - } - } - } + for (i = 0; i < 1000; i++) { + for (j = 0; j < 200; j++) { + err = MPI_Comm_dup(newcomm1, &newcomm2[j]); + if (err) { + errs++; + if (errs < 10) { + fprintf(stderr, "Failed to duplicate communicator for (%d,%d)\n", i, j); + MTestPrintError(err); + } + } + } + for (j = 0; j < 200; j++) { + err = MPI_Comm_free(&newcomm2[j]); + if (err) { + errs++; + if (errs < 10) { + fprintf(stderr, "Failed to free %d,%d\n", i, j); + MTestPrintError(err); + } + } + } } - err = MPI_Comm_free( &newcomm1 ); + err = MPI_Comm_free(&newcomm1); if (err) { - errs++; - fprintf( stderr, "Failed to free newcomm1\n" ); - MTestPrintError( err ); + errs++; + fprintf(stderr, "Failed to free newcomm1\n"); + MTestPrintError(err); } - - MTest_Finalize( errs ); + + MTest_Finalize(errs); MPI_Finalize(); diff --git a/teshsuite/smpi/mpich3-test/comm/ctxsplit.c b/teshsuite/smpi/mpich3-test/comm/ctxsplit.c index 4e73dc5ca1..a235cac666 100644 --- a/teshsuite/smpi/mpich3-test/comm/ctxsplit.c +++ b/teshsuite/smpi/mpich3-test/comm/ctxsplit.c @@ -11,70 +11,71 @@ #include "mpitest.h" /* - * This check is intended to fail if there is a leak of context ids. + * This check is intended to fail if there is a leak of context ids. * Because this is trying to exhaust the number of context ids, it needs - * to run for a longer time than many tests. The for loop uses 100,000 + * to run for a longer time than many tests. The for loop uses 100,000 * iterations, which is adequate for MPICH (with only about 1k context ids * available). */ -int main(int argc, char** argv) { +int main(int argc, char **argv) +{ - int i=0; - int randval; - int rank; - int errs = 0; - MPI_Comm newcomm; - double startTime; - int nLoop = 100000; - - MTest_Init(&argc,&argv); + int i = 0; + int randval; + int rank; + int errs = 0; + MPI_Comm newcomm; + double startTime; + int nLoop = 100000; - for (i=1; i 0) { - rate = i / rate; - MTestPrintfMsg( 10, "After %d (%f)\n", i, rate ); - } - else { - MTestPrintfMsg( 10, "After %d\n", i ); - } - } - - /* FIXME: Explain the rationale behind rand in this test */ - randval=rand(); - - if (randval%(rank+2) == 0) { - MPI_Comm_split(MPI_COMM_WORLD,1,rank,&newcomm); - MPI_Comm_free( &newcomm ); - } - else { - MPI_Comm_split(MPI_COMM_WORLD,MPI_UNDEFINED,rank,&newcomm); - if (newcomm != MPI_COMM_NULL) { - errs++; - printf( "Created a non-null communicator with MPI_UNDEFINED\n" ); - } - } - - } - - MTest_Finalize( errs ); - MPI_Finalize(); - - return 0; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + + startTime = MPI_Wtime(); + for (i = 0; i < nLoop; i++) { + + if (rank == 0 && (i % 100 == 0)) { + double rate = MPI_Wtime() - startTime; + if (rate > 0) { + rate = i / rate; + MTestPrintfMsg(10, "After %d (%f)\n", i, rate); + } + else { + MTestPrintfMsg(10, "After %d\n", i); + } + } + + /* FIXME: Explain the rationale behind rand in this test */ + randval = rand(); + + if (randval % (rank + 2) == 0) { + MPI_Comm_split(MPI_COMM_WORLD, 1, rank, &newcomm); + MPI_Comm_free(&newcomm); + } + else { + MPI_Comm_split(MPI_COMM_WORLD, MPI_UNDEFINED, rank, &newcomm); + if (newcomm != MPI_COMM_NULL) { + errs++; + printf("Created a non-null communicator with MPI_UNDEFINED\n"); + } + } + + } + + MTest_Finalize(errs); + MPI_Finalize(); + + return 0; } diff --git a/teshsuite/smpi/mpich3-test/comm/dup.c b/teshsuite/smpi/mpich3-test/comm/dup.c index a30975fb40..7129ef6383 100644 --- a/teshsuite/smpi/mpich3-test/comm/dup.c +++ b/teshsuite/smpi/mpich3-test/comm/dup.c @@ -8,72 +8,68 @@ #include #include "mpitest.h" -int main( int argc, char **argv ) +int main(int argc, char **argv) { int errs = 0; int rank, size, wrank, wsize, dest, a, b; MPI_Comm newcomm; MPI_Status status; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); /* Can we run comm dup at all? */ - MPI_Comm_dup( MPI_COMM_WORLD, &newcomm ); + MPI_Comm_dup(MPI_COMM_WORLD, &newcomm); /* Check basic properties */ - MPI_Comm_size( MPI_COMM_WORLD, &wsize ); - MPI_Comm_rank( MPI_COMM_WORLD, &wrank ); - MPI_Comm_size( newcomm, &size ); - MPI_Comm_rank( newcomm, &rank ); - + MPI_Comm_size(MPI_COMM_WORLD, &wsize); + MPI_Comm_rank(MPI_COMM_WORLD, &wrank); + MPI_Comm_size(newcomm, &size); + MPI_Comm_rank(newcomm, &rank); + if (size != wsize || rank != wrank) { - errs++; - fprintf( stderr, "Size (%d) or rank (%d) wrong\n", size, rank ); - fflush( stderr ); + errs++; + fprintf(stderr, "Size (%d) or rank (%d) wrong\n", size, rank); + fflush(stderr); } /* Can we communicate with this new communicator? */ dest = MPI_PROC_NULL; if (rank == 0) { - dest = size - 1; - a = rank; - b = -1; - MPI_Sendrecv( &a, 1, MPI_INT, dest, 0, - &b, 1, MPI_INT, dest, 0, newcomm, &status ); - if (b != dest) { - errs++; - fprintf( stderr, "Received %d expected %d on %d\n", b, dest, rank ); - fflush( stderr ); - } - if (status.MPI_SOURCE != dest) { - errs++; - fprintf( stderr, "Source not set correctly in status on %d\n", - rank ); - fflush( stderr ); - } + dest = size - 1; + a = rank; + b = -1; + MPI_Sendrecv(&a, 1, MPI_INT, dest, 0, &b, 1, MPI_INT, dest, 0, newcomm, &status); + if (b != dest) { + errs++; + fprintf(stderr, "Received %d expected %d on %d\n", b, dest, rank); + fflush(stderr); + } + if (status.MPI_SOURCE != dest) { + errs++; + fprintf(stderr, "Source not set correctly in status on %d\n", rank); + fflush(stderr); + } } - else if (rank == size-1) { - dest = 0; - a = rank; - b = -1; - MPI_Sendrecv( &a, 1, MPI_INT, dest, 0, - &b, 1, MPI_INT, dest, 0, newcomm, &status ); - if (b != dest) { - errs++; - fprintf( stderr, "Received %d expected %d on %d\n", b, dest, rank ); - fflush( stderr ); - } - if (status.MPI_SOURCE != dest) { - errs++; - fprintf( stderr, "Source not set correctly in status on %d\n", - rank ); - fflush( stderr ); - } + else if (rank == size - 1) { + dest = 0; + a = rank; + b = -1; + MPI_Sendrecv(&a, 1, MPI_INT, dest, 0, &b, 1, MPI_INT, dest, 0, newcomm, &status); + if (b != dest) { + errs++; + fprintf(stderr, "Received %d expected %d on %d\n", b, dest, rank); + fflush(stderr); + } + if (status.MPI_SOURCE != dest) { + errs++; + fprintf(stderr, "Source not set correctly in status on %d\n", rank); + fflush(stderr); + } } - MPI_Comm_free( &newcomm ); + MPI_Comm_free(&newcomm); - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); diff --git a/teshsuite/smpi/mpich3-test/comm/dup_with_info.c b/teshsuite/smpi/mpich3-test/comm/dup_with_info.c index e63acaaa94..bda2214fc7 100644 --- a/teshsuite/smpi/mpich3-test/comm/dup_with_info.c +++ b/teshsuite/smpi/mpich3-test/comm/dup_with_info.c @@ -7,7 +7,7 @@ #include "mpi.h" #include #include "mpitest.h" -int run_tests(MPI_Comm comm); + int run_tests(MPI_Comm comm) { int rank, size, wrank, wsize, dest, a, b, errs = 0; diff --git a/teshsuite/smpi/mpich3-test/comm/dupic.c b/teshsuite/smpi/mpich3-test/comm/dupic.c index 8a79fb5e9e..e3712769fa 100644 --- a/teshsuite/smpi/mpich3-test/comm/dupic.c +++ b/teshsuite/smpi/mpich3-test/comm/dupic.c @@ -8,7 +8,7 @@ #include #include "mpitest.h" -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; MPI_Comm comm, dupcomm, dupcomm2; @@ -18,78 +18,76 @@ int main( int argc, char *argv[] ) int r1buf, r2buf, s1buf, s2buf; int rank, isLeft; - MTest_Init( &argc, &argv ); - - while (MTestGetIntercomm( &comm, &isLeft, 2 )) { - if (comm == MPI_COMM_NULL) continue; + MTest_Init(&argc, &argv); - MPI_Comm_dup( comm, &dupcomm ); - - /* Check that there are separate contexts. We do this by setting - up nonblocking received on both communicators, and then - sending to them. If the contexts are different, tests on the - unsatisfied communicator should indicate no available message */ - MPI_Comm_rank( comm, &rank ); - if (rank == 0) { - s1buf = 456; - s2buf = 17; - r1buf = r2buf = -1; - /* These are send/receives to the process with rank zero - in the other group (these are intercommunicators) */ - MPI_Irecv( &r1buf, 1, MPI_INT, 0, 0, dupcomm, &rreq[0] ); - MPI_Irecv( &r2buf, 1, MPI_INT, 0, 0, comm, &rreq[1] ); - MPI_Send( &s2buf, 1, MPI_INT, 0, 0, comm ); - MPI_Waitsome(2, rreq, &count, indicies, MPI_STATUSES_IGNORE); - if (count != 1 || indicies[0] != 1) { - /* The only valid return is that exactly one message - has been received */ - errs++; - if (count == 1 && indicies[0] != 1) { - printf( "Error in context values for intercomm\n" ); - } - else if (count == 2) { - printf( "Error: two messages received!\n" ); - } - else { - int i; - printf( "Error: count = %d", count ); - for (i=0; i #include "mpitest.h" -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { MPI_Comm intercomm; - int remote_rank, rank, size, errs = 0; + int remote_rank, rank, size, errs = 0; + volatile int trigger; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); + trigger = 1; +/* while (trigger) ; */ - - MPI_Comm_size( MPI_COMM_WORLD, &size ); + MPI_Comm_size(MPI_COMM_WORLD, &size); if (size < 2) { - printf( "Size must be at least 2\n" ); - MPI_Abort( MPI_COMM_WORLD, 0 ); - exit(0); + printf("Size must be at least 2\n"); + MPI_Abort(MPI_COMM_WORLD, 0); } - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); /* Make an intercomm of the first two elements of comm_world */ if (rank < 2) { - int lrank = rank, rrank = -1; - MPI_Status status; + int lrank = rank, rrank = -1; + MPI_Status status; - remote_rank = 1 - rank; - MPI_Intercomm_create( MPI_COMM_SELF, 0, - MPI_COMM_WORLD, remote_rank, 27, - &intercomm ); + remote_rank = 1 - rank; + MPI_Intercomm_create(MPI_COMM_SELF, 0, MPI_COMM_WORLD, remote_rank, 27, &intercomm); - /* Now, communicate between them */ - MPI_Sendrecv( &lrank, 1, MPI_INT, 0, 13, - &rrank, 1, MPI_INT, 0, 13, intercomm, &status ); + /* Now, communicate between them */ + MPI_Sendrecv(&lrank, 1, MPI_INT, 0, 13, &rrank, 1, MPI_INT, 0, 13, intercomm, &status); - if (rrank != remote_rank) { - errs++; - printf( "%d Expected %d but received %d\n", - rank, remote_rank, rrank ); - } + if (rrank != remote_rank) { + errs++; + printf("%d Expected %d but received %d\n", rank, remote_rank, rrank); + } - MPI_Comm_free( &intercomm ); + MPI_Comm_free(&intercomm); } - + /* The next test should create an intercomm with groups of different - sizes FIXME */ + * sizes FIXME */ - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); - + return 0; } diff --git a/teshsuite/smpi/mpich3-test/comm/ic2.c b/teshsuite/smpi/mpich3-test/comm/ic2.c index adf5449fab..14d8c96fd3 100644 --- a/teshsuite/smpi/mpich3-test/comm/ic2.c +++ b/teshsuite/smpi/mpich3-test/comm/ic2.c @@ -34,7 +34,7 @@ int main(int argc, char **argv) if (size < 33) { printf("ERROR: this test requires at least 33 processes\n"); MPI_Abort(MPI_COMM_WORLD, 1); - exit(1); + return 1; } /* group of c0 @@ -79,8 +79,7 @@ int main(int argc, char **argv) MPI_Comm_free(&ic); - MPI_Reduce((rank == 0 ? MPI_IN_PLACE : &errs), &errs, - 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); + MPI_Reduce((rank == 0 ? MPI_IN_PLACE : &errs), &errs, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); if (rank == 0) { if (errs) { printf("found %d errors\n", errs); @@ -93,4 +92,3 @@ int main(int argc, char **argv) return 0; } - diff --git a/teshsuite/smpi/mpich3-test/comm/iccreate.c b/teshsuite/smpi/mpich3-test/comm/iccreate.c index ef3d36334e..64ce1ed28d 100644 --- a/teshsuite/smpi/mpich3-test/comm/iccreate.c +++ b/teshsuite/smpi/mpich3-test/comm/iccreate.c @@ -13,100 +13,102 @@ * This program tests that MPI_Comm_create applies to intercommunicators; * this is an extension added in MPI-2 */ - -int TestIntercomm( MPI_Comm ); - -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int size, isLeft, wrank; MPI_Comm intercomm, newcomm; MPI_Group oldgroup, newgroup; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - MPI_Comm_size( MPI_COMM_WORLD, &size ); + MPI_Comm_size(MPI_COMM_WORLD, &size); if (size < 4) { - printf( "This test requires at least 4 processes\n" ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); + printf("This test requires at least 4 processes\n"); + MPI_Abort(MPI_COMM_WORLD, 1); } - MPI_Comm_rank( MPI_COMM_WORLD, &wrank ); - - while (MTestGetIntercomm( &intercomm, &isLeft, 2 )) { - int ranks[10], nranks, result; - - if (intercomm == MPI_COMM_NULL) continue; - - MPI_Comm_group( intercomm, &oldgroup ); - ranks[0] = 0; - nranks = 1; - MTestPrintfMsg( 1, "Creating a new intercomm 0-0\n" ); - MPI_Group_incl( oldgroup, nranks, ranks, &newgroup ); - MPI_Comm_create( intercomm, newgroup, &newcomm ); - - /* Make sure that the new communicator has the appropriate pieces */ - if (newcomm != MPI_COMM_NULL) { - int new_rsize, new_size, flag, commok = 1; - - MPI_Comm_set_name( newcomm, (char*)"Single rank in each group" ); - MPI_Comm_test_inter( intercomm, &flag ); - if (!flag) { - errs++; - printf( "[%d] Output communicator is not an intercomm\n", - wrank ); - commok = 0; - } - - MPI_Comm_remote_size( newcomm, &new_rsize ); - MPI_Comm_size( newcomm, &new_size ); - /* The new communicator has 1 process in each group */ - if (new_rsize != 1) { - errs++; - printf( "[%d] Remote size is %d, should be one\n", - wrank, new_rsize ); - commok = 0; - } - if (new_size != 1) { - errs++; - printf( "[%d] Local size is %d, should be one\n", - wrank, new_size ); - commok = 0; - } - /* ... more to do */ - if (commok) { - errs += TestIntercomm( newcomm ); - } - } - MPI_Group_free( &newgroup ); - if (newcomm != MPI_COMM_NULL) { - MPI_Comm_free( &newcomm ); - } - - /* Now, do a sort of dup, using the original group */ - MTestPrintfMsg( 1, "Creating a new intercomm (manual dup)\n" ); - MPI_Comm_create( intercomm, oldgroup, &newcomm ); - MPI_Comm_set_name( newcomm, (char*)"Dup of original" ); - MTestPrintfMsg( 1, "Creating a new intercomm (manual dup (done))\n" ); - - MPI_Comm_compare( intercomm, newcomm, &result ); - MTestPrintfMsg( 1, "Result of comm/intercomm compare is %d\n", result ); - if (result != MPI_CONGRUENT) { - const char *rname=0; - errs++; - switch (result) { - case MPI_IDENT: rname = "IDENT"; break; - case MPI_CONGRUENT: rname = "CONGRUENT"; break; - case MPI_SIMILAR: rname = "SIMILAR"; break; - case MPI_UNEQUAL: rname = "UNEQUAL"; break; - printf( "[%d] Expected MPI_CONGRUENT but saw %d (%s)", - wrank, result, rname ); fflush(stdout); - } - } - else { - /* Try to communication between each member of intercomm */ - errs += TestIntercomm( newcomm ); - } + MPI_Comm_rank(MPI_COMM_WORLD, &wrank); + + while (MTestGetIntercomm(&intercomm, &isLeft, 2)) { + int ranks[10], nranks, result; + + if (intercomm == MPI_COMM_NULL) + continue; + + MPI_Comm_group(intercomm, &oldgroup); + ranks[0] = 0; + nranks = 1; + MTestPrintfMsg(1, "Creating a new intercomm 0-0\n"); + MPI_Group_incl(oldgroup, nranks, ranks, &newgroup); + MPI_Comm_create(intercomm, newgroup, &newcomm); + + /* Make sure that the new communicator has the appropriate pieces */ + if (newcomm != MPI_COMM_NULL) { + int new_rsize, new_size, flag, commok = 1; + + MPI_Comm_set_name(newcomm, (char *) "Single rank in each group"); + MPI_Comm_test_inter(intercomm, &flag); + if (!flag) { + errs++; + printf("[%d] Output communicator is not an intercomm\n", wrank); + commok = 0; + } + + MPI_Comm_remote_size(newcomm, &new_rsize); + MPI_Comm_size(newcomm, &new_size); + /* The new communicator has 1 process in each group */ + if (new_rsize != 1) { + errs++; + printf("[%d] Remote size is %d, should be one\n", wrank, new_rsize); + commok = 0; + } + if (new_size != 1) { + errs++; + printf("[%d] Local size is %d, should be one\n", wrank, new_size); + commok = 0; + } + /* ... more to do */ + if (commok) { + errs += MTestTestComm(newcomm); + } + } + MPI_Group_free(&newgroup); + if (newcomm != MPI_COMM_NULL) { + MPI_Comm_free(&newcomm); + } + + /* Now, do a sort of dup, using the original group */ + MTestPrintfMsg(1, "Creating a new intercomm (manual dup)\n"); + MPI_Comm_create(intercomm, oldgroup, &newcomm); + MPI_Comm_set_name(newcomm, (char *) "Dup of original"); + MTestPrintfMsg(1, "Creating a new intercomm (manual dup (done))\n"); + + MPI_Comm_compare(intercomm, newcomm, &result); + MTestPrintfMsg(1, "Result of comm/intercomm compare is %d\n", result); + if (result != MPI_CONGRUENT) { + const char *rname = 0; + errs++; + switch (result) { + case MPI_IDENT: + rname = "IDENT"; + break; + case MPI_CONGRUENT: + rname = "CONGRUENT"; + break; + case MPI_SIMILAR: + rname = "SIMILAR"; + break; + case MPI_UNEQUAL: + rname = "UNEQUAL"; + break; + printf("[%d] Expected MPI_CONGRUENT but saw %d (%s)", wrank, result, rname); + fflush(stdout); + } + } + else { + /* Try to communication between each member of intercomm */ + errs += MTestTestComm(newcomm); + } if (newcomm != MPI_COMM_NULL) { MPI_Comm_free(&newcomm); @@ -122,15 +124,16 @@ int main( int argc, char *argv[] ) MPI_Comm_create(intercomm, MPI_GROUP_EMPTY, &newcomm); } if (newcomm != MPI_COMM_NULL) { - printf("[%d] expected MPI_COMM_NULL, but got a different communicator\n", wrank); fflush(stdout); + printf("[%d] expected MPI_COMM_NULL, but got a different communicator\n", wrank); + fflush(stdout); errs++; } if (newcomm != MPI_COMM_NULL) { MPI_Comm_free(&newcomm); } - MPI_Group_free( &oldgroup ); - MPI_Comm_free( &intercomm ); + MPI_Group_free(&oldgroup); + MPI_Comm_free(&intercomm); } MTest_Finalize(errs); @@ -139,79 +142,3 @@ int main( int argc, char *argv[] ) return 0; } - -int TestIntercomm( MPI_Comm comm ) -{ - int local_size, remote_size, rank, **bufs, *bufmem, rbuf[2], j; - int errs = 0, wrank, nsize; - char commname[MPI_MAX_OBJECT_NAME+1]; - MPI_Request *reqs; - - MPI_Comm_rank( MPI_COMM_WORLD, &wrank ); - MPI_Comm_size( comm, &local_size ); - MPI_Comm_remote_size( comm, &remote_size ); - MPI_Comm_rank( comm, &rank ); - MPI_Comm_get_name( comm, commname, &nsize ); - - MTestPrintfMsg( 1, "Testing communication on intercomm '%s', remote_size=%d\n", - commname, remote_size ); - - reqs = (MPI_Request *)malloc( remote_size * sizeof(MPI_Request) ); - if (!reqs) { - printf( "[%d] Unable to allocated %d requests for testing intercomm %s\n", - wrank, remote_size, commname ); - errs++; - return errs; - } - bufs = (int **) malloc( remote_size * sizeof(int *) ); - if (!bufs) { - printf( "[%d] Unable to allocated %d int pointers for testing intercomm %s\n", - wrank, remote_size, commname ); - errs++; - return errs; - } - bufmem = (int *) malloc( remote_size * 2 * sizeof(int) ); - if (!bufmem) { - printf( "[%d] Unable to allocated %d int data for testing intercomm %s\n", - wrank, 2*remote_size, commname ); - errs++; - return errs; - } - - /* Each process sends a message containing its own rank and the - rank of the destination with a nonblocking send. Because we're using - nonblocking sends, we need to use different buffers for each isend */ - /* NOTE: the send buffer access restriction was relaxed in MPI-2.2, although - it doesn't really hurt to keep separate buffers for our purposes */ - for (j=0; j