From 8808ddeb7a75657834c56da86b1a1e62a635957c Mon Sep 17 00:00:00 2001 From: degomme Date: Sun, 12 Feb 2017 01:28:48 +0100 Subject: [PATCH] Update topo --- .../smpi/mpich3-test/topo/CMakeLists.txt | 2 +- teshsuite/smpi/mpich3-test/topo/cartcreates.c | 45 +++-- teshsuite/smpi/mpich3-test/topo/cartmap1.c | 54 +++--- teshsuite/smpi/mpich3-test/topo/cartshift1.c | 100 +++++----- teshsuite/smpi/mpich3-test/topo/cartsuball.c | 40 ++-- teshsuite/smpi/mpich3-test/topo/cartzero.c | 111 ++++++----- .../smpi/mpich3-test/topo/dgraph_unwgt.c | 127 ++++++------ teshsuite/smpi/mpich3-test/topo/dims1.c | 178 ++++++++--------- teshsuite/smpi/mpich3-test/topo/dims2.c | 118 ++++++----- teshsuite/smpi/mpich3-test/topo/dims4.c | 2 +- teshsuite/smpi/mpich3-test/topo/dims5.c | 104 ++++++++++ teshsuite/smpi/mpich3-test/topo/distgraph1.c | 183 +++++++++--------- teshsuite/smpi/mpich3-test/topo/graphcr.c | 16 +- teshsuite/smpi/mpich3-test/topo/graphcr2.c | 64 +++--- teshsuite/smpi/mpich3-test/topo/graphmap1.c | 26 +-- teshsuite/smpi/mpich3-test/topo/neighb_coll.c | 39 ++-- teshsuite/smpi/mpich3-test/topo/testlist | 1 + teshsuite/smpi/mpich3-test/topo/topodup.c | 181 +++++++++-------- teshsuite/smpi/mpich3-test/topo/topotest.c | 30 +-- 19 files changed, 752 insertions(+), 669 deletions(-) create mode 100644 teshsuite/smpi/mpich3-test/topo/dims5.c diff --git a/teshsuite/smpi/mpich3-test/topo/CMakeLists.txt b/teshsuite/smpi/mpich3-test/topo/CMakeLists.txt index d132031bc1..d4e98bc26a 100644 --- a/teshsuite/smpi/mpich3-test/topo/CMakeLists.txt +++ b/teshsuite/smpi/mpich3-test/topo/CMakeLists.txt @@ -17,7 +17,7 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite) endforeach() endif() -foreach(file cartcreates cartshift1 cartsuball cartzero cartmap1 dgraph_unwgt dims1 dims2 dims3 dims4 distgraph1 +foreach(file cartcreates cartshift1 cartsuball cartzero cartmap1 dgraph_unwgt dims1 dims2 dims3 dims4 dims5 distgraph1 graphcr2 graphcr graphmap1 neighb_coll topodup topotest) set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${file}.c) endforeach() diff --git a/teshsuite/smpi/mpich3-test/topo/cartcreates.c b/teshsuite/smpi/mpich3-test/topo/cartcreates.c index 92365d7f01..6f1420ad53 100644 --- a/teshsuite/smpi/mpich3-test/topo/cartcreates.c +++ b/teshsuite/smpi/mpich3-test/topo/cartcreates.c @@ -8,45 +8,44 @@ #include #include "mpitest.h" -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int size, rank; int dims[2], periods[2]; MPI_Comm comm; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); /* Create a new cartesian communicator in a subset of the processes */ - MPI_Comm_size( MPI_COMM_WORLD, &size ); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); + MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); if (size < 2) { - fprintf( stderr, "This test needs at least 2 processes\n" ); - MPI_Abort( MPI_COMM_WORLD, 1 ); + fprintf(stderr, "This test needs at least 2 processes\n"); + MPI_Abort(MPI_COMM_WORLD, 1); } - dims[0] = size-1; + dims[0] = size - 1; periods[0] = 1; - MPI_Cart_create( MPI_COMM_WORLD, 1, dims, periods, 0, &comm ); + MPI_Cart_create(MPI_COMM_WORLD, 1, dims, periods, 0, &comm); if (comm != MPI_COMM_NULL) { - int csize; - MPI_Comm_size( comm, &csize ); - if (csize != dims[0]) { - errs++; - fprintf( stderr, - "Sizes is wrong in cart communicator. Is %d, should be %d\n", - csize, dims[0] ); - } - MPI_Barrier( comm ); - - MPI_Comm_free( &comm ); - } + int csize; + MPI_Comm_size(comm, &csize); + if (csize != dims[0]) { + errs++; + fprintf(stderr, + "Sizes is wrong in cart communicator. Is %d, should be %d\n", csize, dims[0]); + } + MPI_Barrier(comm); + + MPI_Comm_free(&comm); + } else if (rank < dims[0]) { - errs++; - fprintf( stderr, "Communicator returned is null!" ); + errs++; + fprintf(stderr, "Communicator returned is null!"); } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); diff --git a/teshsuite/smpi/mpich3-test/topo/cartmap1.c b/teshsuite/smpi/mpich3-test/topo/cartmap1.c index 1ce5ad8d89..30d1c56b02 100644 --- a/teshsuite/smpi/mpich3-test/topo/cartmap1.c +++ b/teshsuite/smpi/mpich3-test/topo/cartmap1.c @@ -8,57 +8,57 @@ #include #include "mpitest.h" -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int dims[2]; int periods[2]; int size, rank, newrank; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); + + MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size( MPI_COMM_WORLD, &size ); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); - /* This defines a one dimensional cartision grid with a single point */ periods[0] = 1; dims[0] = 1; - MPI_Cart_map( MPI_COMM_WORLD, 1, dims, periods, &newrank ); + MPI_Cart_map(MPI_COMM_WORLD, 1, dims, periods, &newrank); if (rank > 0) { - if (newrank != MPI_UNDEFINED) { - errs++; - printf( "rank outside of input communicator not UNDEFINED\n" ); - } + if (newrank != MPI_UNDEFINED) { + errs++; + printf("rank outside of input communicator not UNDEFINED\n"); + } } else { - if (rank != newrank) { - errs++; - printf( "Newrank not defined and should be 0\n" ); - } + if (rank != newrank) { + errs++; + printf("Newrank not defined and should be 0\n"); + } } /* As of MPI 2.1, a 0-dimensional topology is valid (its also a - point) */ - MPI_Cart_map( MPI_COMM_WORLD, 0, dims, periods, &newrank ); + * point) */ + MPI_Cart_map(MPI_COMM_WORLD, 0, dims, periods, &newrank); if (rank > 0) { - if (newrank != MPI_UNDEFINED) { - errs++; - printf( "rank outside of input communicator not UNDEFINED\n" ); - } + if (newrank != MPI_UNDEFINED) { + errs++; + printf("rank outside of input communicator not UNDEFINED\n"); + } } else { - /* rank == 0 */ - if (rank != newrank) { - errs++; - printf( "Newrank not defined and should be 0\n" ); - } + /* rank == 0 */ + if (rank != newrank) { + errs++; + printf("Newrank not defined and should be 0\n"); + } } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; - + } diff --git a/teshsuite/smpi/mpich3-test/topo/cartshift1.c b/teshsuite/smpi/mpich3-test/topo/cartshift1.c index 679f12c18c..5416b3743d 100644 --- a/teshsuite/smpi/mpich3-test/topo/cartshift1.c +++ b/teshsuite/smpi/mpich3-test/topo/cartshift1.c @@ -8,7 +8,7 @@ #include #include "mpitest.h" -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int size, rank; @@ -16,81 +16,77 @@ int main( int argc, char *argv[] ) int dims[2], periods[2]; MPI_Comm comm; - MTest_Init( &argc, &argv ); - - MPI_Comm_size( MPI_COMM_WORLD, &size ); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); - dims[0] = size; + MTest_Init(&argc, &argv); + + MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + dims[0] = size; periods[0] = 1; - MPI_Cart_create( MPI_COMM_WORLD, 1, dims, periods, 0, &comm ); - MPI_Cart_shift( comm, 0, 1, &source, &dest ); + MPI_Cart_create(MPI_COMM_WORLD, 1, dims, periods, 0, &comm); + MPI_Cart_shift(comm, 0, 1, &source, &dest); if (source != ((rank - 1 + size) % size)) { - errs++; - printf( "source for shift 1 is %d\n", source ); + errs++; + printf("source for shift 1 is %d\n", source); } if (dest != ((rank + 1) % size)) { - errs++; - printf( "dest for shift 1 is %d\n", dest ); + errs++; + printf("dest for shift 1 is %d\n", dest); } - MPI_Cart_shift( comm, 0, 0, &source, &dest ); + MPI_Cart_shift(comm, 0, 0, &source, &dest); if (source != rank) { - errs++; - printf( "Source for shift 0 is %d\n", source ); + errs++; + printf("Source for shift 0 is %d\n", source); } if (dest != rank) { - errs++; - printf( "Dest for shift 0 is %d\n", dest ); + errs++; + printf("Dest for shift 0 is %d\n", dest); } - MPI_Cart_shift( comm, 0, -1, &source, &dest ); + MPI_Cart_shift(comm, 0, -1, &source, &dest); if (source != ((rank + 1) % size)) { - errs++; - printf( "source for shift -1 is %d\n", source ); + errs++; + printf("source for shift -1 is %d\n", source); } if (dest != ((rank - 1 + size) % size)) { - errs++; - printf( "dest for shift -1 is %d\n", dest ); + errs++; + printf("dest for shift -1 is %d\n", dest); } /* Now, with non-periodic */ - MPI_Comm_free( &comm ); + MPI_Comm_free(&comm); periods[0] = 0; - MPI_Cart_create( MPI_COMM_WORLD, 1, dims, periods, 0, &comm ); - MPI_Cart_shift( comm, 0, 1, &source, &dest ); - if ((rank > 0 && source != (rank - 1)) || - (rank == 0 && source != MPI_PROC_NULL)) { - errs++; - printf( "source for non-periodic shift 1 is %d\n", source ); + MPI_Cart_create(MPI_COMM_WORLD, 1, dims, periods, 0, &comm); + MPI_Cart_shift(comm, 0, 1, &source, &dest); + if ((rank > 0 && source != (rank - 1)) || (rank == 0 && source != MPI_PROC_NULL)) { + errs++; + printf("source for non-periodic shift 1 is %d\n", source); } - if ((rank < size-1 && dest != rank + 1) || - ((rank == size-1) && dest != MPI_PROC_NULL)) { - errs++; - printf( "dest for non-periodic shift 1 is %d\n", dest ); + if ((rank < size - 1 && dest != rank + 1) || ((rank == size - 1) && dest != MPI_PROC_NULL)) { + errs++; + printf("dest for non-periodic shift 1 is %d\n", dest); } - MPI_Cart_shift( comm, 0, 0, &source, &dest ); + MPI_Cart_shift(comm, 0, 0, &source, &dest); if (source != rank) { - errs++; - printf( "Source for non-periodic shift 0 is %d\n", source ); + errs++; + printf("Source for non-periodic shift 0 is %d\n", source); } if (dest != rank) { - errs++; - printf( "Dest for non-periodic shift 0 is %d\n", dest ); + errs++; + printf("Dest for non-periodic shift 0 is %d\n", dest); } - MPI_Cart_shift( comm, 0, -1, &source, &dest ); - if ((rank < size - 1 && source != rank + 1) || - (rank == size - 1 && source != MPI_PROC_NULL)) { - - errs++; - printf( "source for non-periodic shift -1 is %d\n", source ); + MPI_Cart_shift(comm, 0, -1, &source, &dest); + if ((rank < size - 1 && source != rank + 1) || (rank == size - 1 && source != MPI_PROC_NULL)) { + + errs++; + printf("source for non-periodic shift -1 is %d\n", source); } - if ((rank > 0 && dest != rank - 1) || - (rank == 0 && dest != MPI_PROC_NULL)) { - errs++; - printf( "dest for non-periodic shift -1 is %d\n", dest ); + if ((rank > 0 && dest != rank - 1) || (rank == 0 && dest != MPI_PROC_NULL)) { + errs++; + printf("dest for non-periodic shift -1 is %d\n", dest); } - MPI_Comm_free( &comm ); - - MTest_Finalize( errs ); + MPI_Comm_free(&comm); + + MTest_Finalize(errs); MPI_Finalize(); return 0; - + } diff --git a/teshsuite/smpi/mpich3-test/topo/cartsuball.c b/teshsuite/smpi/mpich3-test/topo/cartsuball.c index 890db5a633..5f817994a4 100644 --- a/teshsuite/smpi/mpich3-test/topo/cartsuball.c +++ b/teshsuite/smpi/mpich3-test/topo/cartsuball.c @@ -8,47 +8,47 @@ #include #include "mpitest.h" -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int size, dims[2], periods[2], remain[2]; int result, rank; MPI_Comm comm, newcomm; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); /* First, create a 1-dim cartesian communicator */ periods[0] = 0; - MPI_Comm_size( MPI_COMM_WORLD, &size ); + MPI_Comm_size(MPI_COMM_WORLD, &size); dims[0] = size; - MPI_Cart_create( MPI_COMM_WORLD, 1, dims, periods, 0, &comm ); - + MPI_Cart_create(MPI_COMM_WORLD, 1, dims, periods, 0, &comm); + /* Now, extract a communicator with no dimensions */ remain[0] = 0; - MPI_Cart_sub( comm, remain, &newcomm ); + MPI_Cart_sub(comm, remain, &newcomm); MPI_Comm_rank(comm, &rank); if (rank == 0) { - /* This should be congruent to MPI_COMM_SELF */ - MPI_Comm_compare( MPI_COMM_SELF, newcomm, &result ); - if (result != MPI_CONGRUENT) { - errs++; - printf( "cart sub to size 0 did not give self\n" ); - } - MPI_Comm_free( &newcomm ); + /* This should be congruent to MPI_COMM_SELF */ + MPI_Comm_compare(MPI_COMM_SELF, newcomm, &result); + if (result != MPI_CONGRUENT) { + errs++; + printf("cart sub to size 0 did not give self\n"); + } + MPI_Comm_free(&newcomm); } else if (newcomm != MPI_COMM_NULL) { - errs++; - printf( "cart sub to size 0 did not give null\n" ); + errs++; + printf("cart sub to size 0 did not give null\n"); } /* Free the new communicator so that storage leak tests will - be happy */ - MPI_Comm_free( &comm ); - - MTest_Finalize( errs ); + * be happy */ + MPI_Comm_free(&comm); + + MTest_Finalize(errs); MPI_Finalize(); return 0; - + } diff --git a/teshsuite/smpi/mpich3-test/topo/cartzero.c b/teshsuite/smpi/mpich3-test/topo/cartzero.c index c8e601ee3e..370947fa1f 100644 --- a/teshsuite/smpi/mpich3-test/topo/cartzero.c +++ b/teshsuite/smpi/mpich3-test/topo/cartzero.c @@ -8,83 +8,80 @@ #include #include "mpitest.h" -/* +/* Check that the MPI implementation properly handles zero-dimensional Cartesian communicators - the original standard implies that these - should be consistent with higher dimensional topologies and thus + should be consistent with higher dimensional topologies and thus these should work with any MPI implementation. MPI 2.1 made this requirement explicit. */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int size, rank, ndims; MPI_Comm comm, newcomm; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); /* Create a new cartesian communicator in a subset of the processes */ - MPI_Comm_size( MPI_COMM_WORLD, &size ); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); + MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); if (size < 2) { - fprintf( stderr, "This test needs at least 2 processes\n" ); - MPI_Abort( MPI_COMM_WORLD, 1 ); + fprintf(stderr, "This test needs at least 2 processes\n"); + MPI_Abort(MPI_COMM_WORLD, 1); } - MPI_Cart_create( MPI_COMM_WORLD, 0, NULL, NULL, 0, &comm ); + MPI_Cart_create(MPI_COMM_WORLD, 0, NULL, NULL, 0, &comm); if (comm != MPI_COMM_NULL) { - int csize; - MPI_Comm_size( comm, &csize ); - if (csize != 1) { - errs++; - fprintf( stderr, - "Sizes is wrong in cart communicator. Is %d, should be 1\n", - csize ); - } - - /* This function is not meaningful, but should not fail */ - MPI_Dims_create(1, 0, NULL); - - ndims = -1; - MPI_Cartdim_get(comm, &ndims); - if (ndims != 0) { - errs++; - fprintf(stderr, "MPI_Cartdim_get: ndims is %d, should be 0\n", ndims); - } - - /* this function should not fail */ - MPI_Cart_get(comm, 0, NULL, NULL, NULL); - - MPI_Cart_rank(comm, NULL, &rank); - if (rank != 0) { - errs++; - fprintf(stderr, "MPI_Cart_rank: rank is %d, should be 0\n", rank); - } - - /* this function should not fail */ - MPI_Cart_coords(comm, 0, 0, NULL); - - MPI_Cart_sub(comm, NULL, &newcomm); - ndims = -1; - MPI_Cartdim_get(newcomm, &ndims); - if (ndims != 0) { - errs++; - fprintf(stderr, - "MPI_Cart_sub did not return zero-dimensional communicator\n"); - } - - MPI_Barrier( comm ); - - MPI_Comm_free( &comm ); - MPI_Comm_free( &newcomm ); - } + int csize; + MPI_Comm_size(comm, &csize); + if (csize != 1) { + errs++; + fprintf(stderr, "Sizes is wrong in cart communicator. Is %d, should be 1\n", csize); + } + + /* This function is not meaningful, but should not fail */ + MPI_Dims_create(1, 0, NULL); + + ndims = -1; + MPI_Cartdim_get(comm, &ndims); + if (ndims != 0) { + errs++; + fprintf(stderr, "MPI_Cartdim_get: ndims is %d, should be 0\n", ndims); + } + + /* this function should not fail */ + MPI_Cart_get(comm, 0, NULL, NULL, NULL); + + MPI_Cart_rank(comm, NULL, &rank); + if (rank != 0) { + errs++; + fprintf(stderr, "MPI_Cart_rank: rank is %d, should be 0\n", rank); + } + + /* this function should not fail */ + MPI_Cart_coords(comm, 0, 0, NULL); + + MPI_Cart_sub(comm, NULL, &newcomm); + ndims = -1; + MPI_Cartdim_get(newcomm, &ndims); + if (ndims != 0) { + errs++; + fprintf(stderr, "MPI_Cart_sub did not return zero-dimensional communicator\n"); + } + + MPI_Barrier(comm); + + MPI_Comm_free(&comm); + MPI_Comm_free(&newcomm); + } else if (rank == 0) { - errs++; - fprintf( stderr, "Communicator returned is null!" ); + errs++; + fprintf(stderr, "Communicator returned is null!"); } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); diff --git a/teshsuite/smpi/mpich3-test/topo/dgraph_unwgt.c b/teshsuite/smpi/mpich3-test/topo/dgraph_unwgt.c index 0f31e2c999..bda35700d9 100644 --- a/teshsuite/smpi/mpich3-test/topo/dgraph_unwgt.c +++ b/teshsuite/smpi/mpich3-test/topo/dgraph_unwgt.c @@ -15,27 +15,26 @@ static int validate_dgraph(MPI_Comm dgraph_comm) { - int comm_topo; - int src_sz, dest_sz; - int wgt_flag, ierr; - int srcs[RING_NUM_NEIGHBORS], dests[RING_NUM_NEIGHBORS]; - int *src_wgts, *dest_wgts; + int comm_topo; + int src_sz, dest_sz; + int wgt_flag, ierr; + int srcs[RING_NUM_NEIGHBORS], dests[RING_NUM_NEIGHBORS]; + int *src_wgts, *dest_wgts; - int world_rank, world_size; - int idx, nbr_sep; + int world_rank, world_size; + int idx, nbr_sep; comm_topo = MPI_UNDEFINED; MPI_Topo_test(dgraph_comm, &comm_topo); switch (comm_topo) { - case MPI_DIST_GRAPH : - break; - default: - fprintf(stderr, "dgraph_comm is NOT of type MPI_DIST_GRAPH\n"); - return 0; + case MPI_DIST_GRAPH: + break; + default: + fprintf(stderr, "dgraph_comm is NOT of type MPI_DIST_GRAPH\n"); + return 0; } - ierr = MPI_Dist_graph_neighbors_count(dgraph_comm, - &src_sz, &dest_sz, &wgt_flag); + ierr = MPI_Dist_graph_neighbors_count(dgraph_comm, &src_sz, &dest_sz, &wgt_flag); if (ierr != MPI_SUCCESS) { fprintf(stderr, "MPI_Dist_graph_neighbors_count() fails!\n"); return 0; @@ -55,22 +54,20 @@ static int validate_dgraph(MPI_Comm dgraph_comm) */ if (src_sz != RING_NUM_NEIGHBORS || dest_sz != RING_NUM_NEIGHBORS) { fprintf(stderr, "source or destination edge array is not of size %d.\n", - RING_NUM_NEIGHBORS); + RING_NUM_NEIGHBORS); fprintf(stderr, "src_sz = %d, dest_sz = %d\n", src_sz, dest_sz); return 0; } /* - src_wgts and dest_wgts could be anything, e.g. NULL, since - MPI_Dist_graph_neighbors_count() returns MPI_UNWEIGHTED. - Since this program has a Fortran77 version, and standard Fortran77 - has no pointer and NULL, so use MPI_UNWEIGHTED for the weighted arrays. - */ - src_wgts = MPI_UNWEIGHTED; + * src_wgts and dest_wgts could be anything, e.g. NULL, since + * MPI_Dist_graph_neighbors_count() returns MPI_UNWEIGHTED. + * Since this program has a Fortran77 version, and standard Fortran77 + * has no pointer and NULL, so use MPI_UNWEIGHTED for the weighted arrays. + */ + src_wgts = MPI_UNWEIGHTED; dest_wgts = MPI_UNWEIGHTED; - ierr = MPI_Dist_graph_neighbors(dgraph_comm, - src_sz, srcs, src_wgts, - dest_sz, dests, dest_wgts); + ierr = MPI_Dist_graph_neighbors(dgraph_comm, src_sz, srcs, src_wgts, dest_sz, dests, dest_wgts); if (ierr != MPI_SUCCESS) { fprintf(stderr, "MPI_Dist_graph_neighbors() fails!\n"); return 0; @@ -81,92 +78,90 @@ static int validate_dgraph(MPI_Comm dgraph_comm) */ /* - Check if the neighbors returned from MPI are really - the nearest neighbors within a ring. - */ + * Check if the neighbors returned from MPI are really + * the nearest neighbors within a ring. + */ MPI_Comm_size(MPI_COMM_WORLD, &world_size); MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); - - for (idx=0; idx < src_sz; idx++) { + + for (idx = 0; idx < src_sz; idx++) { nbr_sep = abs(srcs[idx] - world_rank); - if ( nbr_sep != 1 && nbr_sep != (world_size-1) ) { + if (nbr_sep != 1 && nbr_sep != (world_size - 1)) { fprintf(stderr, "srcs[%d]=%d is NOT a neighbor of my rank %d.\n", - idx, srcs[idx], world_rank); + idx, srcs[idx], world_rank); return 0; - } + } } - for (idx=0; idx < dest_sz; idx++) { + for (idx = 0; idx < dest_sz; idx++) { nbr_sep = abs(dests[idx] - world_rank); - if ( nbr_sep != 1 && nbr_sep != (world_size-1) ) { + if (nbr_sep != 1 && nbr_sep != (world_size - 1)) { fprintf(stderr, "dests[%d]=%d is NOT a neighbor of my rank %d.\n", - idx, dests[idx], world_rank); + idx, dests[idx], world_rank); return 0; - } + } } /* - fprintf(stderr, "dgraph_comm is of type MPI_DIST_GRAPH " - "of a bidirectional ring.\n"); - */ + * fprintf(stderr, "dgraph_comm is of type MPI_DIST_GRAPH " + * "of a bidirectional ring.\n"); + */ return 1; } /* Specify a distributed graph of a bidirectional ring of the MPI_COMM_WORLD, - i.e. everyone only talks to left and right neighbors. + i.e. everyone only talks to left and right neighbors. */ int main(int argc, char *argv[]) { - MPI_Comm dgraph_comm; - int world_size, world_rank, ierr; - int errs = 0; - - int src_sz, dest_sz; - int degs[1]; - int srcs[RING_NUM_NEIGHBORS], dests[RING_NUM_NEIGHBORS]; - + MPI_Comm dgraph_comm; + int world_size, world_rank, ierr; + int errs = 0; + + int src_sz, dest_sz; + int degs[1]; + int srcs[RING_NUM_NEIGHBORS], dests[RING_NUM_NEIGHBORS]; + MTest_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &world_size); MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); - degs[0] = 2; - srcs[0] = world_rank; - dests[0] = world_rank-1 < 0 ? world_size-1 : world_rank-1 ; - dests[1] = world_rank+1 >= world_size ? 0 : world_rank+1 ; + degs[0] = 2; + srcs[0] = world_rank; + dests[0] = world_rank - 1 < 0 ? world_size - 1 : world_rank - 1; + dests[1] = world_rank + 1 >= world_size ? 0 : world_rank + 1; ierr = MPI_Dist_graph_create(MPI_COMM_WORLD, 1, srcs, degs, dests, - MPI_UNWEIGHTED, MPI_INFO_NULL, 1, - &dgraph_comm); - if ( ierr != MPI_SUCCESS ) { + MPI_UNWEIGHTED, MPI_INFO_NULL, 1, &dgraph_comm); + if (ierr != MPI_SUCCESS) { fprintf(stderr, "MPI_Dist_graph_create() fails!\n"); MPI_Abort(MPI_COMM_WORLD, 1); return 1; } if (!validate_dgraph(dgraph_comm)) { - fprintf(stderr, "MPI_Dist_graph_create() does NOT create " - "a bidirectional ring graph!\n"); + fprintf(stderr, "MPI_Dist_graph_create() does NOT create " "a bidirectional ring graph!\n"); MPI_Abort(MPI_COMM_WORLD, 1); return 1; } MPI_Comm_free(&dgraph_comm); - - src_sz = 2; - srcs[0] = world_rank-1 < 0 ? world_size-1 : world_rank-1 ; - srcs[1] = world_rank+1 >= world_size ? 0 : world_rank+1 ; - dest_sz = 2; - dests[0] = world_rank-1 < 0 ? world_size-1 : world_rank-1 ; - dests[1] = world_rank+1 >= world_size ? 0 : world_rank+1 ; + + src_sz = 2; + srcs[0] = world_rank - 1 < 0 ? world_size - 1 : world_rank - 1; + srcs[1] = world_rank + 1 >= world_size ? 0 : world_rank + 1; + dest_sz = 2; + dests[0] = world_rank - 1 < 0 ? world_size - 1 : world_rank - 1; + dests[1] = world_rank + 1 >= world_size ? 0 : world_rank + 1; ierr = MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, src_sz, srcs, MPI_UNWEIGHTED, dest_sz, dests, MPI_UNWEIGHTED, MPI_INFO_NULL, 1, &dgraph_comm); - if ( ierr != MPI_SUCCESS ) { + if (ierr != MPI_SUCCESS) { fprintf(stderr, "MPI_Dist_graph_create_adjacent() fails!\n"); MPI_Abort(MPI_COMM_WORLD, 1); return 1; } if (!validate_dgraph(dgraph_comm)) { fprintf(stderr, "MPI_Dist_graph_create_adjacent() does NOT create " - "a bidirectional ring graph!\n"); + "a bidirectional ring graph!\n"); MPI_Abort(MPI_COMM_WORLD, 1); return 1; } diff --git a/teshsuite/smpi/mpich3-test/topo/dims1.c b/teshsuite/smpi/mpich3-test/topo/dims1.c index b429776470..329be95c52 100644 --- a/teshsuite/smpi/mpich3-test/topo/dims1.c +++ b/teshsuite/smpi/mpich3-test/topo/dims1.c @@ -7,138 +7,132 @@ #include #include "mpitest.h" -int prodof( int ndims, const int dims[] ); -int increasing( int ndims, const int dims[] ); +int prodof(int ndims, const int dims[]); +int increasing(int ndims, const int dims[]); -int prodof( int ndims, const int dims[] ) +int prodof(int ndims, const int dims[]) { - int i, prod=1; - for (i=0; i dims[i-1]) { - printf ("%d = dims[%d] > dims[%d] = %d\n", dims[i], i, - i-1, dims[i-1] ); - err = 1; - } + int i, err = 0; + for (i = 1; i < ndims; i++) { + if (dims[i] > dims[i - 1]) { + printf("%d = dims[%d] > dims[%d] = %d\n", dims[i], i, i - 1, dims[i - 1]); + err = 1; + } } return err; } -int main( int argc, char *argv[] ) + +int main(int argc, char *argv[]) { int errs = 0; int dims[4], nnodes, ndims; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - /* Test multiple dims create values. For each, make sure that the - product of dims is the number of input nodes */ - nnodes = 2*3*5*7*11; - ndims = 2; + /* Test multiple dims create values. For each, make sure that the + * product of dims is the number of input nodes */ + nnodes = 2 * 3 * 5 * 7 * 11; + ndims = 2; dims[0] = dims[1] = 0; - MPI_Dims_create( nnodes, ndims, dims ); - if (prodof(ndims,dims) != nnodes) { - errs++; - printf( "dims create returned the wrong decomposition for %d in %d dims\n", - nnodes, ndims ); + MPI_Dims_create(nnodes, ndims, dims); + if (prodof(ndims, dims) != nnodes) { + errs++; + printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims); } - if (increasing( ndims, dims )) { - errs++; - printf( "dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n" ); - printf( "dims create returned the wrong decomposition for %d in %d dims\n", - nnodes, ndims ); + if (increasing(ndims, dims)) { + errs++; + printf + ("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n"); + printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims); } - /* Test multiple dims create values. For each, make sure that the - product of dims is the number of input nodes */ - nnodes = 2*7; - ndims = 2; + /* Test multiple dims create values. For each, make sure that the + * product of dims is the number of input nodes */ + nnodes = 2 * 7; + ndims = 2; dims[0] = dims[1] = 0; - MPI_Dims_create( nnodes, ndims, dims ); - if (prodof(ndims,dims) != nnodes) { - errs++; - printf( "dims create returned the wrong decomposition for %d in %d dims\n", - nnodes, ndims ); + MPI_Dims_create(nnodes, ndims, dims); + if (prodof(ndims, dims) != nnodes) { + errs++; + printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims); } - if (increasing( ndims, dims )) { - errs++; - printf( "dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n" ); - printf( "dims create returned the wrong decomposition for %d in %d dims\n", - nnodes, ndims ); + if (increasing(ndims, dims)) { + errs++; + printf + ("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n"); + printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims); } - nnodes = 2*2*3*3*5*7*11; - ndims = 2; + nnodes = 2 * 2 * 3 * 3 * 5 * 7 * 11; + ndims = 2; dims[0] = dims[1] = 0; - MPI_Dims_create( nnodes, ndims, dims ); - if (prodof(ndims,dims) != nnodes) { - errs++; - printf( "dims create returned the wrong decomposition for %d in %d dims\n", - nnodes, ndims ); + MPI_Dims_create(nnodes, ndims, dims); + if (prodof(ndims, dims) != nnodes) { + errs++; + printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims); } - if (increasing( ndims, dims )) { - errs++; - printf( "dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n" ); - printf( "dims create returned the wrong decomposition for %d in %d dims\n", - nnodes, ndims ); + if (increasing(ndims, dims)) { + errs++; + printf + ("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n"); + printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims); } nnodes = 11; - ndims = 2; + ndims = 2; dims[0] = dims[1] = 0; - MPI_Dims_create( nnodes, ndims, dims ); - if (prodof(ndims,dims) != nnodes) { - errs++; - printf( "dims create returned the wrong decomposition for %d in %d dims\n", - nnodes, ndims ); + MPI_Dims_create(nnodes, ndims, dims); + if (prodof(ndims, dims) != nnodes) { + errs++; + printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims); } - if (increasing( ndims, dims )) { - errs++; - printf( "dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n" ); - printf( "dims create returned the wrong decomposition for %d in %d dims\n", - nnodes, ndims ); + if (increasing(ndims, dims)) { + errs++; + printf + ("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n"); + printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims); } - nnodes = 5*7*11; - ndims = 4; + nnodes = 5 * 7 * 11; + ndims = 4; dims[0] = dims[1] = dims[2] = dims[3] = 0; - MPI_Dims_create( nnodes, ndims, dims ); - if (prodof(ndims,dims) != nnodes) { - errs++; - printf( "dims create returned the wrong decomposition for %d in %d dims\n", - nnodes, ndims ); + MPI_Dims_create(nnodes, ndims, dims); + if (prodof(ndims, dims) != nnodes) { + errs++; + printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims); } - if (increasing( ndims, dims )) { - errs++; - printf( "dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n" ); - printf( "dims create returned the wrong decomposition for %d in %d dims\n", - nnodes, ndims ); + if (increasing(ndims, dims)) { + errs++; + printf + ("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n"); + printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims); } nnodes = 64; - ndims = 4; + ndims = 4; dims[0] = dims[1] = dims[2] = dims[3] = 0; - MPI_Dims_create( nnodes, ndims, dims ); - if (prodof(ndims,dims) != nnodes) { - errs++; - printf( "dims create returned the wrong decomposition for %d in %d dims\n", - nnodes, ndims ); + MPI_Dims_create(nnodes, ndims, dims); + if (prodof(ndims, dims) != nnodes) { + errs++; + printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims); } - if (increasing( ndims, dims )) { - errs++; - printf( "dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n" ); - printf( "dims create returned the wrong decomposition for %d in %d dims\n", - nnodes, ndims ); + if (increasing(ndims, dims)) { + errs++; + printf + ("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n"); + printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims); } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; - + } diff --git a/teshsuite/smpi/mpich3-test/topo/dims2.c b/teshsuite/smpi/mpich3-test/topo/dims2.c index aa453eb89a..b4cbecf099 100644 --- a/teshsuite/smpi/mpich3-test/topo/dims2.c +++ b/teshsuite/smpi/mpich3-test/topo/dims2.c @@ -7,87 +7,83 @@ #include #include "mpitest.h" -int prodof( int, const int[] ); +int prodof(int, const int[]); /* * Test edge cases of Dims_create */ -int prodof( int ndims, const int dims[] ) +int prodof(int ndims, const int dims[]) { - int i, prod=1; - for (i=0; i +#include "mpitest.h" + +/* + * Test MPI_Dims_create and the choice of decompositions. These should match + * the definition in MPI, which wants a "balanced" decomposition. There + * is some ambiguity in the definition, so this test attempts to deal with + * that. + */ +#define MAX_DIMS 20 + +typedef struct { + int size, dim; + int orderedDecomp[MAX_DIMS]; +} DimsTestVal_t; + +/* MPI 3.1, page 293, line 31, output values of Dims_create are in + non-increasing order */ +DimsTestVal_t tests[] = { +#include "baddims.h" + }; + +/* Forward refs */ +void zeroDims(int, int []); +int checkDims(DimsTestVal_t *, const int []); +int compareDims(int, const int[], const int[], int); + +int main(int argc, char *argv[]) +{ + int i, k, wrank, errs = 0; + int dims[MAX_DIMS]; + + MTest_Init(0, 0); + MPI_Comm_rank(MPI_COMM_WORLD, &wrank); + + if (wrank == 0) { + + for (k=0; tests[k].size > 0; k++) { + zeroDims(tests[k].dim, dims); + MPI_Dims_create(tests[k].size, tests[k].dim, dims); + if (checkDims(&tests[k], dims)) { + errs++; + MTestPrintfMsg(1, "Test %d failed with mismatched output", k); + if (errs < 10) { + fprintf(stderr, "%d in %dd: ", tests[k].size, tests[k].dim); + for (i=0; idim; k++) { + if (dims[k] != test->orderedDecomp[k]) { + errs ++; + } + } + return errs; +} + +int compareDims(int dim, const int d1[], const int d2[], int isweak) +{ + int diff = 0, k; + if (isweak) { + diff = d1[0] - d1[dim-1] - (d2[0] - d2[dim-1]); + if (diff < 0) diff = - diff; + } + else { + for (k=0; k= 3 if (rank == 0) { - MTestPrintfMsg( 1, "testing MPI_Dist_graph_create w/ no graph\n" ); + MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ no graph\n"); } for (reorder = 0; reorder <= 1; reorder++) { MPI_Dist_graph_create(MPI_COMM_WORLD, 0, sources, degrees, destinations, MPI_WEIGHTS_EMPTY, MPI_INFO_NULL, reorder, &comm); MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted); if (!check_weighted) { - fprintf(stderr, "expected weighted == TRUE for the \"no graph -- MPI_WEIGHTS_EMPTY\" case\n"); + fprintf(stderr, + "expected weighted == TRUE for the \"no graph -- MPI_WEIGHTS_EMPTY\" case\n"); ++errs; } MPI_Comm_free(&comm); @@ -448,8 +452,7 @@ int main(int argc, char *argv[]) /* MPI_Dist_graph_create() with no graph -- passing NULLs instead */ if (rank == 0) { - MTestPrintfMsg( 1, - "testing MPI_Dist_graph_create w/ no graph -- NULLs\n" ); + MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ no graph -- NULLs\n"); } for (reorder = 0; reorder <= 1; reorder++) { MPI_Dist_graph_create(MPI_COMM_WORLD, 0, NULL, NULL, @@ -467,8 +470,7 @@ int main(int argc, char *argv[]) /* MPI_Dist_graph_create() with no graph -- passing NULLs+MPI_UNWEIGHTED instead */ if (rank == 0) { - MTestPrintfMsg( 1, - "testing MPI_Dist_graph_create w/ no graph -- NULLs+MPI_UNWEIGHTED\n" ); + MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ no graph -- NULLs+MPI_UNWEIGHTED\n"); } for (reorder = 0; reorder <= 1; reorder++) { MPI_Dist_graph_create(MPI_COMM_WORLD, 0, NULL, NULL, @@ -477,7 +479,8 @@ int main(int argc, char *argv[]) /* ambiguous if they are equal, only check when they are distinct values. */ if (MPI_UNWEIGHTED != NULL) { if (check_weighted) { - fprintf(stderr, "expected weighted == FALSE for the \"no graph -- NULLs+MPI_UNWEIGHTED\" case\n"); + fprintf(stderr, + "expected weighted == FALSE for the \"no graph -- NULLs+MPI_UNWEIGHTED\" case\n"); ++errs; } } @@ -486,12 +489,11 @@ int main(int argc, char *argv[]) /* MPI_Dist_graph_create_adjacent() with no graph */ if (rank == 0) { - MTestPrintfMsg( 1, - "testing MPI_Dist_graph_create_adjacent w/ no graph\n" ); + MTestPrintfMsg(1, "testing MPI_Dist_graph_create_adjacent w/ no graph\n"); } for (reorder = 0; reorder <= 1; reorder++) { MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, 0, sources, sweights, - 0, destinations, dweights, MPI_INFO_NULL, reorder, &comm); + 0, destinations, dweights, MPI_INFO_NULL, reorder, &comm); MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted); if (!check_weighted) { fprintf(stderr, "expected weighted == TRUE for the \"no graph\" case\n"); @@ -501,20 +503,22 @@ int main(int argc, char *argv[]) } /* MPI_Dist_graph_create_adjacent() with no graph -- passing MPI_WEIGHTS_EMPTY instead */ - /* NOTE that MPI_WEIGHTS_EMPTY was added in MPI-3 and does not - appear before then. This part of the test thus requires a check - on the MPI major version */ + /* NOTE that MPI_WEIGHTS_EMPTY was added in MPI-3 and does not + * appear before then. This part of the test thus requires a check + * on the MPI major version */ #if MPI_VERSION >= 3 if (rank == 0) { - MTestPrintfMsg( 1, - "testing MPI_Dist_graph_create_adjacent w/ no graph -- MPI_WEIGHTS_EMPTY\n" ); + MTestPrintfMsg(1, + "testing MPI_Dist_graph_create_adjacent w/ no graph -- MPI_WEIGHTS_EMPTY\n"); } for (reorder = 0; reorder <= 1; reorder++) { MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, 0, sources, MPI_WEIGHTS_EMPTY, - 0, destinations, MPI_WEIGHTS_EMPTY, MPI_INFO_NULL, reorder, &comm); + 0, destinations, MPI_WEIGHTS_EMPTY, MPI_INFO_NULL, reorder, + &comm); MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted); if (!check_weighted) { - fprintf(stderr, "expected weighted == TRUE for the \"no graph -- MPI_WEIGHTS_EMPTY\" case\n"); + fprintf(stderr, + "expected weighted == TRUE for the \"no graph -- MPI_WEIGHTS_EMPTY\" case\n"); ++errs; } MPI_Comm_free(&comm); @@ -523,12 +527,11 @@ int main(int argc, char *argv[]) /* MPI_Dist_graph_create_adjacent() with no graph -- passing NULLs instead */ if (rank == 0) { - MTestPrintfMsg( 1, - "testing MPI_Dist_graph_create_adjacent w/ no graph -- NULLs\n" ); + MTestPrintfMsg(1, "testing MPI_Dist_graph_create_adjacent w/ no graph -- NULLs\n"); } for (reorder = 0; reorder <= 1; reorder++) { MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, 0, NULL, NULL, - 0, NULL, NULL, MPI_INFO_NULL, reorder, &comm); + 0, NULL, NULL, MPI_INFO_NULL, reorder, &comm); MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted); /* ambiguous if they are equal, only check when they are distinct values. */ if (MPI_UNWEIGHTED != NULL) { @@ -542,17 +545,18 @@ int main(int argc, char *argv[]) /* MPI_Dist_graph_create_adjacent() with no graph -- passing NULLs+MPI_UNWEIGHTED instead */ if (rank == 0) { - MTestPrintfMsg( 1, -"testing MPI_Dist_graph_create_adjacent w/ no graph -- NULLs+MPI_UNWEIGHTED\n"); + MTestPrintfMsg(1, + "testing MPI_Dist_graph_create_adjacent w/ no graph -- NULLs+MPI_UNWEIGHTED\n"); } for (reorder = 0; reorder <= 1; reorder++) { MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, 0, NULL, MPI_UNWEIGHTED, - 0, NULL, MPI_UNWEIGHTED, MPI_INFO_NULL, reorder, &comm); + 0, NULL, MPI_UNWEIGHTED, MPI_INFO_NULL, reorder, &comm); MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted); /* ambiguous if they are equal, only check when they are distinct values. */ if (MPI_UNWEIGHTED != NULL) { if (check_weighted) { - fprintf(stderr, "expected weighted == FALSE for the \"no graph -- NULLs+MPI_UNWEIGHTED\" case\n"); + fprintf(stderr, + "expected weighted == FALSE for the \"no graph -- NULLs+MPI_UNWEIGHTED\" case\n"); ++errs; } } @@ -563,6 +567,11 @@ int main(int argc, char *argv[]) for (i = 0; i < size; i++) free(layout[i]); free(layout); + free(sources); + free(sweights); + free(destinations); + free(dweights); + free(degrees); #endif MTest_Finalize(errs); diff --git a/teshsuite/smpi/mpich3-test/topo/graphcr.c b/teshsuite/smpi/mpich3-test/topo/graphcr.c index 2bfac484ab..661e6fc6c1 100644 --- a/teshsuite/smpi/mpich3-test/topo/graphcr.c +++ b/teshsuite/smpi/mpich3-test/topo/graphcr.c @@ -12,23 +12,23 @@ static char MTEST_Descrip[] = "Create a communicator with a graph that contains no processes"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int *index = 0, *edges = 0; MPI_Comm comm; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); /* MPI 2.1, page 246, lines 29-30 make it clear that this is a valid - (not erroneous) call that must return MPI_COMM_NULL */ - MPI_Graph_create( MPI_COMM_WORLD, 0, index, edges, 0, &comm ); + * (not erroneous) call that must return MPI_COMM_NULL */ + MPI_Graph_create(MPI_COMM_WORLD, 0, index, edges, 0, &comm); if (comm != MPI_COMM_NULL) { - errs++; - fprintf( stderr, "Expected MPI_COMM_NULL from empty graph create\n" ); + errs++; + fprintf(stderr, "Expected MPI_COMM_NULL from empty graph create\n"); } - - MTest_Finalize( errs ); + + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/topo/graphcr2.c b/teshsuite/smpi/mpich3-test/topo/graphcr2.c index 6d5fd2ae30..f8e13b71e7 100644 --- a/teshsuite/smpi/mpich3-test/topo/graphcr2.c +++ b/teshsuite/smpi/mpich3-test/topo/graphcr2.c @@ -13,58 +13,58 @@ static char MTEST_Descrip[] = "Create a communicator with a graph that contains null edges and one that contains duplicate edges"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int *index = 0, *edges = 0; int rank, size, i, j, crank, csize; MPI_Comm comm; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - MPI_Comm_size( MPI_COMM_WORLD, &size ); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); + MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); - index = (int *)malloc( size*sizeof(int) ); - edges = (int *)malloc( size*sizeof(int) ); - for (i=0; i #include "mpitest.h" -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int newrank, merr, rank; int index[2], edges[2]; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); /* Graph map where there are no nodes for this process */ - MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN ); + MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN); /* Here is a singleton graph, containing only the root process */ index[0] = 0; edges[0] = 0; - merr = MPI_Graph_map( MPI_COMM_WORLD, 1, index, edges, &newrank ); + merr = MPI_Graph_map(MPI_COMM_WORLD, 1, index, edges, &newrank); if (merr) { - errs++; - printf( "Graph map returned an error\n" ); - MTestPrintError( merr ); + errs++; + printf("Graph map returned an error\n"); + MTestPrintError(merr); } if (rank != 0 && newrank != MPI_UNDEFINED) { - errs++; - printf( "Graph map with no local nodes did not return MPI_UNDEFINED\n" ); + errs++; + printf("Graph map with no local nodes did not return MPI_UNDEFINED\n"); } - - MTest_Finalize( errs ); + + MTest_Finalize(errs); MPI_Finalize(); return 0; - + } diff --git a/teshsuite/smpi/mpich3-test/topo/neighb_coll.c b/teshsuite/smpi/mpich3-test/topo/neighb_coll.c index 0c4a7fd882..7d91138908 100644 --- a/teshsuite/smpi/mpich3-test/topo/neighb_coll.c +++ b/teshsuite/smpi/mpich3-test/topo/neighb_coll.c @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) * neighborhood collective routines */ /* (wrap)--> 0 <--> 1 <--> ... <--> p-1 <--(wrap) */ - MPI_Cart_create(MPI_COMM_WORLD, 1, &wsize, periods, /*reorder=*/0, &cart); + MPI_Cart_create(MPI_COMM_WORLD, 1, &wsize, periods, /*reorder= */ 0, &cart); /* allgather */ { @@ -65,10 +65,10 @@ int main(int argc, char *argv[]) /* allgatherv */ { - int sendbuf[1] = { wrank }; - int recvbuf[2] = { 0xdeadbeef, 0xdeadbeef }; + int sendbuf[1] = { wrank }; + int recvbuf[2] = { 0xdeadbeef, 0xdeadbeef }; int recvcounts[2] = { 1, 1 }; - int displs[2] = { 1, 0}; + int displs[2] = { 1, 0 }; /* should see one send to each neighbor (rank-1 and rank+1) and one receive * each from same, but put them in opposite slots in the buffer */ @@ -87,8 +87,8 @@ int main(int argc, char *argv[]) /* alltoall */ { - int sendbuf[2] = { -(wrank+1), wrank+1 }; - int recvbuf[2] = { 0xdeadbeef, 0xdeadbeef }; + int sendbuf[2] = { -(wrank + 1), wrank + 1 }; + int recvbuf[2] = { 0xdeadbeef, 0xdeadbeef }; /* should see one send to each neighbor (rank-1 and rank+1) and one * receive each from same */ @@ -107,18 +107,17 @@ int main(int argc, char *argv[]) /* alltoallv */ { - int sendbuf[2] = { -(wrank+1), wrank+1 }; - int recvbuf[2] = { 0xdeadbeef, 0xdeadbeef }; + int sendbuf[2] = { -(wrank + 1), wrank + 1 }; + int recvbuf[2] = { 0xdeadbeef, 0xdeadbeef }; int sendcounts[2] = { 1, 1 }; int recvcounts[2] = { 1, 1 }; - int sdispls[2] = { 0, 1 }; - int rdispls[2] = { 1, 0 }; + int sdispls[2] = { 0, 1 }; + int rdispls[2] = { 1, 0 }; /* should see one send to each neighbor (rank-1 and rank+1) and one receive * each from same, but put them in opposite slots in the buffer */ MPI_Neighbor_alltoallv(sendbuf, sendcounts, sdispls, MPI_INT, - recvbuf, recvcounts, rdispls, MPI_INT, - cart); + recvbuf, recvcounts, rdispls, MPI_INT, cart); if (wrank == 0) check(recvbuf[1] == 0xdeadbeef); @@ -133,20 +132,19 @@ int main(int argc, char *argv[]) /* alltoallw */ { - int sendbuf[2] = { -(wrank+1), wrank+1 }; - int recvbuf[2] = { 0xdeadbeef, 0xdeadbeef }; - int sendcounts[2] = { 1, 1 }; - int recvcounts[2] = { 1, 1 }; - MPI_Aint sdispls[2] = { 0, sizeof(int) }; - MPI_Aint rdispls[2] = { sizeof(int), 0 }; + int sendbuf[2] = { -(wrank + 1), wrank + 1 }; + int recvbuf[2] = { 0xdeadbeef, 0xdeadbeef }; + int sendcounts[2] = { 1, 1 }; + int recvcounts[2] = { 1, 1 }; + MPI_Aint sdispls[2] = { 0, sizeof(int) }; + MPI_Aint rdispls[2] = { sizeof(int), 0 }; MPI_Datatype sendtypes[2] = { MPI_INT, MPI_INT }; MPI_Datatype recvtypes[2] = { MPI_INT, MPI_INT }; /* should see one send to each neighbor (rank-1 and rank+1) and one receive * each from same, but put them in opposite slots in the buffer */ MPI_Neighbor_alltoallw(sendbuf, sendcounts, sdispls, sendtypes, - recvbuf, recvcounts, rdispls, recvtypes, - cart); + recvbuf, recvcounts, rdispls, recvtypes, cart); if (wrank == 0) check(recvbuf[1] == 0xdeadbeef); @@ -176,4 +174,3 @@ int main(int argc, char *argv[]) return 0; } - diff --git a/teshsuite/smpi/mpich3-test/topo/testlist b/teshsuite/smpi/mpich3-test/topo/testlist index b966126ab6..ce6fc2eb8f 100644 --- a/teshsuite/smpi/mpich3-test/topo/testlist +++ b/teshsuite/smpi/mpich3-test/topo/testlist @@ -9,6 +9,7 @@ cartcreates 4 #dims2 1 #dims3 1 #dims4 1 +#dims5 1 #need MPI_Error_class, MPI_Comm_remote_size, MPI_Graph_map #graphmap1 4 #need MPI_Topo_test, MPI_Cart_create diff --git a/teshsuite/smpi/mpich3-test/topo/topodup.c b/teshsuite/smpi/mpich3-test/topo/topodup.c index f1c5515ff1..c589edc87e 100644 --- a/teshsuite/smpi/mpich3-test/topo/topodup.c +++ b/teshsuite/smpi/mpich3-test/topo/topodup.c @@ -9,7 +9,7 @@ #include #include "mpitest.h" -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0, i, k; int dims[2], periods[2], wsize; @@ -18,112 +18,107 @@ int main( int argc, char *argv[] ) int *index, *edges, *outindex, *outedges; MPI_Comm comm1, comm2; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - MPI_Comm_size( MPI_COMM_WORLD, &wsize ); + MPI_Comm_size(MPI_COMM_WORLD, &wsize); - /* Create a cartesian topology, get its characteristics, then - dup it and check that the new communicator has the same properties */ + /* Create a cartesian topology, get its characteristics, then + * dup it and check that the new communicator has the same properties */ dims[0] = dims[1] = 0; - MPI_Dims_create( wsize, 2, dims ); + MPI_Dims_create(wsize, 2, dims); periods[0] = periods[1] = 0; - MPI_Cart_create( MPI_COMM_WORLD, 2, dims, periods, 0, &comm1 ); + MPI_Cart_create(MPI_COMM_WORLD, 2, dims, periods, 0, &comm1); - MPI_Comm_dup( comm1, &comm2 ); - MPI_Topo_test( comm2, &topo_type ); + MPI_Comm_dup(comm1, &comm2); + MPI_Topo_test(comm2, &topo_type); if (topo_type != MPI_CART) { - errs++; - printf( "Topo type of duped cart was not cart\n" ); + errs++; + printf("Topo type of duped cart was not cart\n"); } else { - MPI_Cart_get( comm2, 2, outdims, outperiods, outcoords ); - for (i=0; i<2; i++) { - if (outdims[i] != dims[i]) { - errs++; - printf( "%d = outdims[%d] != dims[%d] = %d\n", outdims[i], - i, i, dims[i] ); - } - if (outperiods[i] != periods[i]) { - errs++; - printf( "%d = outperiods[%d] != periods[%d] = %d\n", - outperiods[i], i, i, periods[i] ); - } - } + MPI_Cart_get(comm2, 2, outdims, outperiods, outcoords); + for (i = 0; i < 2; i++) { + if (outdims[i] != dims[i]) { + errs++; + printf("%d = outdims[%d] != dims[%d] = %d\n", outdims[i], i, i, dims[i]); + } + if (outperiods[i] != periods[i]) { + errs++; + printf("%d = outperiods[%d] != periods[%d] = %d\n", + outperiods[i], i, i, periods[i]); + } + } } - MPI_Comm_free( &comm2 ); - MPI_Comm_free( &comm1 ); + MPI_Comm_free(&comm2); + MPI_Comm_free(&comm1); /* Now do the same with a graph topology */ if (wsize >= 3) { - index = (int*)malloc(wsize * sizeof(int) ); - edges = (int*)malloc(wsize * 2 * sizeof(int) ); - if (!index || !edges) { - printf( "Unable to allocate %d words for index or edges\n", - 3 * wsize ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - } - index[0] = 2; - for (i=1; i #include "mpitest.h" -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int topo_type, size, dims[1], periods[1]; MPI_Comm comm; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - /* Check that topo test returns the correct type, including - MPI_UNDEFINED */ + /* Check that topo test returns the correct type, including + * MPI_UNDEFINED */ - MPI_Topo_test( MPI_COMM_WORLD, &topo_type ); + MPI_Topo_test(MPI_COMM_WORLD, &topo_type); if (topo_type != MPI_UNDEFINED) { - errs++; - printf( "Topo type of comm world is not UNDEFINED\n" ); + errs++; + printf("Topo type of comm world is not UNDEFINED\n"); } - MPI_Comm_size( MPI_COMM_WORLD, &size ); + MPI_Comm_size(MPI_COMM_WORLD, &size); dims[0] = size; periods[0] = 0; - MPI_Cart_create( MPI_COMM_WORLD, 1, dims, periods, 0, &comm ); - MPI_Topo_test( comm, &topo_type ); + MPI_Cart_create(MPI_COMM_WORLD, 1, dims, periods, 0, &comm); + MPI_Topo_test(comm, &topo_type); if (topo_type != MPI_CART) { - errs++; - printf( "Topo type of cart comm is not CART\n" ); + errs++; + printf("Topo type of cart comm is not CART\n"); } - MPI_Comm_free( &comm ); + MPI_Comm_free(&comm); /* FIXME: still need graph example */ - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; - + } -- 2.20.1