From 53ef75ab57752782c82fd7c106626a772940dd0a Mon Sep 17 00:00:00 2001 From: degomme Date: Sat, 11 Feb 2017 02:41:42 +0100 Subject: [PATCH] Upgrade coll mpich testlist to new mpich --- .../smpi/mpich3-test/coll/CMakeLists.txt | 20 +- teshsuite/smpi/mpich3-test/coll/allgather2.c | 58 +- teshsuite/smpi/mpich3-test/coll/allgather3.c | 53 +- .../smpi/mpich3-test/coll/allgather_struct.c | 77 ++ teshsuite/smpi/mpich3-test/coll/allgatherv2.c | 75 +- teshsuite/smpi/mpich3-test/coll/allgatherv3.c | 69 +- teshsuite/smpi/mpich3-test/coll/allred.c | 161 +-- teshsuite/smpi/mpich3-test/coll/allred2.c | 59 +- teshsuite/smpi/mpich3-test/coll/allred3.c | 283 +++-- teshsuite/smpi/mpich3-test/coll/allred4.c | 303 ++--- teshsuite/smpi/mpich3-test/coll/allred5.c | 71 +- teshsuite/smpi/mpich3-test/coll/allred6.c | 96 +- teshsuite/smpi/mpich3-test/coll/allredmany.c | 32 +- teshsuite/smpi/mpich3-test/coll/alltoall1.c | 151 ++- teshsuite/smpi/mpich3-test/coll/alltoallv.c | 204 ++-- teshsuite/smpi/mpich3-test/coll/alltoallv0.c | 210 ++-- teshsuite/smpi/mpich3-test/coll/alltoallw1.c | 374 +++--- teshsuite/smpi/mpich3-test/coll/alltoallw2.c | 222 ++-- .../smpi/mpich3-test/coll/alltoallw_zeros.c | 50 +- teshsuite/smpi/mpich3-test/coll/bcast.c | 93 ++ teshsuite/smpi/mpich3-test/coll/bcast2.c | 81 -- teshsuite/smpi/mpich3-test/coll/bcast3.c | 77 -- teshsuite/smpi/mpich3-test/coll/bcasttest.c | 118 +- .../smpi/mpich3-test/coll/bcastzerotype.c | 6 +- teshsuite/smpi/mpich3-test/coll/coll10.c | 64 +- teshsuite/smpi/mpich3-test/coll/coll11.c | 118 +- teshsuite/smpi/mpich3-test/coll/coll12.c | 105 +- teshsuite/smpi/mpich3-test/coll/coll13.c | 72 +- teshsuite/smpi/mpich3-test/coll/coll2.c | 88 +- teshsuite/smpi/mpich3-test/coll/coll3.c | 132 +-- teshsuite/smpi/mpich3-test/coll/coll4.c | 78 +- teshsuite/smpi/mpich3-test/coll/coll5.c | 79 +- teshsuite/smpi/mpich3-test/coll/coll6.c | 133 ++- teshsuite/smpi/mpich3-test/coll/coll7.c | 88 +- teshsuite/smpi/mpich3-test/coll/coll8.c | 47 +- teshsuite/smpi/mpich3-test/coll/coll9.c | 49 +- teshsuite/smpi/mpich3-test/coll/exscan.c | 102 +- teshsuite/smpi/mpich3-test/coll/exscan2.c | 45 +- teshsuite/smpi/mpich3-test/coll/gather.c | 106 +- teshsuite/smpi/mpich3-test/coll/gather2.c | 120 +- .../smpi/mpich3-test/coll/gather2_save.c | 91 -- teshsuite/smpi/mpich3-test/coll/gather_big.c | 87 ++ teshsuite/smpi/mpich3-test/coll/iallred.c | 17 +- teshsuite/smpi/mpich3-test/coll/ibarrier.c | 14 +- teshsuite/smpi/mpich3-test/coll/icallgather.c | 151 +-- .../smpi/mpich3-test/coll/icallgatherv.c | 174 +-- teshsuite/smpi/mpich3-test/coll/icallreduce.c | 110 +- teshsuite/smpi/mpich3-test/coll/icalltoall.c | 108 +- teshsuite/smpi/mpich3-test/coll/icalltoallv.c | 128 +-- teshsuite/smpi/mpich3-test/coll/icalltoallw.c | 146 +-- teshsuite/smpi/mpich3-test/coll/icbarrier.c | 53 +- teshsuite/smpi/mpich3-test/coll/icbcast.c | 107 +- teshsuite/smpi/mpich3-test/coll/icgather.c | 112 +- teshsuite/smpi/mpich3-test/coll/icgatherv.c | 136 +-- teshsuite/smpi/mpich3-test/coll/icreduce.c | 124 +- teshsuite/smpi/mpich3-test/coll/icscatter.c | 132 +-- teshsuite/smpi/mpich3-test/coll/icscatterv.c | 148 +-- teshsuite/smpi/mpich3-test/coll/longuser.c | 96 +- teshsuite/smpi/mpich3-test/coll/nonblocking.c | 120 +- .../smpi/mpich3-test/coll/nonblocking2.c | 150 +-- .../smpi/mpich3-test/coll/nonblocking3.c | 1003 +++++++++-------- .../smpi/mpich3-test/coll/nonblocking4.c | 159 --- .../smpi/mpich3-test/coll/op_commutative.c | 15 +- teshsuite/smpi/mpich3-test/coll/opband.c | 412 +++---- teshsuite/smpi/mpich3-test/coll/opbor.c | 448 ++++---- teshsuite/smpi/mpich3-test/coll/opbxor.c | 448 ++++---- teshsuite/smpi/mpich3-test/coll/opland.c | 333 +++--- teshsuite/smpi/mpich3-test/coll/oplor.c | 336 +++--- teshsuite/smpi/mpich3-test/coll/oplxor.c | 332 +++--- teshsuite/smpi/mpich3-test/coll/opmax.c | 208 ++-- teshsuite/smpi/mpich3-test/coll/opmaxloc.c | 491 ++++---- teshsuite/smpi/mpich3-test/coll/opmin.c | 208 ++-- teshsuite/smpi/mpich3-test/coll/opminloc.c | 406 +++---- teshsuite/smpi/mpich3-test/coll/opprod.c | 429 +++---- teshsuite/smpi/mpich3-test/coll/opsum.c | 356 +++--- teshsuite/smpi/mpich3-test/coll/red3.c | 253 ++--- teshsuite/smpi/mpich3-test/coll/red4.c | 299 +++-- .../smpi/mpich3-test/coll/red_scat_block.c | 19 +- .../smpi/mpich3-test/coll/red_scat_block2.c | 81 +- teshsuite/smpi/mpich3-test/coll/redscat.c | 50 +- teshsuite/smpi/mpich3-test/coll/redscat2.c | 77 +- teshsuite/smpi/mpich3-test/coll/redscat3.c | 103 +- .../smpi/mpich3-test/coll/redscatbkinter.c | 140 ++- teshsuite/smpi/mpich3-test/coll/redscatblk3.c | 76 +- .../smpi/mpich3-test/coll/redscatinter.c | 163 ++- teshsuite/smpi/mpich3-test/coll/reduce.c | 69 +- .../smpi/mpich3-test/coll/reduce_local.c | 31 +- teshsuite/smpi/mpich3-test/coll/scantst.c | 116 +- teshsuite/smpi/mpich3-test/coll/scatter2.c | 88 +- teshsuite/smpi/mpich3-test/coll/scatter3.c | 109 +- teshsuite/smpi/mpich3-test/coll/scattern.c | 69 +- teshsuite/smpi/mpich3-test/coll/scatterv.c | 145 ++- teshsuite/smpi/mpich3-test/coll/testlist | 8 +- teshsuite/smpi/mpich3-test/coll/uoplong.c | 139 ++- 94 files changed, 7051 insertions(+), 7141 deletions(-) create mode 100644 teshsuite/smpi/mpich3-test/coll/allgather_struct.c create mode 100644 teshsuite/smpi/mpich3-test/coll/bcast.c delete mode 100644 teshsuite/smpi/mpich3-test/coll/bcast2.c delete mode 100644 teshsuite/smpi/mpich3-test/coll/bcast3.c delete mode 100644 teshsuite/smpi/mpich3-test/coll/gather2_save.c create mode 100644 teshsuite/smpi/mpich3-test/coll/gather_big.c delete mode 100644 teshsuite/smpi/mpich3-test/coll/nonblocking4.c diff --git a/teshsuite/smpi/mpich3-test/coll/CMakeLists.txt b/teshsuite/smpi/mpich3-test/coll/CMakeLists.txt index 9f36155193..6265ad1da1 100644 --- a/teshsuite/smpi/mpich3-test/coll/CMakeLists.txt +++ b/teshsuite/smpi/mpich3-test/coll/CMakeLists.txt @@ -11,6 +11,7 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite) add_executable(allgather2 allgather2.c) add_executable(allgather3 allgather3.c) + add_executable(allgather_struct allgather_struct.c) add_executable(allgatherv2 allgatherv2.c) add_executable(allgatherv3 allgatherv3.c) if(HAVE_PRIVATIZATION) @@ -31,8 +32,9 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite) # add_executable(alltoallw1 alltoallw1.c) # add_executable(alltoallw2 alltoallw2.c) # add_executable(alltoallw_zeros alltoallw_zeros.c) - add_executable(bcast2 bcast2.c) - add_executable(bcast3 bcast3.c) + add_executable(bcast_full bcast.c) + add_executable(bcast_min_datatypes bcast.c) + add_executable(bcast_comm_world bcast.c) add_executable(bcasttest bcasttest.c) add_executable(bcastzerotype bcastzerotype.c) add_executable(coll10 coll10.c) @@ -50,7 +52,6 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite) add_executable(exscan2 exscan2.c) add_executable(exscan exscan.c) add_executable(gather2 gather2.c) -# add_executable(gather2_save gather2_save.c) add_executable(gather gather.c) # add_executable(iallred iallred.c) # add_executable(ibarrier ibarrier.c) @@ -109,6 +110,7 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite) target_link_libraries(allgatherv2 simgrid mtest_c) target_link_libraries(allgatherv3 simgrid mtest_c) target_link_libraries(allgatherv4 simgrid mtest_c) + target_link_libraries(allgather_struct simgrid mtest_c) target_link_libraries(allred2 simgrid mtest_c) target_link_libraries(allred3 simgrid mtest_c) target_link_libraries(allred4 simgrid mtest_c) @@ -122,8 +124,9 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite) # target_link_libraries(alltoallw1 simgrid mtest_c) # target_link_libraries(alltoallw2 simgrid mtest_c) # target_link_libraries(alltoallw_zeros simgrid mtest_c) - target_link_libraries(bcast2 simgrid mtest_c) - target_link_libraries(bcast3 simgrid mtest_c) + target_link_libraries(bcast_full simgrid mtest_c) + target_link_libraries(bcast_min_datatypes simgrid mtest_c) + target_link_libraries(bcast_comm_world simgrid mtest_c) target_link_libraries(bcasttest simgrid mtest_c) target_link_libraries(bcastzerotype simgrid mtest_c) target_link_libraries(coll10 simgrid mtest_c) @@ -141,7 +144,6 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite) target_link_libraries(exscan2 simgrid mtest_c) target_link_libraries(exscan simgrid mtest_c) target_link_libraries(gather2 simgrid mtest_c) -# target_link_libraries(gather2_save simgrid mtest_c) target_link_libraries(gather simgrid mtest_c) # target_link_libraries(iallred simgrid mtest_c) # target_link_libraries(ibarrier simgrid mtest_c) @@ -196,6 +198,8 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite) # target_link_libraries(uoplong simgrid mtest_c) set_target_properties(allred PROPERTIES COMPILE_FLAGS "-O0" LINK_FLAGS "-O0") + set_target_properties(bcast_min_datatypes PROPERTIES COMPILE_FLAGS "-DBCAST_MIN_DATATYPES_ONLY" LINK_FLAGS "-DBCAST_MIN_DATATYPES_ONLY") + set_target_properties(bcast_comm_world PROPERTIES COMPILE_FLAGS "-DBCAST_COMM_WORLD_ONLY" LINK_FLAGS "-DBCAST_COMM_WORLD_ONLY") if(HAVE_THREAD_CONTEXTS) ADD_TEST(test-smpi-mpich3-coll-thread ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/coll ${PERL_EXECUTABLE} ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests ${TESH_OPTION} -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/coll -tests=testlist -execarg=--cfg=contexts/factory:thread -execarg=--cfg=smpi/privatize-global-variables:${HAVE_PRIVATIZATION}) @@ -243,8 +247,7 @@ set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/alltoallw1.c ${CMAKE_CURRENT_SOURCE_DIR}/alltoallw2.c ${CMAKE_CURRENT_SOURCE_DIR}/alltoallw_zeros.c - ${CMAKE_CURRENT_SOURCE_DIR}/bcast2.c - ${CMAKE_CURRENT_SOURCE_DIR}/bcast3.c + ${CMAKE_CURRENT_SOURCE_DIR}/bcast.c ${CMAKE_CURRENT_SOURCE_DIR}/bcasttest.c ${CMAKE_CURRENT_SOURCE_DIR}/bcastzerotype.c ${CMAKE_CURRENT_SOURCE_DIR}/coll10.c @@ -262,7 +265,6 @@ set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/exscan2.c ${CMAKE_CURRENT_SOURCE_DIR}/exscan.c ${CMAKE_CURRENT_SOURCE_DIR}/gather2.c - ${CMAKE_CURRENT_SOURCE_DIR}/gather2_save.c ${CMAKE_CURRENT_SOURCE_DIR}/gather.c ${CMAKE_CURRENT_SOURCE_DIR}/iallred.c ${CMAKE_CURRENT_SOURCE_DIR}/ibarrier.c diff --git a/teshsuite/smpi/mpich3-test/coll/allgather2.c b/teshsuite/smpi/mpich3-test/coll/allgather2.c index 66a21eca6e..01cf4ab8a7 100644 --- a/teshsuite/smpi/mpich3-test/coll/allgather2.c +++ b/teshsuite/smpi/mpich3-test/coll/allgather2.c @@ -12,59 +12,45 @@ /* Gather data from a vector to contiguous. Use IN_PLACE */ -int main( int argc, char **argv ) +int main(int argc, char **argv) { double *vecout; MPI_Comm comm; - int count, minsize = 2; - int i, errs = 0; - int rank, size; + int count, minsize = 2; + int i, errs = 0; + int rank, size; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); + + while (MTestGetIntracommGeneral(&comm, minsize, 1)) { + if (comm == MPI_COMM_NULL) + continue; + /* Determine the sender and receiver */ + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); - while (MTestGetIntracommGeneral( &comm, minsize, 1 )) { - if (comm == MPI_COMM_NULL) continue; - /* Determine the sender and receiver */ - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); - for (count = 1; count < 9000; count = count * 2) { - vecout = (double *)malloc( size * count * sizeof(double) ); - - for (i=0; i +#include "mpi.h" +#include "mpitest.h" + +/* Allgather a two-field struct datatype. This test + may trigger bugs such as when the implementation + does not handle well misaligned types.*/ + +typedef struct { + int first; + long second; +} int_long_t; + +int main(int argc, char **argv) +{ + MPI_Comm comm; + int minsize = 2; + int i, errs = 0; + int rank, size; + int_long_t object; + MPI_Datatype type; + MPI_Aint begin; + MPI_Aint displacements[2]; + MPI_Datatype types[] = { MPI_INT, MPI_LONG }; + int blocklength[2] = { 1, 1 }; + int_long_t* gathered_objects; + + MTest_Init(&argc, &argv); + + while (MTestGetIntracommGeneral(&comm, minsize, 1)) { + + if (comm == MPI_COMM_NULL) + continue; + /* Determine the sender and receiver */ + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); + + gathered_objects = (int_long_t*) malloc (size*sizeof(int_long_t)); + + /* Local object */ + object.first = rank; + object.second = rank * 10; + + /* Datatype creation */ + MPI_Get_address(&object, &begin); + MPI_Get_address(&object.first, &displacements[0]); + MPI_Get_address(&object.second, &displacements[1]); + + for (i = 0; i != 2; ++i) + displacements[i] -= begin; + + MPI_Type_create_struct(2, &blocklength[0], &displacements[0], &types[0], &type); + MPI_Type_commit(&type); + + MPI_Allgather(&object, 1, type, gathered_objects, 1, type, comm); + + for (i = 0; i < size; i++) { + if (gathered_objects[i].first != i || gathered_objects[i].second != i * 10) + errs++; + } + + MPI_Type_free(&type); + MTestFreeComm(&comm); + free(gathered_objects); + } + + MTest_Finalize(errs); + MPI_Finalize(); + return 0; +} diff --git a/teshsuite/smpi/mpich3-test/coll/allgatherv2.c b/teshsuite/smpi/mpich3-test/coll/allgatherv2.c index 55119d9c6f..0d4248e472 100644 --- a/teshsuite/smpi/mpich3-test/coll/allgatherv2.c +++ b/teshsuite/smpi/mpich3-test/coll/allgatherv2.c @@ -10,71 +10,60 @@ #include #include -/* Gather data from a vector to contiguous. Use IN_PLACE. This is +/* Gather data from a vector to contiguous. Use IN_PLACE. This is the trivial version based on the allgather test (allgatherv but with constant data sizes) */ -int main( int argc, char **argv ) +int main(int argc, char **argv) { double *vecout; MPI_Comm comm; - int count, minsize = 2; - int i, errs = 0; - int rank, size; - int *displs, *recvcounts; + int count, minsize = 2; + int i, errs = 0; + int rank, size; + int *displs, *recvcounts; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - while (MTestGetIntracommGeneral( &comm, minsize, 1 )) { - if (comm == MPI_COMM_NULL) continue; - /* Determine the sender and receiver */ - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + while (MTestGetIntracommGeneral(&comm, minsize, 1)) { + if (comm == MPI_COMM_NULL) + continue; + /* Determine the sender and receiver */ + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); + + displs = (int *) malloc(size * sizeof(int)); + recvcounts = (int *) malloc(size * sizeof(int)); - displs = (int *)malloc( size * sizeof(int) ); - recvcounts = (int *)malloc( size * sizeof(int) ); - for (count = 1; count < 9000; count = count * 2) { - vecout = (double *)malloc( size * count * sizeof(double) ); - - for (i=0; i #include -/* Gather data from a vector to contiguous. This is +/* Gather data from a vector to contiguous. This is the trivial version based on the allgather test (allgatherv but with constant data sizes) */ -int main( int argc, char **argv ) +int main(int argc, char **argv) { double *vecout, *invec; MPI_Comm comm; - int count, minsize = 2; - int i, errs = 0; - int rank, size; - int *displs, *recvcounts; + int count, minsize = 2; + int i, errs = 0; + int rank, size; + int *displs, *recvcounts; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - while (MTestGetIntracommGeneral( &comm, minsize, 1 )) { - if (comm == MPI_COMM_NULL) continue; - /* Determine the sender and receiver */ - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + while (MTestGetIntracommGeneral(&comm, minsize, 1)) { + if (comm == MPI_COMM_NULL) + continue; + /* Determine the sender and receiver */ + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); + + displs = (int *) malloc(size * sizeof(int)); + recvcounts = (int *) malloc(size * sizeof(int)); - displs = (int *)malloc( size * sizeof(int) ); - recvcounts = (int *)malloc( size * sizeof(int) ); - for (count = 1; count < 9000; count = count * 2) { - invec = (double *)malloc( count * sizeof(double) ); - vecout = (double *)malloc( size * count * sizeof(double) ); - - for (i=0; i #endif -SMPI_VARINIT_GLOBAL(count, int); -SMPI_VARINIT_GLOBAL(size, int); -SMPI_VARINIT_GLOBAL(rank, int); -SMPI_VARINIT_GLOBAL(cerrcnt, int); - -struct int_test { int a; int b; }; -struct long_test { long a; int b; }; -struct short_test { short a; int b; }; -struct float_test { float a; int b; }; -struct double_test { double a; int b; }; +int count, size, rank; +int cerrcnt; + +struct int_test { + int a; + int b; +}; +struct long_test { + long a; + int b; +}; +struct short_test { + short a; + int b; +}; +struct float_test { + float a; + int b; +}; +struct double_test { + double a; + int b; +}; #define mpi_op2str(op) \ ((op == MPI_SUM) ? "MPI_SUM" : \ @@ -46,35 +59,35 @@ struct double_test { double a; int b; }; /* calloc to avoid spurious valgrind warnings when "type" has padding bytes */ #define DECL_MALLOC_IN_OUT_SOL(type) \ type *in, *out, *sol; \ - in = (type *) calloc(SMPI_VARGET_GLOBAL(count), sizeof(type)); \ - out = (type *) calloc(SMPI_VARGET_GLOBAL(count), sizeof(type)); \ - sol = (type *) calloc(SMPI_VARGET_GLOBAL(count), sizeof(type)); + in = (type *) calloc(count, sizeof(type)); \ + out = (type *) calloc(count, sizeof(type)); \ + sol = (type *) calloc(count, sizeof(type)); #define SET_INDEX_CONST(arr, val) \ { \ int i; \ - for (i = 0; i < SMPI_VARGET_GLOBAL(count); i++) \ + for (i = 0; i < count; i++) \ arr[i] = val; \ } #define SET_INDEX_SUM(arr, val) \ { \ int i; \ - for (i = 0; i < SMPI_VARGET_GLOBAL(count); i++) \ + for (i = 0; i < count; i++) \ arr[i] = i + val; \ } #define SET_INDEX_FACTOR(arr, val) \ { \ int i; \ - for (i = 0; i < SMPI_VARGET_GLOBAL(count); i++) \ + for (i = 0; i < count; i++) \ arr[i] = i * (val); \ } #define SET_INDEX_POWER(arr, val) \ { \ int i, j; \ - for (i = 0; i < SMPI_VARGET_GLOBAL(count); i++) { \ + for (i = 0; i < count; i++) { \ (arr)[i] = 1; \ for (j = 0; j < (val); j++) \ arr[i] *= i; \ @@ -88,26 +101,26 @@ struct double_test { double a; int b; }; if (lerrcnt) { \ MPI_Type_get_name(mpi_type, name, &len); \ fprintf(stderr, "(%d) Error for type %s and op %s\n", \ - SMPI_VARGET_GLOBAL(rank), name, mpi_op2str(mpi_op)); \ + rank, name, mpi_op2str(mpi_op)); \ } \ free(in); free(out); free(sol); \ - } while(0) + } while (0) -/* The logic on the error check on MPI_Allreduce assumes that all +/* The logic on the error check on MPI_Allreduce assumes that all MPI_Allreduce routines return a failure if any do - this is sufficient for MPI implementations that reject some of the valid op/datatype pairs - (and motivated this addition, as some versions of the IBM MPI + (and motivated this addition, as some versions of the IBM MPI failed in just this way). */ #define ALLREDUCE_AND_FREE(mpi_type, mpi_op, in, out, sol) \ { \ int i, rc, lerrcnt = 0; \ - rc = MPI_Allreduce(in, out, SMPI_VARGET_GLOBAL(count), mpi_type, mpi_op, MPI_COMM_WORLD); \ - if (rc) { lerrcnt++; SMPI_VARGET_GLOBAL(cerrcnt)++; MTestPrintError( rc ); } \ + rc = MPI_Allreduce(in, out, count, mpi_type, mpi_op, MPI_COMM_WORLD); \ + if (rc) { lerrcnt++; cerrcnt++; MTestPrintError(rc); } \ else { \ - for (i = 0; i < SMPI_VARGET_GLOBAL(count); i++) { \ + for (i = 0; i < count; i++) { \ if (out[i] != sol[i]) { \ - SMPI_VARGET_GLOBAL(cerrcnt)++; \ + cerrcnt++; \ lerrcnt++; \ } \ } \ @@ -118,12 +131,12 @@ struct double_test { double a; int b; }; #define STRUCT_ALLREDUCE_AND_FREE(mpi_type, mpi_op, in, out, sol) \ { \ int i, rc, lerrcnt = 0; \ - rc = MPI_Allreduce(in, out, SMPI_VARGET_GLOBAL(count), mpi_type, mpi_op, MPI_COMM_WORLD); \ - if (rc) { lerrcnt++; SMPI_VARGET_GLOBAL(cerrcnt)++; MTestPrintError( rc ); } \ + rc = MPI_Allreduce(in, out, count, mpi_type, mpi_op, MPI_COMM_WORLD); \ + if (rc) { lerrcnt++; cerrcnt++; MTestPrintError(rc); } \ else { \ - for (i = 0; i < SMPI_VARGET_GLOBAL(count); i++) { \ + for (i = 0; i < count; i++) { \ if ((out[i].a != sol[i].a) || (out[i].b != sol[i].b)) { \ - SMPI_VARGET_GLOBAL(cerrcnt)++; \ + cerrcnt++; \ lerrcnt++; \ } \ } \ @@ -134,14 +147,14 @@ struct double_test { double a; int b; }; #define SET_INDEX_STRUCT_CONST(arr, val, el) \ { \ int i; \ - for (i = 0; i < SMPI_VARGET_GLOBAL(count); i++) \ + for (i = 0; i < count; i++) \ arr[i].el = val; \ } #define SET_INDEX_STRUCT_SUM(arr, val, el) \ { \ int i; \ - for (i = 0; i < SMPI_VARGET_GLOBAL(count); i++) \ + for (i = 0; i < count; i++) \ arr[i].el = i + (val); \ } @@ -149,7 +162,7 @@ struct double_test { double a; int b; }; { \ DECL_MALLOC_IN_OUT_SOL(type); \ SET_INDEX_SUM(in, 0); \ - SET_INDEX_FACTOR(sol, SMPI_VARGET_GLOBAL(size)); \ + SET_INDEX_FACTOR(sol, size); \ SET_INDEX_CONST(out, 0); \ ALLREDUCE_AND_FREE(mpi_type, MPI_SUM, in, out, sol); \ } @@ -158,7 +171,7 @@ struct double_test { double a; int b; }; { \ DECL_MALLOC_IN_OUT_SOL(type); \ SET_INDEX_SUM(in, 0); \ - SET_INDEX_POWER(sol, SMPI_VARGET_GLOBAL(size)); \ + SET_INDEX_POWER(sol, size); \ SET_INDEX_CONST(out, 0); \ ALLREDUCE_AND_FREE(mpi_type, MPI_PROD, in, out, sol); \ } @@ -166,8 +179,8 @@ struct double_test { double a; int b; }; #define max_test1(type, mpi_type) \ { \ DECL_MALLOC_IN_OUT_SOL(type); \ - SET_INDEX_SUM(in, SMPI_VARGET_GLOBAL(rank)); \ - SET_INDEX_SUM(sol, SMPI_VARGET_GLOBAL(size) - 1); \ + SET_INDEX_SUM(in, rank); \ + SET_INDEX_SUM(sol, size - 1); \ SET_INDEX_CONST(out, 0); \ ALLREDUCE_AND_FREE(mpi_type, MPI_MAX, in, out, sol); \ } @@ -175,7 +188,7 @@ struct double_test { double a; int b; }; #define min_test1(type, mpi_type) \ { \ DECL_MALLOC_IN_OUT_SOL(type); \ - SET_INDEX_SUM(in, SMPI_VARGET_GLOBAL(rank)); \ + SET_INDEX_SUM(in, rank); \ SET_INDEX_SUM(sol, 0); \ SET_INDEX_CONST(out, 0); \ ALLREDUCE_AND_FREE(mpi_type, MPI_MIN, in, out, sol); \ @@ -191,32 +204,32 @@ struct double_test { double a; int b; }; } #define lor_test1(type, mpi_type) \ - const_test(type, mpi_type, MPI_LOR, (SMPI_VARGET_GLOBAL(rank) & 0x1), (SMPI_VARGET_GLOBAL(size) > 1), 0) + const_test(type, mpi_type, MPI_LOR, (rank & 0x1), (size > 1), 0) #define lor_test2(type, mpi_type) \ const_test(type, mpi_type, MPI_LOR, 0, 0, 0) #define lxor_test1(type, mpi_type) \ - const_test(type, mpi_type, MPI_LXOR, (SMPI_VARGET_GLOBAL(rank) == 1), (SMPI_VARGET_GLOBAL(size) > 1), 0) + const_test(type, mpi_type, MPI_LXOR, (rank == 1), (size > 1), 0) #define lxor_test2(type, mpi_type) \ const_test(type, mpi_type, MPI_LXOR, 0, 0, 0) #define lxor_test3(type, mpi_type) \ - const_test(type, mpi_type, MPI_LXOR, 1, (SMPI_VARGET_GLOBAL(size) & 0x1), 0) + const_test(type, mpi_type, MPI_LXOR, 1, (size & 0x1), 0) #define land_test1(type, mpi_type) \ - const_test(type, mpi_type, MPI_LAND, (SMPI_VARGET_GLOBAL(rank) & 0x1), 0, 0) + const_test(type, mpi_type, MPI_LAND, (rank & 0x1), 0, 0) #define land_test2(type, mpi_type) \ const_test(type, mpi_type, MPI_LAND, 1, 1, 0) #define bor_test1(type, mpi_type) \ - const_test(type, mpi_type, MPI_BOR, (SMPI_VARGET_GLOBAL(rank) & 0x3), ((SMPI_VARGET_GLOBAL(size) < 3) ? SMPI_VARGET_GLOBAL(size) - 1 : 0x3), 0) + const_test(type, mpi_type, MPI_BOR, (rank & 0x3), ((size < 3) ? size - 1 : 0x3), 0) #define bxor_test1(type, mpi_type) \ - const_test(type, mpi_type, MPI_BXOR, (SMPI_VARGET_GLOBAL(rank) == 1) * 0xf0, (SMPI_VARGET_GLOBAL(size) > 1) * 0xf0, 0) + const_test(type, mpi_type, MPI_BXOR, (rank == 1) * 0xf0, (size > 1) * 0xf0, 0) #define bxor_test2(type, mpi_type) \ const_test(type, mpi_type, MPI_BXOR, 0, 0, 0) #define bxor_test3(type, mpi_type) \ - const_test(type, mpi_type, MPI_BXOR, ~0, (SMPI_VARGET_GLOBAL(size) &0x1) ? ~0 : 0, 0) + const_test(type, mpi_type, MPI_BXOR, ~0, (size &0x1) ? ~0 : 0, 0) #define band_test1(type, mpi_type) \ { \ DECL_MALLOC_IN_OUT_SOL(type); \ - if (SMPI_VARGET_GLOBAL(rank) == SMPI_VARGET_GLOBAL(size)-1) { \ + if (rank == size-1) { \ SET_INDEX_SUM(in, 0); \ } \ else { \ @@ -230,7 +243,7 @@ struct double_test { double a; int b; }; #define band_test2(type, mpi_type) \ { \ DECL_MALLOC_IN_OUT_SOL(type); \ - if (SMPI_VARGET_GLOBAL(rank) == SMPI_VARGET_GLOBAL(size)-1) { \ + if (rank == size-1) { \ SET_INDEX_SUM(in, 0); \ } \ else { \ @@ -244,10 +257,10 @@ struct double_test { double a; int b; }; #define maxloc_test(type, mpi_type) \ { \ DECL_MALLOC_IN_OUT_SOL(type); \ - SET_INDEX_STRUCT_SUM(in, SMPI_VARGET_GLOBAL(rank), a); \ - SET_INDEX_STRUCT_CONST(in, SMPI_VARGET_GLOBAL(rank), b); \ - SET_INDEX_STRUCT_SUM(sol, SMPI_VARGET_GLOBAL(size) - 1, a); \ - SET_INDEX_STRUCT_CONST(sol, SMPI_VARGET_GLOBAL(size) - 1, b); \ + SET_INDEX_STRUCT_SUM(in, rank, a); \ + SET_INDEX_STRUCT_CONST(in, rank, b); \ + SET_INDEX_STRUCT_SUM(sol, size - 1, a); \ + SET_INDEX_STRUCT_CONST(sol, size - 1, b); \ SET_INDEX_STRUCT_CONST(out, 0, a); \ SET_INDEX_STRUCT_CONST(out, -1, b); \ STRUCT_ALLREDUCE_AND_FREE(mpi_type, MPI_MAXLOC, in, out, sol); \ @@ -256,8 +269,8 @@ struct double_test { double a; int b; }; #define minloc_test(type, mpi_type) \ { \ DECL_MALLOC_IN_OUT_SOL(type); \ - SET_INDEX_STRUCT_SUM(in, SMPI_VARGET_GLOBAL(rank), a); \ - SET_INDEX_STRUCT_CONST(in, SMPI_VARGET_GLOBAL(rank), b); \ + SET_INDEX_STRUCT_SUM(in, rank, a); \ + SET_INDEX_STRUCT_CONST(in, rank, b); \ SET_INDEX_STRUCT_SUM(sol, 0, a); \ SET_INDEX_STRUCT_CONST(sol, 0, b); \ SET_INDEX_STRUCT_CONST(out, 0, a); \ @@ -284,7 +297,7 @@ struct double_test { double a; int b; }; #if MTEST_HAVE_MIN_MPI_VERSION(3,0) #define test_types_set_mpi_3_0_integer(op,post) do { \ - op##_test##post(MPI_SMPI_VARGET_GLOBAL(count), MPI_SMPI_VARGET_GLOBAL(count)); \ + op##_test##post(MPI_Count, MPI_COUNT); \ } while (0) #else #define test_types_set_mpi_3_0_integer(op,post) do { } while (0) @@ -315,7 +328,7 @@ struct double_test { double a; int b; }; op##_test##post(unsigned char, MPI_BYTE); \ } -/* Make sure that we test complex and double complex, even if long +/* Make sure that we test complex and double complex, even if long double complex is not available */ #if defined(USE_LONG_DOUBLE_COMPLEX) @@ -337,7 +350,7 @@ struct double_test { double a; int b; }; #else #if MTEST_HAVE_MIN_MPI_VERSION(2,2) && defined(HAVE_FLOAT__COMPLEX) \ - && defined(HAVE_DOUBLE__COMPLEX) + && defined(HAVE_DOUBLE__COMPLEX) #define test_types_set4(op, post) \ do { \ op##_test##post(float _Complex, MPI_C_FLOAT_COMPLEX); \ @@ -360,34 +373,32 @@ struct double_test { double a; int b; }; #define test_types_set5(op, post) do { } while (0) #endif -int main( int argc, char **argv ) +int main(int argc, char **argv) { - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &SMPI_VARGET_GLOBAL(size)); - MPI_Comm_rank(MPI_COMM_WORLD, &SMPI_VARGET_GLOBAL(rank)); + MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); - if (SMPI_VARGET_GLOBAL(size) < 2) { - fprintf( stderr, "At least 2 processes required\n" ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); + if (size < 2) { + fprintf(stderr, "At least 2 processes required\n"); + MPI_Abort(MPI_COMM_WORLD, 1); } - /* Set errors return so that we can provide better information - should a routine reject one of the operand/datatype pairs */ - MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN ); + /* Set errors return so that we can provide better information + * should a routine reject one of the operand/datatype pairs */ + MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN); - SMPI_VARGET_GLOBAL(count) = 10; + count = 10; /* Allow an argument to override the count. - Note that the product tests may fail if the count is very large. + * Note that the product tests may fail if the count is very large. */ if (argc >= 2) { - SMPI_VARGET_GLOBAL(count) = atoi( argv[1] ); - if (SMPI_VARGET_GLOBAL(count) <= 0) { - fprintf( stderr, "Invalid count argument %s\n", argv[1] ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } + count = atoi(argv[1]); + if (count <= 0) { + fprintf(stderr, "Invalid count argument %s\n", argv[1]); + MPI_Abort(MPI_COMM_WORLD, 1); + } } test_types_set2(sum, 1); @@ -444,8 +455,8 @@ int main( int argc, char **argv ) minloc_test(struct float_test, MPI_FLOAT_INT); minloc_test(struct double_test, MPI_DOUBLE_INT); - MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL ); - MTest_Finalize( SMPI_VARGET_GLOBAL(cerrcnt) ); + MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL); + MTest_Finalize(cerrcnt); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/coll/allred2.c b/teshsuite/smpi/mpich3-test/coll/allred2.c index f33b245a09..ece40098de 100644 --- a/teshsuite/smpi/mpich3-test/coll/allred2.c +++ b/teshsuite/smpi/mpich3-test/coll/allred2.c @@ -13,43 +13,44 @@ static char MTEST_Descrip[] = "Test MPI_Allreduce with MPI_IN_PLACE"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rank, size; - int minsize = 2, count; - MPI_Comm comm; + int minsize = 2, count; + MPI_Comm comm; int *buf, i; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - while (MTestGetIntracommGeneral( &comm, minsize, 1 )) { - if (comm == MPI_COMM_NULL) continue; - MPI_Comm_size( comm, &size ); - MPI_Comm_rank( comm, &rank ); - - for (count = 1; count < 65000; count = count * 2) { - /* Contiguous data */ - buf = (int *)malloc( count * sizeof(int) ); - for (i=0; i #include "mpitest.h" #include +#include "mpicolltest.h" /* static char MTEST_Descrip[] = ""; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rank, size; - int minsize = 2, count; - MPI_Comm comm; + int minsize = 2, count; + MPI_Comm comm; int *sendbuf, *recvbuf, *p; int sendcount, recvcount; int i, j; MPI_Datatype sendtype, recvtype; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - /* The following illustrates the use of the routines to - run through a selection of communicators and datatypes. - Use subsets of these for tests that do not involve combinations - of communicators, datatypes, and counts of datatypes */ - while (MTestGetIntracommGeneral( &comm, minsize, 1 )) { - if (comm == MPI_COMM_NULL) continue; + /* The following illustrates the use of the routines to + * run through a selection of communicators and datatypes. + * Use subsets of these for tests that do not involve combinations + * of communicators, datatypes, and counts of datatypes */ + while (MTestGetIntracommGeneral(&comm, minsize, 1)) { + if (comm == MPI_COMM_NULL) + continue; - /* Determine the sender and receiver */ - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); - - /* printf( "Size of comm = %d\n", size ); */ - for (count = 1; count < 65000; count = count * 2) { - - /* Create a send buf and a receive buf suitable for testing - all to all. */ - sendcount = count; - recvcount = count; - sendbuf = (int *)malloc( count * size * sizeof(int) ); - recvbuf = (int *)malloc( count * size * sizeof(int) ); - sendtype = MPI_INT; - recvtype = MPI_INT; + /* Determine the sender and receiver */ + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); - if (!sendbuf || !recvbuf) { - errs++; - fprintf( stderr, "Failed to allocate sendbuf and/or recvbuf\n" ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - for (i=0; i /* - This program tests MPI_Alltoallv by having processor each process + This program tests MPI_Alltoallv by having processor each process send data to two neighbors only, using counts of 0 for the other processes. This idiom is sometimes used for halo exchange operations. Because there are separate send and receive types to alltoallv, there need to be tests to rearrange data on the fly. Not done yet. - + Currently, the test uses only MPI_INT; this is adequate for testing systems that use point-to-point operations */ -int main( int argc, char **argv ) +int main(int argc, char **argv) { MPI_Comm comm; - int *sbuf, *rbuf; - int rank, size; - int *sendcounts, *recvcounts, *rdispls, *sdispls; - int i, *p, err; - int left, right, length; - - MTest_Init( &argc, &argv ); + int *sbuf, *rbuf; + int rank, size; + int *sendcounts, *recvcounts, *rdispls, *sdispls; + int i, *p, err; + int left, right, length; + + MTest_Init(&argc, &argv); err = 0; - - while (MTestGetIntracommGeneral( &comm, 2, 1 )) { - if (comm == MPI_COMM_NULL) continue; - - MPI_Comm_size( comm, &size ); - MPI_Comm_rank( comm, &rank ); - - if (size < 3) continue; - - /* Create and load the arguments to alltoallv */ - sendcounts = (int *)malloc( size * sizeof(int) ); - recvcounts = (int *)malloc( size * sizeof(int) ); - rdispls = (int *)malloc( size * sizeof(int) ); - sdispls = (int *)malloc( size * sizeof(int) ); - if (!sendcounts || !recvcounts || !rdispls || !sdispls) { - fprintf( stderr, "Could not allocate arg items!\n" ); - MPI_Abort( comm, 1 ); - exit(1); - } - - /* Get the neighbors */ - left = (rank - 1 + size) % size; - right = (rank + 1) % size; - - /* Set the defaults */ - for (i=0; i +#include "mpitest.h" + +/* +static char MTEST_Descrip[] = "Test of broadcast with various roots and datatypes"; +*/ + +int main(int argc, char *argv[]) +{ + int errs = 0, err; + int rank, size, root; + int minsize = 2, count; + MPI_Comm comm; + MTestDatatype sendtype, recvtype; + + MTest_Init(&argc, &argv); + + /* The following illustrates the use of the routines to + * run through a selection of communicators and datatypes. + * Use subsets of these for tests that do not involve combinations + * of communicators, datatypes, and counts of datatypes */ + while (MTestGetIntracommGeneral(&comm, minsize, 1)) { + if (comm == MPI_COMM_NULL) + continue; + +#if defined BCAST_COMM_WORLD_ONLY + if (comm != MPI_COMM_WORLD) { + MTestFreeComm(&comm); + continue; + } +#endif /* BCAST_COMM_WORLD_ONLY */ + + /* Determine the sender and receiver */ + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); + + /* To improve reporting of problems about operations, we + * change the error handler to errors return */ + MPI_Errhandler_set(comm, MPI_ERRORS_RETURN); + + MTEST_DATATYPE_FOR_EACH_COUNT(count) { + + /* To shorten test time, only run the default version of datatype tests + * for comm world and run the minimum version for other communicators. */ +#if defined BCAST_MIN_DATATYPES_ONLY + MTestInitMinDatatypes(); +#endif /* BCAST_MIN_DATATYPES_ONLY */ + + while (MTestGetDatatypes(&sendtype, &recvtype, count)) { + for (root = 0; root < size; root++) { + if (rank == root) { + sendtype.InitBuf(&sendtype); + err = MPI_Bcast(sendtype.buf, sendtype.count, + sendtype.datatype, root, comm); + if (err) { + errs++; + MTestPrintError(err); + } + } + else { + recvtype.InitBuf(&recvtype); + err = MPI_Bcast(recvtype.buf, recvtype.count, + recvtype.datatype, root, comm); + if (err) { + errs++; + fprintf(stderr, "Error with communicator %s and datatype %s\n", + MTestGetIntracommName(), MTestGetDatatypeName(&recvtype)); + MTestPrintError(err); + } + err = MTestCheckRecv(0, &recvtype); + if (err) { + errs += errs; + } + } + } + MTestFreeDatatype(&recvtype); + MTestFreeDatatype(&sendtype); + } + } + MTestFreeComm(&comm); + } + + MTest_Finalize(errs); + MPI_Finalize(); + return 0; +} diff --git a/teshsuite/smpi/mpich3-test/coll/bcast2.c b/teshsuite/smpi/mpich3-test/coll/bcast2.c deleted file mode 100644 index 91c8878dc1..0000000000 --- a/teshsuite/smpi/mpich3-test/coll/bcast2.c +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ -/* - * - * (C) 2003 by Argonne National Laboratory. - * See COPYRIGHT in top-level directory. - */ -#include "mpi.h" -#include -#include "mpitest.h" - -/* -static char MTEST_Descrip[] = "Test of broadcast with various roots and datatypes"; -*/ - -int main( int argc, char *argv[] ) -{ - int errs = 0, err; - int rank, size, root; - int minsize = 2, count; - MPI_Comm comm; - MTestDatatype sendtype, recvtype; - - MTest_Init( &argc, &argv ); - - /* The following illustrates the use of the routines to - run through a selection of communicators and datatypes. - Use subsets of these for tests that do not involve combinations - of communicators, datatypes, and counts of datatypes */ - while (MTestGetIntracommGeneral( &comm, minsize, 1 )) { - if (comm == MPI_COMM_NULL) continue; - - /* Determine the sender and receiver */ - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); - - /* To improve reporting of problems about operations, we - change the error handler to errors return */ - MPI_Errhandler_set( comm, MPI_ERRORS_RETURN ); - - /* The max value of count must be very large to ensure that we - reach the long message algorithms */ - for (count = 1; count < 2800; count = count * 4) { - while (MTestGetDatatypes( &sendtype, &recvtype, count )) { - for (root=0; root -#include "mpitest.h" - -/* -static char MTEST_Descrip[] = "Test of broadcast with various roots and datatypes and sizes that are not powers of two"; -*/ - -int main( int argc, char *argv[] ) -{ - int errs = 0, err; - int rank, size, root; - int minsize = 2, count; - MPI_Comm comm; - MTestDatatype sendtype, recvtype; - - MTest_Init( &argc, &argv ); - - /* The following illustrates the use of the routines to - run through a selection of communicators and datatypes. - Use subsets of these for tests that do not involve combinations - of communicators, datatypes, and counts of datatypes */ - while (MTestGetIntracommGeneral( &comm, minsize, 1 )) { - if (comm == MPI_COMM_NULL) continue; - /* Determine the sender and receiver */ - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); - - count = 1; - /* This must be very large to ensure that we reach the long message - algorithms */ - for (count = 4; count < 6600; count = count * 4) { - while (MTestGetDatatypes( &sendtype, &recvtype, count-1 )) { - for (root=0; root 1) - { - if (strcmp(argv[1], "-novalidate") == 0 || strcmp(argv[1], "-noverify") == 0) - bVerify = 0; + if (argc > 1) { + if (strcmp(argv[1], "-novalidate") == 0 || strcmp(argv[1], "-noverify") == 0) + bVerify = 0; } - buf = (int *) malloc(sizes[NUM_SIZES-1]*sizeof(int)); - memset(buf, 0, sizes[NUM_SIZES-1]*sizeof(int)); + buf = (int *) malloc(sizes[NUM_SIZES - 1] * sizeof(int)); + memset(buf, 0, sizes[NUM_SIZES - 1] * sizeof(int)); - for (n=0; n= 10) - { - printf("Error: Rank=%d, num_errors = %d\n", rank, num_errors); - fflush(stdout); - } - } - } + MPI_Bcast(buf, sizes[n], MPI_INT, ROOT, MPI_COMM_WORLD); + + if (bVerify) { + num_errors = 0; + for (i = 0; i < sizes[n]; i++) { + if (buf[i] != 1000000 * (n * NUM_REPS + reps) + i) { + num_errors++; + if (num_errors < 10) { + printf("Error: Rank=%d, n=%d, reps=%d, i=%d, buf[i]=%d expected=%d\n", + rank, n, reps, i, buf[i], 1000000 * (n * NUM_REPS + reps) + i); + fflush(stdout); + } + } + } + if (num_errors >= 10) { + printf("Error: Rank=%d, num_errors = %d\n", rank, num_errors); + fflush(stdout); + } + } + } } - + free(buf); - MTest_Finalize( num_errors ); + MTest_Finalize(num_errors); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/coll/bcastzerotype.c b/teshsuite/smpi/mpich3-test/coll/bcastzerotype.c index 166647879a..d6716d4de7 100644 --- a/teshsuite/smpi/mpich3-test/coll/bcastzerotype.c +++ b/teshsuite/smpi/mpich3-test/coll/bcastzerotype.c @@ -26,8 +26,8 @@ int main(int argc, char *argv[]) /* a random non-zero sized buffer */ #define NELEM (10) - buf = malloc(NELEM*sizeof(int)); - assert(buf!=NULL); + buf = malloc(NELEM * sizeof(int)); + assert(buf); for (i = 0; i < NELEM; i++) { buf[i] = wrank * NELEM + i; @@ -47,6 +47,8 @@ int main(int argc, char *argv[]) assert(buf[i] == wrank * NELEM + i); } + free(buf); + MPI_Type_free(&type); MPI_Finalize(); diff --git a/teshsuite/smpi/mpich3-test/coll/coll10.c b/teshsuite/smpi/mpich3-test/coll/coll10.c index e93abedc59..e2a424af7e 100644 --- a/teshsuite/smpi/mpich3-test/coll/coll10.c +++ b/teshsuite/smpi/mpich3-test/coll/coll10.c @@ -9,53 +9,53 @@ #define BAD_ANSWER 100000 -int assoc ( int *, int *, int *, MPI_Datatype * ); +int assoc(int *, int *, int *, MPI_Datatype *); /* - The operation is inoutvec[i] = invec[i] op inoutvec[i] + The operation is inoutvec[i] = invec[i] op inoutvec[i] (see 4.9.4). The order is important. Note that the computation is in process rank (in the communicator) order, independant of the root. */ -int assoc(int *invec, int *inoutvec, int *len, MPI_Datatype *dtype) +int assoc(int *invec, int *inoutvec, int *len, MPI_Datatype * dtype) { - int i; - for ( i=0; i<*len; i++ ) { - if (inoutvec[i] <= invec[i] ) { - int rank; - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); - fprintf( stderr, "[%d] inout[0] = %d, in[0] = %d\n", - rank, inoutvec[0], invec[0] ); - inoutvec[i] = BAD_ANSWER; - } - else - inoutvec[i] = invec[i]; - } - return (1); + int i; + for (i = 0; i < *len; i++) { + if (inoutvec[i] <= invec[i]) { + int rank; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + fprintf(stderr, "[%d] inout[0] = %d, in[0] = %d\n", rank, inoutvec[0], invec[0]); + inoutvec[i] = BAD_ANSWER; + } + else + inoutvec[i] = invec[i]; + } + return (1); } -int main( int argc, char **argv ) +int main(int argc, char **argv) { - int rank, size; - int data; - int errors=0; - int result = -100; - MPI_Op op; + int rank, size; + int data; + int errors = 0; + int result = -100; + MPI_Op op; - MTest_Init( &argc, &argv ); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); - MPI_Comm_size( MPI_COMM_WORLD, &size ); + MTest_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); data = rank; - MPI_Op_create( (MPI_User_function*)assoc, 0, &op ); - MPI_Reduce ( &data, &result, 1, MPI_INT, op, size-1, MPI_COMM_WORLD ); - MPI_Bcast ( &result, 1, MPI_INT, size-1, MPI_COMM_WORLD ); - MPI_Op_free( &op ); - if (result == BAD_ANSWER) errors++; + MPI_Op_create((MPI_User_function *) assoc, 0, &op); + MPI_Reduce(&data, &result, 1, MPI_INT, op, size - 1, MPI_COMM_WORLD); + MPI_Bcast(&result, 1, MPI_INT, size - 1, MPI_COMM_WORLD); + MPI_Op_free(&op); + if (result == BAD_ANSWER) + errors++; - MTest_Finalize( errors ); + MTest_Finalize(errors); MPI_Finalize(); - return MTestReturnValue( errors ); + return MTestReturnValue(errors); } diff --git a/teshsuite/smpi/mpich3-test/coll/coll11.c b/teshsuite/smpi/mpich3-test/coll/coll11.c index 9b5ddda888..b79482e3a0 100644 --- a/teshsuite/smpi/mpich3-test/coll/coll11.c +++ b/teshsuite/smpi/mpich3-test/coll/coll11.c @@ -7,102 +7,98 @@ #include #include "mpitest.h" -void addem ( int *, int *, int *, MPI_Datatype * ); -void assoc ( int *, int *, int *, MPI_Datatype * ); +void addem(int *, int *, int *, MPI_Datatype *); +void assoc(int *, int *, int *, MPI_Datatype *); -void addem(int *invec, int *inoutvec, int *len, MPI_Datatype *dtype) +void addem(int *invec, int *inoutvec, int *len, MPI_Datatype * dtype) { - int i; - for ( i=0; i<*len; i++ ) - inoutvec[i] += invec[i]; + int i; + for (i = 0; i < *len; i++) + inoutvec[i] += invec[i]; } #define BAD_ANSWER 100000 /* - The operation is inoutvec[i] = invec[i] op inoutvec[i] + The operation is inoutvec[i] = invec[i] op inoutvec[i] (see 4.9.4). The order is important. Note that the computation is in process rank (in the communicator) order, independant of the root. */ -void assoc(int *invec, int *inoutvec, int *len, MPI_Datatype *dtype) +void assoc(int *invec, int *inoutvec, int *len, MPI_Datatype * dtype) { - int i; - for ( i=0; i<*len; i++ ) { - if (inoutvec[i] <= invec[i] ) { - int rank; - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); - fprintf( stderr, "[%d] inout[0] = %d, in[0] = %d\n", - rank, inoutvec[0], invec[0] ); - inoutvec[i] = BAD_ANSWER; - } - else - inoutvec[i] = invec[i]; - } + int i; + for (i = 0; i < *len; i++) { + if (inoutvec[i] <= invec[i]) { + int rank; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + fprintf(stderr, "[%d] inout[0] = %d, in[0] = %d\n", rank, inoutvec[0], invec[0]); + inoutvec[i] = BAD_ANSWER; + } + else + inoutvec[i] = invec[i]; + } } -int main( int argc, char **argv ) +int main(int argc, char **argv) { - int rank, size, i; - int data; - int errors=0; - int result = -100; - int correct_result; - MPI_Op op_assoc, op_addem; + int rank, size, i; + int data; + int errors = 0; + int result = -100; + int correct_result; + MPI_Op op_assoc, op_addem; - MTest_Init( &argc, &argv ); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); - MPI_Comm_size( MPI_COMM_WORLD, &size ); + MTest_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); data = rank; correct_result = 0; - for (i=0;i<=rank;i++) - correct_result += i; + for (i = 0; i <= rank; i++) + correct_result += i; - MPI_Scan ( &data, &result, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD ); + MPI_Scan(&data, &result, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); if (result != correct_result) { - fprintf( stderr, "[%d] Error suming ints with scan\n", rank ); - errors++; - } + fprintf(stderr, "[%d] Error suming ints with scan\n", rank); + errors++; + } - MPI_Scan ( &data, &result, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD ); + MPI_Scan(&data, &result, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); if (result != correct_result) { - fprintf( stderr, "[%d] Error summing ints with scan (2)\n", rank ); - errors++; - } + fprintf(stderr, "[%d] Error summing ints with scan (2)\n", rank); + errors++; + } data = rank; result = -100; - MPI_Op_create( (MPI_User_function *)assoc, 0, &op_assoc ); - MPI_Op_create( (MPI_User_function *)addem, 1, &op_addem ); - MPI_Scan ( &data, &result, 1, MPI_INT, op_addem, MPI_COMM_WORLD ); + MPI_Op_create((MPI_User_function *) assoc, 0, &op_assoc); + MPI_Op_create((MPI_User_function *) addem, 1, &op_addem); + MPI_Scan(&data, &result, 1, MPI_INT, op_addem, MPI_COMM_WORLD); if (result != correct_result) { - fprintf( stderr, "[%d] Error summing ints with scan (userop)\n", - rank ); - errors++; - } + fprintf(stderr, "[%d] Error summing ints with scan (userop)\n", rank); + errors++; + } - MPI_Scan ( &data, &result, 1, MPI_INT, op_addem, MPI_COMM_WORLD ); + MPI_Scan(&data, &result, 1, MPI_INT, op_addem, MPI_COMM_WORLD); if (result != correct_result) { - fprintf( stderr, "[%d] Error summing ints with scan (userop2)\n", - rank ); - errors++; - } + fprintf(stderr, "[%d] Error summing ints with scan (userop2)\n", rank); + errors++; + } result = -100; data = rank; - MPI_Scan ( &data, &result, 1, MPI_INT, op_assoc, MPI_COMM_WORLD ); + MPI_Scan(&data, &result, 1, MPI_INT, op_assoc, MPI_COMM_WORLD); if (result == BAD_ANSWER) { - fprintf( stderr, "[%d] Error scanning with non-commutative op\n", - rank ); - errors++; - } + fprintf(stderr, "[%d] Error scanning with non-commutative op\n", rank); + errors++; + } - MPI_Op_free( &op_assoc ); - MPI_Op_free( &op_addem ); + MPI_Op_free(&op_assoc); + MPI_Op_free(&op_addem); - MTest_Finalize( errors ); + MTest_Finalize(errors); MPI_Finalize(); - return MTestReturnValue( errors ); + return MTestReturnValue(errors); } diff --git a/teshsuite/smpi/mpich3-test/coll/coll12.c b/teshsuite/smpi/mpich3-test/coll/coll12.c index d493a5948f..63bd9897f5 100644 --- a/teshsuite/smpi/mpich3-test/coll/coll12.c +++ b/teshsuite/smpi/mpich3-test/coll/coll12.c @@ -10,64 +10,71 @@ #define TABLE_SIZE 2 -int main( int argc, char **argv ) +int main(int argc, char **argv) { - int rank, size; - double a[TABLE_SIZE]; - struct { double a; int b; } in[TABLE_SIZE], out[TABLE_SIZE]; - int i; - int errors = 0; + int rank, size; + double a[TABLE_SIZE]; + struct { + double a; + int b; + } in[TABLE_SIZE], out[TABLE_SIZE]; + int i; + int errors = 0, toterrors; - /* Initialize the environment and some variables */ - MTest_Init( &argc, &argv ); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); - MPI_Comm_size( MPI_COMM_WORLD, &size ); + /* Initialize the environment and some variables */ + MTest_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); - /* Initialize the maxloc data */ - for ( i=0; i #include "mpitest.h" +#include "mpicolltest.h" #define MAX_PROCESSES 10 -int main( int argc, char **argv ) +int main(int argc, char **argv) { - int rank, size, i,j; - int table[MAX_PROCESSES][MAX_PROCESSES]; - int errors=0; - int participants; + int rank, size, i, j; + int table[MAX_PROCESSES][MAX_PROCESSES]; + int errors = 0; + int participants; - MTest_Init( &argc, &argv ); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); - MPI_Comm_size( MPI_COMM_WORLD, &size ); + MTest_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); /* A maximum of MAX_PROCESSES processes can participate */ - if ( size > MAX_PROCESSES ) participants = MAX_PROCESSES; - else participants = size; + if (size > MAX_PROCESSES) + participants = MAX_PROCESSES; + else + participants = size; if (MAX_PROCESSES % participants) { - fprintf( stderr, "Number of processors must divide %d\n", - MAX_PROCESSES ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - if ( (rank < participants) ) { + fprintf(stderr, "Number of processors must divide %d\n", MAX_PROCESSES); + MPI_Abort(MPI_COMM_WORLD, 1); + } + if ((rank < participants)) { - /* Determine what rows are my responsibility */ - int block_size = MAX_PROCESSES / participants; - int begin_row = rank * block_size; - int end_row = (rank+1) * block_size; - int send_count = block_size * MAX_PROCESSES; - int recv_count = send_count; + /* Determine what rows are my responsibility */ + int block_size = MAX_PROCESSES / participants; + int begin_row = rank * block_size; + int end_row = (rank + 1) * block_size; + int send_count = block_size * MAX_PROCESSES; + int recv_count = send_count; - /* Paint my rows my color */ - for (i=begin_row; i MAX_PROCESSES ) participants = MAX_PROCESSES; - else participants = size; + if (size > MAX_PROCESSES) + participants = MAX_PROCESSES; + else + participants = size; /* while (MAX_PROCESSES % participants) participants--; */ if (MAX_PROCESSES % participants) { - fprintf( stderr, "Number of processors must divide %d\n", - MAX_PROCESSES ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - if ( (rank < participants) ) { + fprintf(stderr, "Number of processors must divide %d\n", MAX_PROCESSES); + MPI_Abort(MPI_COMM_WORLD, 1); + } + if ((rank < participants)) { - /* Determine what rows are my responsibility */ - int block_size = MAX_PROCESSES / participants; - int begin_row = rank * block_size; - int end_row = (rank+1) * block_size; - int send_count = block_size * MAX_PROCESSES; - - /* Fill in the displacements and recv_counts */ - for (i=0; i MAX_PROCESSES ) { - participants = MAX_PROCESSES; - MPI_Comm_split( MPI_COMM_WORLD, rank < MAX_PROCESSES, rank, &comm ); + if (size > MAX_PROCESSES) { + participants = MAX_PROCESSES; + MPI_Comm_split(MPI_COMM_WORLD, rank < MAX_PROCESSES, rank, &comm); } - else { - participants = size; - MPI_Comm_dup( MPI_COMM_WORLD, &comm ); + else { + participants = size; + MPI_Comm_dup(MPI_COMM_WORLD, &comm); } - if ( (rank < participants) ) { - int send_count = MAX_PROCESSES; - int recv_count = MAX_PROCESSES; - - /* If I'm the root (process 0), then fill out the big table */ - if (rank == 0) - for ( i=0; i MAX_PROCESSES ) participants = MAX_PROCESSES; - else participants = size; - if ( (rank < participants) ) { - int recv_count = MAX_PROCESSES; - - /* If I'm the root (process 0), then fill out the big table */ - /* and setup send_counts and displs arrays */ - if (rank == 0) - for ( i=0; i MAX_PROCESSES) + participants = MAX_PROCESSES; + else + participants = size; + if ((rank < participants)) { + int recv_count = MAX_PROCESSES; + + /* If I'm the root (process 0), then fill out the big table */ + /* and setup send_counts and displs arrays */ + if (rank == 0) + for (i = 0; i < participants; i++) { + send_counts[i] = recv_count; + displs[i] = i * MAX_PROCESSES; + for (j = 0; j < MAX_PROCESSES; j++) + table[i][j] = i + j; + } + + /* Scatter the big table to everybody's little table */ + MPI_Scatterv(&table[0][0], send_counts, displs, MPI_INT, + &row[0], recv_count, MPI_INT, 0, MPI_COMM_WORLD); + + /* Now see if our row looks right */ + for (i = 0; i < MAX_PROCESSES; i++) + if (row[i] != i + rank) + errors++; + } + + MTest_Finalize(errors); MPI_Finalize(); - return MTestReturnValue( errors ); + return MTestReturnValue(errors); } diff --git a/teshsuite/smpi/mpich3-test/coll/coll6.c b/teshsuite/smpi/mpich3-test/coll/coll6.c index e0973f9a1b..077cdcd15d 100644 --- a/teshsuite/smpi/mpich3-test/coll/coll6.c +++ b/teshsuite/smpi/mpich3-test/coll/coll6.c @@ -9,87 +9,84 @@ #define MAX_PROCESSES 10 -int main( int argc, char **argv ) +int main(int argc, char **argv) { - int rank, size, i,j; - int table[MAX_PROCESSES][MAX_PROCESSES]; - int errors=0; - int participants; - int displs[MAX_PROCESSES]; - int recv_counts[MAX_PROCESSES]; - MPI_Comm test_comm; + int rank, size, i, j; + int table[MAX_PROCESSES][MAX_PROCESSES]; + int errors = 0; + int participants; + int displs[MAX_PROCESSES]; + int recv_counts[MAX_PROCESSES]; + MPI_Comm test_comm; - MTest_Init( &argc, &argv ); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); - MPI_Comm_size( MPI_COMM_WORLD, &size ); + MTest_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); /* A maximum of MAX_PROCESSES processes can participate */ - participants = ( size > MAX_PROCESSES ) ? MAX_PROCESSES : size; + participants = (size > MAX_PROCESSES) ? MAX_PROCESSES : size; if (MAX_PROCESSES % participants) { - fprintf( stderr, "Number of processors must divide %d\n", - MAX_PROCESSES ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - MPI_Comm_split(MPI_COMM_WORLD, rank MAX_PROCESSES ) participants = MAX_PROCESSES; - else participants = size; + if (size > MAX_PROCESSES) + participants = MAX_PROCESSES; + else + participants = size; if (MAX_PROCESSES % participants) { - fprintf( stderr, "Number of processors must divide %d\n", - MAX_PROCESSES ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } + fprintf(stderr, "Number of processors must divide %d\n", MAX_PROCESSES); + MPI_Abort(MPI_COMM_WORLD, 1); + } /* while (MAX_PROCESSES % participants) participants--; */ - if ( (rank < participants) ) { - - /* Determine what rows are my responsibility */ - int block_size = MAX_PROCESSES / participants; - int begin_row = rank * block_size; - int end_row = (rank+1) * block_size; - int send_count = block_size * MAX_PROCESSES; - int recv_count = send_count; - - /* Paint my rows my color */ - for (i=begin_row; i #include "mpitest.h" -int main( int argc, char **argv ) +int main(int argc, char **argv) { - int rank, size, i; - int data; - int errors=0; - int result = -100; - int correct_result; + int rank, size, i; + int data; + int errors = 0; + int result = -100; + int correct_result; - MTest_Init( &argc, &argv ); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); - MPI_Comm_size( MPI_COMM_WORLD, &size ); + MTest_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); data = rank; - MPI_Reduce ( &data, &result, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD ); - MPI_Bcast ( &result, 1, MPI_INT, 0, MPI_COMM_WORLD ); + MPI_Reduce(&data, &result, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); + MPI_Bcast(&result, 1, MPI_INT, 0, MPI_COMM_WORLD); correct_result = 0; - for(i=0;i #include "mpitest.h" -void addem ( int *, int *, int *, MPI_Datatype * ); +void addem(int *, int *, int *, MPI_Datatype *); -void addem(int *invec, int *inoutvec, int *len, MPI_Datatype *dtype) +void addem(int *invec, int *inoutvec, int *len, MPI_Datatype * dtype) { - int i; - for ( i=0; i<*len; i++ ) - inoutvec[i] += invec[i]; + int i; + for (i = 0; i < *len; i++) + inoutvec[i] += invec[i]; } -int main( int argc, char **argv ) +int main(int argc, char **argv) { - int rank, size, i; - int data; - int errors=0; - int result = -100; - int correct_result; - MPI_Op op; + int rank, size, i; + int data; + int errors = 0; + int result = -100; + int correct_result; + MPI_Op op; - MTest_Init( &argc, &argv ); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); - MPI_Comm_size( MPI_COMM_WORLD, &size ); + MTest_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); data = rank; - MPI_Op_create( (MPI_User_function *)addem, 1, &op ); - MPI_Reduce ( &data, &result, 1, MPI_INT, op, 0, MPI_COMM_WORLD ); - MPI_Bcast ( &result, 1, MPI_INT, 0, MPI_COMM_WORLD ); - MPI_Op_free( &op ); + MPI_Op_create((MPI_User_function *) addem, 1, &op); + MPI_Reduce(&data, &result, 1, MPI_INT, op, 0, MPI_COMM_WORLD); + MPI_Bcast(&result, 1, MPI_INT, 0, MPI_COMM_WORLD); + MPI_Op_free(&op); correct_result = 0; - for(i=0;i 0) { - int result; - for (i=0; i 0) { + int result; + for (i = 0; i < count; i++) { + result = rank * i * size + ((rank) * (rank - 1)) / 2; + if (recvbuf[i] != result) { + errs++; + if (errs < 10) { + fprintf(stderr, "Error in recvbuf[%d] = %d on %d, expected %d\n", + i, recvbuf[i], rank, result); + } + } + } + } #if MTEST_HAVE_MIN_MPI_VERSION(2,2) /* now try the MPI_IN_PLACE flavor */ - for (i=0; i 0) { - int result = (((rank) * (rank-1))/2); - /* printf( "%d: %d\n", rank, result ); */ - if (recvbuf[0] != result) { - errs++; - fprintf( stderr, "Error in recvbuf = %d on %d, expected %d\n", - recvbuf[0], rank, result ); - } + int result = (((rank) * (rank - 1)) / 2); + /* printf("%d: %d\n", rank, result); */ + if (recvbuf[0] != result) { + errs++; + fprintf(stderr, "Error in recvbuf = %d on %d, expected %d\n", recvbuf[0], rank, result); + } } else if (recvbuf[0] != -2) { - errs++; - fprintf( stderr, "Error in recvbuf on zero, is %d\n", recvbuf[0] ); + errs++; + fprintf(stderr, "Error in recvbuf on zero, is %d\n", recvbuf[0]); } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/coll/gather.c b/teshsuite/smpi/mpich3-test/coll/gather.c index e14503f3b1..b7152c16ba 100644 --- a/teshsuite/smpi/mpich3-test/coll/gather.c +++ b/teshsuite/smpi/mpich3-test/coll/gather.c @@ -12,73 +12,63 @@ /* Gather data from a vector to contiguous */ -int main( int argc, char **argv ) +int main(int argc, char **argv) { MPI_Datatype vec; - MPI_Comm comm; + MPI_Comm comm; double *vecin, *vecout; - int minsize = 2, count; - int root, i, n, stride, errs = 0; - int rank, size; + int minsize = 2, count; + int root, i, n, stride, errs = 0; + int rank, size; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - while (MTestGetIntracommGeneral( &comm, minsize, 1 )) { - if (comm == MPI_COMM_NULL) continue; - /* Determine the sender and receiver */ - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); - - for (root=0; root -#include - -/* Gather data from a vector to contiguous. Use IN_PLACE */ - -int main( int argc, char **argv ) -{ - MPI_Datatype vec; - double *vecin, *vecout; - MPI_Comm comm; - int count, minsize = 2; - int root, i, n, stride, errs = 0; - int rank, size; - - MTest_Init( &argc, &argv ); - - while (MTestGetIntracommGeneral( &comm, minsize, 1 )) { - if (comm == MPI_COMM_NULL) continue; - /* Determine the sender and receiver */ - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); - - for (root=0; root +#include + +#define ROOT 7 +#if 0 +/* Following should always work for -n 8 256, -N 32, using longs */ +#define COUNT 1048576*32 +#endif +#if 1 +/* Following will fail for -n 8 unless gather path is 64 bit clean */ +#define COUNT (1024*1024*128+1) +#endif +#define VERIFY_CONST 100000000L + +int main(int argc, char *argv[]) +{ + int rank, size; + int i, j; + long *sendbuf = NULL; + long *recvbuf = NULL; + + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + + if (size < (ROOT+1)) { + fprintf(stderr, "At least %d processes required\n", ROOT+1); + MPI_Abort(MPI_COMM_WORLD, 1); + } + + sendbuf = malloc(COUNT * sizeof(long)); + if (sendbuf == NULL) { + fprintf(stderr, "PE %d:ERROR: malloc of sendbuf failed\n", rank); + } + for (i = 0; i < COUNT; i++) { + sendbuf[i] = (long) i + (long) rank *VERIFY_CONST; + } + + if (rank == ROOT) { + recvbuf = malloc(COUNT * sizeof(long) * size); + if (recvbuf == NULL) { + fprintf(stderr, "PE %d:ERROR: malloc of recvbuf failed\n", rank); + } + for (i = 0; i < COUNT * size; i++) { + recvbuf[i] = -456789L; + } + } + + MPI_Gather(sendbuf, COUNT, MPI_LONG, recvbuf, COUNT, MPI_LONG, ROOT, MPI_COMM_WORLD); + + int lerr = 0; + if (rank == ROOT) { + for (i = 0; i < size; i++) { + for (j = 0; j < COUNT; j++) { + if (recvbuf[i * COUNT + j] != i * VERIFY_CONST + j) { + printf("PE 0: mis-match error"); + printf(" recbuf[%d * %d + %d] = ", i, COUNT, j); + printf(" %ld,", recvbuf[i * COUNT + j]); + printf(" should be %ld\n", i * VERIFY_CONST + j); + lerr++; + if (lerr > 10) { + j = COUNT; + } + } + } + } + MTest_Finalize(lerr); + free(recvbuf); + } + else { + MTest_Finalize(lerr); + } + + MPI_Barrier(MPI_COMM_WORLD); + MPI_Finalize(); + + free(sendbuf); + return 0; +} diff --git a/teshsuite/smpi/mpich3-test/coll/iallred.c b/teshsuite/smpi/mpich3-test/coll/iallred.c index 684fd507e7..455c22dbc9 100644 --- a/teshsuite/smpi/mpich3-test/coll/iallred.c +++ b/teshsuite/smpi/mpich3-test/coll/iallred.c @@ -15,27 +15,20 @@ int main(int argc, char *argv[]) MPI_Request request; int size, rank; int one = 1, two = 2, isum, sum; - int errs = 0; - MPI_Init(&argc,&argv); + MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_rank(MPI_COMM_WORLD, &rank); assert(size == 2); - MPI_Iallreduce(&one,&isum,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD,&request); - MPI_Allreduce(&two,&sum,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD); - MPI_Wait(&request,MPI_STATUS_IGNORE); + MPI_Iallreduce(&one, &isum, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &request); + MPI_Allreduce(&two, &sum, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); + MPI_Wait(&request, MPI_STATUS_IGNORE); assert(isum == 2); assert(sum == 4); - - MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN); - if (MPI_SUCCESS == MPI_Iallreduce(&one, &one, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &request)) - errs++; - - if (rank == 0 && errs == 0) + if (rank == 0) printf(" No errors\n"); MPI_Finalize(); return 0; } - diff --git a/teshsuite/smpi/mpich3-test/coll/ibarrier.c b/teshsuite/smpi/mpich3-test/coll/ibarrier.c index affde1f587..a672da0803 100644 --- a/teshsuite/smpi/mpich3-test/coll/ibarrier.c +++ b/teshsuite/smpi/mpich3-test/coll/ibarrier.c @@ -14,15 +14,15 @@ int main(int argc, char *argv[]) { MPI_Request barrier; - int rank,i,done; + int rank, i, done; - MPI_Init(&argc,&argv); - MPI_Comm_rank(MPI_COMM_WORLD,&rank); - MPI_Ibarrier(MPI_COMM_WORLD,&barrier); - for (i=0,done=0; !done; i++) { + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Ibarrier(MPI_COMM_WORLD, &barrier); + for (i = 0, done = 0; !done; i++) { usleep(1000); - /*printf("[%d] MPI_Test: %d\n",rank,i);*/ - MPI_Test(&barrier,&done,MPI_STATUS_IGNORE); + /*printf("[%d] MPI_Test: %d\n",rank,i); */ + MPI_Test(&barrier, &done, MPI_STATUS_IGNORE); } if (rank == 0) diff --git a/teshsuite/smpi/mpich3-test/coll/icallgather.c b/teshsuite/smpi/mpich3-test/coll/icallgather.c index 987e01ab74..3418167c7a 100644 --- a/teshsuite/smpi/mpich3-test/coll/icallgather.c +++ b/teshsuite/smpi/mpich3-test/coll/icallgather.c @@ -8,12 +8,13 @@ #include #include #include "mpitest.h" +#include "mpicolltest.h" /* static char MTEST_Descrip[] = "Simple intercomm allgather test"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0, err; int *rbuf = 0, *sbuf = 0; @@ -21,87 +22,89 @@ int main( int argc, char *argv[] ) MPI_Comm comm; MPI_Datatype datatype; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); datatype = MPI_INT; /* Get an intercommunicator */ - while (MTestGetIntercomm( &comm, &leftGroup, 4 )) { - if (comm == MPI_COMM_NULL) continue; - MPI_Comm_rank( comm, &rank ); - MPI_Comm_remote_size( comm, &rsize ); + while (MTestGetIntercomm(&comm, &leftGroup, 4)) { + if (comm == MPI_COMM_NULL) + continue; + MPI_Comm_rank(comm, &rank); + MPI_Comm_remote_size(comm, &rsize); - /* To improve reporting of problems about operations, we - change the error handler to errors return */ - MPI_Errhandler_set( comm, MPI_ERRORS_RETURN ); + /* To improve reporting of problems about operations, we + * change the error handler to errors return */ + MPI_Errhandler_set(comm, MPI_ERRORS_RETURN); - for (count = 1; count < 65000; count = 2 * count) { - /* The left group will send rank to the right group; - The right group will send -rank to the left group */ - rbuf = (int *)malloc( count * rsize * sizeof(int) ); - sbuf = (int *)malloc( count * sizeof(int) ); - for (i=0; i #include #include "mpitest.h" +#include "mpicolltest.h" /* static char MTEST_Descrip[] = "Simple intercomm allgatherv test"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0, err; int *rbuf = 0, *sbuf = 0; @@ -22,101 +23,104 @@ int main( int argc, char *argv[] ) MPI_Comm comm; MPI_Datatype datatype; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); datatype = MPI_INT; - /* Get an intercommunicator */ - while (MTestGetIntercomm( &comm, &leftGroup, 4 )) { - if (comm == MPI_COMM_NULL) continue; - MPI_Comm_rank( comm, &rank ); - MPI_Comm_remote_size( comm, &rsize ); + /* Get an intercommunicator */ + while (MTestGetIntercomm(&comm, &leftGroup, 4)) { + if (comm == MPI_COMM_NULL) + continue; + MPI_Comm_rank(comm, &rank); + MPI_Comm_remote_size(comm, &rsize); - /* To improve reporting of problems about operations, we - change the error handler to errors return */ - MPI_Errhandler_set( comm, MPI_ERRORS_RETURN ); + /* To improve reporting of problems about operations, we + * change the error handler to errors return */ + MPI_Errhandler_set(comm, MPI_ERRORS_RETURN); - for (count = 1; count < 65000; count = 2 * count) { - /* The left group will send rank to the right group; - The right group will send -rank to the left group */ - rbuf = (int *)malloc( count * rsize * sizeof(int) ); - sbuf = (int *)malloc( count * sizeof(int) ); - recvcounts = (int *) malloc( rsize * sizeof(int) ); - recvdispls = (int *) malloc( rsize * sizeof(int) ); - for (i=0; i #include #include "mpitest.h" +#include "mpicolltest.h" /* static char MTEST_Descrip[] = "Simple intercomm allreduce test"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0, err; int *sendbuf = 0, *recvbuf = 0; @@ -21,65 +22,68 @@ int main( int argc, char *argv[] ) MPI_Comm comm; MPI_Datatype datatype; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); datatype = MPI_INT; /* Get an intercommunicator */ - while (MTestGetIntercomm( &comm, &leftGroup, 4 )) { - if (comm == MPI_COMM_NULL) continue; - MPI_Comm_rank( comm, &rank ); - MPI_Comm_remote_size( comm, &rsize ); + while (MTestGetIntercomm(&comm, &leftGroup, 4)) { + if (comm == MPI_COMM_NULL) + continue; + MPI_Comm_rank(comm, &rank); + MPI_Comm_remote_size(comm, &rsize); - /* To improve reporting of problems about operations, we - change the error handler to errors return */ - MPI_Errhandler_set( comm, MPI_ERRORS_RETURN ); + /* To improve reporting of problems about operations, we + * change the error handler to errors return */ + MPI_Errhandler_set(comm, MPI_ERRORS_RETURN); - for (count = 1; count < 65000; count = 2 * count) { - /* printf( "rank = %d(%d)\n", rank, leftGroup ); fflush(stdout); */ - sendbuf = (int *)malloc( count * sizeof(int) ); - recvbuf = (int *)malloc( count * sizeof(int) ); - if (leftGroup) { - for (i=0; i #include #include "mpitest.h" +#include "mpicolltest.h" /* static char MTEST_Descrip[] = "Simple intercomm alltoall test"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0, err; int *sendbuf = 0, *recvbuf = 0; @@ -21,65 +22,64 @@ int main( int argc, char *argv[] ) MPI_Comm comm; MPI_Datatype datatype; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); datatype = MPI_INT; - while (MTestGetIntercomm( &comm, &leftGroup, 4 )) { - if (comm == MPI_COMM_NULL) continue; - for (count = 1; count < 66000; count = 2 * count) { - /* Get an intercommunicator */ - MPI_Comm_remote_size( comm, &rsize ); - MPI_Comm_rank( comm, &rrank ); - sendbuf = (int *)malloc( rsize * count * sizeof(int) ); - recvbuf = (int *)malloc( rsize * count * sizeof(int) ); - for (i=0; i #include +#include "mpicolltest.h" /* This program tests MPI_Alltoallv by having processor i send different @@ -14,88 +15,87 @@ Because there are separate send and receive types to alltoallv, there need to be tests to rearrange data on the fly. Not done yet. - + The first test sends i items to processor i from all processors. Currently, the test uses only MPI_INT; this is adequate for testing systems that use point-to-point operations */ -int main( int argc, char **argv ) +int main(int argc, char **argv) { MPI_Comm comm; - int *sbuf, *rbuf; - int rank, size, lsize, asize; - int *sendcounts, *recvcounts, *rdispls, *sdispls; - int i, j, *p, err; - int leftGroup; + int *sbuf, *rbuf; + int rank, size, lsize, asize; + int *sendcounts, *recvcounts, *rdispls, *sdispls; + int i, j, *p, err; + int leftGroup; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); err = 0; - while (MTestGetIntercomm( &comm, &leftGroup, 4 )) { - if (comm == MPI_COMM_NULL) continue; + while (MTestGetIntercomm(&comm, &leftGroup, 4)) { + if (comm == MPI_COMM_NULL) + continue; - /* Create the buffer */ - MPI_Comm_size( comm, &lsize ); - MPI_Comm_remote_size( comm, &size ); - asize = (lsize > size) ? lsize : size; - MPI_Comm_rank( comm, &rank ); - sbuf = (int *)malloc( size * size * sizeof(int) ); - rbuf = (int *)malloc( asize * asize * sizeof(int) ); - if (!sbuf || !rbuf) { - fprintf( stderr, "Could not allocated buffers!\n" ); - MPI_Abort( comm, 1 ); - exit(1); - } + /* Create the buffer */ + MPI_Comm_size(comm, &lsize); + MPI_Comm_remote_size(comm, &size); + asize = (lsize > size) ? lsize : size; + MPI_Comm_rank(comm, &rank); + sbuf = (int *) malloc(size * size * sizeof(int)); + rbuf = (int *) malloc(asize * asize * sizeof(int)); + if (!sbuf || !rbuf) { + fprintf(stderr, "Could not allocated buffers!\n"); + MPI_Abort(comm, 1); + } - /* Load up the buffers */ - for (i=0; i #include +#include "mpicolltest.h" /* This program tests MPI_Alltoallw by having processor i send different @@ -15,97 +16,96 @@ Because there are separate send and receive types to alltoallw, there need to be tests to rearrange data on the fly. Not done yet. - + The first test sends i items to processor i from all processors. Currently, the test uses only MPI_INT; this is adequate for testing systems that use point-to-point operations */ -int main( int argc, char **argv ) +int main(int argc, char **argv) { MPI_Comm comm; - int *sbuf, *rbuf; - int rank, size, lsize, asize; - int *sendcounts, *recvcounts, *rdispls, *sdispls; - int i, j, *p, err; + int *sbuf, *rbuf; + int rank, size, lsize, asize; + int *sendcounts, *recvcounts, *rdispls, *sdispls; + int i, j, *p, err; MPI_Datatype *sendtypes, *recvtypes; - int leftGroup; + int leftGroup; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); err = 0; - while (MTestGetIntercomm( &comm, &leftGroup, 4 )) { - if (comm == MPI_COMM_NULL) continue; + while (MTestGetIntercomm(&comm, &leftGroup, 4)) { + if (comm == MPI_COMM_NULL) + continue; + + /* Create the buffer */ + MPI_Comm_size(comm, &lsize); + MPI_Comm_remote_size(comm, &size); + asize = (lsize > size) ? lsize : size; + MPI_Comm_rank(comm, &rank); + sbuf = (int *) malloc(size * size * sizeof(int)); + rbuf = (int *) malloc(asize * asize * sizeof(int)); + if (!sbuf || !rbuf) { + fprintf(stderr, "Could not allocated buffers!\n"); + MPI_Abort(comm, 1); + } + + /* Load up the buffers */ + for (i = 0; i < size * size; i++) { + sbuf[i] = i + 100 * rank; + rbuf[i] = -i; + } - /* Create the buffer */ - MPI_Comm_size( comm, &lsize ); - MPI_Comm_remote_size( comm, &size ); - asize = (lsize > size) ? lsize : size; - MPI_Comm_rank( comm, &rank ); - sbuf = (int *)malloc( size * size * sizeof(int) ); - rbuf = (int *)malloc( asize * asize * sizeof(int) ); - if (!sbuf || !rbuf) { - fprintf( stderr, "Could not allocated buffers!\n" ); - MPI_Abort( comm, 1 ); - exit(1); - } - - /* Load up the buffers */ - for (i=0; i #include #include "mpitest.h" +#include "mpicolltest.h" /* static char MTEST_Descrip[] = "Simple intercomm barrier test"; @@ -15,45 +16,45 @@ static char MTEST_Descrip[] = "Simple intercomm barrier test"; /* This only checks that the Barrier operation accepts intercommunicators. It does not check for the semantics of a intercomm barrier (all processes - in the local group can exit when (but not before) all processes in the + in the local group can exit when (but not before) all processes in the remote group enter the barrier */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0, err; int leftGroup; MPI_Comm comm; - /* MPI_Datatype datatype; */ + MPI_Datatype datatype; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - /* datatype = MPI_INT; */ + datatype = MPI_INT; /* Get an intercommunicator */ - while (MTestGetIntercomm( &comm, &leftGroup, 4 )) { + while (MTestGetIntercomm(&comm, &leftGroup, 4)) { if (comm == MPI_COMM_NULL) continue; - /* To improve reporting of problems about operations, we - change the error handler to errors return */ - MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN ); - if (leftGroup) { - err = MPI_Barrier( comm ); - if (err) { - errs++; - MTestPrintError( err ); - } - } - else { - /* In the right group */ - err = MPI_Barrier( comm ); - if (err) { - errs++; - MTestPrintError( err ); - } - } - MTestFreeComm( &comm ); + /* To improve reporting of problems about operations, we + * change the error handler to errors return */ + MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN); + if (leftGroup) { + err = MTest_Barrier(comm); + if (err) { + errs++; + MTestPrintError(err); + } + } + else { + /* In the right group */ + err = MTest_Barrier(comm); + if (err) { + errs++; + MTestPrintError(err); + } + } + MTestFreeComm(&comm); } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/coll/icbcast.c b/teshsuite/smpi/mpich3-test/coll/icbcast.c index 660d8614e2..39d0cda33b 100644 --- a/teshsuite/smpi/mpich3-test/coll/icbcast.c +++ b/teshsuite/smpi/mpich3-test/coll/icbcast.c @@ -8,12 +8,13 @@ #include #include #include "mpitest.h" +#include "mpicolltest.h" /* static char MTEST_Descrip[] = "Simple intercomm broadcast test"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0, err; int *buf = 0; @@ -21,67 +22,69 @@ int main( int argc, char *argv[] ) MPI_Comm comm; MPI_Datatype datatype; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); datatype = MPI_INT; /* Get an intercommunicator */ - while (MTestGetIntercomm( &comm, &leftGroup, 4 )) { + while (MTestGetIntercomm(&comm, &leftGroup, 4)) { if (comm == MPI_COMM_NULL) continue; - MPI_Comm_rank( comm, &rank ); + MPI_Comm_rank(comm, &rank); - /* To improve reporting of problems about operations, we - change the error handler to errors return */ - MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN ); + /* To improve reporting of problems about operations, we + * change the error handler to errors return */ + MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN); - for (count = 1; count < 65000; count = 2 * count) { - buf = (int *)malloc( count * sizeof(int) ); - if (leftGroup) { - if (rank == 0) { - for (i=0; i #include #include "mpitest.h" +#include "mpicolltest.h" /* static char MTEST_Descrip[] = "Simple intercomm gather test"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0, err; int *buf = 0; @@ -21,66 +22,67 @@ int main( int argc, char *argv[] ) MPI_Comm comm; MPI_Datatype datatype; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); datatype = MPI_INT; /* Get an intercommunicator */ - while (MTestGetIntercomm( &comm, &leftGroup, 4 )) { - if (comm == MPI_COMM_NULL) continue; - MPI_Comm_rank( comm, &rank ); - MPI_Comm_remote_size( comm, &rsize ); - MPI_Comm_size( comm, &size ); - /* To improve reporting of problems about operations, we - change the error handler to errors return */ - MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN ); - for (count = 1; count < 65000; count = 2 * count) { - if (leftGroup) { - buf = (int *)malloc( count * rsize * sizeof(int) ); - for (i=0; i #include #include "mpitest.h" +#include "mpicolltest.h" /* static char MTEST_Descrip[] = "Simple intercomm gatherv test"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0, err; int *buf = 0; @@ -23,78 +24,79 @@ int main( int argc, char *argv[] ) MPI_Comm comm; MPI_Datatype datatype; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); datatype = MPI_INT; - while (MTestGetIntercomm( &comm, &leftGroup, 4 )) { - if (comm == MPI_COMM_NULL) continue; - MPI_Comm_rank( comm, &rank ); - MPI_Comm_remote_size( comm, &rsize ); - MPI_Comm_size( comm, &size ); - - /* To improve reporting of problems about operations, we - change the error handler to errors return */ - MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN ); + while (MTestGetIntercomm(&comm, &leftGroup, 4)) { + if (comm == MPI_COMM_NULL) + continue; + MPI_Comm_rank(comm, &rank); + MPI_Comm_remote_size(comm, &rsize); + MPI_Comm_size(comm, &size); - for (count = 1; count < 65000; count = 2 * count) { - /* Get an intercommunicator */ - recvcounts = (int *)malloc( rsize * sizeof(int) ); - recvdispls = (int *)malloc( rsize * sizeof(int) ); - /* This simple test duplicates the Gather test, - using the same lengths for all messages */ - for (i=0; i #include #include "mpitest.h" +#include "mpicolltest.h" /* static char MTEST_Descrip[] = "Simple intercomm reduce test"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0, err; - int *sendbuf = 0, *recvbuf=0; + int *sendbuf = 0, *recvbuf = 0; int leftGroup, i, count, rank, rsize; MPI_Comm comm; MPI_Datatype datatype; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); datatype = MPI_INT; /* Get an intercommunicator */ - while (MTestGetIntercomm( &comm, &leftGroup, 4 )) { + while (MTestGetIntercomm(&comm, &leftGroup, 4)) { if (comm == MPI_COMM_NULL) continue; - MPI_Comm_rank( comm, &rank ); - MPI_Comm_remote_size( comm, &rsize ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_remote_size(comm, &rsize); - /* To improve reporting of problems about operations, we - change the error handler to errors return */ - MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN ); + /* To improve reporting of problems about operations, we + * change the error handler to errors return */ + MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN); - for (count = 1; count < 65000; count = 2 * count) { - sendbuf = (int *)malloc( count * sizeof(int) ); - recvbuf = (int *)malloc( count * sizeof(int) ); - for (i=0; i #include #include "mpitest.h" +#include "mpicolltest.h" /* static char MTEST_Descrip[] = "Simple intercomm scatter test"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0, err; int *buf = 0; @@ -21,77 +22,78 @@ int main( int argc, char *argv[] ) MPI_Comm comm; MPI_Datatype datatype; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); datatype = MPI_INT; /* Get an intercommunicator */ - while (MTestGetIntercomm( &comm, &leftGroup, 4 )) { - if (comm == MPI_COMM_NULL) continue; - MPI_Comm_remote_size( comm, &rsize ); - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + while (MTestGetIntercomm(&comm, &leftGroup, 4)) { + if (comm == MPI_COMM_NULL) + continue; + MPI_Comm_remote_size(comm, &rsize); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); - /* To improve reporting of problems about operations, we - change the error handler to errors return */ - MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN ); + /* To improve reporting of problems about operations, we + * change the error handler to errors return */ + MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN); - for (count = 1; count < 65000; count = 2 * count) { - buf = 0; - if (leftGroup) { - buf = (int *)malloc( count * rsize * sizeof(int) ); - if (rank == 0) { - for (i=0; i #include #include "mpitest.h" +#include "mpicolltest.h" /* static char MTEST_Descrip[] = "Simple intercomm scatterv test"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0, err; int *buf = 0; @@ -23,85 +24,86 @@ int main( int argc, char *argv[] ) MPI_Comm comm; MPI_Datatype datatype; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); datatype = MPI_INT; /* Get an intercommunicator */ - while (MTestGetIntercomm( &comm, &leftGroup, 4 )) { - if (comm == MPI_COMM_NULL) continue; - MPI_Comm_remote_size( comm, &rsize ); - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + while (MTestGetIntercomm(&comm, &leftGroup, 4)) { + if (comm == MPI_COMM_NULL) + continue; + MPI_Comm_remote_size(comm, &rsize); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); - /* To improve reporting of problems about operations, we - change the error handler to errors return */ - MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN ); + /* To improve reporting of problems about operations, we + * change the error handler to errors return */ + MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN); - for (count = 1; count < 65000; count = 2 * count) { - buf = 0; - sendcounts = (int *)malloc( rsize * sizeof(int) ); - senddispls = (int *)malloc( rsize * sizeof(int) ); - for (i=0; i #include -int add ( double *, double *, int *, MPI_Datatype * ); +int add(double *, double *, int *, MPI_Datatype *); /* * User-defined operation on a long value (tests proper handling of * possible pipelining in the implementation of reductions with user-defined * operations). */ -int add( double *invec, double *inoutvec, int *len, MPI_Datatype *dtype ) +int add(double *invec, double *inoutvec, int *len, MPI_Datatype * dtype) { int i, n = *len; - for (i=0; i PRIME); /* sanity */ + buf_alias = (signed char *) buf; + my_assert(COUNT * size * sizeof(int) > PRIME); /* sanity */ for (i = 0; i < PRIME; ++i) { if (rank == 0) buf_alias[i] = i; @@ -117,16 +116,17 @@ int main(int argc, char **argv) MPI_Wait(&req, MPI_STATUS_IGNORE); if (rank == 0) { for (i = 0; i < COUNT; ++i) { - if (recvbuf[i] != ((size * (size-1) / 2) + (i * size))) - printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i], ((size * (size-1) / 2) + (i * size))); - my_assert(recvbuf[i] == ((size * (size-1) / 2) + (i * size))); + if (recvbuf[i] != ((size * (size - 1) / 2) + (i * size))) + printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i], + ((size * (size - 1) / 2) + (i * size))); + my_assert(recvbuf[i] == ((size * (size - 1) / 2) + (i * size))); } } /* same again, use a user op and free it before the wait */ { MPI_Op op = MPI_OP_NULL; - MPI_Op_create(sum_fn, /*commute=*/1, &op); + MPI_Op_create(sum_fn, /*commute= */ 1, &op); for (i = 0; i < COUNT; ++i) { buf[i] = rank + i; @@ -137,9 +137,10 @@ int main(int argc, char **argv) MPI_Wait(&req, MPI_STATUS_IGNORE); if (rank == 0) { for (i = 0; i < COUNT; ++i) { - if (recvbuf[i] != ((size * (size-1) / 2) + (i * size))) - printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i], ((size * (size-1) / 2) + (i * size))); - my_assert(recvbuf[i] == ((size * (size-1) / 2) + (i * size))); + if (recvbuf[i] != ((size * (size - 1) / 2) + (i * size))) + printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i], + ((size * (size - 1) / 2) + (i * size))); + my_assert(recvbuf[i] == ((size * (size - 1) / 2) + (i * size))); } } } @@ -152,9 +153,10 @@ int main(int argc, char **argv) MPI_Iallreduce(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &req); MPI_Wait(&req, MPI_STATUS_IGNORE); for (i = 0; i < COUNT; ++i) { - if (recvbuf[i] != ((size * (size-1) / 2) + (i * size))) - printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i], ((size * (size-1) / 2) + (i * size))); - my_assert(recvbuf[i] == ((size * (size-1) / 2) + (i * size))); + if (recvbuf[i] != ((size * (size - 1) / 2) + (i * size))) + printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i], + ((size * (size - 1) / 2) + (i * size))); + my_assert(recvbuf[i] == ((size * (size - 1) / 2) + (i * size))); } /* MPI_Ialltoallv (a weak test, neither irregular nor sparse) */ @@ -164,21 +166,22 @@ int main(int argc, char **argv) sdispls[i] = COUNT * i; rdispls[i] = COUNT * i; for (j = 0; j < COUNT; ++j) { - buf[i*COUNT+j] = rank + (i * j); - recvbuf[i*COUNT+j] = 0xdeadbeef; + buf[i * COUNT + j] = rank + (i * j); + recvbuf[i * COUNT + j] = 0xdeadbeef; } } - MPI_Ialltoallv(buf, sendcounts, sdispls, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, MPI_COMM_WORLD, &req); + MPI_Ialltoallv(buf, sendcounts, sdispls, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, + MPI_COMM_WORLD, &req); MPI_Wait(&req, MPI_STATUS_IGNORE); for (i = 0; i < size; ++i) { for (j = 0; j < COUNT; ++j) { - /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j)));*/ - my_assert(recvbuf[i*COUNT+j] == (i + (rank * j))); + /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j))); */ + my_assert(recvbuf[i * COUNT + j] == (i + (rank * j))); } } /* MPI_Igather */ - for (i = 0; i < size*COUNT; ++i) { + for (i = 0; i < size * COUNT; ++i) { buf[i] = rank + i; recvbuf[i] = 0xdeadbeef; } @@ -187,12 +190,12 @@ int main(int argc, char **argv) if (rank == 0) { for (i = 0; i < size; ++i) { for (j = 0; j < COUNT; ++j) { - my_assert(recvbuf[i*COUNT+j] == i + j); + my_assert(recvbuf[i * COUNT + j] == i + j); } } } else { - for (i = 0; i < size*COUNT; ++i) { + for (i = 0; i < size * COUNT; ++i) { my_assert(recvbuf[i] == 0xdeadbeef); } } @@ -202,23 +205,23 @@ int main(int argc, char **argv) MPI_Datatype type = MPI_DATATYPE_NULL; MPI_Type_dup(MPI_INT, &type); - for (i = 0; i < size*COUNT; ++i) { + for (i = 0; i < size * COUNT; ++i) { buf[i] = rank + i; recvbuf[i] = 0xdeadbeef; } MPI_Igather(buf, COUNT, MPI_INT, recvbuf, COUNT, type, 0, MPI_COMM_WORLD, &req); - MPI_Type_free(&type); /* should cause implementations that don't refcount - correctly to blow up or hang in the wait */ + MPI_Type_free(&type); /* should cause implementations that don't refcount + * correctly to blow up or hang in the wait */ MPI_Wait(&req, MPI_STATUS_IGNORE); if (rank == 0) { for (i = 0; i < size; ++i) { for (j = 0; j < COUNT; ++j) { - my_assert(recvbuf[i*COUNT+j] == i + j); + my_assert(recvbuf[i * COUNT + j] == i + j); } } } else { - for (i = 0; i < size*COUNT; ++i) { + for (i = 0; i < size * COUNT; ++i) { my_assert(recvbuf[i] == 0xdeadbeef); } } @@ -228,10 +231,10 @@ int main(int argc, char **argv) for (i = 0; i < size; ++i) { for (j = 0; j < COUNT; ++j) { if (rank == 0) - buf[i*COUNT+j] = i + j; + buf[i * COUNT + j] = i + j; else - buf[i*COUNT+j] = 0xdeadbeef; - recvbuf[i*COUNT+j] = 0xdeadbeef; + buf[i * COUNT + j] = 0xdeadbeef; + recvbuf[i * COUNT + j] = 0xdeadbeef; } } MPI_Iscatter(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, 0, MPI_COMM_WORLD, &req); @@ -240,7 +243,7 @@ int main(int argc, char **argv) my_assert(recvbuf[j] == rank + j); } if (rank != 0) { - for (i = 0; i < size*COUNT; ++i) { + for (i = 0; i < size * COUNT; ++i) { /* check we didn't corrupt the sendbuf somehow */ my_assert(buf[i] == 0xdeadbeef); } @@ -253,19 +256,20 @@ int main(int argc, char **argv) sdispls[i] = i * COUNT; for (j = 0; j < COUNT; ++j) { if (rank == 0) - buf[i*COUNT+j] = i + j; + buf[i * COUNT + j] = i + j; else - buf[i*COUNT+j] = 0xdeadbeef; - recvbuf[i*COUNT+j] = 0xdeadbeef; + buf[i * COUNT + j] = 0xdeadbeef; + recvbuf[i * COUNT + j] = 0xdeadbeef; } } - MPI_Iscatterv(buf, sendcounts, sdispls, MPI_INT, recvbuf, COUNT, MPI_INT, 0, MPI_COMM_WORLD, &req); + MPI_Iscatterv(buf, sendcounts, sdispls, MPI_INT, recvbuf, COUNT, MPI_INT, 0, MPI_COMM_WORLD, + &req); MPI_Wait(&req, MPI_STATUS_IGNORE); for (j = 0; j < COUNT; ++j) { my_assert(recvbuf[j] == rank + j); } if (rank != 0) { - for (i = 0; i < size*COUNT; ++i) { + for (i = 0; i < size * COUNT; ++i) { /* check we didn't corrupt the sendbuf somehow */ my_assert(buf[i] == 0xdeadbeef); } @@ -273,7 +277,7 @@ int main(int argc, char **argv) for (i = 1; i < size; ++i) { for (j = 0; j < COUNT; ++j) { /* check we didn't corrupt the rest of the recvbuf */ - my_assert(recvbuf[i*COUNT+j] == 0xdeadbeef); + my_assert(recvbuf[i * COUNT + j] == 0xdeadbeef); } } @@ -281,8 +285,8 @@ int main(int argc, char **argv) for (i = 0; i < size; ++i) { recvcounts[i] = COUNT; for (j = 0; j < COUNT; ++j) { - buf[i*COUNT+j] = rank + i; - recvbuf[i*COUNT+j] = 0xdeadbeef; + buf[i * COUNT + j] = rank + i; + recvbuf[i * COUNT + j] = 0xdeadbeef; } } MPI_Ireduce_scatter(buf, recvbuf, recvcounts, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &req); @@ -293,15 +297,15 @@ int main(int argc, char **argv) for (i = 1; i < size; ++i) { for (j = 0; j < COUNT; ++j) { /* check we didn't corrupt the rest of the recvbuf */ - my_assert(recvbuf[i*COUNT+j] == 0xdeadbeef); + my_assert(recvbuf[i * COUNT + j] == 0xdeadbeef); } } /* MPI_Ireduce_scatter_block */ for (i = 0; i < size; ++i) { for (j = 0; j < COUNT; ++j) { - buf[i*COUNT+j] = rank + i; - recvbuf[i*COUNT+j] = 0xdeadbeef; + buf[i * COUNT + j] = rank + i; + recvbuf[i * COUNT + j] = 0xdeadbeef; } } MPI_Ireduce_scatter_block(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &req); @@ -312,12 +316,12 @@ int main(int argc, char **argv) for (i = 1; i < size; ++i) { for (j = 0; j < COUNT; ++j) { /* check we didn't corrupt the rest of the recvbuf */ - my_assert(recvbuf[i*COUNT+j] == 0xdeadbeef); + my_assert(recvbuf[i * COUNT + j] == 0xdeadbeef); } } /* MPI_Igatherv */ - for (i = 0; i < size*COUNT; ++i) { + for (i = 0; i < size * COUNT; ++i) { buf[i] = 0xdeadbeef; recvbuf[i] = 0xdeadbeef; } @@ -328,17 +332,18 @@ int main(int argc, char **argv) recvcounts[i] = COUNT; rdispls[i] = i * COUNT; } - MPI_Igatherv(buf, COUNT, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, 0, MPI_COMM_WORLD, &req); + MPI_Igatherv(buf, COUNT, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, 0, MPI_COMM_WORLD, + &req); MPI_Wait(&req, MPI_STATUS_IGNORE); if (rank == 0) { for (i = 0; i < size; ++i) { for (j = 0; j < COUNT; ++j) { - my_assert(recvbuf[i*COUNT+j] == i + j); + my_assert(recvbuf[i * COUNT + j] == i + j); } } } else { - for (i = 0; i < size*COUNT; ++i) { + for (i = 0; i < size * COUNT; ++i) { my_assert(recvbuf[i] == 0xdeadbeef); } } @@ -346,21 +351,21 @@ int main(int argc, char **argv) /* MPI_Ialltoall */ for (i = 0; i < size; ++i) { for (j = 0; j < COUNT; ++j) { - buf[i*COUNT+j] = rank + (i * j); - recvbuf[i*COUNT+j] = 0xdeadbeef; + buf[i * COUNT + j] = rank + (i * j); + recvbuf[i * COUNT + j] = 0xdeadbeef; } } MPI_Ialltoall(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, MPI_COMM_WORLD, &req); MPI_Wait(&req, MPI_STATUS_IGNORE); for (i = 0; i < size; ++i) { for (j = 0; j < COUNT; ++j) { - /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (i * j)));*/ - my_assert(recvbuf[i*COUNT+j] == (i + (rank * j))); + /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (i * j))); */ + my_assert(recvbuf[i * COUNT + j] == (i + (rank * j))); } } /* MPI_Iallgather */ - for (i = 0; i < size*COUNT; ++i) { + for (i = 0; i < size * COUNT; ++i) { buf[i] = rank + i; recvbuf[i] = 0xdeadbeef; } @@ -368,25 +373,26 @@ int main(int argc, char **argv) MPI_Wait(&req, MPI_STATUS_IGNORE); for (i = 0; i < size; ++i) { for (j = 0; j < COUNT; ++j) { - my_assert(recvbuf[i*COUNT+j] == i + j); + my_assert(recvbuf[i * COUNT + j] == i + j); } } /* MPI_Iallgatherv */ for (i = 0; i < size; ++i) { for (j = 0; j < COUNT; ++j) { - recvbuf[i*COUNT+j] = 0xdeadbeef; + recvbuf[i * COUNT + j] = 0xdeadbeef; } recvcounts[i] = COUNT; rdispls[i] = i * COUNT; } for (i = 0; i < COUNT; ++i) buf[i] = rank + i; - MPI_Iallgatherv(buf, COUNT, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, MPI_COMM_WORLD, &req); + MPI_Iallgatherv(buf, COUNT, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, MPI_COMM_WORLD, + &req); MPI_Wait(&req, MPI_STATUS_IGNORE); for (i = 0; i < size; ++i) { for (j = 0; j < COUNT; ++j) { - my_assert(recvbuf[i*COUNT+j] == i + j); + my_assert(recvbuf[i * COUNT + j] == i + j); } } @@ -398,7 +404,7 @@ int main(int argc, char **argv) MPI_Iscan(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &req); MPI_Wait(&req, MPI_STATUS_IGNORE); for (i = 0; i < COUNT; ++i) { - my_assert(recvbuf[i] == ((rank * (rank+1) / 2) + (i * (rank + 1)))); + my_assert(recvbuf[i] == ((rank * (rank + 1) / 2) + (i * (rank + 1)))); } /* MPI_Iexscan */ @@ -412,7 +418,7 @@ int main(int argc, char **argv) if (rank == 0) my_assert(recvbuf[i] == 0xdeadbeef); else - my_assert(recvbuf[i] == ((rank * (rank+1) / 2) + (i * (rank + 1)) - (rank + i))); + my_assert(recvbuf[i] == ((rank * (rank + 1) / 2) + (i * (rank + 1)) - (rank + i))); } /* MPI_Ialltoallw (a weak test, neither irregular nor sparse) */ @@ -424,16 +430,17 @@ int main(int argc, char **argv) sendtypes[i] = MPI_INT; recvtypes[i] = MPI_INT; for (j = 0; j < COUNT; ++j) { - buf[i*COUNT+j] = rank + (i * j); - recvbuf[i*COUNT+j] = 0xdeadbeef; + buf[i * COUNT + j] = rank + (i * j); + recvbuf[i * COUNT + j] = 0xdeadbeef; } } - MPI_Ialltoallw(buf, sendcounts, sdispls, sendtypes, recvbuf, recvcounts, rdispls, recvtypes, MPI_COMM_WORLD, &req); + MPI_Ialltoallw(buf, sendcounts, sdispls, sendtypes, recvbuf, recvcounts, rdispls, recvtypes, + MPI_COMM_WORLD, &req); MPI_Wait(&req, MPI_STATUS_IGNORE); for (i = 0; i < size; ++i) { for (j = 0; j < COUNT; ++j) { - /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j)));*/ - my_assert(recvbuf[i*COUNT+j] == (i + (rank * j))); + /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j))); */ + my_assert(recvbuf[i * COUNT + j] == (i + (rank * j))); } } @@ -452,4 +459,3 @@ int main(int argc, char **argv) free(sendtypes); return 0; } - diff --git a/teshsuite/smpi/mpich3-test/coll/nonblocking3.c b/teshsuite/smpi/mpich3-test/coll/nonblocking3.c index 2a92994959..35cc4280f5 100644 --- a/teshsuite/smpi/mpich3-test/coll/nonblocking3.c +++ b/teshsuite/smpi/mpich3-test/coll/nonblocking3.c @@ -19,7 +19,7 @@ #include #include -#if HAVE_UNISTD_H +#ifdef HAVE_UNISTD_H #include #endif @@ -33,7 +33,7 @@ static int errs = 0; /* we sleep with probability 1/CHANCE_OF_SLEEP */ #define CHANCE_OF_SLEEP (1000) /* JITTER_DELAY is denominated in microseconds (us) */ -#define JITTER_DELAY (50000) /* 0.05 seconds */ +#define JITTER_DELAY (50000) /* 0.05 seconds */ /* NUM_COMMS is the number of communicators on which ops will be posted */ #define NUM_COMMS (4) @@ -65,7 +65,7 @@ static unsigned int gen_prn(unsigned int x) * a=279470273, good primitive root of m from "TABLES OF LINEAR * CONGRUENTIAL GENERATORS OF DIFFERENT SIZES AND GOOD * LATTICE STRUCTURE", by Pierre L’Ecuyer */ - return (279470273UL * (unsigned long)x) % 4294967291UL; + return (279470273UL * (unsigned long) x) % 4294967291UL; } /* given a random unsigned int value "rndval_" from gen_prn, this evaluates to a @@ -74,7 +74,7 @@ static unsigned int gen_prn(unsigned int x) ((unsigned int)((min_) + ((rndval_) * (1.0 / (GEN_PRN_MAX+1.0)) * ((max_) - (min_))))) -static void sum_fn(void *invec, void *inoutvec, int *len, MPI_Datatype *datatype) +static void sum_fn(void *invec, void *inoutvec, int *len, MPI_Datatype * datatype) { int i; int *in = invec; @@ -87,7 +87,7 @@ static void sum_fn(void *invec, void *inoutvec, int *len, MPI_Datatype *datatype /* used to keep track of buffers that should be freed after the corresponding * operation has completed */ struct laundry { - int case_num; /* which test case initiated this req/laundry */ + int case_num; /* which test case initiated this req/laundry */ MPI_Comm comm; int *buf; int *recvbuf; @@ -103,21 +103,30 @@ static void cleanup_laundry(struct laundry *l) { l->case_num = -1; l->comm = MPI_COMM_NULL; - if (l->buf) free(l->buf); - if (l->recvbuf) free(l->recvbuf); - if (l->sendcounts) free(l->sendcounts); - if (l->recvcounts) free(l->recvcounts); - if (l->sdispls) free(l->sdispls); - if (l->rdispls) free(l->rdispls); - if (l->sendtypes) free(l->sendtypes); - if (l->recvtypes) free(l->recvtypes); + if (l->buf) + free(l->buf); + if (l->recvbuf) + free(l->recvbuf); + if (l->sendcounts) + free(l->sendcounts); + if (l->recvcounts) + free(l->recvcounts); + if (l->sdispls) + free(l->sdispls); + if (l->rdispls) + free(l->rdispls); + if (l->sendtypes) + free(l->sendtypes); + if (l->recvtypes) + free(l->recvtypes); } /* Starts a "random" operation on "comm" corresponding to "rndnum" and returns * in (*req) a request handle corresonding to that operation. This call should * be considered collective over comm (with a consistent value for "rndnum"), * even though the operation may only be a point-to-point request. */ -static void start_random_nonblocking(MPI_Comm comm, unsigned int rndnum, MPI_Request *req, struct laundry *l) +static void start_random_nonblocking(MPI_Comm comm, unsigned int rndnum, MPI_Request * req, + struct laundry *l) { int i, j; int rank, size; @@ -139,262 +148,263 @@ static void start_random_nonblocking(MPI_Comm comm, unsigned int rndnum, MPI_Req l->case_num = -1; l->comm = comm; - l->buf = buf = malloc(COUNT*size*sizeof(int)); - l->recvbuf = recvbuf = malloc(COUNT*size*sizeof(int)); - l->sendcounts = sendcounts = malloc(size*sizeof(int)); - l->recvcounts = recvcounts = malloc(size*sizeof(int)); - l->sdispls = sdispls = malloc(size*sizeof(int)); - l->rdispls = rdispls = malloc(size*sizeof(int)); - l->sendtypes = sendtypes = malloc(size*sizeof(MPI_Datatype)); - l->recvtypes = recvtypes = malloc(size*sizeof(MPI_Datatype)); + l->buf = buf = malloc(COUNT * size * sizeof(int)); + l->recvbuf = recvbuf = malloc(COUNT * size * sizeof(int)); + l->sendcounts = sendcounts = malloc(size * sizeof(int)); + l->recvcounts = recvcounts = malloc(size * sizeof(int)); + l->sdispls = sdispls = malloc(size * sizeof(int)); + l->rdispls = rdispls = malloc(size * sizeof(int)); + l->sendtypes = sendtypes = malloc(size * sizeof(MPI_Datatype)); + l->recvtypes = recvtypes = malloc(size * sizeof(MPI_Datatype)); #define NUM_CASES (21) l->case_num = rand_range(rndnum, 0, NUM_CASES); switch (l->case_num) { - case 0: /* MPI_Ibcast */ - for (i = 0; i < COUNT; ++i) { - if (rank == 0) { - buf[i] = i; - } - else { - buf[i] = 0xdeadbeef; - } - } - MPI_Ibcast(buf, COUNT, MPI_INT, 0, comm, req); - break; - - case 1: /* MPI_Ibcast (again, but designed to stress scatter/allgather impls) */ - /* FIXME fiddle with PRIME and buffer allocation s.t. PRIME is much larger (1021?) */ - buf_alias = (signed char *)buf; - my_assert(COUNT*size*sizeof(int) > PRIME); /* sanity */ - for (i = 0; i < PRIME; ++i) { - if (rank == 0) - buf_alias[i] = i; - else - buf_alias[i] = 0xdb; + case 0: /* MPI_Ibcast */ + for (i = 0; i < COUNT; ++i) { + if (rank == 0) { + buf[i] = i; } - for (i = PRIME; i < COUNT * size * sizeof(int); ++i) { - buf_alias[i] = 0xbf; + else { + buf[i] = 0xdeadbeef; } - MPI_Ibcast(buf_alias, PRIME, MPI_SIGNED_CHAR, 0, comm, req); - break; - - case 2: /* MPI_Ibarrier */ - MPI_Ibarrier(comm, req); - break; + } + MPI_Ibcast(buf, COUNT, MPI_INT, 0, comm, req); + break; + + case 1: /* MPI_Ibcast (again, but designed to stress scatter/allgather impls) */ + /* FIXME fiddle with PRIME and buffer allocation s.t. PRIME is much larger (1021?) */ + buf_alias = (signed char *) buf; + my_assert(COUNT * size * sizeof(int) > PRIME); /* sanity */ + for (i = 0; i < PRIME; ++i) { + if (rank == 0) + buf_alias[i] = i; + else + buf_alias[i] = 0xdb; + } + for (i = PRIME; i < COUNT * size * sizeof(int); ++i) { + buf_alias[i] = 0xbf; + } + MPI_Ibcast(buf_alias, PRIME, MPI_SIGNED_CHAR, 0, comm, req); + break; - case 3: /* MPI_Ireduce */ - for (i = 0; i < COUNT; ++i) { - buf[i] = rank + i; - recvbuf[i] = 0xdeadbeef; - } - MPI_Ireduce(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, 0, comm, req); - break; + case 2: /* MPI_Ibarrier */ + MPI_Ibarrier(comm, req); + break; - case 4: /* same again, use a user op and free it before the wait */ - { - MPI_Op op = MPI_OP_NULL; - MPI_Op_create(sum_fn, /*commute=*/1, &op); - for (i = 0; i < COUNT; ++i) { - buf[i] = rank + i; - recvbuf[i] = 0xdeadbeef; - } - MPI_Ireduce(buf, recvbuf, COUNT, MPI_INT, op, 0, comm, req); - MPI_Op_free(&op); - } - break; + case 3: /* MPI_Ireduce */ + for (i = 0; i < COUNT; ++i) { + buf[i] = rank + i; + recvbuf[i] = 0xdeadbeef; + } + MPI_Ireduce(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, 0, comm, req); + break; - case 5: /* MPI_Iallreduce */ + case 4: /* same again, use a user op and free it before the wait */ + { + MPI_Op op = MPI_OP_NULL; + MPI_Op_create(sum_fn, /*commute= */ 1, &op); for (i = 0; i < COUNT; ++i) { buf[i] = rank + i; recvbuf[i] = 0xdeadbeef; } - MPI_Iallreduce(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req); - break; + MPI_Ireduce(buf, recvbuf, COUNT, MPI_INT, op, 0, comm, req); + MPI_Op_free(&op); + } + break; - case 6: /* MPI_Ialltoallv (a weak test, neither irregular nor sparse) */ - for (i = 0; i < size; ++i) { - sendcounts[i] = COUNT; - recvcounts[i] = COUNT; - sdispls[i] = COUNT * i; - rdispls[i] = COUNT * i; - for (j = 0; j < COUNT; ++j) { - buf[i*COUNT+j] = rank + (i * j); - recvbuf[i*COUNT+j] = 0xdeadbeef; - } + case 5: /* MPI_Iallreduce */ + for (i = 0; i < COUNT; ++i) { + buf[i] = rank + i; + recvbuf[i] = 0xdeadbeef; + } + MPI_Iallreduce(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req); + break; + + case 6: /* MPI_Ialltoallv (a weak test, neither irregular nor sparse) */ + for (i = 0; i < size; ++i) { + sendcounts[i] = COUNT; + recvcounts[i] = COUNT; + sdispls[i] = COUNT * i; + rdispls[i] = COUNT * i; + for (j = 0; j < COUNT; ++j) { + buf[i * COUNT + j] = rank + (i * j); + recvbuf[i * COUNT + j] = 0xdeadbeef; } - MPI_Ialltoallv(buf, sendcounts, sdispls, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, comm, req); - break; - - case 7: /* MPI_Igather */ - for (i = 0; i < size*COUNT; ++i) { + } + MPI_Ialltoallv(buf, sendcounts, sdispls, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, + comm, req); + break; + + case 7: /* MPI_Igather */ + for (i = 0; i < size * COUNT; ++i) { + buf[i] = rank + i; + recvbuf[i] = 0xdeadbeef; + } + MPI_Igather(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, 0, comm, req); + break; + + case 8: /* same test again, just use a dup'ed datatype and free it before the wait */ + { + MPI_Datatype type = MPI_DATATYPE_NULL; + MPI_Type_dup(MPI_INT, &type); + for (i = 0; i < size * COUNT; ++i) { buf[i] = rank + i; recvbuf[i] = 0xdeadbeef; } - MPI_Igather(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, 0, comm, req); - break; - - case 8: /* same test again, just use a dup'ed datatype and free it before the wait */ - { - MPI_Datatype type = MPI_DATATYPE_NULL; - MPI_Type_dup(MPI_INT, &type); - for (i = 0; i < size*COUNT; ++i) { - buf[i] = rank + i; - recvbuf[i] = 0xdeadbeef; - } - MPI_Igather(buf, COUNT, MPI_INT, recvbuf, COUNT, type, 0, comm, req); - MPI_Type_free(&type); /* should cause implementations that don't refcount - correctly to blow up or hang in the wait */ - } - break; - - case 9: /* MPI_Iscatter */ - for (i = 0; i < size; ++i) { - for (j = 0; j < COUNT; ++j) { - if (rank == 0) - buf[i*COUNT+j] = i + j; - else - buf[i*COUNT+j] = 0xdeadbeef; - recvbuf[i*COUNT+j] = 0xdeadbeef; - } - } - MPI_Iscatter(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, 0, comm, req); - break; - - case 10: /* MPI_Iscatterv */ - for (i = 0; i < size; ++i) { - /* weak test, just test the regular case where all counts are equal */ - sendcounts[i] = COUNT; - sdispls[i] = i * COUNT; - for (j = 0; j < COUNT; ++j) { - if (rank == 0) - buf[i*COUNT+j] = i + j; - else - buf[i*COUNT+j] = 0xdeadbeef; - recvbuf[i*COUNT+j] = 0xdeadbeef; - } - } - MPI_Iscatterv(buf, sendcounts, sdispls, MPI_INT, recvbuf, COUNT, MPI_INT, 0, comm, req); - break; + MPI_Igather(buf, COUNT, MPI_INT, recvbuf, COUNT, type, 0, comm, req); + MPI_Type_free(&type); /* should cause implementations that don't refcount + * correctly to blow up or hang in the wait */ + } + break; - case 11: /* MPI_Ireduce_scatter */ - for (i = 0; i < size; ++i) { - recvcounts[i] = COUNT; - for (j = 0; j < COUNT; ++j) { - buf[i*COUNT+j] = rank + i; - recvbuf[i*COUNT+j] = 0xdeadbeef; - } + case 9: /* MPI_Iscatter */ + for (i = 0; i < size; ++i) { + for (j = 0; j < COUNT; ++j) { + if (rank == 0) + buf[i * COUNT + j] = i + j; + else + buf[i * COUNT + j] = 0xdeadbeef; + recvbuf[i * COUNT + j] = 0xdeadbeef; } - MPI_Ireduce_scatter(buf, recvbuf, recvcounts, MPI_INT, MPI_SUM, comm, req); - break; - - case 12: /* MPI_Ireduce_scatter_block */ - for (i = 0; i < size; ++i) { - for (j = 0; j < COUNT; ++j) { - buf[i*COUNT+j] = rank + i; - recvbuf[i*COUNT+j] = 0xdeadbeef; - } + } + MPI_Iscatter(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, 0, comm, req); + break; + + case 10: /* MPI_Iscatterv */ + for (i = 0; i < size; ++i) { + /* weak test, just test the regular case where all counts are equal */ + sendcounts[i] = COUNT; + sdispls[i] = i * COUNT; + for (j = 0; j < COUNT; ++j) { + if (rank == 0) + buf[i * COUNT + j] = i + j; + else + buf[i * COUNT + j] = 0xdeadbeef; + recvbuf[i * COUNT + j] = 0xdeadbeef; } - MPI_Ireduce_scatter_block(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req); - break; + } + MPI_Iscatterv(buf, sendcounts, sdispls, MPI_INT, recvbuf, COUNT, MPI_INT, 0, comm, req); + break; - case 13: /* MPI_Igatherv */ - for (i = 0; i < size*COUNT; ++i) { - buf[i] = 0xdeadbeef; - recvbuf[i] = 0xdeadbeef; - } - for (i = 0; i < COUNT; ++i) { - buf[i] = rank + i; - } - for (i = 0; i < size; ++i) { - recvcounts[i] = COUNT; - rdispls[i] = i * COUNT; + case 11: /* MPI_Ireduce_scatter */ + for (i = 0; i < size; ++i) { + recvcounts[i] = COUNT; + for (j = 0; j < COUNT; ++j) { + buf[i * COUNT + j] = rank + i; + recvbuf[i * COUNT + j] = 0xdeadbeef; } - MPI_Igatherv(buf, COUNT, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, 0, comm, req); - break; + } + MPI_Ireduce_scatter(buf, recvbuf, recvcounts, MPI_INT, MPI_SUM, comm, req); + break; - case 14: /* MPI_Ialltoall */ - for (i = 0; i < size; ++i) { - for (j = 0; j < COUNT; ++j) { - buf[i*COUNT+j] = rank + (i * j); - recvbuf[i*COUNT+j] = 0xdeadbeef; - } + case 12: /* MPI_Ireduce_scatter_block */ + for (i = 0; i < size; ++i) { + for (j = 0; j < COUNT; ++j) { + buf[i * COUNT + j] = rank + i; + recvbuf[i * COUNT + j] = 0xdeadbeef; } - MPI_Ialltoall(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, comm, req); - break; + } + MPI_Ireduce_scatter_block(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req); + break; - case 15: /* MPI_Iallgather */ - for (i = 0; i < size*COUNT; ++i) { - buf[i] = rank + i; - recvbuf[i] = 0xdeadbeef; - } - MPI_Iallgather(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, comm, req); - break; + case 13: /* MPI_Igatherv */ + for (i = 0; i < size * COUNT; ++i) { + buf[i] = 0xdeadbeef; + recvbuf[i] = 0xdeadbeef; + } + for (i = 0; i < COUNT; ++i) { + buf[i] = rank + i; + } + for (i = 0; i < size; ++i) { + recvcounts[i] = COUNT; + rdispls[i] = i * COUNT; + } + MPI_Igatherv(buf, COUNT, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, 0, comm, req); + break; - case 16: /* MPI_Iallgatherv */ - for (i = 0; i < size; ++i) { - for (j = 0; j < COUNT; ++j) { - recvbuf[i*COUNT+j] = 0xdeadbeef; - } - recvcounts[i] = COUNT; - rdispls[i] = i * COUNT; + case 14: /* MPI_Ialltoall */ + for (i = 0; i < size; ++i) { + for (j = 0; j < COUNT; ++j) { + buf[i * COUNT + j] = rank + (i * j); + recvbuf[i * COUNT + j] = 0xdeadbeef; } - for (i = 0; i < COUNT; ++i) - buf[i] = rank + i; - MPI_Iallgatherv(buf, COUNT, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, comm, req); - break; + } + MPI_Ialltoall(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, comm, req); + break; - case 17: /* MPI_Iscan */ - for (i = 0; i < COUNT; ++i) { - buf[i] = rank + i; - recvbuf[i] = 0xdeadbeef; - } - MPI_Iscan(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req); - break; + case 15: /* MPI_Iallgather */ + for (i = 0; i < size * COUNT; ++i) { + buf[i] = rank + i; + recvbuf[i] = 0xdeadbeef; + } + MPI_Iallgather(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, comm, req); + break; - case 18: /* MPI_Iexscan */ - for (i = 0; i < COUNT; ++i) { - buf[i] = rank + i; - recvbuf[i] = 0xdeadbeef; + case 16: /* MPI_Iallgatherv */ + for (i = 0; i < size; ++i) { + for (j = 0; j < COUNT; ++j) { + recvbuf[i * COUNT + j] = 0xdeadbeef; } - MPI_Iexscan(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req); - break; + recvcounts[i] = COUNT; + rdispls[i] = i * COUNT; + } + for (i = 0; i < COUNT; ++i) + buf[i] = rank + i; + MPI_Iallgatherv(buf, COUNT, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, comm, req); + break; + + case 17: /* MPI_Iscan */ + for (i = 0; i < COUNT; ++i) { + buf[i] = rank + i; + recvbuf[i] = 0xdeadbeef; + } + MPI_Iscan(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req); + break; - case 19: /* MPI_Ialltoallw (a weak test, neither irregular nor sparse) */ - for (i = 0; i < size; ++i) { - sendcounts[i] = COUNT; - recvcounts[i] = COUNT; - sdispls[i] = COUNT * i * sizeof(int); - rdispls[i] = COUNT * i * sizeof(int); - sendtypes[i] = MPI_INT; - recvtypes[i] = MPI_INT; - for (j = 0; j < COUNT; ++j) { - buf[i*COUNT+j] = rank + (i * j); - recvbuf[i*COUNT+j] = 0xdeadbeef; - } + case 18: /* MPI_Iexscan */ + for (i = 0; i < COUNT; ++i) { + buf[i] = rank + i; + recvbuf[i] = 0xdeadbeef; + } + MPI_Iexscan(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req); + break; + + case 19: /* MPI_Ialltoallw (a weak test, neither irregular nor sparse) */ + for (i = 0; i < size; ++i) { + sendcounts[i] = COUNT; + recvcounts[i] = COUNT; + sdispls[i] = COUNT * i * sizeof(int); + rdispls[i] = COUNT * i * sizeof(int); + sendtypes[i] = MPI_INT; + recvtypes[i] = MPI_INT; + for (j = 0; j < COUNT; ++j) { + buf[i * COUNT + j] = rank + (i * j); + recvbuf[i * COUNT + j] = 0xdeadbeef; } - MPI_Ialltoallw(buf, sendcounts, sdispls, sendtypes, recvbuf, recvcounts, rdispls, recvtypes, comm, req); - break; + } + MPI_Ialltoallw(buf, sendcounts, sdispls, sendtypes, recvbuf, recvcounts, rdispls, recvtypes, + comm, req); + break; - case 20: /* basic pt2pt MPI_Isend/MPI_Irecv pairing */ - /* even ranks send to odd ranks, but only if we have a full pair */ - if ((rank % 2 != 0) || (rank != size-1)) { - for (j = 0; j < COUNT; ++j) { - buf[j] = j; - recvbuf[j] = 0xdeadbeef; - } - if (rank % 2 == 0) - MPI_Isend(buf, COUNT, MPI_INT, rank+1, 5, comm, req); - else - MPI_Irecv(recvbuf, COUNT, MPI_INT, rank-1, 5, comm, req); + case 20: /* basic pt2pt MPI_Isend/MPI_Irecv pairing */ + /* even ranks send to odd ranks, but only if we have a full pair */ + if ((rank % 2 != 0) || (rank != size - 1)) { + for (j = 0; j < COUNT; ++j) { + buf[j] = j; + recvbuf[j] = 0xdeadbeef; } - break; + if (rank % 2 == 0) + MPI_Isend(buf, COUNT, MPI_INT, rank + 1, 5, comm, req); + else + MPI_Irecv(recvbuf, COUNT, MPI_INT, rank - 1, 5, comm, req); + } + break; - default: - fprintf(stderr, "unexpected value for l->case_num=%d)\n", (l->case_num)); - MPI_Abort(comm, 1); - exit(1); - break; + default: + fprintf(stderr, "unexpected value for l->case_num=%d)\n", (l->case_num)); + MPI_Abort(comm, 1); + break; } } @@ -402,335 +412,341 @@ static void check_after_completion(struct laundry *l) { int i, j; int rank, size; - MPI_Comm comm = l->comm; - int *buf = l->buf; - int *recvbuf = l->recvbuf; + MPI_Comm comm = l->comm; + int *buf = l->buf; + int *recvbuf = l->recvbuf; int *sendcounts = l->sendcounts; int *recvcounts = l->recvcounts; - int *sdispls = l->sdispls; - int *rdispls = l->rdispls; - int *sendtypes = l->sendtypes; - int *recvtypes = l->recvtypes; - char *buf_alias = (char *)buf; + int *sdispls = l->sdispls; + int *rdispls = l->rdispls; + int *sendtypes = l->sendtypes; + int *recvtypes = l->recvtypes; + char *buf_alias = (char *) buf; MPI_Comm_rank(comm, &rank); MPI_Comm_size(comm, &size); /* these cases all correspond to cases in start_random_nonblocking */ switch (l->case_num) { - case 0: /* MPI_Ibcast */ - for (i = 0; i < COUNT; ++i) { - if (buf[i] != i) - printf("buf[%d]=%d i=%d\n", i, buf[i], i); - my_assert(buf[i] == i); - } - break; + case 0: /* MPI_Ibcast */ + for (i = 0; i < COUNT; ++i) { + if (buf[i] != i) + printf("buf[%d]=%d i=%d\n", i, buf[i], i); + my_assert(buf[i] == i); + } + break; - case 1: /* MPI_Ibcast (again, but designed to stress scatter/allgather impls) */ - for (i = 0; i < PRIME; ++i) { - if (buf_alias[i] != i) - printf("buf_alias[%d]=%d i=%d\n", i, buf_alias[i], i); - my_assert(buf_alias[i] == i); - } - break; + case 1: /* MPI_Ibcast (again, but designed to stress scatter/allgather impls) */ + for (i = 0; i < PRIME; ++i) { + if (buf_alias[i] != i) + printf("buf_alias[%d]=%d i=%d\n", i, buf_alias[i], i); + my_assert(buf_alias[i] == i); + } + break; - case 2: /* MPI_Ibarrier */ - /* nothing to check */ - break; + case 2: /* MPI_Ibarrier */ + /* nothing to check */ + break; - case 3: /* MPI_Ireduce */ - if (rank == 0) { - for (i = 0; i < COUNT; ++i) { - if (recvbuf[i] != ((size * (size-1) / 2) + (i * size))) - printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i], ((size * (size-1) / 2) + (i * size))); - my_assert(recvbuf[i] == ((size * (size-1) / 2) + (i * size))); - } + case 3: /* MPI_Ireduce */ + if (rank == 0) { + for (i = 0; i < COUNT; ++i) { + if (recvbuf[i] != ((size * (size - 1) / 2) + (i * size))) + printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i], + ((size * (size - 1) / 2) + (i * size))); + my_assert(recvbuf[i] == ((size * (size - 1) / 2) + (i * size))); } - break; + } + break; - case 4: /* same again, use a user op and free it before the wait */ - if (rank == 0) { - for (i = 0; i < COUNT; ++i) { - if (recvbuf[i] != ((size * (size-1) / 2) + (i * size))) - printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i], ((size * (size-1) / 2) + (i * size))); - my_assert(recvbuf[i] == ((size * (size-1) / 2) + (i * size))); - } + case 4: /* same again, use a user op and free it before the wait */ + if (rank == 0) { + for (i = 0; i < COUNT; ++i) { + if (recvbuf[i] != ((size * (size - 1) / 2) + (i * size))) + printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i], + ((size * (size - 1) / 2) + (i * size))); + my_assert(recvbuf[i] == ((size * (size - 1) / 2) + (i * size))); } - break; + } + break; + + case 5: /* MPI_Iallreduce */ + for (i = 0; i < COUNT; ++i) { + if (recvbuf[i] != ((size * (size - 1) / 2) + (i * size))) + printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i], + ((size * (size - 1) / 2) + (i * size))); + my_assert(recvbuf[i] == ((size * (size - 1) / 2) + (i * size))); + } + break; - case 5: /* MPI_Iallreduce */ - for (i = 0; i < COUNT; ++i) { - if (recvbuf[i] != ((size * (size-1) / 2) + (i * size))) - printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i], ((size * (size-1) / 2) + (i * size))); - my_assert(recvbuf[i] == ((size * (size-1) / 2) + (i * size))); + case 6: /* MPI_Ialltoallv (a weak test, neither irregular nor sparse) */ + for (i = 0; i < size; ++i) { + for (j = 0; j < COUNT; ++j) { + /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j))); */ + my_assert(recvbuf[i * COUNT + j] == (i + (rank * j))); } - break; + } + break; - case 6: /* MPI_Ialltoallv (a weak test, neither irregular nor sparse) */ + case 7: /* MPI_Igather */ + if (rank == 0) { for (i = 0; i < size; ++i) { for (j = 0; j < COUNT; ++j) { - /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j)));*/ - my_assert(recvbuf[i*COUNT+j] == (i + (rank * j))); + my_assert(recvbuf[i * COUNT + j] == i + j); } } - break; - - case 7: /* MPI_Igather */ - if (rank == 0) { - for (i = 0; i < size; ++i) { - for (j = 0; j < COUNT; ++j) { - my_assert(recvbuf[i*COUNT+j] == i + j); - } - } - } - else { - for (i = 0; i < size*COUNT; ++i) { - my_assert(recvbuf[i] == 0xdeadbeef); - } + } + else { + for (i = 0; i < size * COUNT; ++i) { + my_assert(recvbuf[i] == 0xdeadbeef); } - break; + } + break; - case 8: /* same test again, just use a dup'ed datatype and free it before the wait */ - if (rank == 0) { - for (i = 0; i < size; ++i) { - for (j = 0; j < COUNT; ++j) { - my_assert(recvbuf[i*COUNT+j] == i + j); - } + case 8: /* same test again, just use a dup'ed datatype and free it before the wait */ + if (rank == 0) { + for (i = 0; i < size; ++i) { + for (j = 0; j < COUNT; ++j) { + my_assert(recvbuf[i * COUNT + j] == i + j); } } - else { - for (i = 0; i < size*COUNT; ++i) { - my_assert(recvbuf[i] == 0xdeadbeef); - } + } + else { + for (i = 0; i < size * COUNT; ++i) { + my_assert(recvbuf[i] == 0xdeadbeef); } - break; + } + break; - case 9: /* MPI_Iscatter */ - for (j = 0; j < COUNT; ++j) { - my_assert(recvbuf[j] == rank + j); - } - if (rank != 0) { - for (i = 0; i < size*COUNT; ++i) { - /* check we didn't corrupt the sendbuf somehow */ - my_assert(buf[i] == 0xdeadbeef); - } + case 9: /* MPI_Iscatter */ + for (j = 0; j < COUNT; ++j) { + my_assert(recvbuf[j] == rank + j); + } + if (rank != 0) { + for (i = 0; i < size * COUNT; ++i) { + /* check we didn't corrupt the sendbuf somehow */ + my_assert(buf[i] == 0xdeadbeef); } - break; + } + break; - case 10: /* MPI_Iscatterv */ - for (j = 0; j < COUNT; ++j) { - my_assert(recvbuf[j] == rank + j); - } - if (rank != 0) { - for (i = 0; i < size*COUNT; ++i) { - /* check we didn't corrupt the sendbuf somehow */ - my_assert(buf[i] == 0xdeadbeef); - } - } - for (i = 1; i < size; ++i) { - for (j = 0; j < COUNT; ++j) { - /* check we didn't corrupt the rest of the recvbuf */ - my_assert(recvbuf[i*COUNT+j] == 0xdeadbeef); - } + case 10: /* MPI_Iscatterv */ + for (j = 0; j < COUNT; ++j) { + my_assert(recvbuf[j] == rank + j); + } + if (rank != 0) { + for (i = 0; i < size * COUNT; ++i) { + /* check we didn't corrupt the sendbuf somehow */ + my_assert(buf[i] == 0xdeadbeef); } - break; - - case 11: /* MPI_Ireduce_scatter */ + } + for (i = 1; i < size; ++i) { for (j = 0; j < COUNT; ++j) { - my_assert(recvbuf[j] == (size * rank + ((size - 1) * size) / 2)); + /* check we didn't corrupt the rest of the recvbuf */ + my_assert(recvbuf[i * COUNT + j] == 0xdeadbeef); } - for (i = 1; i < size; ++i) { - for (j = 0; j < COUNT; ++j) { - /* check we didn't corrupt the rest of the recvbuf */ - my_assert(recvbuf[i*COUNT+j] == 0xdeadbeef); - } - } - break; + } + break; - case 12: /* MPI_Ireduce_scatter_block */ + case 11: /* MPI_Ireduce_scatter */ + for (j = 0; j < COUNT; ++j) { + my_assert(recvbuf[j] == (size * rank + ((size - 1) * size) / 2)); + } + for (i = 1; i < size; ++i) { for (j = 0; j < COUNT; ++j) { - my_assert(recvbuf[j] == (size * rank + ((size - 1) * size) / 2)); - } - for (i = 1; i < size; ++i) { - for (j = 0; j < COUNT; ++j) { - /* check we didn't corrupt the rest of the recvbuf */ - my_assert(recvbuf[i*COUNT+j] == 0xdeadbeef); - } + /* check we didn't corrupt the rest of the recvbuf */ + my_assert(recvbuf[i * COUNT + j] == 0xdeadbeef); } - break; + } + break; - case 13: /* MPI_Igatherv */ - if (rank == 0) { - for (i = 0; i < size; ++i) { - for (j = 0; j < COUNT; ++j) { - my_assert(recvbuf[i*COUNT+j] == i + j); - } - } - } - else { - for (i = 0; i < size*COUNT; ++i) { - my_assert(recvbuf[i] == 0xdeadbeef); - } + case 12: /* MPI_Ireduce_scatter_block */ + for (j = 0; j < COUNT; ++j) { + my_assert(recvbuf[j] == (size * rank + ((size - 1) * size) / 2)); + } + for (i = 1; i < size; ++i) { + for (j = 0; j < COUNT; ++j) { + /* check we didn't corrupt the rest of the recvbuf */ + my_assert(recvbuf[i * COUNT + j] == 0xdeadbeef); } - break; + } + break; - case 14: /* MPI_Ialltoall */ + case 13: /* MPI_Igatherv */ + if (rank == 0) { for (i = 0; i < size; ++i) { for (j = 0; j < COUNT; ++j) { - /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (i * j)));*/ - my_assert(recvbuf[i*COUNT+j] == (i + (rank * j))); + my_assert(recvbuf[i * COUNT + j] == i + j); } } - break; - - case 15: /* MPI_Iallgather */ - for (i = 0; i < size; ++i) { - for (j = 0; j < COUNT; ++j) { - my_assert(recvbuf[i*COUNT+j] == i + j); - } + } + else { + for (i = 0; i < size * COUNT; ++i) { + my_assert(recvbuf[i] == 0xdeadbeef); } - break; + } + break; - case 16: /* MPI_Iallgatherv */ - for (i = 0; i < size; ++i) { - for (j = 0; j < COUNT; ++j) { - my_assert(recvbuf[i*COUNT+j] == i + j); - } + case 14: /* MPI_Ialltoall */ + for (i = 0; i < size; ++i) { + for (j = 0; j < COUNT; ++j) { + /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (i * j))); */ + my_assert(recvbuf[i * COUNT + j] == (i + (rank * j))); } - break; + } + break; - case 17: /* MPI_Iscan */ - for (i = 0; i < COUNT; ++i) { - my_assert(recvbuf[i] == ((rank * (rank+1) / 2) + (i * (rank + 1)))); + case 15: /* MPI_Iallgather */ + for (i = 0; i < size; ++i) { + for (j = 0; j < COUNT; ++j) { + my_assert(recvbuf[i * COUNT + j] == i + j); } - break; + } + break; - case 18: /* MPI_Iexscan */ - for (i = 0; i < COUNT; ++i) { - if (rank == 0) - my_assert(recvbuf[i] == 0xdeadbeef); - else - my_assert(recvbuf[i] == ((rank * (rank+1) / 2) + (i * (rank + 1)) - (rank + i))); + case 16: /* MPI_Iallgatherv */ + for (i = 0; i < size; ++i) { + for (j = 0; j < COUNT; ++j) { + my_assert(recvbuf[i * COUNT + j] == i + j); } - break; + } + break; - case 19: /* MPI_Ialltoallw (a weak test, neither irregular nor sparse) */ - for (i = 0; i < size; ++i) { - for (j = 0; j < COUNT; ++j) { - /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j)));*/ - my_assert(recvbuf[i*COUNT+j] == (i + (rank * j))); - } + case 17: /* MPI_Iscan */ + for (i = 0; i < COUNT; ++i) { + my_assert(recvbuf[i] == ((rank * (rank + 1) / 2) + (i * (rank + 1)))); + } + break; + + case 18: /* MPI_Iexscan */ + for (i = 0; i < COUNT; ++i) { + if (rank == 0) + my_assert(recvbuf[i] == 0xdeadbeef); + else + my_assert(recvbuf[i] == ((rank * (rank + 1) / 2) + (i * (rank + 1)) - (rank + i))); + } + break; + + case 19: /* MPI_Ialltoallw (a weak test, neither irregular nor sparse) */ + for (i = 0; i < size; ++i) { + for (j = 0; j < COUNT; ++j) { + /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j))); */ + my_assert(recvbuf[i * COUNT + j] == (i + (rank * j))); } - break; + } + break; - case 20: /* basic pt2pt MPI_Isend/MPI_Irecv pairing */ - /* even ranks send to odd ranks, but only if we have a full pair */ - if ((rank % 2 != 0) || (rank != size-1)) { - for (j = 0; j < COUNT; ++j) { - /* only odd procs did a recv */ - if (rank % 2 == 0) { - my_assert(recvbuf[j] == 0xdeadbeef); - } - else { - if (recvbuf[j] != j) printf("recvbuf[%d]=%d j=%d\n", j, recvbuf[j], j); - my_assert(recvbuf[j] == j); - } + case 20: /* basic pt2pt MPI_Isend/MPI_Irecv pairing */ + /* even ranks send to odd ranks, but only if we have a full pair */ + if ((rank % 2 != 0) || (rank != size - 1)) { + for (j = 0; j < COUNT; ++j) { + /* only odd procs did a recv */ + if (rank % 2 == 0) { + my_assert(recvbuf[j] == 0xdeadbeef); + } + else { + if (recvbuf[j] != j) + printf("recvbuf[%d]=%d j=%d\n", j, recvbuf[j], j); + my_assert(recvbuf[j] == j); } } - break; + } + break; - default: - printf("invalid case_num (%d) detected\n", l->case_num); - assert(0); - break; + default: + printf("invalid case_num (%d) detected\n", l->case_num); + assert(0); + break; } } + #undef NUM_CASES -static void complete_something_somehow(unsigned int rndnum, int numreqs, MPI_Request reqs[], int *outcount, int indices[]) +static void complete_something_somehow(unsigned int rndnum, int numreqs, MPI_Request reqs[], + int *outcount, int indices[]) { int i, idx, flag; #define COMPLETION_CASES (8) switch (rand_range(rndnum, 0, COMPLETION_CASES)) { - case 0: - MPI_Waitall(numreqs, reqs, MPI_STATUSES_IGNORE); - *outcount = numreqs; - for (i = 0; i < numreqs; ++i) { - indices[i] = i; - } - break; - - case 1: - MPI_Testsome(numreqs, reqs, outcount, indices, MPI_STATUS_IGNORE); - if (*outcount == MPI_UNDEFINED) { - *outcount = 0; - } - break; - - case 2: - MPI_Waitsome(numreqs, reqs, outcount, indices, MPI_STATUS_IGNORE); - if (*outcount == MPI_UNDEFINED) { - *outcount = 0; - } - break; - - case 3: - MPI_Waitany(numreqs, reqs, &idx, MPI_STATUS_IGNORE); - if (idx == MPI_UNDEFINED) { - *outcount = 0; - } - else { - *outcount = 1; - indices[0] = idx; - } - break; + case 0: + MPI_Waitall(numreqs, reqs, MPI_STATUSES_IGNORE); + *outcount = numreqs; + for (i = 0; i < numreqs; ++i) { + indices[i] = i; + } + break; - case 4: - MPI_Testany(numreqs, reqs, &idx, &flag, MPI_STATUS_IGNORE); - if (idx == MPI_UNDEFINED) { - *outcount = 0; - } - else { - *outcount = 1; - indices[0] = idx; - } - break; + case 1: + MPI_Testsome(numreqs, reqs, outcount, indices, MPI_STATUS_IGNORE); + if (*outcount == MPI_UNDEFINED) { + *outcount = 0; + } + break; - case 5: - MPI_Testall(numreqs, reqs, &flag, MPI_STATUSES_IGNORE); - if (flag) { - *outcount = numreqs; - for (i = 0; i < numreqs; ++i) { - indices[i] = i; - } - } - else { - *outcount = 0; - } - break; + case 2: + MPI_Waitsome(numreqs, reqs, outcount, indices, MPI_STATUS_IGNORE); + if (*outcount == MPI_UNDEFINED) { + *outcount = 0; + } + break; - case 6: - /* select a new random index and wait on it */ - rndnum = gen_prn(rndnum); - idx = rand_range(rndnum, 0, numreqs); - MPI_Wait(&reqs[idx], MPI_STATUS_IGNORE); + case 3: + MPI_Waitany(numreqs, reqs, &idx, MPI_STATUS_IGNORE); + if (idx == MPI_UNDEFINED) { + *outcount = 0; + } + else { *outcount = 1; indices[0] = idx; - break; - - case 7: - /* select a new random index and wait on it */ - rndnum = gen_prn(rndnum); - idx = rand_range(rndnum, 0, numreqs); - MPI_Test(&reqs[idx], &flag, MPI_STATUS_IGNORE); - *outcount = (flag ? 1 : 0); + } + break; + + case 4: + MPI_Testany(numreqs, reqs, &idx, &flag, MPI_STATUS_IGNORE); + if (idx == MPI_UNDEFINED) { + *outcount = 0; + } + else { + *outcount = 1; indices[0] = idx; - break; + } + break; - default: - assert(0); - break; + case 5: + MPI_Testall(numreqs, reqs, &flag, MPI_STATUSES_IGNORE); + if (flag) { + *outcount = numreqs; + for (i = 0; i < numreqs; ++i) { + indices[i] = i; + } + } + else { + *outcount = 0; + } + break; + + case 6: + /* select a new random index and wait on it */ + rndnum = gen_prn(rndnum); + idx = rand_range(rndnum, 0, numreqs); + MPI_Wait(&reqs[idx], MPI_STATUS_IGNORE); + *outcount = 1; + indices[0] = idx; + break; + + case 7: + /* select a new random index and wait on it */ + rndnum = gen_prn(rndnum); + idx = rand_range(rndnum, 0, numreqs); + MPI_Test(&reqs[idx], &flag, MPI_STATUS_IGNORE); + *outcount = (flag ? 1 : 0); + indices[0] = idx; + break; + + default: + assert(0); + break; } #undef COMPLETION_CASES } @@ -802,7 +818,7 @@ int main(int argc, char **argv) /* "randomly" and infrequently introduce some jitter into the system */ if (0 == rand_range(gen_prn(complete_seq + wrank), 0, CHANCE_OF_SLEEP)) { - usleep(JITTER_DELAY); /* take a short nap */ + usleep(JITTER_DELAY); /* take a short nap */ } } @@ -821,4 +837,3 @@ int main(int argc, char **argv) return 0; } - diff --git a/teshsuite/smpi/mpich3-test/coll/nonblocking4.c b/teshsuite/smpi/mpich3-test/coll/nonblocking4.c deleted file mode 100644 index 8cf7c250ff..0000000000 --- a/teshsuite/smpi/mpich3-test/coll/nonblocking4.c +++ /dev/null @@ -1,159 +0,0 @@ -/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ -/* - * (C) 2010 by Argonne National Laboratory. - * See COPYRIGHT in top-level directory. - */ - -/* This is a very weak sanity test that all nonblocking collectives specified by - * MPI-3 are present in the library and take arguments as expected. This test - * does not check for progress, matching issues, or sensible output buffer - * values. */ - -#include "mpi.h" -#include -#include -#include "mpitest.h" - -#define NUM_INTS (2) - -#define my_assert(cond_) \ - do { \ - if (!(cond_)) { \ - fprintf(stderr, "assertion (%s) failed, aborting\n", #cond_); \ - MPI_Abort(MPI_COMM_WORLD, 1); \ - } \ - } while (0) - -int main(int argc, char **argv) -{ - int errs = 0; - int i; - int rank, size; - int *sbuf = NULL; - int *rbuf = NULL; - int *scounts = NULL; - int *rcounts = NULL; - int *sdispls = NULL; - int *rdispls = NULL; - int *types = NULL; - MPI_Comm comm; - MPI_Request req; - - /* intentionally not using MTest_Init/MTest_Finalize in order to make it - * easy to take this test and use it as an NBC sanity test outside of the - * MPICH test suite */ - MPI_Init(&argc, &argv); - - comm = MPI_COMM_WORLD; - - MPI_Comm_size(comm, &size); - MPI_Comm_rank(comm, &rank); - - MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN); - - /* enough space for every process to contribute at least NUM_INTS ints to any - * collective operation */ - sbuf = malloc(NUM_INTS*size*sizeof(int)); - my_assert(sbuf); - rbuf = malloc(NUM_INTS*size*sizeof(int)); - my_assert(rbuf); - scounts = malloc(size*sizeof(int)); - my_assert(scounts); - rcounts = malloc(size*sizeof(int)); - my_assert(rcounts); - sdispls = malloc(size*sizeof(int)); - my_assert(sdispls); - rdispls = malloc(size*sizeof(int)); - my_assert(rdispls); - types = malloc(size*sizeof(int)); - my_assert(types); - - for (i = 0; i < size; ++i) { - sbuf[2*i] = i; - sbuf[2*i+1] = i; - rbuf[2*i] = i; - rbuf[2*i+1] = i; - scounts[i] = NUM_INTS; - rcounts[i] = NUM_INTS; - sdispls[i] = i * NUM_INTS; - rdispls[i] = i * NUM_INTS; - types[i] = MPI_INT; - } - - if (rank == 0 && MPI_SUCCESS == - MPI_Igather(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm, &req)) - errs++; - - if (rank == 0 && MPI_SUCCESS == - MPI_Igatherv(sbuf, NUM_INTS, MPI_INT, sbuf, rcounts, rdispls, MPI_INT, 0, comm, &req)) - errs++; - - if (rank == 0 && MPI_SUCCESS == - MPI_Iscatter(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm, &req)) - errs++; - - if (rank == 0 && MPI_SUCCESS == - MPI_Iscatterv(sbuf, scounts, sdispls, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm, &req)) - errs++; - - if (MPI_SUCCESS == - MPI_Iallgather(&sbuf[rank], 1, MPI_INT, sbuf, 1, MPI_INT, comm, &req)) - errs++; - - if (MPI_SUCCESS == - MPI_Iallgatherv(&sbuf[rank * rcounts[rank]], rcounts[rank], MPI_INT, sbuf, rcounts, rdispls, MPI_INT, comm, &req)) - errs++; - - if (MPI_SUCCESS == - MPI_Ialltoall(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, comm, &req)) - errs++; - - if (MPI_SUCCESS == - MPI_Ialltoallv(sbuf, scounts, sdispls, MPI_INT, sbuf, scounts, sdispls, MPI_INT, comm, &req)) - errs++; - - if (MPI_SUCCESS == - MPI_Ialltoallw(sbuf, scounts, sdispls, types, sbuf, scounts, sdispls, types, comm, &req)) - errs++; - - if (rank == 0 && MPI_SUCCESS == - MPI_Ireduce(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, 0, comm, &req)) - errs++; - - if (MPI_SUCCESS == - MPI_Iallreduce(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req)) - errs++; - - if (MPI_SUCCESS == - MPI_Ireduce_scatter(sbuf, sbuf, rcounts, MPI_INT, MPI_SUM, comm, &req)) - errs++; - - if (MPI_SUCCESS == - MPI_Ireduce_scatter_block(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req)) - errs++; - - if (MPI_SUCCESS == - MPI_Iscan(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req)) - errs++; - - if (MPI_SUCCESS == - MPI_Iexscan(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req)) - errs++; - - if (sbuf) free(sbuf); - if (rbuf) free(rbuf); - if (scounts) free(scounts); - if (rcounts) free(rcounts); - if (sdispls) free(sdispls); - if (rdispls) free(rdispls); - - if (rank == 0) { - if (errs) - fprintf(stderr, "Found %d errors\n", errs); - else - printf(" No errors\n"); - } - MPI_Finalize(); - return 0; -} - diff --git a/teshsuite/smpi/mpich3-test/coll/op_commutative.c b/teshsuite/smpi/mpich3-test/coll/op_commutative.c index 28043eff09..5b004faff1 100644 --- a/teshsuite/smpi/mpich3-test/coll/op_commutative.c +++ b/teshsuite/smpi/mpich3-test/coll/op_commutative.c @@ -29,11 +29,11 @@ static void noncomm_user_op(void *invec, void *inoutvec, int *len, MPI_Datatype } */ -static void user_op(void *invec, void *inoutvec, int *len, MPI_Datatype *datatype) +static void user_op(void *invec, void *inoutvec, int *len, MPI_Datatype * datatype) { int i; - int *invec_int = (int *)invec; - int *inoutvec_int = (int *)inoutvec; + int *invec_int = (int *) invec; + int *inoutvec_int = (int *) inoutvec; if (*datatype != MPI_INT) { ++errs; @@ -47,19 +47,17 @@ static void user_op(void *invec, void *inoutvec, int *len, MPI_Datatype *datatyp } -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { MPI_Op c_uop = MPI_OP_NULL; MPI_Op nc_uop = MPI_OP_NULL; -#if MTEST_HAVE_MIN_MPI_VERSION(2,2) int is_commutative = 0; -#endif MTest_Init(&argc, &argv); /* make sure that user-define ops work too */ - MPI_Op_create(&user_op, 1/*commute*/, &c_uop); - MPI_Op_create(&user_op, 0/*!commute*/, &nc_uop); + MPI_Op_create(&user_op, 1 /*commute */ , &c_uop); + MPI_Op_create(&user_op, 0 /*!commute */ , &nc_uop); #if MTEST_HAVE_MIN_MPI_VERSION(2,2) /* this function was added in MPI-2.2 */ @@ -106,4 +104,3 @@ int main( int argc, char *argv[] ) MPI_Finalize(); return 0; } - diff --git a/teshsuite/smpi/mpich3-test/coll/opband.c b/teshsuite/smpi/mpich3-test/coll/opband.c index b8ac9d0a7c..19a37041f0 100644 --- a/teshsuite/smpi/mpich3-test/coll/opband.c +++ b/teshsuite/smpi/mpich3-test/coll/opband.c @@ -14,16 +14,16 @@ static char MTEST_Descrip[] = "Test MPI_BAND operations on optional datatypes du */ /* - * This test looks at the handling of logical and for types that are not + * This test looks at the handling of logical and for types that are not * integers or are not required integers (e.g., long long). MPICH allows * these as well. A strict MPI test should not include this test. */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rc; int rank, size; - MPI_Comm comm; + MPI_Comm comm; char cinbuf[3], coutbuf[3]; signed char scinbuf[3], scoutbuf[3]; unsigned char ucinbuf[3], ucoutbuf[3]; @@ -32,21 +32,21 @@ int main( int argc, char *argv[] ) long linbuf[3], loutbuf[3]; unsigned long ulinbuf[3], uloutbuf[3]; unsigned uinbuf[3], uoutbuf[3]; - - MTest_Init( &argc, &argv ); + + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - /* Set errors return so that we can provide better information - should a routine reject one of the operand/datatype pairs */ - MPI_Errhandler_set( comm, MPI_ERRORS_RETURN ); + /* Set errors return so that we can provide better information + * should a routine reject one of the operand/datatype pairs */ + MPI_Errhandler_set(comm, MPI_ERRORS_RETURN); - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); #ifndef USE_STRICT_MPI /* char */ - MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_CHAR\n"); cinbuf[0] = 0xff; cinbuf[1] = 0; cinbuf[2] = (rank > 0) ? 0xff : 0xf0; @@ -54,31 +54,31 @@ int main( int argc, char *argv[] ) coutbuf[0] = 0; coutbuf[1] = 1; coutbuf[2] = 1; - rc = MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_BAND, 0, comm ); + rc = MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_BAND, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BAND and MPI_CHAR", rc ); - errs++; + MTestPrintErrorMsg("MPI_BAND and MPI_CHAR", rc); + errs++; } else { - if (rank == 0) { - if (coutbuf[0] != (char)0xff) { - errs++; - fprintf( stderr, "char BAND(1) test failed\n" ); - } - if (coutbuf[1]) { - errs++; - fprintf( stderr, "char BAND(0) test failed\n" ); - } - if (coutbuf[2] != (char)0xf0 && size > 1) { - errs++; - fprintf( stderr, "char BAND(>) test failed\n" ); - } - } + if (rank == 0) { + if (coutbuf[0] != (char) 0xff) { + errs++; + fprintf(stderr, "char BAND(1) test failed\n"); + } + if (coutbuf[1]) { + errs++; + fprintf(stderr, "char BAND(0) test failed\n"); + } + if (coutbuf[2] != (char) 0xf0 && size > 1) { + errs++; + fprintf(stderr, "char BAND(>) test failed\n"); + } + } } #endif /* USE_STRICT_MPI */ /* signed char */ - MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n"); scinbuf[0] = 0xff; scinbuf[1] = 0; scinbuf[2] = (rank > 0) ? 0xff : 0xf0; @@ -86,30 +86,30 @@ int main( int argc, char *argv[] ) scoutbuf[0] = 0; scoutbuf[1] = 1; scoutbuf[2] = 1; - rc = MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_BAND, 0, comm ); + rc = MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_BAND, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BAND and MPI_SIGNED_CHAR", rc ); - errs++; + MTestPrintErrorMsg("MPI_BAND and MPI_SIGNED_CHAR", rc); + errs++; } else { - if (rank == 0) { - if (scoutbuf[0] != (signed char)0xff) { - errs++; - fprintf( stderr, "signed char BAND(1) test failed\n" ); - } - if (scoutbuf[1]) { - errs++; - fprintf( stderr, "signed char BAND(0) test failed\n" ); - } - if (scoutbuf[2] != (signed char)0xf0 && size > 1) { - errs++; - fprintf( stderr, "signed char BAND(>) test failed\n" ); - } - } + if (rank == 0) { + if (scoutbuf[0] != (signed char) 0xff) { + errs++; + fprintf(stderr, "signed char BAND(1) test failed\n"); + } + if (scoutbuf[1]) { + errs++; + fprintf(stderr, "signed char BAND(0) test failed\n"); + } + if (scoutbuf[2] != (signed char) 0xf0 && size > 1) { + errs++; + fprintf(stderr, "signed char BAND(>) test failed\n"); + } + } } /* unsigned char */ - MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n"); ucinbuf[0] = 0xff; ucinbuf[1] = 0; ucinbuf[2] = (rank > 0) ? 0xff : 0xf0; @@ -117,30 +117,30 @@ int main( int argc, char *argv[] ) ucoutbuf[0] = 0; ucoutbuf[1] = 1; ucoutbuf[2] = 1; - rc = MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_BAND, 0, comm ); + rc = MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_BAND, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BAND and MPI_UNSIGNED_CHAR", rc ); - errs++; + MTestPrintErrorMsg("MPI_BAND and MPI_UNSIGNED_CHAR", rc); + errs++; } else { - if (rank == 0) { - if (ucoutbuf[0] != 0xff) { - errs++; - fprintf( stderr, "unsigned char BAND(1) test failed\n" ); - } - if (ucoutbuf[1]) { - errs++; - fprintf( stderr, "unsigned char BAND(0) test failed\n" ); - } - if (ucoutbuf[2] != 0xf0 && size > 1) { - errs++; - fprintf( stderr, "unsigned char BAND(>) test failed\n" ); - } - } + if (rank == 0) { + if (ucoutbuf[0] != 0xff) { + errs++; + fprintf(stderr, "unsigned char BAND(1) test failed\n"); + } + if (ucoutbuf[1]) { + errs++; + fprintf(stderr, "unsigned char BAND(0) test failed\n"); + } + if (ucoutbuf[2] != 0xf0 && size > 1) { + errs++; + fprintf(stderr, "unsigned char BAND(>) test failed\n"); + } + } } /* bytes */ - MTestPrintfMsg( 10, "Reduce of MPI_BYTE\n" ); + MTestPrintfMsg(10, "Reduce of MPI_BYTE\n"); cinbuf[0] = 0xff; cinbuf[1] = 0; cinbuf[2] = (rank > 0) ? 0xff : 0xf0; @@ -148,30 +148,30 @@ int main( int argc, char *argv[] ) coutbuf[0] = 0; coutbuf[1] = 1; coutbuf[2] = 1; - rc = MPI_Reduce( cinbuf, coutbuf, 3, MPI_BYTE, MPI_BAND, 0, comm ); + rc = MPI_Reduce(cinbuf, coutbuf, 3, MPI_BYTE, MPI_BAND, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BAND and MPI_BYTE", rc ); - errs++; + MTestPrintErrorMsg("MPI_BAND and MPI_BYTE", rc); + errs++; } else { - if (rank == 0) { - if (coutbuf[0] != (char)0xff) { - errs++; - fprintf( stderr, "byte BAND(1) test failed\n" ); - } - if (coutbuf[1]) { - errs++; - fprintf( stderr, "byte BAND(0) test failed\n" ); - } - if (coutbuf[2] != (char)0xf0 && size > 1) { - errs++; - fprintf( stderr, "byte BAND(>) test failed\n" ); - } - } + if (rank == 0) { + if (coutbuf[0] != (char) 0xff) { + errs++; + fprintf(stderr, "byte BAND(1) test failed\n"); + } + if (coutbuf[1]) { + errs++; + fprintf(stderr, "byte BAND(0) test failed\n"); + } + if (coutbuf[2] != (char) 0xf0 && size > 1) { + errs++; + fprintf(stderr, "byte BAND(>) test failed\n"); + } + } } /* short */ - MTestPrintfMsg( 10, "Reduce of MPI_SHORT\n" ); + MTestPrintfMsg(10, "Reduce of MPI_SHORT\n"); sinbuf[0] = 0xffff; sinbuf[1] = 0; sinbuf[2] = (rank > 0) ? 0xffff : 0xf0f0; @@ -179,29 +179,29 @@ int main( int argc, char *argv[] ) soutbuf[0] = 0; soutbuf[1] = 1; soutbuf[2] = 1; - rc = MPI_Reduce( sinbuf, soutbuf, 3, MPI_SHORT, MPI_BAND, 0, comm ); + rc = MPI_Reduce(sinbuf, soutbuf, 3, MPI_SHORT, MPI_BAND, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BAND and MPI_SHORT", rc ); - errs++; + MTestPrintErrorMsg("MPI_BAND and MPI_SHORT", rc); + errs++; } else { - if (rank == 0) { - if (soutbuf[0] != (short)0xffff) { - errs++; - fprintf( stderr, "short BAND(1) test failed\n" ); - } - if (soutbuf[1]) { - errs++; - fprintf( stderr, "short BAND(0) test failed\n" ); - } - if (soutbuf[2] != (short)0xf0f0 && size > 1) { - errs++; - fprintf( stderr, "short BAND(>) test failed\n" ); - } - } + if (rank == 0) { + if (soutbuf[0] != (short) 0xffff) { + errs++; + fprintf(stderr, "short BAND(1) test failed\n"); + } + if (soutbuf[1]) { + errs++; + fprintf(stderr, "short BAND(0) test failed\n"); + } + if (soutbuf[2] != (short) 0xf0f0 && size > 1) { + errs++; + fprintf(stderr, "short BAND(>) test failed\n"); + } + } } - MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_SHORT\n" ); + MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_SHORT\n"); /* unsigned short */ usinbuf[0] = 0xffff; usinbuf[1] = 0; @@ -210,30 +210,30 @@ int main( int argc, char *argv[] ) usoutbuf[0] = 0; usoutbuf[1] = 1; usoutbuf[2] = 1; - rc = MPI_Reduce( usinbuf, usoutbuf, 3, MPI_UNSIGNED_SHORT, MPI_BAND, 0, comm ); + rc = MPI_Reduce(usinbuf, usoutbuf, 3, MPI_UNSIGNED_SHORT, MPI_BAND, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BAND and MPI_UNSIGNED_SHORT", rc ); - errs++; + MTestPrintErrorMsg("MPI_BAND and MPI_UNSIGNED_SHORT", rc); + errs++; } else { - if (rank == 0) { - if (usoutbuf[0] != 0xffff) { - errs++; - fprintf( stderr, "short BAND(1) test failed\n" ); - } - if (usoutbuf[1]) { - errs++; - fprintf( stderr, "short BAND(0) test failed\n" ); - } - if (usoutbuf[2] != 0xf0f0 && size > 1) { - errs++; - fprintf( stderr, "short BAND(>) test failed\n" ); - } - } + if (rank == 0) { + if (usoutbuf[0] != 0xffff) { + errs++; + fprintf(stderr, "short BAND(1) test failed\n"); + } + if (usoutbuf[1]) { + errs++; + fprintf(stderr, "short BAND(0) test failed\n"); + } + if (usoutbuf[2] != 0xf0f0 && size > 1) { + errs++; + fprintf(stderr, "short BAND(>) test failed\n"); + } + } } /* unsigned */ - MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED\n" ); + MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED\n"); uinbuf[0] = 0xffffffff; uinbuf[1] = 0; uinbuf[2] = (rank > 0) ? 0xffffffff : 0xf0f0f0f0; @@ -241,30 +241,30 @@ int main( int argc, char *argv[] ) uoutbuf[0] = 0; uoutbuf[1] = 1; uoutbuf[2] = 1; - rc = MPI_Reduce( uinbuf, uoutbuf, 3, MPI_UNSIGNED, MPI_BAND, 0, comm ); + rc = MPI_Reduce(uinbuf, uoutbuf, 3, MPI_UNSIGNED, MPI_BAND, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BAND and MPI_UNSIGNED", rc ); - errs++; + MTestPrintErrorMsg("MPI_BAND and MPI_UNSIGNED", rc); + errs++; } else { - if (rank == 0) { - if (uoutbuf[0] != 0xffffffff) { - errs++; - fprintf( stderr, "unsigned BAND(1) test failed\n" ); - } - if (uoutbuf[1]) { - errs++; - fprintf( stderr, "unsigned BAND(0) test failed\n" ); - } - if (uoutbuf[2] != 0xf0f0f0f0 && size > 1) { - errs++; - fprintf( stderr, "unsigned BAND(>) test failed\n" ); - } - } + if (rank == 0) { + if (uoutbuf[0] != 0xffffffff) { + errs++; + fprintf(stderr, "unsigned BAND(1) test failed\n"); + } + if (uoutbuf[1]) { + errs++; + fprintf(stderr, "unsigned BAND(0) test failed\n"); + } + if (uoutbuf[2] != 0xf0f0f0f0 && size > 1) { + errs++; + fprintf(stderr, "unsigned BAND(>) test failed\n"); + } + } } /* long */ - MTestPrintfMsg( 10, "Reduce of MPI_LONG\n" ); + MTestPrintfMsg(10, "Reduce of MPI_LONG\n"); linbuf[0] = 0xffffffff; linbuf[1] = 0; linbuf[2] = (rank > 0) ? 0xffffffff : 0xf0f0f0f0; @@ -272,29 +272,29 @@ int main( int argc, char *argv[] ) loutbuf[0] = 0; loutbuf[1] = 1; loutbuf[2] = 1; - rc = MPI_Reduce( linbuf, loutbuf, 3, MPI_LONG, MPI_BAND, 0, comm ); + rc = MPI_Reduce(linbuf, loutbuf, 3, MPI_LONG, MPI_BAND, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BAND and MPI_LONG", rc ); - errs++; + MTestPrintErrorMsg("MPI_BAND and MPI_LONG", rc); + errs++; } else { - if (rank == 0) { - if (loutbuf[0] != 0xffffffff) { - errs++; - fprintf( stderr, "long BAND(1) test failed\n" ); - } - if (loutbuf[1]) { - errs++; - fprintf( stderr, "long BAND(0) test failed\n" ); - } - if (loutbuf[2] != 0xf0f0f0f0 && size > 1) { - errs++; - fprintf( stderr, "long BAND(>) test failed\n" ); - } - } + if (rank == 0) { + if (loutbuf[0] != 0xffffffff) { + errs++; + fprintf(stderr, "long BAND(1) test failed\n"); + } + if (loutbuf[1]) { + errs++; + fprintf(stderr, "long BAND(0) test failed\n"); + } + if (loutbuf[2] != 0xf0f0f0f0 && size > 1) { + errs++; + fprintf(stderr, "long BAND(>) test failed\n"); + } + } } - MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_LONG\n" ); + MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_LONG\n"); /* unsigned long */ ulinbuf[0] = 0xffffffff; ulinbuf[1] = 0; @@ -303,68 +303,68 @@ int main( int argc, char *argv[] ) uloutbuf[0] = 0; uloutbuf[1] = 1; uloutbuf[2] = 1; - rc = MPI_Reduce( ulinbuf, uloutbuf, 3, MPI_UNSIGNED_LONG, MPI_BAND, 0, comm ); + rc = MPI_Reduce(ulinbuf, uloutbuf, 3, MPI_UNSIGNED_LONG, MPI_BAND, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BAND and MPI_UNSIGNED_LONG", rc ); - errs++; + MTestPrintErrorMsg("MPI_BAND and MPI_UNSIGNED_LONG", rc); + errs++; } else { - if (rank == 0) { - if (uloutbuf[0] != 0xffffffff) { - errs++; - fprintf( stderr, "unsigned long BAND(1) test failed\n" ); - } - if (uloutbuf[1]) { - errs++; - fprintf( stderr, "unsigned long BAND(0) test failed\n" ); - } - if (uloutbuf[2] != 0xf0f0f0f0 && size > 1) { - errs++; - fprintf( stderr, "unsigned long BAND(>) test failed\n" ); - } - } + if (rank == 0) { + if (uloutbuf[0] != 0xffffffff) { + errs++; + fprintf(stderr, "unsigned long BAND(1) test failed\n"); + } + if (uloutbuf[1]) { + errs++; + fprintf(stderr, "unsigned long BAND(0) test failed\n"); + } + if (uloutbuf[2] != 0xf0f0f0f0 && size > 1) { + errs++; + fprintf(stderr, "unsigned long BAND(>) test failed\n"); + } + } } #ifdef HAVE_LONG_LONG { - long long llinbuf[3], lloutbuf[3]; - /* long long */ - llinbuf[0] = 0xffffffff; - llinbuf[1] = 0; - llinbuf[2] = (rank > 0) ? 0xffffffff : 0xf0f0f0f0; + long long llinbuf[3], lloutbuf[3]; + /* long long */ + llinbuf[0] = 0xffffffff; + llinbuf[1] = 0; + llinbuf[2] = (rank > 0) ? 0xffffffff : 0xf0f0f0f0; - lloutbuf[0] = 0; - lloutbuf[1] = 1; - lloutbuf[2] = 1; - if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { - MTestPrintfMsg( 10, "Reduce of MPI_LONG_LONG\n" ); - rc = MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_BAND, 0, comm ); - if (rc) { - MTestPrintErrorMsg( "MPI_BAND and MPI_LONG_LONG", rc ); - errs++; - } - else { - if (rank == 0) { - if (lloutbuf[0] != 0xffffffff) { - errs++; - fprintf( stderr, "long long BAND(1) test failed\n" ); - } - if (lloutbuf[1]) { - errs++; - fprintf( stderr, "long long BAND(0) test failed\n" ); - } - if (lloutbuf[2] != 0xf0f0f0f0 && size > 1) { - errs++; - fprintf( stderr, "long long BAND(>) test failed\n" ); - } - } - } - } + lloutbuf[0] = 0; + lloutbuf[1] = 1; + lloutbuf[2] = 1; + if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { + MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n"); + rc = MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_BAND, 0, comm); + if (rc) { + MTestPrintErrorMsg("MPI_BAND and MPI_LONG_LONG", rc); + errs++; + } + else { + if (rank == 0) { + if (lloutbuf[0] != 0xffffffff) { + errs++; + fprintf(stderr, "long long BAND(1) test failed\n"); + } + if (lloutbuf[1]) { + errs++; + fprintf(stderr, "long long BAND(0) test failed\n"); + } + if (lloutbuf[2] != 0xf0f0f0f0 && size > 1) { + errs++; + fprintf(stderr, "long long BAND(>) test failed\n"); + } + } + } + } } #endif - MPI_Errhandler_set( comm, MPI_ERRORS_ARE_FATAL ); - MTest_Finalize( errs ); + MPI_Errhandler_set(comm, MPI_ERRORS_ARE_FATAL); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/coll/opbor.c b/teshsuite/smpi/mpich3-test/coll/opbor.c index 7c4e5d6541..1841607fad 100644 --- a/teshsuite/smpi/mpich3-test/coll/opbor.c +++ b/teshsuite/smpi/mpich3-test/coll/opbor.c @@ -14,16 +14,16 @@ static char MTEST_Descrip[] = "Test MPI_BOR operations on optional datatypes dup */ /* - * This test looks at the handling of logical and for types that are not + * This test looks at the handling of logical and for types that are not * integers or are not required integers (e.g., long long). MPICH allows * these as well. A strict MPI test should not include this test. */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rc; int rank, size; - MPI_Comm comm; + MPI_Comm comm; char cinbuf[3], coutbuf[3]; signed char scinbuf[3], scoutbuf[3]; unsigned char ucinbuf[3], ucoutbuf[3]; @@ -33,21 +33,21 @@ int main( int argc, char *argv[] ) unsigned long ulinbuf[3], uloutbuf[3]; unsigned uinbuf[3], uoutbuf[3]; int iinbuf[3], ioutbuf[3]; - - MTest_Init( &argc, &argv ); + + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - /* Set errors return so that we can provide better information - should a routine reject one of the operand/datatype pairs */ - MPI_Errhandler_set( comm, MPI_ERRORS_RETURN ); + /* Set errors return so that we can provide better information + * should a routine reject one of the operand/datatype pairs */ + MPI_Errhandler_set(comm, MPI_ERRORS_RETURN); - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); #ifndef USE_STRICT_MPI /* char */ - MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_CHAR\n"); cinbuf[0] = 0xff; cinbuf[1] = 0; cinbuf[2] = (rank > 0) ? 0x3c : 0xc3; @@ -55,31 +55,31 @@ int main( int argc, char *argv[] ) coutbuf[0] = 0; coutbuf[1] = 1; coutbuf[2] = 1; - rc = MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_BOR, 0, comm ); + rc = MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_BOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BOR and MPI_CHAR", rc ); - errs++; + MTestPrintErrorMsg("MPI_BOR and MPI_CHAR", rc); + errs++; } else { - if (rank == 0) { - if (coutbuf[0] != (char)0xff) { - errs++; - fprintf( stderr, "char BOR(1) test failed\n" ); - } - if (coutbuf[1]) { - errs++; - fprintf( stderr, "char BOR(0) test failed\n" ); - } - if (coutbuf[2] != (char)0xff && size > 1) { - errs++; - fprintf( stderr, "char BOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (coutbuf[0] != (char) 0xff) { + errs++; + fprintf(stderr, "char BOR(1) test failed\n"); + } + if (coutbuf[1]) { + errs++; + fprintf(stderr, "char BOR(0) test failed\n"); + } + if (coutbuf[2] != (char) 0xff && size > 1) { + errs++; + fprintf(stderr, "char BOR(>) test failed\n"); + } + } } #endif /* USE_STRICT_MPI */ /* signed char */ - MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n"); scinbuf[0] = 0xff; scinbuf[1] = 0; scinbuf[2] = (rank > 0) ? 0x3c : 0xc3; @@ -87,30 +87,30 @@ int main( int argc, char *argv[] ) scoutbuf[0] = 0; scoutbuf[1] = 1; scoutbuf[2] = 1; - rc = MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_BOR, 0, comm ); + rc = MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_BOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BOR and MPI_SIGNED_CHAR", rc ); - errs++; + MTestPrintErrorMsg("MPI_BOR and MPI_SIGNED_CHAR", rc); + errs++; } else { - if (rank == 0) { - if (scoutbuf[0] != (signed char)0xff) { - errs++; - fprintf( stderr, "signed char BOR(1) test failed\n" ); - } - if (scoutbuf[1]) { - errs++; - fprintf( stderr, "signed char BOR(0) test failed\n" ); - } - if (scoutbuf[2] != (signed char)0xff && size > 1) { - errs++; - fprintf( stderr, "signed char BOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (scoutbuf[0] != (signed char) 0xff) { + errs++; + fprintf(stderr, "signed char BOR(1) test failed\n"); + } + if (scoutbuf[1]) { + errs++; + fprintf(stderr, "signed char BOR(0) test failed\n"); + } + if (scoutbuf[2] != (signed char) 0xff && size > 1) { + errs++; + fprintf(stderr, "signed char BOR(>) test failed\n"); + } + } } /* unsigned char */ - MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n"); ucinbuf[0] = 0xff; ucinbuf[1] = 0; ucinbuf[2] = (rank > 0) ? 0x3c : 0xc3; @@ -118,30 +118,30 @@ int main( int argc, char *argv[] ) ucoutbuf[0] = 0; ucoutbuf[1] = 1; ucoutbuf[2] = 1; - rc = MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_BOR, 0, comm ); + rc = MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_BOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BOR and MPI_UNSIGNED_CHAR", rc ); - errs++; + MTestPrintErrorMsg("MPI_BOR and MPI_UNSIGNED_CHAR", rc); + errs++; } else { - if (rank == 0) { - if (ucoutbuf[0] != 0xff) { - errs++; - fprintf( stderr, "unsigned char BOR(1) test failed\n" ); - } - if (ucoutbuf[1]) { - errs++; - fprintf( stderr, "unsigned char BOR(0) test failed\n" ); - } - if (ucoutbuf[2] != 0xff && size > 1) { - errs++; - fprintf( stderr, "unsigned char BOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (ucoutbuf[0] != 0xff) { + errs++; + fprintf(stderr, "unsigned char BOR(1) test failed\n"); + } + if (ucoutbuf[1]) { + errs++; + fprintf(stderr, "unsigned char BOR(0) test failed\n"); + } + if (ucoutbuf[2] != 0xff && size > 1) { + errs++; + fprintf(stderr, "unsigned char BOR(>) test failed\n"); + } + } } /* bytes */ - MTestPrintfMsg( 10, "Reduce of MPI_BYTE\n" ); + MTestPrintfMsg(10, "Reduce of MPI_BYTE\n"); cinbuf[0] = 0xff; cinbuf[1] = 0; cinbuf[2] = (rank > 0) ? 0x3c : 0xc3; @@ -149,30 +149,30 @@ int main( int argc, char *argv[] ) coutbuf[0] = 0; coutbuf[1] = 1; coutbuf[2] = 1; - rc = MPI_Reduce( cinbuf, coutbuf, 3, MPI_BYTE, MPI_BOR, 0, comm ); + rc = MPI_Reduce(cinbuf, coutbuf, 3, MPI_BYTE, MPI_BOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BOR and MPI_BYTE", rc ); - errs++; + MTestPrintErrorMsg("MPI_BOR and MPI_BYTE", rc); + errs++; } else { - if (rank == 0) { - if (coutbuf[0] != (char)0xff) { - errs++; - fprintf( stderr, "byte BOR(1) test failed\n" ); - } - if (coutbuf[1]) { - errs++; - fprintf( stderr, "byte BOR(0) test failed\n" ); - } - if (coutbuf[2] != (char)0xff && size > 1) { - errs++; - fprintf( stderr, "byte BOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (coutbuf[0] != (char) 0xff) { + errs++; + fprintf(stderr, "byte BOR(1) test failed\n"); + } + if (coutbuf[1]) { + errs++; + fprintf(stderr, "byte BOR(0) test failed\n"); + } + if (coutbuf[2] != (char) 0xff && size > 1) { + errs++; + fprintf(stderr, "byte BOR(>) test failed\n"); + } + } } /* short */ - MTestPrintfMsg( 10, "Reduce of MPI_SHORT\n" ); + MTestPrintfMsg(10, "Reduce of MPI_SHORT\n"); sinbuf[0] = 0xffff; sinbuf[1] = 0; sinbuf[2] = (rank > 0) ? 0x3c3c : 0xc3c3; @@ -180,30 +180,30 @@ int main( int argc, char *argv[] ) soutbuf[0] = 0; soutbuf[1] = 1; soutbuf[2] = 1; - rc = MPI_Reduce( sinbuf, soutbuf, 3, MPI_SHORT, MPI_BOR, 0, comm ); + rc = MPI_Reduce(sinbuf, soutbuf, 3, MPI_SHORT, MPI_BOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BOR and MPI_SHORT", rc ); - errs++; + MTestPrintErrorMsg("MPI_BOR and MPI_SHORT", rc); + errs++; } else { - if (rank == 0) { - if (soutbuf[0] != (short)0xffff) { - errs++; - fprintf( stderr, "short BOR(1) test failed\n" ); - } - if (soutbuf[1]) { - errs++; - fprintf( stderr, "short BOR(0) test failed\n" ); - } - if (soutbuf[2] != (short)0xffff && size > 1) { - errs++; - fprintf( stderr, "short BOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (soutbuf[0] != (short) 0xffff) { + errs++; + fprintf(stderr, "short BOR(1) test failed\n"); + } + if (soutbuf[1]) { + errs++; + fprintf(stderr, "short BOR(0) test failed\n"); + } + if (soutbuf[2] != (short) 0xffff && size > 1) { + errs++; + fprintf(stderr, "short BOR(>) test failed\n"); + } + } } /* unsigned short */ - MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_SHORT\n" ); + MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_SHORT\n"); usinbuf[0] = 0xffff; usinbuf[1] = 0; usinbuf[2] = (rank > 0) ? 0x3c3c : 0xc3c3; @@ -211,30 +211,30 @@ int main( int argc, char *argv[] ) usoutbuf[0] = 0; usoutbuf[1] = 1; usoutbuf[2] = 1; - rc = MPI_Reduce( usinbuf, usoutbuf, 3, MPI_UNSIGNED_SHORT, MPI_BOR, 0, comm ); + rc = MPI_Reduce(usinbuf, usoutbuf, 3, MPI_UNSIGNED_SHORT, MPI_BOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BOR and MPI_UNSIGNED_SHORT", rc ); - errs++; + MTestPrintErrorMsg("MPI_BOR and MPI_UNSIGNED_SHORT", rc); + errs++; } else { - if (rank == 0) { - if (usoutbuf[0] != 0xffff) { - errs++; - fprintf( stderr, "short BOR(1) test failed\n" ); - } - if (usoutbuf[1]) { - errs++; - fprintf( stderr, "short BOR(0) test failed\n" ); - } - if (usoutbuf[2] != 0xffff && size > 1) { - errs++; - fprintf( stderr, "short BOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (usoutbuf[0] != 0xffff) { + errs++; + fprintf(stderr, "short BOR(1) test failed\n"); + } + if (usoutbuf[1]) { + errs++; + fprintf(stderr, "short BOR(0) test failed\n"); + } + if (usoutbuf[2] != 0xffff && size > 1) { + errs++; + fprintf(stderr, "short BOR(>) test failed\n"); + } + } } /* unsigned */ - MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED\n" ); + MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED\n"); uinbuf[0] = 0xffffffff; uinbuf[1] = 0; uinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3; @@ -242,30 +242,30 @@ int main( int argc, char *argv[] ) uoutbuf[0] = 0; uoutbuf[1] = 1; uoutbuf[2] = 1; - rc = MPI_Reduce( uinbuf, uoutbuf, 3, MPI_UNSIGNED, MPI_BOR, 0, comm ); + rc = MPI_Reduce(uinbuf, uoutbuf, 3, MPI_UNSIGNED, MPI_BOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BOR and MPI_UNSIGNED", rc ); - errs++; + MTestPrintErrorMsg("MPI_BOR and MPI_UNSIGNED", rc); + errs++; } else { - if (rank == 0) { - if (uoutbuf[0] != 0xffffffff) { - errs++; - fprintf( stderr, "unsigned BOR(1) test failed\n" ); - } - if (uoutbuf[1]) { - errs++; - fprintf( stderr, "unsigned BOR(0) test failed\n" ); - } - if (uoutbuf[2] != 0xffffffff && size > 1) { - errs++; - fprintf( stderr, "unsigned BOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (uoutbuf[0] != 0xffffffff) { + errs++; + fprintf(stderr, "unsigned BOR(1) test failed\n"); + } + if (uoutbuf[1]) { + errs++; + fprintf(stderr, "unsigned BOR(0) test failed\n"); + } + if (uoutbuf[2] != 0xffffffff && size > 1) { + errs++; + fprintf(stderr, "unsigned BOR(>) test failed\n"); + } + } } /* int */ - MTestPrintfMsg( 10, "Reduce of MPI_INT\n" ); + MTestPrintfMsg(10, "Reduce of MPI_INT\n"); iinbuf[0] = 0xffffffff; iinbuf[1] = 0; iinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3; @@ -273,30 +273,30 @@ int main( int argc, char *argv[] ) ioutbuf[0] = 0; ioutbuf[1] = 1; ioutbuf[2] = 1; - rc = MPI_Reduce( iinbuf, ioutbuf, 3, MPI_INT, MPI_BOR, 0, comm ); + rc = MPI_Reduce(iinbuf, ioutbuf, 3, MPI_INT, MPI_BOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BOR and MPI_INT", rc ); - errs++; + MTestPrintErrorMsg("MPI_BOR and MPI_INT", rc); + errs++; } else { - if (rank == 0) { - if (ioutbuf[0] != 0xffffffff) { - errs++; - fprintf( stderr, "int BOR(1) test failed\n" ); - } - if (ioutbuf[1]) { - errs++; - fprintf( stderr, "int BOR(0) test failed\n" ); - } - if (ioutbuf[2] != 0xffffffff && size > 1) { - errs++; - fprintf( stderr, "int BOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (ioutbuf[0] != 0xffffffff) { + errs++; + fprintf(stderr, "int BOR(1) test failed\n"); + } + if (ioutbuf[1]) { + errs++; + fprintf(stderr, "int BOR(0) test failed\n"); + } + if (ioutbuf[2] != 0xffffffff && size > 1) { + errs++; + fprintf(stderr, "int BOR(>) test failed\n"); + } + } } /* long */ - MTestPrintfMsg( 10, "Reduce of MPI_LONG\n" ); + MTestPrintfMsg(10, "Reduce of MPI_LONG\n"); linbuf[0] = 0xffffffff; linbuf[1] = 0; linbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3; @@ -304,30 +304,30 @@ int main( int argc, char *argv[] ) loutbuf[0] = 0; loutbuf[1] = 1; loutbuf[2] = 1; - rc = MPI_Reduce( linbuf, loutbuf, 3, MPI_LONG, MPI_BOR, 0, comm ); + rc = MPI_Reduce(linbuf, loutbuf, 3, MPI_LONG, MPI_BOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BOR and MPI_LONG", rc ); - errs++; + MTestPrintErrorMsg("MPI_BOR and MPI_LONG", rc); + errs++; } else { - if (rank == 0) { - if (loutbuf[0] != 0xffffffff) { - errs++; - fprintf( stderr, "long BOR(1) test failed\n" ); - } - if (loutbuf[1]) { - errs++; - fprintf( stderr, "long BOR(0) test failed\n" ); - } - if (loutbuf[2] != 0xffffffff && size > 1) { - errs++; - fprintf( stderr, "long BOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (loutbuf[0] != 0xffffffff) { + errs++; + fprintf(stderr, "long BOR(1) test failed\n"); + } + if (loutbuf[1]) { + errs++; + fprintf(stderr, "long BOR(0) test failed\n"); + } + if (loutbuf[2] != 0xffffffff && size > 1) { + errs++; + fprintf(stderr, "long BOR(>) test failed\n"); + } + } } /* unsigned long */ - MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_LONG\n" ); + MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_LONG\n"); ulinbuf[0] = 0xffffffff; ulinbuf[1] = 0; ulinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3; @@ -335,68 +335,68 @@ int main( int argc, char *argv[] ) uloutbuf[0] = 0; uloutbuf[1] = 1; uloutbuf[2] = 1; - rc = MPI_Reduce( ulinbuf, uloutbuf, 3, MPI_UNSIGNED_LONG, MPI_BOR, 0, comm ); + rc = MPI_Reduce(ulinbuf, uloutbuf, 3, MPI_UNSIGNED_LONG, MPI_BOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BOR and MPI_UNSIGNED_LONG", rc ); - errs++; + MTestPrintErrorMsg("MPI_BOR and MPI_UNSIGNED_LONG", rc); + errs++; } else { - if (rank == 0) { - if (uloutbuf[0] != 0xffffffff) { - errs++; - fprintf( stderr, "unsigned long BOR(1) test failed\n" ); - } - if (uloutbuf[1]) { - errs++; - fprintf( stderr, "unsigned long BOR(0) test failed\n" ); - } - if (uloutbuf[2] != 0xffffffff && size > 1) { - errs++; - fprintf( stderr, "unsigned long BOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (uloutbuf[0] != 0xffffffff) { + errs++; + fprintf(stderr, "unsigned long BOR(1) test failed\n"); + } + if (uloutbuf[1]) { + errs++; + fprintf(stderr, "unsigned long BOR(0) test failed\n"); + } + if (uloutbuf[2] != 0xffffffff && size > 1) { + errs++; + fprintf(stderr, "unsigned long BOR(>) test failed\n"); + } + } } #ifdef HAVE_LONG_LONG { - long long llinbuf[3], lloutbuf[3]; - /* long long */ - llinbuf[0] = 0xffffffff; - llinbuf[1] = 0; - llinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3; + long long llinbuf[3], lloutbuf[3]; + /* long long */ + llinbuf[0] = 0xffffffff; + llinbuf[1] = 0; + llinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3; - lloutbuf[0] = 0; - lloutbuf[1] = 1; - lloutbuf[2] = 1; - if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { - MTestPrintfMsg( 10, "Reduce of MPI_LONG_LONG\n" ); - rc = MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_BOR, 0, comm ); - if (rc) { - MTestPrintErrorMsg( "MPI_BOR and MPI_LONG_LONG", rc ); - errs++; - } - else { - if (rank == 0) { - if (lloutbuf[0] != 0xffffffff) { - errs++; - fprintf( stderr, "long long BOR(1) test failed\n" ); - } - if (lloutbuf[1]) { - errs++; - fprintf( stderr, "long long BOR(0) test failed\n" ); - } - if (lloutbuf[2] != 0xffffffff && size > 1) { - errs++; - fprintf( stderr, "long long BOR(>) test failed\n" ); - } - } - } - } + lloutbuf[0] = 0; + lloutbuf[1] = 1; + lloutbuf[2] = 1; + if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { + MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n"); + rc = MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_BOR, 0, comm); + if (rc) { + MTestPrintErrorMsg("MPI_BOR and MPI_LONG_LONG", rc); + errs++; + } + else { + if (rank == 0) { + if (lloutbuf[0] != 0xffffffff) { + errs++; + fprintf(stderr, "long long BOR(1) test failed\n"); + } + if (lloutbuf[1]) { + errs++; + fprintf(stderr, "long long BOR(0) test failed\n"); + } + if (lloutbuf[2] != 0xffffffff && size > 1) { + errs++; + fprintf(stderr, "long long BOR(>) test failed\n"); + } + } + } + } } #endif - MPI_Errhandler_set( comm, MPI_ERRORS_ARE_FATAL ); - MTest_Finalize( errs ); + MPI_Errhandler_set(comm, MPI_ERRORS_ARE_FATAL); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/coll/opbxor.c b/teshsuite/smpi/mpich3-test/coll/opbxor.c index 6673561a48..d5b64db442 100644 --- a/teshsuite/smpi/mpich3-test/coll/opbxor.c +++ b/teshsuite/smpi/mpich3-test/coll/opbxor.c @@ -14,16 +14,16 @@ static char MTEST_Descrip[] = "Test MPI_BXOR operations on optional datatypes du */ /* - * This test looks at the handling of logical and for types that are not + * This test looks at the handling of logical and for types that are not * integers or are not required integers (e.g., long long). MPICH allows * these as well. A strict MPI test should not include this test. */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rc; int rank, size; - MPI_Comm comm; + MPI_Comm comm; char cinbuf[3], coutbuf[3]; signed char scinbuf[3], scoutbuf[3]; unsigned char ucinbuf[3], ucoutbuf[3]; @@ -33,21 +33,21 @@ int main( int argc, char *argv[] ) unsigned long ulinbuf[3], uloutbuf[3]; unsigned uinbuf[3], uoutbuf[3]; int iinbuf[3], ioutbuf[3]; - - MTest_Init( &argc, &argv ); + + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - /* Set errors return so that we can provide better information - should a routine reject one of the operand/datatype pairs */ - MPI_Errhandler_set( comm, MPI_ERRORS_RETURN ); + /* Set errors return so that we can provide better information + * should a routine reject one of the operand/datatype pairs */ + MPI_Errhandler_set(comm, MPI_ERRORS_RETURN); - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); #ifndef USE_STRICT_MPI /* char */ - MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_CHAR\n"); cinbuf[0] = 0xff; cinbuf[1] = 0; cinbuf[2] = (rank > 0) ? 0x3c : 0xc3; @@ -55,31 +55,31 @@ int main( int argc, char *argv[] ) coutbuf[0] = 0xf; coutbuf[1] = 1; coutbuf[2] = 1; - rc = MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_BXOR, 0, comm ); + rc = MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_BXOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BXOR and MPI_CHAR", rc ); - errs++; + MTestPrintErrorMsg("MPI_BXOR and MPI_CHAR", rc); + errs++; } else { - if (rank == 0) { - if (coutbuf[0] != ((size % 2) ? (char)0xff : (char)0) ) { - errs++; - fprintf( stderr, "char BXOR(1) test failed\n" ); - } - if (coutbuf[1]) { - errs++; - fprintf( stderr, "char BXOR(0) test failed\n" ); - } - if (coutbuf[2] != ((size % 2) ? (char)0xc3 : (char)0xff)) { - errs++; - fprintf( stderr, "char BXOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (coutbuf[0] != ((size % 2) ? (char) 0xff : (char) 0)) { + errs++; + fprintf(stderr, "char BXOR(1) test failed\n"); + } + if (coutbuf[1]) { + errs++; + fprintf(stderr, "char BXOR(0) test failed\n"); + } + if (coutbuf[2] != ((size % 2) ? (char) 0xc3 : (char) 0xff)) { + errs++; + fprintf(stderr, "char BXOR(>) test failed\n"); + } + } } #endif /* USE_STRICT_MPI */ /* signed char */ - MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n"); scinbuf[0] = 0xff; scinbuf[1] = 0; scinbuf[2] = (rank > 0) ? 0x3c : 0xc3; @@ -87,30 +87,30 @@ int main( int argc, char *argv[] ) scoutbuf[0] = 0xf; scoutbuf[1] = 1; scoutbuf[2] = 1; - rc = MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_BXOR, 0, comm ); + rc = MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_BXOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BXOR and MPI_SIGNED_CHAR", rc ); - errs++; + MTestPrintErrorMsg("MPI_BXOR and MPI_SIGNED_CHAR", rc); + errs++; } else { - if (rank == 0) { - if (scoutbuf[0] != ((size % 2) ? (signed char)0xff : (signed char)0) ) { - errs++; - fprintf( stderr, "signed char BXOR(1) test failed\n" ); - } - if (scoutbuf[1]) { - errs++; - fprintf( stderr, "signed char BXOR(0) test failed\n" ); - } - if (scoutbuf[2] != ((size % 2) ? (signed char)0xc3 : (signed char)0xff)) { - errs++; - fprintf( stderr, "signed char BXOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (scoutbuf[0] != ((size % 2) ? (signed char) 0xff : (signed char) 0)) { + errs++; + fprintf(stderr, "signed char BXOR(1) test failed\n"); + } + if (scoutbuf[1]) { + errs++; + fprintf(stderr, "signed char BXOR(0) test failed\n"); + } + if (scoutbuf[2] != ((size % 2) ? (signed char) 0xc3 : (signed char) 0xff)) { + errs++; + fprintf(stderr, "signed char BXOR(>) test failed\n"); + } + } } /* unsigned char */ - MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n"); ucinbuf[0] = 0xff; ucinbuf[1] = 0; ucinbuf[2] = (rank > 0) ? 0x3c : 0xc3; @@ -118,30 +118,30 @@ int main( int argc, char *argv[] ) ucoutbuf[0] = 0; ucoutbuf[1] = 1; ucoutbuf[2] = 1; - rc = MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_BXOR, 0, comm ); + rc = MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_BXOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BXOR and MPI_UNSIGNED_CHAR", rc ); - errs++; + MTestPrintErrorMsg("MPI_BXOR and MPI_UNSIGNED_CHAR", rc); + errs++; } else { - if (rank == 0) { - if (ucoutbuf[0] != ((size % 2) ? 0xff : 0)) { - errs++; - fprintf( stderr, "unsigned char BXOR(1) test failed\n" ); - } - if (ucoutbuf[1]) { - errs++; - fprintf( stderr, "unsigned char BXOR(0) test failed\n" ); - } - if (ucoutbuf[2] != ((size % 2) ? (unsigned char)0xc3 : (unsigned char)0xff)) { - errs++; - fprintf( stderr, "unsigned char BXOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (ucoutbuf[0] != ((size % 2) ? 0xff : 0)) { + errs++; + fprintf(stderr, "unsigned char BXOR(1) test failed\n"); + } + if (ucoutbuf[1]) { + errs++; + fprintf(stderr, "unsigned char BXOR(0) test failed\n"); + } + if (ucoutbuf[2] != ((size % 2) ? (unsigned char) 0xc3 : (unsigned char) 0xff)) { + errs++; + fprintf(stderr, "unsigned char BXOR(>) test failed\n"); + } + } } /* bytes */ - MTestPrintfMsg( 10, "Reduce of MPI_BYTE\n" ); + MTestPrintfMsg(10, "Reduce of MPI_BYTE\n"); cinbuf[0] = 0xff; cinbuf[1] = 0; cinbuf[2] = (rank > 0) ? 0x3c : 0xc3; @@ -149,30 +149,30 @@ int main( int argc, char *argv[] ) coutbuf[0] = 0; coutbuf[1] = 1; coutbuf[2] = 1; - rc = MPI_Reduce( cinbuf, coutbuf, 3, MPI_BYTE, MPI_BXOR, 0, comm ); + rc = MPI_Reduce(cinbuf, coutbuf, 3, MPI_BYTE, MPI_BXOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BXOR and MPI_BYTE", rc ); - errs++; + MTestPrintErrorMsg("MPI_BXOR and MPI_BYTE", rc); + errs++; } else { - if (rank == 0) { - if (coutbuf[0] != ((size % 2) ? (char)0xff : 0)) { - errs++; - fprintf( stderr, "byte BXOR(1) test failed\n" ); - } - if (coutbuf[1]) { - errs++; - fprintf( stderr, "byte BXOR(0) test failed\n" ); - } - if (coutbuf[2] != ((size % 2) ? (char)0xc3 : (char)0xff)) { - errs++; - fprintf( stderr, "byte BXOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (coutbuf[0] != ((size % 2) ? (char) 0xff : 0)) { + errs++; + fprintf(stderr, "byte BXOR(1) test failed\n"); + } + if (coutbuf[1]) { + errs++; + fprintf(stderr, "byte BXOR(0) test failed\n"); + } + if (coutbuf[2] != ((size % 2) ? (char) 0xc3 : (char) 0xff)) { + errs++; + fprintf(stderr, "byte BXOR(>) test failed\n"); + } + } } /* short */ - MTestPrintfMsg( 10, "Reduce of MPI_SHORT\n" ); + MTestPrintfMsg(10, "Reduce of MPI_SHORT\n"); sinbuf[0] = 0xffff; sinbuf[1] = 0; sinbuf[2] = (rank > 0) ? 0x3c3c : 0xc3c3; @@ -180,30 +180,30 @@ int main( int argc, char *argv[] ) soutbuf[0] = 0; soutbuf[1] = 1; soutbuf[2] = 1; - rc = MPI_Reduce( sinbuf, soutbuf, 3, MPI_SHORT, MPI_BXOR, 0, comm ); + rc = MPI_Reduce(sinbuf, soutbuf, 3, MPI_SHORT, MPI_BXOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BXOR and MPI_SHORT", rc ); - errs++; + MTestPrintErrorMsg("MPI_BXOR and MPI_SHORT", rc); + errs++; } else { - if (rank == 0) { - if (soutbuf[0] != ((size % 2) ? (short)0xffff : 0)) { - errs++; - fprintf( stderr, "short BXOR(1) test failed\n" ); - } - if (soutbuf[1]) { - errs++; - fprintf( stderr, "short BXOR(0) test failed\n" ); - } - if (soutbuf[2] != ((size % 2) ? (short)0xc3c3 : (short)0xffff)) { - errs++; - fprintf( stderr, "short BXOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (soutbuf[0] != ((size % 2) ? (short) 0xffff : 0)) { + errs++; + fprintf(stderr, "short BXOR(1) test failed\n"); + } + if (soutbuf[1]) { + errs++; + fprintf(stderr, "short BXOR(0) test failed\n"); + } + if (soutbuf[2] != ((size % 2) ? (short) 0xc3c3 : (short) 0xffff)) { + errs++; + fprintf(stderr, "short BXOR(>) test failed\n"); + } + } } /* unsigned short */ - MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_SHORT\n" ); + MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_SHORT\n"); usinbuf[0] = 0xffff; usinbuf[1] = 0; usinbuf[2] = (rank > 0) ? 0x3c3c : 0xc3c3; @@ -211,30 +211,30 @@ int main( int argc, char *argv[] ) usoutbuf[0] = 0; usoutbuf[1] = 1; usoutbuf[2] = 1; - rc = MPI_Reduce( usinbuf, usoutbuf, 3, MPI_UNSIGNED_SHORT, MPI_BXOR, 0, comm ); + rc = MPI_Reduce(usinbuf, usoutbuf, 3, MPI_UNSIGNED_SHORT, MPI_BXOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BXOR and MPI_UNSIGNED_SHORT", rc ); - errs++; + MTestPrintErrorMsg("MPI_BXOR and MPI_UNSIGNED_SHORT", rc); + errs++; } else { - if (rank == 0) { - if (usoutbuf[0] != ((size % 2) ? 0xffff : 0)) { - errs++; - fprintf( stderr, "short BXOR(1) test failed\n" ); - } - if (usoutbuf[1]) { - errs++; - fprintf( stderr, "short BXOR(0) test failed\n" ); - } - if (usoutbuf[2] != ((size % 2) ? 0xc3c3 : 0xffff)) { - errs++; - fprintf( stderr, "short BXOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (usoutbuf[0] != ((size % 2) ? 0xffff : 0)) { + errs++; + fprintf(stderr, "short BXOR(1) test failed\n"); + } + if (usoutbuf[1]) { + errs++; + fprintf(stderr, "short BXOR(0) test failed\n"); + } + if (usoutbuf[2] != ((size % 2) ? 0xc3c3 : 0xffff)) { + errs++; + fprintf(stderr, "short BXOR(>) test failed\n"); + } + } } /* unsigned */ - MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED\n" ); + MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED\n"); uinbuf[0] = 0xffffffff; uinbuf[1] = 0; uinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3; @@ -242,30 +242,30 @@ int main( int argc, char *argv[] ) uoutbuf[0] = 0; uoutbuf[1] = 1; uoutbuf[2] = 1; - rc = MPI_Reduce( uinbuf, uoutbuf, 3, MPI_UNSIGNED, MPI_BXOR, 0, comm ); + rc = MPI_Reduce(uinbuf, uoutbuf, 3, MPI_UNSIGNED, MPI_BXOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BXOR and MPI_UNSIGNED", rc ); - errs++; + MTestPrintErrorMsg("MPI_BXOR and MPI_UNSIGNED", rc); + errs++; } else { - if (rank == 0) { - if (uoutbuf[0] != ((size % 2) ? 0xffffffff : 0)) { - errs++; - fprintf( stderr, "unsigned BXOR(1) test failed\n" ); - } - if (uoutbuf[1]) { - errs++; - fprintf( stderr, "unsigned BXOR(0) test failed\n" ); - } - if (uoutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) { - errs++; - fprintf( stderr, "unsigned BXOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (uoutbuf[0] != ((size % 2) ? 0xffffffff : 0)) { + errs++; + fprintf(stderr, "unsigned BXOR(1) test failed\n"); + } + if (uoutbuf[1]) { + errs++; + fprintf(stderr, "unsigned BXOR(0) test failed\n"); + } + if (uoutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) { + errs++; + fprintf(stderr, "unsigned BXOR(>) test failed\n"); + } + } } /* int */ - MTestPrintfMsg( 10, "Reduce of MPI_INT\n" ); + MTestPrintfMsg(10, "Reduce of MPI_INT\n"); iinbuf[0] = 0xffffffff; iinbuf[1] = 0; iinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3; @@ -273,30 +273,30 @@ int main( int argc, char *argv[] ) ioutbuf[0] = 0; ioutbuf[1] = 1; ioutbuf[2] = 1; - rc = MPI_Reduce( iinbuf, ioutbuf, 3, MPI_INT, MPI_BXOR, 0, comm ); + rc = MPI_Reduce(iinbuf, ioutbuf, 3, MPI_INT, MPI_BXOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BXOR and MPI_INT", rc ); - errs++; + MTestPrintErrorMsg("MPI_BXOR and MPI_INT", rc); + errs++; } else { - if (rank == 0) { - if (ioutbuf[0] != ((size % 2) ? 0xffffffff : 0)) { - errs++; - fprintf( stderr, "int BXOR(1) test failed\n" ); - } - if (ioutbuf[1]) { - errs++; - fprintf( stderr, "int BXOR(0) test failed\n" ); - } - if (ioutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) { - errs++; - fprintf( stderr, "int BXOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (ioutbuf[0] != ((size % 2) ? 0xffffffff : 0)) { + errs++; + fprintf(stderr, "int BXOR(1) test failed\n"); + } + if (ioutbuf[1]) { + errs++; + fprintf(stderr, "int BXOR(0) test failed\n"); + } + if (ioutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) { + errs++; + fprintf(stderr, "int BXOR(>) test failed\n"); + } + } } /* long */ - MTestPrintfMsg( 10, "Reduce of MPI_LONG\n" ); + MTestPrintfMsg(10, "Reduce of MPI_LONG\n"); linbuf[0] = 0xffffffff; linbuf[1] = 0; linbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3; @@ -304,30 +304,30 @@ int main( int argc, char *argv[] ) loutbuf[0] = 0; loutbuf[1] = 1; loutbuf[2] = 1; - rc = MPI_Reduce( linbuf, loutbuf, 3, MPI_LONG, MPI_BXOR, 0, comm ); + rc = MPI_Reduce(linbuf, loutbuf, 3, MPI_LONG, MPI_BXOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BXOR and MPI_LONG", rc ); - errs++; + MTestPrintErrorMsg("MPI_BXOR and MPI_LONG", rc); + errs++; } else { - if (rank == 0) { - if (loutbuf[0] != ((size % 2) ? 0xffffffff : 0)) { - errs++; - fprintf( stderr, "long BXOR(1) test failed\n" ); - } - if (loutbuf[1]) { - errs++; - fprintf( stderr, "long BXOR(0) test failed\n" ); - } - if (loutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) { - errs++; - fprintf( stderr, "long BXOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (loutbuf[0] != ((size % 2) ? 0xffffffff : 0)) { + errs++; + fprintf(stderr, "long BXOR(1) test failed\n"); + } + if (loutbuf[1]) { + errs++; + fprintf(stderr, "long BXOR(0) test failed\n"); + } + if (loutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) { + errs++; + fprintf(stderr, "long BXOR(>) test failed\n"); + } + } } /* unsigned long */ - MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_LONG\n" ); + MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_LONG\n"); ulinbuf[0] = 0xffffffff; ulinbuf[1] = 0; ulinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3; @@ -335,68 +335,68 @@ int main( int argc, char *argv[] ) uloutbuf[0] = 0; uloutbuf[1] = 1; uloutbuf[2] = 1; - rc = MPI_Reduce( ulinbuf, uloutbuf, 3, MPI_UNSIGNED_LONG, MPI_BXOR, 0, comm ); + rc = MPI_Reduce(ulinbuf, uloutbuf, 3, MPI_UNSIGNED_LONG, MPI_BXOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_BXOR and MPI_UNSIGNED_LONG", rc ); - errs++; + MTestPrintErrorMsg("MPI_BXOR and MPI_UNSIGNED_LONG", rc); + errs++; } else { - if (rank == 0) { - if (uloutbuf[0] != ((size % 2) ? 0xffffffff : 0)) { - errs++; - fprintf( stderr, "unsigned long BXOR(1) test failed\n" ); - } - if (uloutbuf[1]) { - errs++; - fprintf( stderr, "unsigned long BXOR(0) test failed\n" ); - } - if (uloutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) { - errs++; - fprintf( stderr, "unsigned long BXOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (uloutbuf[0] != ((size % 2) ? 0xffffffff : 0)) { + errs++; + fprintf(stderr, "unsigned long BXOR(1) test failed\n"); + } + if (uloutbuf[1]) { + errs++; + fprintf(stderr, "unsigned long BXOR(0) test failed\n"); + } + if (uloutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) { + errs++; + fprintf(stderr, "unsigned long BXOR(>) test failed\n"); + } + } } #ifdef HAVE_LONG_LONG { - long long llinbuf[3], lloutbuf[3]; - /* long long */ - llinbuf[0] = 0xffffffff; - llinbuf[1] = 0; - llinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3; + long long llinbuf[3], lloutbuf[3]; + /* long long */ + llinbuf[0] = 0xffffffff; + llinbuf[1] = 0; + llinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3; - lloutbuf[0] = 0; - lloutbuf[1] = 1; - lloutbuf[2] = 1; - if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { - MTestPrintfMsg( 10, "Reduce of MPI_LONG_LONG\n" ); - rc = MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_BXOR, 0, comm ); - if (rc) { - MTestPrintErrorMsg( "MPI_BXOR and MPI_LONG_LONG", rc ); - errs++; - } - else { - if (rank == 0) { - if (lloutbuf[0] != ((size % 2) ? 0xffffffff : 0)) { - errs++; - fprintf( stderr, "long long BXOR(1) test failed\n" ); - } - if (lloutbuf[1]) { - errs++; - fprintf( stderr, "long long BXOR(0) test failed\n" ); - } - if (lloutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) { - errs++; - fprintf( stderr, "long long BXOR(>) test failed\n" ); - } - } - } - } + lloutbuf[0] = 0; + lloutbuf[1] = 1; + lloutbuf[2] = 1; + if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { + MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n"); + rc = MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_BXOR, 0, comm); + if (rc) { + MTestPrintErrorMsg("MPI_BXOR and MPI_LONG_LONG", rc); + errs++; + } + else { + if (rank == 0) { + if (lloutbuf[0] != ((size % 2) ? 0xffffffff : 0)) { + errs++; + fprintf(stderr, "long long BXOR(1) test failed\n"); + } + if (lloutbuf[1]) { + errs++; + fprintf(stderr, "long long BXOR(0) test failed\n"); + } + if (lloutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) { + errs++; + fprintf(stderr, "long long BXOR(>) test failed\n"); + } + } + } + } } #endif - MPI_Errhandler_set( comm, MPI_ERRORS_ARE_FATAL ); - MTest_Finalize( errs ); + MPI_Errhandler_set(comm, MPI_ERRORS_ARE_FATAL); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/coll/opland.c b/teshsuite/smpi/mpich3-test/coll/opland.c index ad32a75686..e41917409a 100644 --- a/teshsuite/smpi/mpich3-test/coll/opland.c +++ b/teshsuite/smpi/mpich3-test/coll/opland.c @@ -14,35 +14,35 @@ static char MTEST_Descrip[] = "Test MPI_LAND operations on optional datatypes du */ /* - * This test looks at the handling of logical and for types that are not + * This test looks at the handling of logical and for types that are not * integers or are not required integers (e.g., long long). MPICH allows * these as well. A strict MPI test should not include this test. */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rc; int rank, size; - MPI_Comm comm; + MPI_Comm comm; char cinbuf[3], coutbuf[3]; signed char scinbuf[3], scoutbuf[3]; unsigned char ucinbuf[3], ucoutbuf[3]; float finbuf[3], foutbuf[3]; double dinbuf[3], doutbuf[3]; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - /* Set errors return so that we can provide better information - should a routine reject one of the operand/datatype pairs */ - MPI_Errhandler_set( comm, MPI_ERRORS_RETURN ); + /* Set errors return so that we can provide better information + * should a routine reject one of the operand/datatype pairs */ + MPI_Errhandler_set(comm, MPI_ERRORS_RETURN); - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); #ifndef USE_STRICT_MPI /* char */ - MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_CHAR\n"); cinbuf[0] = 1; cinbuf[1] = 0; cinbuf[2] = (rank > 0); @@ -50,31 +50,31 @@ int main( int argc, char *argv[] ) coutbuf[0] = 0; coutbuf[1] = 1; coutbuf[2] = 1; - rc = MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_LAND, 0, comm ); + rc = MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_LAND, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_LAND and MPI_CHAR", rc ); - errs++; + MTestPrintErrorMsg("MPI_LAND and MPI_CHAR", rc); + errs++; } else { - if (rank == 0) { - if (!coutbuf[0]) { - errs++; - fprintf( stderr, "char AND(1) test failed\n" ); - } - if (coutbuf[1]) { - errs++; - fprintf( stderr, "char AND(0) test failed\n" ); - } - if (coutbuf[2] && size > 1) { - errs++; - fprintf( stderr, "char AND(>) test failed\n" ); - } - } + if (rank == 0) { + if (!coutbuf[0]) { + errs++; + fprintf(stderr, "char AND(1) test failed\n"); + } + if (coutbuf[1]) { + errs++; + fprintf(stderr, "char AND(0) test failed\n"); + } + if (coutbuf[2] && size > 1) { + errs++; + fprintf(stderr, "char AND(>) test failed\n"); + } + } } #endif /* USE_STRICT_MPI */ /* signed char */ - MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n"); scinbuf[0] = 1; scinbuf[1] = 0; scinbuf[2] = (rank > 0); @@ -82,30 +82,30 @@ int main( int argc, char *argv[] ) scoutbuf[0] = 0; scoutbuf[1] = 1; scoutbuf[2] = 1; - rc = MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_LAND, 0, comm ); + rc = MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_LAND, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_LAND and MPI_SIGNED_CHAR", rc ); - errs++; + MTestPrintErrorMsg("MPI_LAND and MPI_SIGNED_CHAR", rc); + errs++; } else { - if (rank == 0) { - if (!scoutbuf[0]) { - errs++; - fprintf( stderr, "signed char AND(1) test failed\n" ); - } - if (scoutbuf[1]) { - errs++; - fprintf( stderr, "signed char AND(0) test failed\n" ); - } - if (scoutbuf[2] && size > 1) { - errs++; - fprintf( stderr, "signed char AND(>) test failed\n" ); - } - } + if (rank == 0) { + if (!scoutbuf[0]) { + errs++; + fprintf(stderr, "signed char AND(1) test failed\n"); + } + if (scoutbuf[1]) { + errs++; + fprintf(stderr, "signed char AND(0) test failed\n"); + } + if (scoutbuf[2] && size > 1) { + errs++; + fprintf(stderr, "signed char AND(>) test failed\n"); + } + } } /* unsigned char */ - MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n"); ucinbuf[0] = 1; ucinbuf[1] = 0; ucinbuf[2] = (rank > 0); @@ -113,31 +113,31 @@ int main( int argc, char *argv[] ) ucoutbuf[0] = 0; ucoutbuf[1] = 1; ucoutbuf[2] = 1; - rc = MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_LAND, 0, comm ); + rc = MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_LAND, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_LAND and MPI_UNSIGNED_CHAR", rc ); - errs++; + MTestPrintErrorMsg("MPI_LAND and MPI_UNSIGNED_CHAR", rc); + errs++; } else { - if (rank == 0) { - if (!ucoutbuf[0]) { - errs++; - fprintf( stderr, "unsigned char AND(1) test failed\n" ); - } - if (ucoutbuf[1]) { - errs++; - fprintf( stderr, "unsigned char AND(0) test failed\n" ); - } - if (ucoutbuf[2] && size > 1) { - errs++; - fprintf( stderr, "unsigned char AND(>) test failed\n" ); - } - } + if (rank == 0) { + if (!ucoutbuf[0]) { + errs++; + fprintf(stderr, "unsigned char AND(1) test failed\n"); + } + if (ucoutbuf[1]) { + errs++; + fprintf(stderr, "unsigned char AND(0) test failed\n"); + } + if (ucoutbuf[2] && size > 1) { + errs++; + fprintf(stderr, "unsigned char AND(>) test failed\n"); + } + } } #ifndef USE_STRICT_MPI /* float */ - MTestPrintfMsg( 10, "Reduce of MPI_FLOAT\n" ); + MTestPrintfMsg(10, "Reduce of MPI_FLOAT\n"); finbuf[0] = 1; finbuf[1] = 0; finbuf[2] = (rank > 0); @@ -145,29 +145,29 @@ int main( int argc, char *argv[] ) foutbuf[0] = 0; foutbuf[1] = 1; foutbuf[2] = 1; - rc = MPI_Reduce( finbuf, foutbuf, 3, MPI_FLOAT, MPI_LAND, 0, comm ); + rc = MPI_Reduce(finbuf, foutbuf, 3, MPI_FLOAT, MPI_LAND, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_LAND and MPI_FLOAT", rc ); - errs++; + MTestPrintErrorMsg("MPI_LAND and MPI_FLOAT", rc); + errs++; } else { - if (rank == 0) { - if (!foutbuf[0]) { - errs++; - fprintf( stderr, "float AND(1) test failed\n" ); - } - if (foutbuf[1]) { - errs++; - fprintf( stderr, "float AND(0) test failed\n" ); - } - if (foutbuf[2] && size > 1) { - errs++; - fprintf( stderr, "float AND(>) test failed\n" ); - } - } + if (rank == 0) { + if (!foutbuf[0]) { + errs++; + fprintf(stderr, "float AND(1) test failed\n"); + } + if (foutbuf[1]) { + errs++; + fprintf(stderr, "float AND(0) test failed\n"); + } + if (foutbuf[2] && size > 1) { + errs++; + fprintf(stderr, "float AND(>) test failed\n"); + } + } } - MTestPrintfMsg( 10, "Reduce of MPI_DOUBLE\n" ); + MTestPrintfMsg(10, "Reduce of MPI_DOUBLE\n"); /* double */ dinbuf[0] = 1; dinbuf[1] = 0; @@ -176,62 +176,64 @@ int main( int argc, char *argv[] ) doutbuf[0] = 0; doutbuf[1] = 1; doutbuf[2] = 1; - rc = MPI_Reduce( dinbuf, doutbuf, 3, MPI_DOUBLE, MPI_LAND, 0, comm ); + rc = MPI_Reduce(dinbuf, doutbuf, 3, MPI_DOUBLE, MPI_LAND, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_LAND and MPI_DOUBLE", rc ); - errs++; + MTestPrintErrorMsg("MPI_LAND and MPI_DOUBLE", rc); + errs++; } else { - if (rank == 0) { - if (!doutbuf[0]) { - errs++; - fprintf( stderr, "double AND(1) test failed\n" ); - } - if (doutbuf[1]) { - errs++; - fprintf( stderr, "double AND(0) test failed\n" ); - } - if (doutbuf[2] && size > 1) { - errs++; - fprintf( stderr, "double AND(>) test failed\n" ); - } - } + if (rank == 0) { + if (!doutbuf[0]) { + errs++; + fprintf(stderr, "double AND(1) test failed\n"); + } + if (doutbuf[1]) { + errs++; + fprintf(stderr, "double AND(0) test failed\n"); + } + if (doutbuf[2] && size > 1) { + errs++; + fprintf(stderr, "double AND(>) test failed\n"); + } + } } #ifdef HAVE_LONG_DOUBLE - { long double ldinbuf[3], ldoutbuf[3]; - /* long double */ - ldinbuf[0] = 1; - ldinbuf[1] = 0; - ldinbuf[2] = (rank > 0); + { + long double ldinbuf[3], ldoutbuf[3]; + /* long double */ + MTEST_VG_MEM_INIT(ldinbuf, 3* sizeof(ldinbuf[0])); + ldinbuf[0] = 1; + ldinbuf[1] = 0; + ldinbuf[2] = (rank > 0); - ldoutbuf[0] = 0; - ldoutbuf[1] = 1; - ldoutbuf[2] = 1; - if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) { - MTestPrintfMsg( 10, "Reduce of MPI_LONG_DOUBLE\n" ); - rc = MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_LAND, 0, comm ); - if (rc) { - MTestPrintErrorMsg( "MPI_LAND and MPI_LONG_DOUBLE", rc ); - errs++; - } - else { - if (rank == 0) { - if (!ldoutbuf[0]) { - errs++; - fprintf( stderr, "long double AND(1) test failed\n" ); - } - if (ldoutbuf[1]) { - errs++; - fprintf( stderr, "long double AND(0) test failed\n" ); - } - if (ldoutbuf[2] && size > 1) { - errs++; - fprintf( stderr, "long double AND(>) test failed\n" ); - } - } - } - } + ldoutbuf[0] = 0; + ldoutbuf[1] = 1; + ldoutbuf[2] = 1; + if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) { + MTestPrintfMsg(10, "Reduce of MPI_LONG_DOUBLE\n"); + rc = MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_LAND, 0, comm); + if (rc) { + MTestPrintErrorMsg("MPI_LAND and MPI_LONG_DOUBLE", rc); + errs++; + } + else { + if (rank == 0) { + if (!ldoutbuf[0]) { + errs++; + fprintf(stderr, "long double AND(1) test failed\n"); + } + if (ldoutbuf[1]) { + errs++; + fprintf(stderr, "long double AND(0) test failed\n"); + } + if (ldoutbuf[2] && size > 1) { + errs++; + fprintf(stderr, "long double AND(>) test failed\n"); + } + } + } + } } #endif /* HAVE_LONG_DOUBLE */ #endif /* USE_STRICT_MPI */ @@ -239,45 +241,44 @@ int main( int argc, char *argv[] ) #ifdef HAVE_LONG_LONG { - long long llinbuf[3], lloutbuf[3]; - /* long long */ - llinbuf[0] = 1; - llinbuf[1] = 0; - llinbuf[2] = (rank > 0); + long long llinbuf[3], lloutbuf[3]; + /* long long */ + llinbuf[0] = 1; + llinbuf[1] = 0; + llinbuf[2] = (rank > 0); - lloutbuf[0] = 0; - lloutbuf[1] = 1; - lloutbuf[2] = 1; - if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { - MTestPrintfMsg( 10, "Reduce of MPI_LONG_LONG\n" ); - rc = MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_LAND, 0, comm ); - if (rc) { - MTestPrintErrorMsg( "MPI_LAND and MPI_LONG_LONG", rc ); - errs++; - } - else { - if (rank == 0) { - if (!lloutbuf[0]) { - errs++; - fprintf( stderr, "long long AND(1) test failed\n" ); - } - if (lloutbuf[1]) { - errs++; - fprintf( stderr, "long long AND(0) test failed\n" ); - } - if (lloutbuf[2] && size > 1) { - errs++; - fprintf( stderr, "long long AND(>) test failed\n" ); - } - } - } - } + lloutbuf[0] = 0; + lloutbuf[1] = 1; + lloutbuf[2] = 1; + if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { + MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n"); + rc = MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_LAND, 0, comm); + if (rc) { + MTestPrintErrorMsg("MPI_LAND and MPI_LONG_LONG", rc); + errs++; + } + else { + if (rank == 0) { + if (!lloutbuf[0]) { + errs++; + fprintf(stderr, "long long AND(1) test failed\n"); + } + if (lloutbuf[1]) { + errs++; + fprintf(stderr, "long long AND(0) test failed\n"); + } + if (lloutbuf[2] && size > 1) { + errs++; + fprintf(stderr, "long long AND(>) test failed\n"); + } + } + } + } } #endif - MPI_Errhandler_set( comm, MPI_ERRORS_ARE_FATAL ); - MTest_Finalize( errs ); + MPI_Errhandler_set(comm, MPI_ERRORS_ARE_FATAL); + MTest_Finalize(errs); MPI_Finalize(); return 0; } - diff --git a/teshsuite/smpi/mpich3-test/coll/oplor.c b/teshsuite/smpi/mpich3-test/coll/oplor.c index a168d35abb..14fafd28bd 100644 --- a/teshsuite/smpi/mpich3-test/coll/oplor.c +++ b/teshsuite/smpi/mpich3-test/coll/oplor.c @@ -14,38 +14,38 @@ static char MTEST_Descrip[] = "Test MPI_LOR operations on optional datatypes dup */ /* - * This test looks at the handling of logical and for types that are not + * This test looks at the handling of logical and for types that are not * integers or are not required integers (e.g., long long). MPICH allows * these as well. A strict MPI test should not include this test. */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0, err; int rank, size; - MPI_Comm comm; + MPI_Comm comm; char cinbuf[3], coutbuf[3]; signed char scinbuf[3], scoutbuf[3]; unsigned char ucinbuf[3], ucoutbuf[3]; float finbuf[3], foutbuf[3]; double dinbuf[3], doutbuf[3]; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); /* Some MPI implementations do not implement all of the required - (datatype,operations) combinations, and further, they do not - always provide clear and specific error messages. By catching - the error, we can provide a higher quality, more specific message. - */ - MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN ); + * (datatype,operations) combinations, and further, they do not + * always provide clear and specific error messages. By catching + * the error, we can provide a higher quality, more specific message. + */ + MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN); #ifndef USE_STRICT_MPI /* char */ - MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_CHAR\n"); cinbuf[0] = 1; cinbuf[1] = 0; cinbuf[2] = (rank > 0); @@ -53,31 +53,31 @@ int main( int argc, char *argv[] ) coutbuf[0] = 0; coutbuf[1] = 1; coutbuf[2] = 1; - err = MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_LOR, 0, comm ); + err = MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_LOR, 0, comm); if (err) { - errs++; - MTestPrintErrorMsg( "MPI_LOR and MPI_CHAR", err ); + errs++; + MTestPrintErrorMsg("MPI_LOR and MPI_CHAR", err); } else { - if (rank == 0) { - if (!coutbuf[0]) { - errs++; - fprintf( stderr, "char OR(1) test failed\n" ); - } - if (coutbuf[1]) { - errs++; - fprintf( stderr, "char OR(0) test failed\n" ); - } - if (!coutbuf[2] && size > 1) { - errs++; - fprintf( stderr, "char OR(>) test failed\n" ); - } - } + if (rank == 0) { + if (!coutbuf[0]) { + errs++; + fprintf(stderr, "char OR(1) test failed\n"); + } + if (coutbuf[1]) { + errs++; + fprintf(stderr, "char OR(0) test failed\n"); + } + if (!coutbuf[2] && size > 1) { + errs++; + fprintf(stderr, "char OR(>) test failed\n"); + } + } } #endif /* USE_STRICT_MPI */ /* signed char */ - MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n"); scinbuf[0] = 1; scinbuf[1] = 0; scinbuf[2] = (rank > 0); @@ -85,30 +85,30 @@ int main( int argc, char *argv[] ) scoutbuf[0] = 0; scoutbuf[1] = 1; scoutbuf[2] = 1; - err = MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_LOR, 0, comm ); + err = MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_LOR, 0, comm); if (err) { - errs++; - MTestPrintErrorMsg( "MPI_LOR and MPI_SIGNED_CHAR", err ); + errs++; + MTestPrintErrorMsg("MPI_LOR and MPI_SIGNED_CHAR", err); } else { - if (rank == 0) { - if (!scoutbuf[0]) { - errs++; - fprintf( stderr, "signed char OR(1) test failed\n" ); - } - if (scoutbuf[1]) { - errs++; - fprintf( stderr, "signed char OR(0) test failed\n" ); - } - if (!scoutbuf[2] && size > 1) { - errs++; - fprintf( stderr, "signed char OR(>) test failed\n" ); - } - } + if (rank == 0) { + if (!scoutbuf[0]) { + errs++; + fprintf(stderr, "signed char OR(1) test failed\n"); + } + if (scoutbuf[1]) { + errs++; + fprintf(stderr, "signed char OR(0) test failed\n"); + } + if (!scoutbuf[2] && size > 1) { + errs++; + fprintf(stderr, "signed char OR(>) test failed\n"); + } + } } /* unsigned char */ - MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n"); ucinbuf[0] = 1; ucinbuf[1] = 0; ucinbuf[2] = (rank > 0); @@ -116,31 +116,31 @@ int main( int argc, char *argv[] ) ucoutbuf[0] = 0; ucoutbuf[1] = 1; ucoutbuf[2] = 1; - err = MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_LOR, 0, comm ); + err = MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_LOR, 0, comm); if (err) { - errs++; - MTestPrintErrorMsg( "MPI_LOR and MPI_UNSIGNED_CHAR", err ); + errs++; + MTestPrintErrorMsg("MPI_LOR and MPI_UNSIGNED_CHAR", err); } else { - if (rank == 0) { - if (!ucoutbuf[0]) { - errs++; - fprintf( stderr, "unsigned char OR(1) test failed\n" ); - } - if (ucoutbuf[1]) { - errs++; - fprintf( stderr, "unsigned char OR(0) test failed\n" ); - } - if (!ucoutbuf[2] && size > 1) { - errs++; - fprintf( stderr, "unsigned char OR(>) test failed\n" ); - } - } + if (rank == 0) { + if (!ucoutbuf[0]) { + errs++; + fprintf(stderr, "unsigned char OR(1) test failed\n"); + } + if (ucoutbuf[1]) { + errs++; + fprintf(stderr, "unsigned char OR(0) test failed\n"); + } + if (!ucoutbuf[2] && size > 1) { + errs++; + fprintf(stderr, "unsigned char OR(>) test failed\n"); + } + } } #ifndef USE_STRICT_MPI /* float */ - MTestPrintfMsg( 10, "Reduce of MPI_FLOAT\n" ); + MTestPrintfMsg(10, "Reduce of MPI_FLOAT\n"); finbuf[0] = 1; finbuf[1] = 0; finbuf[2] = (rank > 0); @@ -148,30 +148,30 @@ int main( int argc, char *argv[] ) foutbuf[0] = 0; foutbuf[1] = 1; foutbuf[2] = 1; - err = MPI_Reduce( finbuf, foutbuf, 3, MPI_FLOAT, MPI_LOR, 0, comm ); + err = MPI_Reduce(finbuf, foutbuf, 3, MPI_FLOAT, MPI_LOR, 0, comm); if (err) { - errs++; - MTestPrintErrorMsg( "MPI_LOR and MPI_FLOAT", err ); + errs++; + MTestPrintErrorMsg("MPI_LOR and MPI_FLOAT", err); } else { - if (rank == 0) { - if (!foutbuf[0]) { - errs++; - fprintf( stderr, "float OR(1) test failed\n" ); - } - if (foutbuf[1]) { - errs++; - fprintf( stderr, "float OR(0) test failed\n" ); - } - if (!foutbuf[2] && size > 1) { - errs++; - fprintf( stderr, "float OR(>) test failed\n" ); - } - } + if (rank == 0) { + if (!foutbuf[0]) { + errs++; + fprintf(stderr, "float OR(1) test failed\n"); + } + if (foutbuf[1]) { + errs++; + fprintf(stderr, "float OR(0) test failed\n"); + } + if (!foutbuf[2] && size > 1) { + errs++; + fprintf(stderr, "float OR(>) test failed\n"); + } + } } /* double */ - MTestPrintfMsg( 10, "Reduce of MPI_DOUBLE\n" ); + MTestPrintfMsg(10, "Reduce of MPI_DOUBLE\n"); dinbuf[0] = 1; dinbuf[1] = 0; dinbuf[2] = (rank > 0); @@ -179,106 +179,108 @@ int main( int argc, char *argv[] ) doutbuf[0] = 0; doutbuf[1] = 1; doutbuf[2] = 1; - err = MPI_Reduce( dinbuf, doutbuf, 3, MPI_DOUBLE, MPI_LOR, 0, comm ); + err = MPI_Reduce(dinbuf, doutbuf, 3, MPI_DOUBLE, MPI_LOR, 0, comm); if (err) { - errs++; - MTestPrintErrorMsg( "MPI_LOR and MPI_DOUBLE", err ); + errs++; + MTestPrintErrorMsg("MPI_LOR and MPI_DOUBLE", err); } else { - if (rank == 0) { - if (!doutbuf[0]) { - errs++; - fprintf( stderr, "double OR(1) test failed\n" ); - } - if (doutbuf[1]) { - errs++; - fprintf( stderr, "double OR(0) test failed\n" ); - } - if (!doutbuf[2] && size > 1) { - errs++; - fprintf( stderr, "double OR(>) test failed\n" ); - } - } + if (rank == 0) { + if (!doutbuf[0]) { + errs++; + fprintf(stderr, "double OR(1) test failed\n"); + } + if (doutbuf[1]) { + errs++; + fprintf(stderr, "double OR(0) test failed\n"); + } + if (!doutbuf[2] && size > 1) { + errs++; + fprintf(stderr, "double OR(>) test failed\n"); + } + } } #ifdef HAVE_LONG_DOUBLE - { long double ldinbuf[3], ldoutbuf[3]; - /* long double */ - ldinbuf[0] = 1; - ldinbuf[1] = 0; - ldinbuf[2] = (rank > 0); + { + long double ldinbuf[3], ldoutbuf[3]; + /* long double */ + MTEST_VG_MEM_INIT(ldinbuf, 3* sizeof(ldinbuf[0])); + ldinbuf[0] = 1; + ldinbuf[1] = 0; + ldinbuf[2] = (rank > 0); - ldoutbuf[0] = 0; - ldoutbuf[1] = 1; - ldoutbuf[2] = 1; - if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) { - MTestPrintfMsg( 10, "Reduce of MPI_LONG_DOUBLE\n" ); - err = MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_LOR, 0, comm ); - if (err) { - errs++; - MTestPrintErrorMsg( "MPI_LOR and MPI_LONG_DOUBLE", err ); - } - else { - if (rank == 0) { - if (!ldoutbuf[0]) { - errs++; - fprintf( stderr, "long double OR(1) test failed\n" ); - } - if (ldoutbuf[1]) { - errs++; - fprintf( stderr, "long double OR(0) test failed\n" ); - } - if (!ldoutbuf[2] && size > 1) { - errs++; - fprintf( stderr, "long double OR(>) test failed\n" ); - } - } - } - } + ldoutbuf[0] = 0; + ldoutbuf[1] = 1; + ldoutbuf[2] = 1; + if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) { + MTestPrintfMsg(10, "Reduce of MPI_LONG_DOUBLE\n"); + err = MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_LOR, 0, comm); + if (err) { + errs++; + MTestPrintErrorMsg("MPI_LOR and MPI_LONG_DOUBLE", err); + } + else { + if (rank == 0) { + if (!ldoutbuf[0]) { + errs++; + fprintf(stderr, "long double OR(1) test failed\n"); + } + if (ldoutbuf[1]) { + errs++; + fprintf(stderr, "long double OR(0) test failed\n"); + } + if (!ldoutbuf[2] && size > 1) { + errs++; + fprintf(stderr, "long double OR(>) test failed\n"); + } + } + } + } } #endif /* HAVE_LONG_DOUBLE */ #endif /* USE_STRICT_MPI */ #ifdef HAVE_LONG_LONG { - long long llinbuf[3], lloutbuf[3]; - /* long long */ - llinbuf[0] = 1; - llinbuf[1] = 0; - llinbuf[2] = (rank > 0); + long long llinbuf[3], lloutbuf[3]; + /* long long */ + llinbuf[0] = 1; + llinbuf[1] = 0; + llinbuf[2] = (rank > 0); - lloutbuf[0] = 0; - lloutbuf[1] = 1; - lloutbuf[2] = 1; - if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { - MTestPrintfMsg( 10, "Reduce of MPI_LONG_LONG\n" ); - err = MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_LOR, 0, comm ); - if (err) { - errs++; - MTestPrintErrorMsg( "MPI_LOR and MPI_LONG_LONG", err ); - } - else { - if (rank == 0) { - if (!lloutbuf[0]) { - errs++; - fprintf( stderr, "long long OR(1) test failed\n" ); - } - if (lloutbuf[1]) { - errs++; - fprintf( stderr, "long long OR(0) test failed\n" ); - } - if (!lloutbuf[2] && size > 1) { - errs++; - fprintf( stderr, "long long OR(>) test failed\n" ); - } - } - } - } + lloutbuf[0] = 0; + lloutbuf[1] = 1; + lloutbuf[2] = 1; + if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { + MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n"); + err = MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_LOR, 0, comm); + if (err) { + errs++; + MTestPrintErrorMsg("MPI_LOR and MPI_LONG_LONG", err); + } + else { + if (rank == 0) { + if (!lloutbuf[0]) { + errs++; + fprintf(stderr, "long long OR(1) test failed\n"); + } + if (lloutbuf[1]) { + errs++; + fprintf(stderr, "long long OR(0) test failed\n"); + } + if (!lloutbuf[2] && size > 1) { + errs++; + fprintf(stderr, "long long OR(>) test failed\n"); + } + } + } + } } #endif - MPI_Errhandler_set( comm, MPI_ERRORS_ARE_FATAL ); - MTest_Finalize( errs ); + MPI_Errhandler_set(comm, MPI_ERRORS_ARE_FATAL); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/coll/oplxor.c b/teshsuite/smpi/mpich3-test/coll/oplxor.c index e55970d797..f5099b80b8 100644 --- a/teshsuite/smpi/mpich3-test/coll/oplxor.c +++ b/teshsuite/smpi/mpich3-test/coll/oplxor.c @@ -14,35 +14,35 @@ static char MTEST_Descrip[] = "Test MPI_LXOR operations on optional datatypes du */ /* - * This test looks at the handling of logical and for types that are not + * This test looks at the handling of logical and for types that are not * integers or are not required integers (e.g., long long). MPICH allows * these as well. A strict MPI test should not include this test. */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rc; int rank, size; - MPI_Comm comm; + MPI_Comm comm; char cinbuf[3], coutbuf[3]; signed char scinbuf[3], scoutbuf[3]; unsigned char ucinbuf[3], ucoutbuf[3]; float finbuf[3], foutbuf[3]; double dinbuf[3], doutbuf[3]; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - /* Set errors return so that we can provide better information - should a routine reject one of the operand/datatype pairs */ - MPI_Errhandler_set( comm, MPI_ERRORS_RETURN ); + /* Set errors return so that we can provide better information + * should a routine reject one of the operand/datatype pairs */ + MPI_Errhandler_set(comm, MPI_ERRORS_RETURN); - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); #ifndef USE_STRICT_MPI /* char */ - MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_CHAR\n"); cinbuf[0] = 1; cinbuf[1] = 0; cinbuf[2] = (rank > 0); @@ -50,31 +50,31 @@ int main( int argc, char *argv[] ) coutbuf[0] = 0; coutbuf[1] = 1; coutbuf[2] = 1; - rc = MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_LXOR, 0, comm ); + rc = MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_LXOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_LXOR and MPI_CHAR", rc ); - errs++; + MTestPrintErrorMsg("MPI_LXOR and MPI_CHAR", rc); + errs++; } else { - if (rank == 0) { - if (coutbuf[0] != (size % 2)) { - errs++; - fprintf( stderr, "char XOR(1) test failed\n" ); - } - if (coutbuf[1]) { - errs++; - fprintf( stderr, "char XOR(0) test failed\n" ); - } - if (coutbuf[2] == (size % 2) && size > 1) { - errs++; - fprintf( stderr, "char XOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (coutbuf[0] != (size % 2)) { + errs++; + fprintf(stderr, "char XOR(1) test failed\n"); + } + if (coutbuf[1]) { + errs++; + fprintf(stderr, "char XOR(0) test failed\n"); + } + if (coutbuf[2] == (size % 2) && size > 1) { + errs++; + fprintf(stderr, "char XOR(>) test failed\n"); + } + } } #endif /* USE_STRICT_MPI */ /* signed char */ - MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n"); scinbuf[0] = 1; scinbuf[1] = 0; scinbuf[2] = (rank > 0); @@ -82,30 +82,30 @@ int main( int argc, char *argv[] ) scoutbuf[0] = 0; scoutbuf[1] = 1; scoutbuf[2] = 1; - rc = MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_LXOR, 0, comm ); + rc = MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_LXOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_LXOR and MPI_SIGNED_CHAR", rc ); - errs++; + MTestPrintErrorMsg("MPI_LXOR and MPI_SIGNED_CHAR", rc); + errs++; } else { - if (rank == 0) { - if (scoutbuf[0] != (size % 2)) { - errs++; - fprintf( stderr, "signed char XOR(1) test failed\n" ); - } - if (scoutbuf[1]) { - errs++; - fprintf( stderr, "signed char XOR(0) test failed\n" ); - } - if (scoutbuf[2] == (size % 2) && size > 1) { - errs++; - fprintf( stderr, "signed char XOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (scoutbuf[0] != (size % 2)) { + errs++; + fprintf(stderr, "signed char XOR(1) test failed\n"); + } + if (scoutbuf[1]) { + errs++; + fprintf(stderr, "signed char XOR(0) test failed\n"); + } + if (scoutbuf[2] == (size % 2) && size > 1) { + errs++; + fprintf(stderr, "signed char XOR(>) test failed\n"); + } + } } /* unsigned char */ - MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n"); ucinbuf[0] = 1; ucinbuf[1] = 0; ucinbuf[2] = (rank > 0); @@ -113,31 +113,31 @@ int main( int argc, char *argv[] ) ucoutbuf[0] = 0; ucoutbuf[1] = 1; ucoutbuf[2] = 1; - rc = MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_LXOR, 0, comm ); + rc = MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_LXOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_LXOR and MPI_UNSIGNED_CHAR", rc ); - errs++; + MTestPrintErrorMsg("MPI_LXOR and MPI_UNSIGNED_CHAR", rc); + errs++; } else { - if (rank == 0) { - if (ucoutbuf[0] != (size % 2)) { - errs++; - fprintf( stderr, "unsigned char XOR(1) test failed\n" ); - } - if (ucoutbuf[1]) { - errs++; - fprintf( stderr, "unsigned char XOR(0) test failed\n" ); - } - if (ucoutbuf[2] == (size % 2) && size > 1) { - errs++; - fprintf( stderr, "unsigned char XOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (ucoutbuf[0] != (size % 2)) { + errs++; + fprintf(stderr, "unsigned char XOR(1) test failed\n"); + } + if (ucoutbuf[1]) { + errs++; + fprintf(stderr, "unsigned char XOR(0) test failed\n"); + } + if (ucoutbuf[2] == (size % 2) && size > 1) { + errs++; + fprintf(stderr, "unsigned char XOR(>) test failed\n"); + } + } } #ifndef USE_STRICT_MPI /* float */ - MTestPrintfMsg( 10, "Reduce of MPI_FLOAT\n" ); + MTestPrintfMsg(10, "Reduce of MPI_FLOAT\n"); finbuf[0] = 1; finbuf[1] = 0; finbuf[2] = (rank > 0); @@ -145,30 +145,30 @@ int main( int argc, char *argv[] ) foutbuf[0] = 0; foutbuf[1] = 1; foutbuf[2] = 1; - rc = MPI_Reduce( finbuf, foutbuf, 3, MPI_FLOAT, MPI_LXOR, 0, comm ); + rc = MPI_Reduce(finbuf, foutbuf, 3, MPI_FLOAT, MPI_LXOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_LXOR and MPI_FLOAT", rc ); - errs++; + MTestPrintErrorMsg("MPI_LXOR and MPI_FLOAT", rc); + errs++; } else { - if (rank == 0) { - if (foutbuf[0] != (size % 2)) { - errs++; - fprintf( stderr, "float XOR(1) test failed\n" ); - } - if (foutbuf[1]) { - errs++; - fprintf( stderr, "float XOR(0) test failed\n" ); - } - if (foutbuf[2] == (size % 2) && size > 1) { - errs++; - fprintf( stderr, "float XOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (foutbuf[0] != (size % 2)) { + errs++; + fprintf(stderr, "float XOR(1) test failed\n"); + } + if (foutbuf[1]) { + errs++; + fprintf(stderr, "float XOR(0) test failed\n"); + } + if (foutbuf[2] == (size % 2) && size > 1) { + errs++; + fprintf(stderr, "float XOR(>) test failed\n"); + } + } } /* double */ - MTestPrintfMsg( 10, "Reduce of MPI_DOUBLE\n" ); + MTestPrintfMsg(10, "Reduce of MPI_DOUBLE\n"); dinbuf[0] = 1; dinbuf[1] = 0; dinbuf[2] = (rank > 0); @@ -176,106 +176,108 @@ int main( int argc, char *argv[] ) doutbuf[0] = 0; doutbuf[1] = 1; doutbuf[2] = 1; - rc = MPI_Reduce( dinbuf, doutbuf, 3, MPI_DOUBLE, MPI_LXOR, 0, comm ); + rc = MPI_Reduce(dinbuf, doutbuf, 3, MPI_DOUBLE, MPI_LXOR, 0, comm); if (rc) { - MTestPrintErrorMsg( "MPI_LXOR and MPI_DOUBLE", rc ); - errs++; + MTestPrintErrorMsg("MPI_LXOR and MPI_DOUBLE", rc); + errs++; } else { - if (rank == 0) { - if (doutbuf[0] != (size % 2)) { - errs++; - fprintf( stderr, "double XOR(1) test failed\n" ); - } - if (doutbuf[1]) { - errs++; - fprintf( stderr, "double XOR(0) test failed\n" ); - } - if (doutbuf[2] == (size % 2) && size > 1) { - errs++; - fprintf( stderr, "double XOR(>) test failed\n" ); - } - } + if (rank == 0) { + if (doutbuf[0] != (size % 2)) { + errs++; + fprintf(stderr, "double XOR(1) test failed\n"); + } + if (doutbuf[1]) { + errs++; + fprintf(stderr, "double XOR(0) test failed\n"); + } + if (doutbuf[2] == (size % 2) && size > 1) { + errs++; + fprintf(stderr, "double XOR(>) test failed\n"); + } + } } #ifdef HAVE_LONG_DOUBLE - { long double ldinbuf[3], ldoutbuf[3]; - /* long double */ - ldinbuf[0] = 1; - ldinbuf[1] = 0; - ldinbuf[2] = (rank > 0); + { + long double ldinbuf[3], ldoutbuf[3]; + /* long double */ + MTEST_VG_MEM_INIT(ldinbuf, 3* sizeof(ldinbuf[0])); + ldinbuf[0] = 1; + ldinbuf[1] = 0; + ldinbuf[2] = (rank > 0); - ldoutbuf[0] = 0; - ldoutbuf[1] = 1; - ldoutbuf[2] = 1; - if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) { - MTestPrintfMsg( 10, "Reduce of MPI_LONG_DOUBLE\n" ); - rc = MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_LXOR, 0, comm ); - if (rc) { - MTestPrintErrorMsg( "MPI_LXOR and MPI_LONG_DOUBLE", rc ); - errs++; - } - else { - if (rank == 0) { - if (ldoutbuf[0] != (size % 2)) { - errs++; - fprintf( stderr, "long double XOR(1) test failed\n" ); - } - if (ldoutbuf[1]) { - errs++; - fprintf( stderr, "long double XOR(0) test failed\n" ); - } - if (ldoutbuf[2] == (size % 2) && size > 1) { - errs++; - fprintf( stderr, "long double XOR(>) test failed\n" ); - } - } - } - } + ldoutbuf[0] = 0; + ldoutbuf[1] = 1; + ldoutbuf[2] = 1; + if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) { + MTestPrintfMsg(10, "Reduce of MPI_LONG_DOUBLE\n"); + rc = MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_LXOR, 0, comm); + if (rc) { + MTestPrintErrorMsg("MPI_LXOR and MPI_LONG_DOUBLE", rc); + errs++; + } + else { + if (rank == 0) { + if (ldoutbuf[0] != (size % 2)) { + errs++; + fprintf(stderr, "long double XOR(1) test failed\n"); + } + if (ldoutbuf[1]) { + errs++; + fprintf(stderr, "long double XOR(0) test failed\n"); + } + if (ldoutbuf[2] == (size % 2) && size > 1) { + errs++; + fprintf(stderr, "long double XOR(>) test failed\n"); + } + } + } + } } #endif /* HAVE_LONG_DOUBLE */ #endif /* USE_STRICT_MPI */ #ifdef HAVE_LONG_LONG { - long long llinbuf[3], lloutbuf[3]; - /* long long */ - llinbuf[0] = 1; - llinbuf[1] = 0; - llinbuf[2] = (rank > 0); + long long llinbuf[3], lloutbuf[3]; + /* long long */ + llinbuf[0] = 1; + llinbuf[1] = 0; + llinbuf[2] = (rank > 0); - lloutbuf[0] = 0; - lloutbuf[1] = 1; - lloutbuf[2] = 1; - if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { - MTestPrintfMsg( 10, "Reduce of MPI_LONG_LONG\n" ); - rc = MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_LXOR, 0, comm ); - if (rc) { - MTestPrintErrorMsg( "MPI_LXOR and MPI_LONG_LONG", rc ); - errs++; - } - else { - if (rank == 0) { - if (lloutbuf[0] != (size % 2)) { - errs++; - fprintf( stderr, "long long XOR(1) test failed\n" ); - } - if (lloutbuf[1]) { - errs++; - fprintf( stderr, "long long XOR(0) test failed\n" ); - } - if (lloutbuf[2] == (size % 2) && size > 1) { - errs++; - fprintf( stderr, "long long XOR(>) test failed\n" ); - } - } - } - } + lloutbuf[0] = 0; + lloutbuf[1] = 1; + lloutbuf[2] = 1; + if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { + MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n"); + rc = MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_LXOR, 0, comm); + if (rc) { + MTestPrintErrorMsg("MPI_LXOR and MPI_LONG_LONG", rc); + errs++; + } + else { + if (rank == 0) { + if (lloutbuf[0] != (size % 2)) { + errs++; + fprintf(stderr, "long long XOR(1) test failed\n"); + } + if (lloutbuf[1]) { + errs++; + fprintf(stderr, "long long XOR(0) test failed\n"); + } + if (lloutbuf[2] == (size % 2) && size > 1) { + errs++; + fprintf(stderr, "long long XOR(>) test failed\n"); + } + } + } + } } #endif - MPI_Errhandler_set( comm, MPI_ERRORS_ARE_FATAL ); - MTest_Finalize( errs ); + MPI_Errhandler_set(comm, MPI_ERRORS_ARE_FATAL); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/coll/opmax.c b/teshsuite/smpi/mpich3-test/coll/opmax.c index 1c9c1ffaf5..cc8049b057 100644 --- a/teshsuite/smpi/mpich3-test/coll/opmax.c +++ b/teshsuite/smpi/mpich3-test/coll/opmax.c @@ -14,29 +14,29 @@ static char MTEST_Descrip[] = "Test MPI_MAX operations on optional datatypes dup */ /* - * This test looks at the handling of char and types that are not required + * This test looks at the handling of char and types that are not required * integers (e.g., long long). MPICH allows * these as well. A strict MPI test should not include this test. */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rank, size; - MPI_Comm comm; + MPI_Comm comm; char cinbuf[3], coutbuf[3]; signed char scinbuf[3], scoutbuf[3]; unsigned char ucinbuf[3], ucoutbuf[3]; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); #ifndef USE_STRICT_MPI /* char */ - MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_CHAR\n"); cinbuf[0] = 1; cinbuf[1] = 0; cinbuf[2] = rank; @@ -44,25 +44,25 @@ int main( int argc, char *argv[] ) coutbuf[0] = 0; coutbuf[1] = 1; coutbuf[2] = 1; - MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_MAX, 0, comm ); + MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_MAX, 0, comm); if (rank == 0) { - if (coutbuf[0] != 1) { - errs++; - fprintf( stderr, "char MAX(1) test failed\n" ); - } - if (coutbuf[1] != 0) { - errs++; - fprintf( stderr, "char MAX(0) test failed\n" ); - } - if (size < 128 && coutbuf[2] != size - 1) { - errs++; - fprintf( stderr, "char MAX(>) test failed\n" ); - } + if (coutbuf[0] != 1) { + errs++; + fprintf(stderr, "char MAX(1) test failed\n"); + } + if (coutbuf[1] != 0) { + errs++; + fprintf(stderr, "char MAX(0) test failed\n"); + } + if (size < 128 && coutbuf[2] != size - 1) { + errs++; + fprintf(stderr, "char MAX(>) test failed\n"); + } } #endif /* USE_STRICT_MPI */ /* signed char */ - MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n"); scinbuf[0] = 1; scinbuf[1] = 0; scinbuf[2] = rank; @@ -70,24 +70,24 @@ int main( int argc, char *argv[] ) scoutbuf[0] = 0; scoutbuf[1] = 1; scoutbuf[2] = 1; - MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_MAX, 0, comm ); + MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_MAX, 0, comm); if (rank == 0) { - if (scoutbuf[0] != 1) { - errs++; - fprintf( stderr, "signed char MAX(1) test failed\n" ); - } - if (scoutbuf[1] != 0) { - errs++; - fprintf( stderr, "signed char MAX(0) test failed\n" ); - } - if (size < 128 && scoutbuf[2] != size - 1) { - errs++; - fprintf( stderr, "signed char MAX(>) test failed\n" ); - } + if (scoutbuf[0] != 1) { + errs++; + fprintf(stderr, "signed char MAX(1) test failed\n"); + } + if (scoutbuf[1] != 0) { + errs++; + fprintf(stderr, "signed char MAX(0) test failed\n"); + } + if (size < 128 && scoutbuf[2] != size - 1) { + errs++; + fprintf(stderr, "signed char MAX(>) test failed\n"); + } } /* unsigned char */ - MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n"); ucinbuf[0] = 1; ucinbuf[1] = 0; ucinbuf[2] = rank; @@ -95,86 +95,88 @@ int main( int argc, char *argv[] ) ucoutbuf[0] = 0; ucoutbuf[1] = 1; ucoutbuf[2] = 1; - MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_MAX, 0, comm ); + MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_MAX, 0, comm); if (rank == 0) { - if (ucoutbuf[0] != 1) { - errs++; - fprintf( stderr, "unsigned char MAX(1) test failed\n" ); - } - if (ucoutbuf[1]) { - errs++; - fprintf( stderr, "unsigned char MAX(0) test failed\n" ); - } - if (size < 256 && ucoutbuf[2] != size - 1) { - errs++; - fprintf( stderr, "unsigned char MAX(>) test failed\n" ); - } + if (ucoutbuf[0] != 1) { + errs++; + fprintf(stderr, "unsigned char MAX(1) test failed\n"); + } + if (ucoutbuf[1]) { + errs++; + fprintf(stderr, "unsigned char MAX(0) test failed\n"); + } + if (size < 256 && ucoutbuf[2] != size - 1) { + errs++; + fprintf(stderr, "unsigned char MAX(>) test failed\n"); + } } #ifdef HAVE_LONG_DOUBLE - { long double ldinbuf[3], ldoutbuf[3]; - /* long double */ - ldinbuf[0] = 1; - ldinbuf[1] = 0; - ldinbuf[2] = rank; - - ldoutbuf[0] = 0; - ldoutbuf[1] = 1; - ldoutbuf[2] = 1; - if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) { - MTestPrintfMsg( 10, "Reduce of MPI_LONG_DOUBLE\n" ); - MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_MAX, 0, comm ); - if (rank == 0) { - if (ldoutbuf[0] != 1) { - errs++; - fprintf( stderr, "long double MAX(1) test failed\n" ); - } - if (ldoutbuf[1] != 0.0) { - errs++; - fprintf( stderr, "long double MAX(0) test failed\n" ); - } - if (ldoutbuf[2] != size - 1) { - errs++; - fprintf( stderr, "long double MAX(>) test failed\n" ); - } - } - } + { + long double ldinbuf[3], ldoutbuf[3]; + /* long double */ + MTEST_VG_MEM_INIT(ldinbuf, 3* sizeof(ldinbuf[0])); + ldinbuf[0] = 1; + ldinbuf[1] = 0; + ldinbuf[2] = rank; + + ldoutbuf[0] = 0; + ldoutbuf[1] = 1; + ldoutbuf[2] = 1; + if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) { + MTestPrintfMsg(10, "Reduce of MPI_LONG_DOUBLE\n"); + MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_MAX, 0, comm); + if (rank == 0) { + if (ldoutbuf[0] != 1) { + errs++; + fprintf(stderr, "long double MAX(1) test failed\n"); + } + if (ldoutbuf[1] != 0.0) { + errs++; + fprintf(stderr, "long double MAX(0) test failed\n"); + } + if (ldoutbuf[2] != size - 1) { + errs++; + fprintf(stderr, "long double MAX(>) test failed\n"); + } + } + } } #endif /* HAVE_LONG_DOUBLE */ #ifdef HAVE_LONG_LONG { - long long llinbuf[3], lloutbuf[3]; - /* long long */ - llinbuf[0] = 1; - llinbuf[1] = 0; - llinbuf[2] = rank; - - lloutbuf[0] = 0; - lloutbuf[1] = 1; - lloutbuf[2] = 1; - if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { - MTestPrintfMsg( 10, "Reduce of MPI_LONG_LONG\n" ); - MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_MAX, 0, comm ); - if (rank == 0) { - if (lloutbuf[0] != 1) { - errs++; - fprintf( stderr, "long long MAX(1) test failed\n" ); - } - if (lloutbuf[1] != 0) { - errs++; - fprintf( stderr, "long long MAX(0) test failed\n" ); - } - if (lloutbuf[2] != size - 1) { - errs++; - fprintf( stderr, "long long MAX(>) test failed\n" ); - } - } - } + long long llinbuf[3], lloutbuf[3]; + /* long long */ + llinbuf[0] = 1; + llinbuf[1] = 0; + llinbuf[2] = rank; + + lloutbuf[0] = 0; + lloutbuf[1] = 1; + lloutbuf[2] = 1; + if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { + MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n"); + MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_MAX, 0, comm); + if (rank == 0) { + if (lloutbuf[0] != 1) { + errs++; + fprintf(stderr, "long long MAX(1) test failed\n"); + } + if (lloutbuf[1] != 0) { + errs++; + fprintf(stderr, "long long MAX(0) test failed\n"); + } + if (lloutbuf[2] != size - 1) { + errs++; + fprintf(stderr, "long long MAX(>) test failed\n"); + } + } + } } #endif /* HAVE_LONG_LONG */ - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/coll/opmaxloc.c b/teshsuite/smpi/mpich3-test/coll/opmaxloc.c index 9ea01f60d4..9a187b8936 100644 --- a/teshsuite/smpi/mpich3-test/coll/opmaxloc.c +++ b/teshsuite/smpi/mpich3-test/coll/opmaxloc.c @@ -15,272 +15,315 @@ static char MTEST_Descrip[] = "Test MPI_MAXLOC operations on datatypes dupported */ /* - * This test looks at the handling of char and types that are not required + * This test looks at the handling of char and types that are not required * integers (e.g., long long). MPICH allows * these as well. A strict MPI test should not include this test. * * The rule on max loc is that if there is a tie in the value, the minimum * rank is used (see 4.9.3 in the MPI-1 standard) */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rank, size; - MPI_Comm comm; + MPI_Comm comm; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); /* 2 int */ { - struct twoint { int val; int loc; } cinbuf[3], coutbuf[3]; - - cinbuf[0].val = 1; - cinbuf[0].loc = rank; - cinbuf[1].val = 0; - cinbuf[1].loc = rank; - cinbuf[2].val = rank; - cinbuf[2].loc = rank; - - coutbuf[0].val = 0; - coutbuf[0].loc = -1; - coutbuf[1].val = 1; - coutbuf[1].loc = -1; - coutbuf[2].val = 1; - coutbuf[2].loc = -1; - MPI_Reduce( cinbuf, coutbuf, 3, MPI_2INT, MPI_MAXLOC, 0, comm ); - if (rank == 0) { - if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { - errs++; - fprintf( stderr, "2int MAXLOC(1) test failed\n" ); - } - if (coutbuf[1].val != 0) { - errs++; - fprintf( stderr, "2int MAXLOC(0) test failed, value = %d, should be zero\n", coutbuf[1].val ); - } - if (coutbuf[1].loc != 0) { - errs++; - fprintf( stderr, "2int MAXLOC(0) test failed, location of max = %d, should be zero\n", coutbuf[1].loc ); - } - if (coutbuf[2].val != size-1 || coutbuf[2].loc != size-1) { - errs++; - fprintf( stderr, "2int MAXLOC(>) test failed\n" ); - } - } + struct twoint { + int val; + int loc; + } cinbuf[3], coutbuf[3]; + + cinbuf[0].val = 1; + cinbuf[0].loc = rank; + cinbuf[1].val = 0; + cinbuf[1].loc = rank; + cinbuf[2].val = rank; + cinbuf[2].loc = rank; + + coutbuf[0].val = 0; + coutbuf[0].loc = -1; + coutbuf[1].val = 1; + coutbuf[1].loc = -1; + coutbuf[2].val = 1; + coutbuf[2].loc = -1; + MPI_Reduce(cinbuf, coutbuf, 3, MPI_2INT, MPI_MAXLOC, 0, comm); + if (rank == 0) { + if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { + errs++; + fprintf(stderr, "2int MAXLOC(1) test failed\n"); + } + if (coutbuf[1].val != 0) { + errs++; + fprintf(stderr, "2int MAXLOC(0) test failed, value = %d, should be zero\n", + coutbuf[1].val); + } + if (coutbuf[1].loc != 0) { + errs++; + fprintf(stderr, + "2int MAXLOC(0) test failed, location of max = %d, should be zero\n", + coutbuf[1].loc); + } + if (coutbuf[2].val != size - 1 || coutbuf[2].loc != size - 1) { + errs++; + fprintf(stderr, "2int MAXLOC(>) test failed\n"); + } + } } /* float int */ { - struct floatint { float val; int loc; } cinbuf[3], coutbuf[3]; - - cinbuf[0].val = 1; - cinbuf[0].loc = rank; - cinbuf[1].val = 0; - cinbuf[1].loc = rank; - cinbuf[2].val = (float)rank; - cinbuf[2].loc = rank; - - coutbuf[0].val = 0; - coutbuf[0].loc = -1; - coutbuf[1].val = 1; - coutbuf[1].loc = -1; - coutbuf[2].val = 1; - coutbuf[2].loc = -1; - MPI_Reduce( cinbuf, coutbuf, 3, MPI_FLOAT_INT, MPI_MAXLOC, 0, comm ); - if (rank == 0) { - if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { - errs++; - fprintf( stderr, "float-int MAXLOC(1) test failed\n" ); - } - if (coutbuf[1].val != 0) { - errs++; - fprintf( stderr, "float-int MAXLOC(0) test failed, value = %f, should be zero\n", coutbuf[1].val ); - } - if (coutbuf[1].loc != 0) { - errs++; - fprintf( stderr, "float-int MAXLOC(0) test failed, location of max = %d, should be zero\n", coutbuf[1].loc ); - } - if (coutbuf[2].val != size-1 || coutbuf[2].loc != size-1) { - errs++; - fprintf( stderr, "float-int MAXLOC(>) test failed\n" ); - } - } + struct floatint { + float val; + int loc; + } cinbuf[3], coutbuf[3]; + + cinbuf[0].val = 1; + cinbuf[0].loc = rank; + cinbuf[1].val = 0; + cinbuf[1].loc = rank; + cinbuf[2].val = (float) rank; + cinbuf[2].loc = rank; + + coutbuf[0].val = 0; + coutbuf[0].loc = -1; + coutbuf[1].val = 1; + coutbuf[1].loc = -1; + coutbuf[2].val = 1; + coutbuf[2].loc = -1; + MPI_Reduce(cinbuf, coutbuf, 3, MPI_FLOAT_INT, MPI_MAXLOC, 0, comm); + if (rank == 0) { + if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { + errs++; + fprintf(stderr, "float-int MAXLOC(1) test failed\n"); + } + if (coutbuf[1].val != 0) { + errs++; + fprintf(stderr, "float-int MAXLOC(0) test failed, value = %f, should be zero\n", + coutbuf[1].val); + } + if (coutbuf[1].loc != 0) { + errs++; + fprintf(stderr, + "float-int MAXLOC(0) test failed, location of max = %d, should be zero\n", + coutbuf[1].loc); + } + if (coutbuf[2].val != size - 1 || coutbuf[2].loc != size - 1) { + errs++; + fprintf(stderr, "float-int MAXLOC(>) test failed\n"); + } + } } - + /* long int */ { - struct longint { long val; int loc; } cinbuf[3], coutbuf[3]; - - cinbuf[0].val = 1; - cinbuf[0].loc = rank; - cinbuf[1].val = 0; - cinbuf[1].loc = rank; - cinbuf[2].val = rank; - cinbuf[2].loc = rank; - - coutbuf[0].val = 0; - coutbuf[0].loc = -1; - coutbuf[1].val = 1; - coutbuf[1].loc = -1; - coutbuf[2].val = 1; - coutbuf[2].loc = -1; - MPI_Reduce( cinbuf, coutbuf, 3, MPI_LONG_INT, MPI_MAXLOC, 0, comm ); - if (rank == 0) { - if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { - errs++; - fprintf( stderr, "long-int MAXLOC(1) test failed\n" ); - } - if (coutbuf[1].val != 0) { - errs++; - fprintf( stderr, "long-int MAXLOC(0) test failed, value = %ld, should be zero\n", coutbuf[1].val ); - } - if (coutbuf[1].loc != 0) { - errs++; - fprintf( stderr, "long-int MAXLOC(0) test failed, location of max = %d, should be zero\n", coutbuf[1].loc ); - } - if (coutbuf[2].val != size-1 || coutbuf[2].loc != size-1) { - errs++; - fprintf( stderr, "long-int MAXLOC(>) test failed\n" ); - } - } + struct longint { + long val; + int loc; + } cinbuf[3], coutbuf[3]; + + cinbuf[0].val = 1; + cinbuf[0].loc = rank; + cinbuf[1].val = 0; + cinbuf[1].loc = rank; + cinbuf[2].val = rank; + cinbuf[2].loc = rank; + + coutbuf[0].val = 0; + coutbuf[0].loc = -1; + coutbuf[1].val = 1; + coutbuf[1].loc = -1; + coutbuf[2].val = 1; + coutbuf[2].loc = -1; + MPI_Reduce(cinbuf, coutbuf, 3, MPI_LONG_INT, MPI_MAXLOC, 0, comm); + if (rank == 0) { + if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { + errs++; + fprintf(stderr, "long-int MAXLOC(1) test failed\n"); + } + if (coutbuf[1].val != 0) { + errs++; + fprintf(stderr, "long-int MAXLOC(0) test failed, value = %ld, should be zero\n", + coutbuf[1].val); + } + if (coutbuf[1].loc != 0) { + errs++; + fprintf(stderr, + "long-int MAXLOC(0) test failed, location of max = %d, should be zero\n", + coutbuf[1].loc); + } + if (coutbuf[2].val != size - 1 || coutbuf[2].loc != size - 1) { + errs++; + fprintf(stderr, "long-int MAXLOC(>) test failed\n"); + } + } } /* short int */ { - struct shortint { short val; int loc; } cinbuf[3], coutbuf[3]; - - cinbuf[0].val = 1; - cinbuf[0].loc = rank; - cinbuf[1].val = 0; - cinbuf[1].loc = rank; - cinbuf[2].val = rank; - cinbuf[2].loc = rank; - - coutbuf[0].val = 0; - coutbuf[0].loc = -1; - coutbuf[1].val = 1; - coutbuf[1].loc = -1; - coutbuf[2].val = 1; - coutbuf[2].loc = -1; - MPI_Reduce( cinbuf, coutbuf, 3, MPI_SHORT_INT, MPI_MAXLOC, 0, comm ); - if (rank == 0) { - if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { - errs++; - fprintf( stderr, "short-int MAXLOC(1) test failed\n" ); - } - if (coutbuf[1].val != 0) { - errs++; - fprintf( stderr, "short-int MAXLOC(0) test failed, value = %d, should be zero\n", coutbuf[1].val ); - } - if (coutbuf[1].loc != 0) { - errs++; - fprintf( stderr, "short-int MAXLOC(0) test failed, location of max = %d, should be zero\n", coutbuf[1].loc ); - } - if (coutbuf[2].val != size-1) { - errs++; - fprintf( stderr, "short-int MAXLOC(>) test failed, value = %d, should be %d\n", coutbuf[2].val, size-1 ); - } - if (coutbuf[2].loc != size -1) { - errs++; - fprintf( stderr, "short-int MAXLOC(>) test failed, location of max = %d, should be %d\n", coutbuf[2].loc, size-1 ); - } - } + struct shortint { + short val; + int loc; + } cinbuf[3], coutbuf[3]; + + cinbuf[0].val = 1; + cinbuf[0].loc = rank; + cinbuf[1].val = 0; + cinbuf[1].loc = rank; + cinbuf[2].val = rank; + cinbuf[2].loc = rank; + + coutbuf[0].val = 0; + coutbuf[0].loc = -1; + coutbuf[1].val = 1; + coutbuf[1].loc = -1; + coutbuf[2].val = 1; + coutbuf[2].loc = -1; + MPI_Reduce(cinbuf, coutbuf, 3, MPI_SHORT_INT, MPI_MAXLOC, 0, comm); + if (rank == 0) { + if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { + errs++; + fprintf(stderr, "short-int MAXLOC(1) test failed\n"); + } + if (coutbuf[1].val != 0) { + errs++; + fprintf(stderr, "short-int MAXLOC(0) test failed, value = %d, should be zero\n", + coutbuf[1].val); + } + if (coutbuf[1].loc != 0) { + errs++; + fprintf(stderr, + "short-int MAXLOC(0) test failed, location of max = %d, should be zero\n", + coutbuf[1].loc); + } + if (coutbuf[2].val != size - 1) { + errs++; + fprintf(stderr, "short-int MAXLOC(>) test failed, value = %d, should be %d\n", + coutbuf[2].val, size - 1); + } + if (coutbuf[2].loc != size - 1) { + errs++; + fprintf(stderr, + "short-int MAXLOC(>) test failed, location of max = %d, should be %d\n", + coutbuf[2].loc, size - 1); + } + } } - + /* double int */ { - struct doubleint { double val; int loc; } cinbuf[3], coutbuf[3]; - - cinbuf[0].val = 1; - cinbuf[0].loc = rank; - cinbuf[1].val = 0; - cinbuf[1].loc = rank; - cinbuf[2].val = rank; - cinbuf[2].loc = rank; - - coutbuf[0].val = 0; - coutbuf[0].loc = -1; - coutbuf[1].val = 1; - coutbuf[1].loc = -1; - coutbuf[2].val = 1; - coutbuf[2].loc = -1; - MPI_Reduce( cinbuf, coutbuf, 3, MPI_DOUBLE_INT, MPI_MAXLOC, 0, comm ); - if (rank == 0) { - if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { - errs++; - fprintf( stderr, "double-int MAXLOC(1) test failed\n" ); - } - if (coutbuf[1].val != 0) { - errs++; - fprintf( stderr, "double-int MAXLOC(0) test failed, value = %f, should be zero\n", coutbuf[1].val ); - } - if (coutbuf[1].loc != 0) { - errs++; - fprintf( stderr, "double-int MAXLOC(0) test failed, location of max = %d, should be zero\n", coutbuf[1].loc ); - } - if (coutbuf[2].val != size-1 || coutbuf[2].loc != size-1) { - errs++; - fprintf( stderr, "double-int MAXLOC(>) test failed\n" ); - } - } + struct doubleint { + double val; + int loc; + } cinbuf[3], coutbuf[3]; + + cinbuf[0].val = 1; + cinbuf[0].loc = rank; + cinbuf[1].val = 0; + cinbuf[1].loc = rank; + cinbuf[2].val = rank; + cinbuf[2].loc = rank; + + coutbuf[0].val = 0; + coutbuf[0].loc = -1; + coutbuf[1].val = 1; + coutbuf[1].loc = -1; + coutbuf[2].val = 1; + coutbuf[2].loc = -1; + MPI_Reduce(cinbuf, coutbuf, 3, MPI_DOUBLE_INT, MPI_MAXLOC, 0, comm); + if (rank == 0) { + if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { + errs++; + fprintf(stderr, "double-int MAXLOC(1) test failed\n"); + } + if (coutbuf[1].val != 0) { + errs++; + fprintf(stderr, "double-int MAXLOC(0) test failed, value = %lf, should be zero\n", + coutbuf[1].val); + } + if (coutbuf[1].loc != 0) { + errs++; + fprintf(stderr, + "double-int MAXLOC(0) test failed, location of max = %d, should be zero\n", + coutbuf[1].loc); + } + if (coutbuf[2].val != size - 1 || coutbuf[2].loc != size - 1) { + errs++; + fprintf(stderr, "double-int MAXLOC(>) test failed\n"); + } + } } - + #ifdef HAVE_LONG_DOUBLE /* long double int */ { - struct longdoubleint { long double val; int loc; } cinbuf[3], coutbuf[3]; + struct longdoubleint { + long double val; + int loc; + } cinbuf[3], coutbuf[3]; /* avoid valgrind warnings about padding bytes in the long double */ memset(&cinbuf[0], 0, sizeof(cinbuf)); memset(&coutbuf[0], 0, sizeof(coutbuf)); - cinbuf[0].val = 1; - cinbuf[0].loc = rank; - cinbuf[1].val = 0; - cinbuf[1].loc = rank; - cinbuf[2].val = rank; - cinbuf[2].loc = rank; - - coutbuf[0].val = 0; - coutbuf[0].loc = -1; - coutbuf[1].val = 1; - coutbuf[1].loc = -1; - coutbuf[2].val = 1; - coutbuf[2].loc = -1; - if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) { - MPI_Reduce( cinbuf, coutbuf, 3, MPI_LONG_DOUBLE_INT, MPI_MAXLOC, - 0, comm ); - if (rank == 0) { - if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { - errs++; - fprintf( stderr, "long double-int MAXLOC(1) test failed\n" ); - } - if (coutbuf[1].val != 0) { - errs++; - fprintf( stderr, "long double-int MAXLOC(0) test failed, value = %f, should be zero\n", (double)coutbuf[1].val ); - } - if (coutbuf[1].loc != 0) { - errs++; - fprintf( stderr, "long double-int MAXLOC(0) test failed, location of max = %d, should be zero\n", coutbuf[1].loc ); - } - if (coutbuf[2].val != size-1) { - errs++; - fprintf( stderr, "long double-int MAXLOC(>) test failed, value = %f, should be %d\n", (double)coutbuf[2].val, size-1 ); - } - if (coutbuf[2].loc != size-1) { - errs++; - fprintf( stderr, "long double-int MAXLOC(>) test failed, location of max = %d, should be %d\n", coutbuf[2].loc, size-1 ); - } - } - } + cinbuf[0].val = 1; + cinbuf[0].loc = rank; + cinbuf[1].val = 0; + cinbuf[1].loc = rank; + cinbuf[2].val = rank; + cinbuf[2].loc = rank; + + coutbuf[0].val = 0; + coutbuf[0].loc = -1; + coutbuf[1].val = 1; + coutbuf[1].loc = -1; + coutbuf[2].val = 1; + coutbuf[2].loc = -1; + if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) { + MPI_Reduce(cinbuf, coutbuf, 3, MPI_LONG_DOUBLE_INT, MPI_MAXLOC, 0, comm); + if (rank == 0) { + if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { + errs++; + fprintf(stderr, "long double-int MAXLOC(1) test failed\n"); + } + if (coutbuf[1].val != 0) { + errs++; + fprintf(stderr, + "long double-int MAXLOC(0) test failed, value = %lf, should be zero\n", + (double) coutbuf[1].val); + } + if (coutbuf[1].loc != 0) { + errs++; + fprintf(stderr, + "long double-int MAXLOC(0) test failed, location of max = %d, should be zero\n", + coutbuf[1].loc); + } + if (coutbuf[2].val != size - 1) { + errs++; + fprintf(stderr, + "long double-int MAXLOC(>) test failed, value = %lf, should be %d\n", + (double) coutbuf[2].val, size - 1); + } + if (coutbuf[2].loc != size - 1) { + errs++; + fprintf(stderr, + "long double-int MAXLOC(>) test failed, location of max = %d, should be %d\n", + coutbuf[2].loc, size - 1); + } + } + } } #endif - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/coll/opmin.c b/teshsuite/smpi/mpich3-test/coll/opmin.c index 59202da903..bc758a5883 100644 --- a/teshsuite/smpi/mpich3-test/coll/opmin.c +++ b/teshsuite/smpi/mpich3-test/coll/opmin.c @@ -14,29 +14,29 @@ static char MTEST_Descrip[] = "Test MPI_MIN operations on optional datatypes dup */ /* - * This test looks at the handling of char and types that are not required + * This test looks at the handling of char and types that are not required * integers (e.g., long long). MPICH allows * these as well. A strict MPI test should not include this test. */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rank, size; - MPI_Comm comm; + MPI_Comm comm; char cinbuf[3], coutbuf[3]; signed char scinbuf[3], scoutbuf[3]; unsigned char ucinbuf[3], ucoutbuf[3]; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); #ifndef USE_STRICT_MPI /* char */ - MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_CHAR\n"); cinbuf[0] = 1; cinbuf[1] = 0; cinbuf[2] = (rank & 0x7f); @@ -44,25 +44,25 @@ int main( int argc, char *argv[] ) coutbuf[0] = 0; coutbuf[1] = 1; coutbuf[2] = 1; - MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_MIN, 0, comm ); + MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_MIN, 0, comm); if (rank == 0) { - if (coutbuf[0] != 1) { - errs++; - fprintf( stderr, "char MIN(1) test failed\n" ); - } - if (coutbuf[1] != 0) { - errs++; - fprintf( stderr, "char MIN(0) test failed\n" ); - } - if (coutbuf[2] != 0) { - errs++; - fprintf( stderr, "char MIN(>) test failed\n" ); - } + if (coutbuf[0] != 1) { + errs++; + fprintf(stderr, "char MIN(1) test failed\n"); + } + if (coutbuf[1] != 0) { + errs++; + fprintf(stderr, "char MIN(0) test failed\n"); + } + if (coutbuf[2] != 0) { + errs++; + fprintf(stderr, "char MIN(>) test failed\n"); + } } #endif /* USE_STRICT_MPI */ /* signed char */ - MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n"); scinbuf[0] = 1; scinbuf[1] = 0; scinbuf[2] = (rank & 0x7f); @@ -70,24 +70,24 @@ int main( int argc, char *argv[] ) scoutbuf[0] = 0; scoutbuf[1] = 1; scoutbuf[2] = 1; - MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_MIN, 0, comm ); + MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_MIN, 0, comm); if (rank == 0) { - if (scoutbuf[0] != 1) { - errs++; - fprintf( stderr, "signed char MIN(1) test failed\n" ); - } - if (scoutbuf[1] != 0) { - errs++; - fprintf( stderr, "signed char MIN(0) test failed\n" ); - } - if (scoutbuf[2] != 0) { - errs++; - fprintf( stderr, "signed char MIN(>) test failed\n" ); - } + if (scoutbuf[0] != 1) { + errs++; + fprintf(stderr, "signed char MIN(1) test failed\n"); + } + if (scoutbuf[1] != 0) { + errs++; + fprintf(stderr, "signed char MIN(0) test failed\n"); + } + if (scoutbuf[2] != 0) { + errs++; + fprintf(stderr, "signed char MIN(>) test failed\n"); + } } /* unsigned char */ - MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n"); ucinbuf[0] = 1; ucinbuf[1] = 0; ucinbuf[2] = (rank & 0x7f); @@ -95,86 +95,88 @@ int main( int argc, char *argv[] ) ucoutbuf[0] = 0; ucoutbuf[1] = 1; ucoutbuf[2] = 1; - MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_MIN, 0, comm ); + MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_MIN, 0, comm); if (rank == 0) { - if (ucoutbuf[0] != 1) { - errs++; - fprintf( stderr, "unsigned char MIN(1) test failed\n" ); - } - if (ucoutbuf[1]) { - errs++; - fprintf( stderr, "unsigned char MIN(0) test failed\n" ); - } - if (ucoutbuf[2] != 0) { - errs++; - fprintf( stderr, "unsigned char MIN(>) test failed\n" ); - } + if (ucoutbuf[0] != 1) { + errs++; + fprintf(stderr, "unsigned char MIN(1) test failed\n"); + } + if (ucoutbuf[1]) { + errs++; + fprintf(stderr, "unsigned char MIN(0) test failed\n"); + } + if (ucoutbuf[2] != 0) { + errs++; + fprintf(stderr, "unsigned char MIN(>) test failed\n"); + } } #ifdef HAVE_LONG_DOUBLE - { long double ldinbuf[3], ldoutbuf[3]; - /* long double */ - ldinbuf[0] = 1; - ldinbuf[1] = 0; - ldinbuf[2] = rank; - - ldoutbuf[0] = 0; - ldoutbuf[1] = 1; - ldoutbuf[2] = 1; - if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) { - MTestPrintfMsg( 10, "Reduce of MPI_LONG_DOUBLE\n" ); - MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_MIN, 0, comm ); - if (rank == 0) { - if (ldoutbuf[0] != 1) { - errs++; - fprintf( stderr, "long double MIN(1) test failed\n" ); - } - if (ldoutbuf[1] != 0.0) { - errs++; - fprintf( stderr, "long double MIN(0) test failed\n" ); - } - if (ldoutbuf[2] != 0.0) { - errs++; - fprintf( stderr, "long double MIN(>) test failed\n" ); - } - } - } + { + long double ldinbuf[3], ldoutbuf[3]; + /* long double */ + MTEST_VG_MEM_INIT(ldinbuf, 3* sizeof(ldinbuf[0])); + ldinbuf[0] = 1; + ldinbuf[1] = 0; + ldinbuf[2] = rank; + + ldoutbuf[0] = 0; + ldoutbuf[1] = 1; + ldoutbuf[2] = 1; + if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) { + MTestPrintfMsg(10, "Reduce of MPI_LONG_DOUBLE\n"); + MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_MIN, 0, comm); + if (rank == 0) { + if (ldoutbuf[0] != 1) { + errs++; + fprintf(stderr, "long double MIN(1) test failed\n"); + } + if (ldoutbuf[1] != 0.0) { + errs++; + fprintf(stderr, "long double MIN(0) test failed\n"); + } + if (ldoutbuf[2] != 0.0) { + errs++; + fprintf(stderr, "long double MIN(>) test failed\n"); + } + } + } } #endif /* HAVE_LONG_DOUBLE */ #ifdef HAVE_LONG_LONG { - long long llinbuf[3], lloutbuf[3]; - /* long long */ - llinbuf[0] = 1; - llinbuf[1] = 0; - llinbuf[2] = rank; - - lloutbuf[0] = 0; - lloutbuf[1] = 1; - lloutbuf[2] = 1; - if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { - MTestPrintfMsg( 10, "Reduce of MPI_LONG_LONG\n" ); - MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_MIN, 0, comm ); - if (rank == 0) { - if (lloutbuf[0] != 1) { - errs++; - fprintf( stderr, "long long MIN(1) test failed\n" ); - } - if (lloutbuf[1] != 0) { - errs++; - fprintf( stderr, "long long MIN(0) test failed\n" ); - } - if (lloutbuf[2] != 0) { - errs++; - fprintf( stderr, "long long MIN(>) test failed\n" ); - } - } - } + long long llinbuf[3], lloutbuf[3]; + /* long long */ + llinbuf[0] = 1; + llinbuf[1] = 0; + llinbuf[2] = rank; + + lloutbuf[0] = 0; + lloutbuf[1] = 1; + lloutbuf[2] = 1; + if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { + MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n"); + MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_MIN, 0, comm); + if (rank == 0) { + if (lloutbuf[0] != 1) { + errs++; + fprintf(stderr, "long long MIN(1) test failed\n"); + } + if (lloutbuf[1] != 0) { + errs++; + fprintf(stderr, "long long MIN(0) test failed\n"); + } + if (lloutbuf[2] != 0) { + errs++; + fprintf(stderr, "long long MIN(>) test failed\n"); + } + } + } } #endif /* HAVE_LONG_LONG */ - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/coll/opminloc.c b/teshsuite/smpi/mpich3-test/coll/opminloc.c index 9eb84ee7c6..b7f047c1e5 100644 --- a/teshsuite/smpi/mpich3-test/coll/opminloc.c +++ b/teshsuite/smpi/mpich3-test/coll/opminloc.c @@ -14,236 +14,254 @@ static char MTEST_Descrip[] = "Test MPI_MINLOC operations on datatypes dupported */ /* - * This test looks at the handling of char and types that are not required + * This test looks at the handling of char and types that are not required * integers (e.g., long long). MPICH allows * these as well. A strict MPI test should not include this test. * * The rule on min loc is that if there is a tie in the value, the minimum * rank is used (see 4.9.3 in the MPI-1 standard) */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rank, size; - MPI_Comm comm; + MPI_Comm comm; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); /* 2 int */ { - struct twoint { int val; int loc; } cinbuf[3], coutbuf[3]; - - cinbuf[0].val = 1; - cinbuf[0].loc = rank; - cinbuf[1].val = 0; - cinbuf[1].loc = rank; - cinbuf[2].val = (rank & 0x7f); - cinbuf[2].loc = rank; - - coutbuf[0].val = 0; - coutbuf[0].loc = -1; - coutbuf[1].val = 1; - coutbuf[1].loc = -1; - coutbuf[2].val = 1; - coutbuf[2].loc = -1; - MPI_Reduce( cinbuf, coutbuf, 3, MPI_2INT, MPI_MINLOC, 0, comm ); - if (rank == 0) { - if (coutbuf[0].val != 1 && coutbuf[0].loc != -1) { - errs++; - fprintf( stderr, "2int MINLOC(1) test failed\n" ); - } - if (coutbuf[1].val != 0 && coutbuf[1].loc != -1) { - errs++; - fprintf( stderr, "2int MINLOC(0) test failed\n" ); - } - if (coutbuf[2].val != 0 && coutbuf[2].loc != 0) { - errs++; - fprintf( stderr, "2int MINLOC(>) test failed\n" ); - } - } + struct twoint { + int val; + int loc; + } cinbuf[3], coutbuf[3]; + + cinbuf[0].val = 1; + cinbuf[0].loc = rank; + cinbuf[1].val = 0; + cinbuf[1].loc = rank; + cinbuf[2].val = (rank & 0x7f); + cinbuf[2].loc = rank; + + coutbuf[0].val = 0; + coutbuf[0].loc = -1; + coutbuf[1].val = 1; + coutbuf[1].loc = -1; + coutbuf[2].val = 1; + coutbuf[2].loc = -1; + MPI_Reduce(cinbuf, coutbuf, 3, MPI_2INT, MPI_MINLOC, 0, comm); + if (rank == 0) { + if (coutbuf[0].val != 1 && coutbuf[0].loc != -1) { + errs++; + fprintf(stderr, "2int MINLOC(1) test failed\n"); + } + if (coutbuf[1].val != 0 && coutbuf[1].loc != -1) { + errs++; + fprintf(stderr, "2int MINLOC(0) test failed\n"); + } + if (coutbuf[2].val != 0 && coutbuf[2].loc != 0) { + errs++; + fprintf(stderr, "2int MINLOC(>) test failed\n"); + } + } } - + /* float int */ { - struct floatint { float val; int loc; } cinbuf[3], coutbuf[3]; - - cinbuf[0].val = 1; - cinbuf[0].loc = rank; - cinbuf[1].val = 0; - cinbuf[1].loc = rank; - cinbuf[2].val = (float)rank; - cinbuf[2].loc = rank; - - coutbuf[0].val = 0; - coutbuf[0].loc = -1; - coutbuf[1].val = 1; - coutbuf[1].loc = -1; - coutbuf[2].val = 1; - coutbuf[2].loc = -1; - MPI_Reduce( cinbuf, coutbuf, 3, MPI_FLOAT_INT, MPI_MINLOC, 0, comm ); - if (rank == 0) { - if (coutbuf[0].val != 1 && coutbuf[0].loc != -1) { - errs++; - fprintf( stderr, "float-int MINLOC(1) test failed\n" ); - } - if (coutbuf[1].val != 0 && coutbuf[1].loc != -1) { - errs++; - fprintf( stderr, "float-int MINLOC(0) test failed\n" ); - } - if (coutbuf[2].val != 0 && coutbuf[2].loc != 0) { - errs++; - fprintf( stderr, "float-int MINLOC(>) test failed\n" ); - } - } + struct floatint { + float val; + int loc; + } cinbuf[3], coutbuf[3]; + + cinbuf[0].val = 1; + cinbuf[0].loc = rank; + cinbuf[1].val = 0; + cinbuf[1].loc = rank; + cinbuf[2].val = (float) rank; + cinbuf[2].loc = rank; + + coutbuf[0].val = 0; + coutbuf[0].loc = -1; + coutbuf[1].val = 1; + coutbuf[1].loc = -1; + coutbuf[2].val = 1; + coutbuf[2].loc = -1; + MPI_Reduce(cinbuf, coutbuf, 3, MPI_FLOAT_INT, MPI_MINLOC, 0, comm); + if (rank == 0) { + if (coutbuf[0].val != 1 && coutbuf[0].loc != -1) { + errs++; + fprintf(stderr, "float-int MINLOC(1) test failed\n"); + } + if (coutbuf[1].val != 0 && coutbuf[1].loc != -1) { + errs++; + fprintf(stderr, "float-int MINLOC(0) test failed\n"); + } + if (coutbuf[2].val != 0 && coutbuf[2].loc != 0) { + errs++; + fprintf(stderr, "float-int MINLOC(>) test failed\n"); + } + } } - + /* long int */ { - struct longint { long val; int loc; } cinbuf[3], coutbuf[3]; - - cinbuf[0].val = 1; - cinbuf[0].loc = rank; - cinbuf[1].val = 0; - cinbuf[1].loc = rank; - cinbuf[2].val = rank; - cinbuf[2].loc = rank; - - coutbuf[0].val = 0; - coutbuf[0].loc = -1; - coutbuf[1].val = 1; - coutbuf[1].loc = -1; - coutbuf[2].val = 1; - coutbuf[2].loc = -1; - MPI_Reduce( cinbuf, coutbuf, 3, MPI_LONG_INT, MPI_MINLOC, 0, comm ); - if (rank == 0) { - if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { - errs++; - fprintf( stderr, "long-int MINLOC(1) test failed\n" ); - } - if (coutbuf[1].val != 0 || coutbuf[1].loc != 0) { - errs++; - fprintf( stderr, "long-int MINLOC(0) test failed\n" ); - } - if (coutbuf[2].val != 0 || coutbuf[2].loc != 0) { - errs++; - fprintf( stderr, "long-int MINLOC(>) test failed\n" ); - } - } + struct longint { + long val; + int loc; + } cinbuf[3], coutbuf[3]; + + cinbuf[0].val = 1; + cinbuf[0].loc = rank; + cinbuf[1].val = 0; + cinbuf[1].loc = rank; + cinbuf[2].val = rank; + cinbuf[2].loc = rank; + + coutbuf[0].val = 0; + coutbuf[0].loc = -1; + coutbuf[1].val = 1; + coutbuf[1].loc = -1; + coutbuf[2].val = 1; + coutbuf[2].loc = -1; + MPI_Reduce(cinbuf, coutbuf, 3, MPI_LONG_INT, MPI_MINLOC, 0, comm); + if (rank == 0) { + if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { + errs++; + fprintf(stderr, "long-int MINLOC(1) test failed\n"); + } + if (coutbuf[1].val != 0 || coutbuf[1].loc != 0) { + errs++; + fprintf(stderr, "long-int MINLOC(0) test failed\n"); + } + if (coutbuf[2].val != 0 || coutbuf[2].loc != 0) { + errs++; + fprintf(stderr, "long-int MINLOC(>) test failed\n"); + } + } } /* short int */ { - struct shortint { short val; int loc; } cinbuf[3], coutbuf[3]; - - cinbuf[0].val = 1; - cinbuf[0].loc = rank; - cinbuf[1].val = 0; - cinbuf[1].loc = rank; - cinbuf[2].val = rank; - cinbuf[2].loc = rank; - - coutbuf[0].val = 0; - coutbuf[0].loc = -1; - coutbuf[1].val = 1; - coutbuf[1].loc = -1; - coutbuf[2].val = 1; - coutbuf[2].loc = -1; - MPI_Reduce( cinbuf, coutbuf, 3, MPI_SHORT_INT, MPI_MINLOC, 0, comm ); - if (rank == 0) { - if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { - errs++; - fprintf( stderr, "short-int MINLOC(1) test failed\n" ); - } - if (coutbuf[1].val != 0 || coutbuf[1].loc != 0) { - errs++; - fprintf( stderr, "short-int MINLOC(0) test failed\n" ); - } - if (coutbuf[2].val != 0 || coutbuf[2].loc != 0) { - errs++; - fprintf( stderr, "short-int MINLOC(>) test failed\n" ); - } - } + struct shortint { + short val; + int loc; + } cinbuf[3], coutbuf[3]; + + cinbuf[0].val = 1; + cinbuf[0].loc = rank; + cinbuf[1].val = 0; + cinbuf[1].loc = rank; + cinbuf[2].val = rank; + cinbuf[2].loc = rank; + + coutbuf[0].val = 0; + coutbuf[0].loc = -1; + coutbuf[1].val = 1; + coutbuf[1].loc = -1; + coutbuf[2].val = 1; + coutbuf[2].loc = -1; + MPI_Reduce(cinbuf, coutbuf, 3, MPI_SHORT_INT, MPI_MINLOC, 0, comm); + if (rank == 0) { + if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { + errs++; + fprintf(stderr, "short-int MINLOC(1) test failed\n"); + } + if (coutbuf[1].val != 0 || coutbuf[1].loc != 0) { + errs++; + fprintf(stderr, "short-int MINLOC(0) test failed\n"); + } + if (coutbuf[2].val != 0 || coutbuf[2].loc != 0) { + errs++; + fprintf(stderr, "short-int MINLOC(>) test failed\n"); + } + } } - + /* double int */ { - struct doubleint { double val; int loc; } cinbuf[3], coutbuf[3]; - - cinbuf[0].val = 1; - cinbuf[0].loc = rank; - cinbuf[1].val = 0; - cinbuf[1].loc = rank; - cinbuf[2].val = rank; - cinbuf[2].loc = rank; - - coutbuf[0].val = 0; - coutbuf[0].loc = -1; - coutbuf[1].val = 1; - coutbuf[1].loc = -1; - coutbuf[2].val = 1; - coutbuf[2].loc = -1; - MPI_Reduce( cinbuf, coutbuf, 3, MPI_DOUBLE_INT, MPI_MINLOC, 0, comm ); - if (rank == 0) { - if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { - errs++; - fprintf( stderr, "double-int MINLOC(1) test failed\n" ); - } - if (coutbuf[1].val != 0 || coutbuf[1].loc != 0) { - errs++; - fprintf( stderr, "double-int MINLOC(0) test failed\n" ); - } - if (coutbuf[2].val != 0 || coutbuf[2].loc != 0) { - errs++; - fprintf( stderr, "double-int MINLOC(>) test failed\n" ); - } - } + struct doubleint { + double val; + int loc; + } cinbuf[3], coutbuf[3]; + + cinbuf[0].val = 1; + cinbuf[0].loc = rank; + cinbuf[1].val = 0; + cinbuf[1].loc = rank; + cinbuf[2].val = rank; + cinbuf[2].loc = rank; + + coutbuf[0].val = 0; + coutbuf[0].loc = -1; + coutbuf[1].val = 1; + coutbuf[1].loc = -1; + coutbuf[2].val = 1; + coutbuf[2].loc = -1; + MPI_Reduce(cinbuf, coutbuf, 3, MPI_DOUBLE_INT, MPI_MINLOC, 0, comm); + if (rank == 0) { + if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { + errs++; + fprintf(stderr, "double-int MINLOC(1) test failed\n"); + } + if (coutbuf[1].val != 0 || coutbuf[1].loc != 0) { + errs++; + fprintf(stderr, "double-int MINLOC(0) test failed\n"); + } + if (coutbuf[2].val != 0 || coutbuf[2].loc != 0) { + errs++; + fprintf(stderr, "double-int MINLOC(>) test failed\n"); + } + } } - + #ifdef HAVE_LONG_DOUBLE /* long double int */ { - struct longdoubleint { long double val; int loc; } cinbuf[3], coutbuf[3]; - - cinbuf[0].val = 1; - cinbuf[0].loc = rank; - cinbuf[1].val = 0; - cinbuf[1].loc = rank; - cinbuf[2].val = rank; - cinbuf[2].loc = rank; - - coutbuf[0].val = 0; - coutbuf[0].loc = -1; - coutbuf[1].val = 1; - coutbuf[1].loc = -1; - coutbuf[2].val = 1; - coutbuf[2].loc = -1; - if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) { - MPI_Reduce( cinbuf, coutbuf, 3, MPI_LONG_DOUBLE_INT, MPI_MINLOC, - 0, comm ); - if (rank == 0) { - if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { - errs++; - fprintf( stderr, "long double-int MINLOC(1) test failed\n" ); - } - if (coutbuf[1].val != 0 || coutbuf[1].loc != 0) { - errs++; - fprintf( stderr, "long double-int MINLOC(0) test failed\n" ); - } - if (coutbuf[2].val != 0 || coutbuf[2].loc != 0) { - errs++; - fprintf( stderr, "long double-int MINLOC(>) test failed\n" ); - } - } - } + struct longdoubleint { + long double val; + int loc; + } cinbuf[3], coutbuf[3]; + MTEST_VG_MEM_INIT(cinbuf, 3* sizeof(cinbuf[0])); + + cinbuf[0].val = 1; + cinbuf[0].loc = rank; + cinbuf[1].val = 0; + cinbuf[1].loc = rank; + cinbuf[2].val = rank; + cinbuf[2].loc = rank; + + coutbuf[0].val = 0; + coutbuf[0].loc = -1; + coutbuf[1].val = 1; + coutbuf[1].loc = -1; + coutbuf[2].val = 1; + coutbuf[2].loc = -1; + if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) { + MPI_Reduce(cinbuf, coutbuf, 3, MPI_LONG_DOUBLE_INT, MPI_MINLOC, 0, comm); + if (rank == 0) { + if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) { + errs++; + fprintf(stderr, "long double-int MINLOC(1) test failed\n"); + } + if (coutbuf[1].val != 0 || coutbuf[1].loc != 0) { + errs++; + fprintf(stderr, "long double-int MINLOC(0) test failed\n"); + } + if (coutbuf[2].val != 0 || coutbuf[2].loc != 0) { + errs++; + fprintf(stderr, "long double-int MINLOC(>) test failed\n"); + } + } + } } #endif - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/coll/opprod.c b/teshsuite/smpi/mpich3-test/coll/opprod.c index e96aae21b2..9c8001e6f4 100644 --- a/teshsuite/smpi/mpich3-test/coll/opprod.c +++ b/teshsuite/smpi/mpich3-test/coll/opprod.c @@ -13,43 +13,49 @@ static char MTEST_Descrip[] = "Test MPI_PROD operations on optional datatypes dupported by MPICH"; */ -typedef struct { double r, i; } d_complex; +typedef struct { + double r, i; +} d_complex; #ifdef HAVE_LONG_DOUBLE -typedef struct { long double r, i; } ld_complex; +typedef struct { + long double r, i; +} ld_complex; #endif /* - * This test looks at the handling of logical and for types that are not + * This test looks at the handling of logical and for types that are not * integers or are not required integers (e.g., long long). MPICH allows * these as well. A strict MPI test should not include this test. */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rank, size, maxsize, result[6] = { 1, 1, 2, 6, 24, 120 }; - MPI_Comm comm; + MPI_Comm comm; char cinbuf[3], coutbuf[3]; signed char scinbuf[3], scoutbuf[3]; unsigned char ucinbuf[3], ucoutbuf[3]; d_complex dinbuf[3], doutbuf[3]; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); - if (size > 5) maxsize = 5; - else maxsize = size; + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); + if (size > 5) + maxsize = 5; + else + maxsize = size; - /* General forumula: If we multiple the values from 1 to n, the - product is n!. This grows very fast, so we'll only use the first - five (1! = 1, 2! = 2, 3! = 6, 4! = 24, 5! = 120), with n! - stored in the array result[n] */ + /* General forumula: If we multiple the values from 1 to n, the + * product is n!. This grows very fast, so we'll only use the first + * five (1! = 1, 2! = 2, 3! = 6, 4! = 24, 5! = 120), with n! + * stored in the array result[n] */ #ifndef USE_STRICT_MPI /* char */ - MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_CHAR\n"); cinbuf[0] = (rank < maxsize && rank > 0) ? rank : 1; cinbuf[1] = 0; cinbuf[2] = (rank > 1); @@ -57,26 +63,26 @@ int main( int argc, char *argv[] ) coutbuf[0] = 0; coutbuf[1] = 1; coutbuf[2] = 1; - MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_PROD, 0, comm ); + MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_PROD, 0, comm); if (rank == 0) { - if (coutbuf[0] != (char)result[maxsize-1]) { - errs++; - fprintf( stderr, "char PROD(rank) test failed (%d!=%d)\n", - (int)coutbuf[0], (int)result[maxsize]); - } - if (coutbuf[1]) { - errs++; - fprintf( stderr, "char PROD(0) test failed\n" ); - } - if (size > 1 && coutbuf[2]) { - errs++; - fprintf( stderr, "char PROD(>) test failed\n" ); - } + if (coutbuf[0] != (char) result[maxsize - 1]) { + errs++; + fprintf(stderr, "char PROD(rank) test failed (%d!=%d)\n", + (int) coutbuf[0], (int) result[maxsize]); + } + if (coutbuf[1]) { + errs++; + fprintf(stderr, "char PROD(0) test failed\n"); + } + if (size > 1 && coutbuf[2]) { + errs++; + fprintf(stderr, "char PROD(>) test failed\n"); + } } #endif /* USE_STRICT_MPI */ /* signed char */ - MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n"); scinbuf[0] = (rank < maxsize && rank > 0) ? rank : 1; scinbuf[1] = 0; scinbuf[2] = (rank > 1); @@ -84,25 +90,25 @@ int main( int argc, char *argv[] ) scoutbuf[0] = 0; scoutbuf[1] = 1; scoutbuf[2] = 1; - MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_PROD, 0, comm ); + MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_PROD, 0, comm); if (rank == 0) { - if (scoutbuf[0] != (signed char)result[maxsize-1]) { - errs++; - fprintf( stderr, "signed char PROD(rank) test failed (%d!=%d)\n", - (int)scoutbuf[0], (int)result[maxsize]); - } - if (scoutbuf[1]) { - errs++; - fprintf( stderr, "signed char PROD(0) test failed\n" ); - } - if (size > 1 && scoutbuf[2]) { - errs++; - fprintf( stderr, "signed char PROD(>) test failed\n" ); - } + if (scoutbuf[0] != (signed char) result[maxsize - 1]) { + errs++; + fprintf(stderr, "signed char PROD(rank) test failed (%d!=%d)\n", + (int) scoutbuf[0], (int) result[maxsize]); + } + if (scoutbuf[1]) { + errs++; + fprintf(stderr, "signed char PROD(0) test failed\n"); + } + if (size > 1 && scoutbuf[2]) { + errs++; + fprintf(stderr, "signed char PROD(>) test failed\n"); + } } /* unsigned char */ - MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n"); ucinbuf[0] = (rank < maxsize && rank > 0) ? rank : 1; ucinbuf[1] = 0; ucinbuf[2] = (rank > 0); @@ -110,180 +116,209 @@ int main( int argc, char *argv[] ) ucoutbuf[0] = 0; ucoutbuf[1] = 1; ucoutbuf[2] = 1; - MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_PROD, 0, comm ); + MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_PROD, 0, comm); if (rank == 0) { - if (ucoutbuf[0] != (unsigned char)result[maxsize-1]) { - errs++; - fprintf( stderr, "unsigned char PROD(rank) test failed\n" ); - } - if (ucoutbuf[1]) { - errs++; - fprintf( stderr, "unsigned char PROD(0) test failed\n" ); - } - if (size > 1 && ucoutbuf[2]) { - errs++; - fprintf( stderr, "unsigned char PROD(>) test failed\n" ); - } + if (ucoutbuf[0] != (unsigned char) result[maxsize - 1]) { + errs++; + fprintf(stderr, "unsigned char PROD(rank) test failed\n"); + } + if (ucoutbuf[1]) { + errs++; + fprintf(stderr, "unsigned char PROD(0) test failed\n"); + } + if (size > 1 && ucoutbuf[2]) { + errs++; + fprintf(stderr, "unsigned char PROD(>) test failed\n"); + } } #ifndef USE_STRICT_MPI /* For some reason, complex is not allowed for sum and prod */ if (MPI_DOUBLE_COMPLEX != MPI_DATATYPE_NULL) { - int dc; -#ifdef HAVE_LONG_DOUBLE - ld_complex ldinbuf[3], ldoutbuf[3]; -#endif - /* Must determine which C type matches this Fortran type */ - MPI_Type_size( MPI_DOUBLE_COMPLEX, &dc ); - if (dc == sizeof(d_complex)) { - /* double complex; may be null if we do not have Fortran support */ - dinbuf[0].r = (rank < maxsize && rank > 0) ? rank : 1; - dinbuf[1].r = 0; - dinbuf[2].r = (rank > 0); - dinbuf[0].i = 0; - dinbuf[1].i = 1; - dinbuf[2].i = -(rank > 0); - - doutbuf[0].r = 0; - doutbuf[1].r = 1; - doutbuf[2].r = 1; - doutbuf[0].i = 0; - doutbuf[1].i = 1; - doutbuf[2].i = 1; - MPI_Reduce( dinbuf, doutbuf, 3, MPI_DOUBLE_COMPLEX, MPI_PROD, 0, comm ); - if (rank == 0) { - double imag, real; - if (doutbuf[0].r != (double)result[maxsize-1] || doutbuf[0].i != 0) { - errs++; - fprintf( stderr, "double complex PROD(rank) test failed\n" ); - } - /* Multiplying the imaginary part depends on size mod 4 */ - imag = 1.0; real = 0.0; /* Make compiler happy */ - switch (size % 4) { - case 1: imag = 1.0; real = 0.0; break; - case 2: imag = 0.0; real = -1.0; break; - case 3: imag =-1.0; real = 0.0; break; - case 0: imag = 0.0; real = 1.0; break; - } - if (doutbuf[1].r != real || doutbuf[1].i != imag) { - errs++; - fprintf( stderr, "double complex PROD(i) test failed (%f,%f)!=(%f,%f)\n", - doutbuf[1].r,doutbuf[1].i,real,imag); - } - if (doutbuf[2].r != 0 || doutbuf[2].i != 0) { - errs++; - fprintf( stderr, "double complex PROD(>) test failed\n" ); - } - } - } + int dc; #ifdef HAVE_LONG_DOUBLE - else if (dc == sizeof(ld_complex)) { - /* double complex; may be null if we do not have Fortran support */ - ldinbuf[0].r = (rank < maxsize && rank > 0) ? rank : 1; - ldinbuf[1].r = 0; - ldinbuf[2].r = (rank > 0); - ldinbuf[0].i = 0; - ldinbuf[1].i = 1; - ldinbuf[2].i = -(rank > 0); - - ldoutbuf[0].r = 0; - ldoutbuf[1].r = 1; - ldoutbuf[2].r = 1; - ldoutbuf[0].i = 0; - ldoutbuf[1].i = 1; - ldoutbuf[2].i = 1; - MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_DOUBLE_COMPLEX, MPI_PROD, 0, comm ); - if (rank == 0) { - long double imag, real; - if (ldoutbuf[0].r != (double)result[maxsize-1] || ldoutbuf[0].i != 0) { - errs++; - fprintf( stderr, "double complex PROD(rank) test failed\n" ); - } - /* Multiplying the imaginary part depends on size mod 4 */ - imag = 1.0; real = 0.0; /* Make compiler happy */ - switch (size % 4) { - case 1: imag = 1.0; real = 0.0; break; - case 2: imag = 0.0; real = -1.0; break; - case 3: imag =-1.0; real = 0.0; break; - case 0: imag = 0.0; real = 1.0; break; - } - if (ldoutbuf[1].r != real || ldoutbuf[1].i != imag) { - errs++; - fprintf( stderr, "double complex PROD(i) test failed (%Lf,%Lf)!=(%Lf,%Lf)\n", - ldoutbuf[1].r,ldoutbuf[1].i,real,imag); - } - if (ldoutbuf[2].r != 0 || ldoutbuf[2].i != 0) { - errs++; - fprintf( stderr, "double complex PROD(>) test failed\n" ); - } - } - } + ld_complex ldinbuf[3], ldoutbuf[3]; + MTEST_VG_MEM_INIT(ldinbuf, 3* sizeof(ldinbuf[0])); +#endif + /* Must determine which C type matches this Fortran type */ + MPI_Type_size(MPI_DOUBLE_COMPLEX, &dc); + if (dc == sizeof(d_complex)) { + /* double complex; may be null if we do not have Fortran support */ + dinbuf[0].r = (rank < maxsize && rank > 0) ? rank : 1; + dinbuf[1].r = 0; + dinbuf[2].r = (rank > 0); + dinbuf[0].i = 0; + dinbuf[1].i = 1; + dinbuf[2].i = -(rank > 0); + + doutbuf[0].r = 0; + doutbuf[1].r = 1; + doutbuf[2].r = 1; + doutbuf[0].i = 0; + doutbuf[1].i = 1; + doutbuf[2].i = 1; + MPI_Reduce(dinbuf, doutbuf, 3, MPI_DOUBLE_COMPLEX, MPI_PROD, 0, comm); + if (rank == 0) { + double imag, real; + if (doutbuf[0].r != (double) result[maxsize - 1] || doutbuf[0].i != 0) { + errs++; + fprintf(stderr, "double complex PROD(rank) test failed\n"); + } + /* Multiplying the imaginary part depends on size mod 4 */ + imag = 1.0; + real = 0.0; /* Make compiler happy */ + switch (size % 4) { + case 1: + imag = 1.0; + real = 0.0; + break; + case 2: + imag = 0.0; + real = -1.0; + break; + case 3: + imag = -1.0; + real = 0.0; + break; + case 0: + imag = 0.0; + real = 1.0; + break; + } + if (doutbuf[1].r != real || doutbuf[1].i != imag) { + errs++; + fprintf(stderr, "double complex PROD(i) test failed (%f,%f)!=(%f,%f)\n", + doutbuf[1].r, doutbuf[1].i, real, imag); + } + if (doutbuf[2].r != 0 || doutbuf[2].i != 0) { + errs++; + fprintf(stderr, "double complex PROD(>) test failed\n"); + } + } + } +#ifdef HAVE_LONG_DOUBLE + else if (dc == sizeof(ld_complex)) { + /* double complex; may be null if we do not have Fortran support */ + ldinbuf[0].r = (rank < maxsize && rank > 0) ? rank : 1; + ldinbuf[1].r = 0; + ldinbuf[2].r = (rank > 0); + ldinbuf[0].i = 0; + ldinbuf[1].i = 1; + ldinbuf[2].i = -(rank > 0); + + ldoutbuf[0].r = 0; + ldoutbuf[1].r = 1; + ldoutbuf[2].r = 1; + ldoutbuf[0].i = 0; + ldoutbuf[1].i = 1; + ldoutbuf[2].i = 1; + MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_DOUBLE_COMPLEX, MPI_PROD, 0, comm); + if (rank == 0) { + long double imag, real; + if (ldoutbuf[0].r != (double) result[maxsize - 1] || ldoutbuf[0].i != 0) { + errs++; + fprintf(stderr, "double complex PROD(rank) test failed\n"); + } + /* Multiplying the imaginary part depends on size mod 4 */ + imag = 1.0; + real = 0.0; /* Make compiler happy */ + switch (size % 4) { + case 1: + imag = 1.0; + real = 0.0; + break; + case 2: + imag = 0.0; + real = -1.0; + break; + case 3: + imag = -1.0; + real = 0.0; + break; + case 0: + imag = 0.0; + real = 1.0; + break; + } + if (ldoutbuf[1].r != real || ldoutbuf[1].i != imag) { + errs++; + fprintf(stderr, "double complex PROD(i) test failed (%Lf,%Lf)!=(%Lf,%Lf)\n", + ldoutbuf[1].r, ldoutbuf[1].i, real, imag); + } + if (ldoutbuf[2].r != 0 || ldoutbuf[2].i != 0) { + errs++; + fprintf(stderr, "double complex PROD(>) test failed\n"); + } + } + } #endif /* HAVE_LONG_DOUBLE */ } #endif /* USE_STRICT_MPI */ #ifdef HAVE_LONG_DOUBLE - { long double ldinbuf[3], ldoutbuf[3]; - /* long double */ - ldinbuf[0] = (rank < maxsize && rank > 0) ? rank : 1; - ldinbuf[1] = 0; - ldinbuf[2] = (rank > 0); + { + long double ldinbuf[3], ldoutbuf[3]; + MTEST_VG_MEM_INIT(ldinbuf, 3 * sizeof(ldinbuf[0])); + /* long double */ + ldinbuf[0] = (rank < maxsize && rank > 0) ? rank : 1; + ldinbuf[1] = 0; + ldinbuf[2] = (rank > 0); - ldoutbuf[0] = 0; - ldoutbuf[1] = 1; - ldoutbuf[2] = 1; - if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) { - MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_PROD, 0, comm ); - if (rank == 0) { - if (ldoutbuf[0] != (long double)result[maxsize-1]) { - errs++; - fprintf( stderr, "long double PROD(rank) test failed\n" ); - } - if (ldoutbuf[1]) { - errs++; - fprintf( stderr, "long double PROD(0) test failed\n" ); - } - if (size > 1 && ldoutbuf[2] != 0) { - errs++; - fprintf( stderr, "long double PROD(>) test failed\n" ); - } - } - } + ldoutbuf[0] = 0; + ldoutbuf[1] = 1; + ldoutbuf[2] = 1; + if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) { + MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_PROD, 0, comm); + if (rank == 0) { + if (ldoutbuf[0] != (long double) result[maxsize - 1]) { + errs++; + fprintf(stderr, "long double PROD(rank) test failed\n"); + } + if (ldoutbuf[1]) { + errs++; + fprintf(stderr, "long double PROD(0) test failed\n"); + } + if (size > 1 && ldoutbuf[2] != 0) { + errs++; + fprintf(stderr, "long double PROD(>) test failed\n"); + } + } + } } #endif /* HAVE_LONG_DOUBLE */ #ifdef HAVE_LONG_LONG { - long long llinbuf[3], lloutbuf[3]; - /* long long */ - llinbuf[0] = (rank < maxsize && rank > 0) ? rank : 1; - llinbuf[1] = 0; - llinbuf[2] = (rank > 0); + long long llinbuf[3], lloutbuf[3]; + /* long long */ + llinbuf[0] = (rank < maxsize && rank > 0) ? rank : 1; + llinbuf[1] = 0; + llinbuf[2] = (rank > 0); - lloutbuf[0] = 0; - lloutbuf[1] = 1; - lloutbuf[2] = 1; - if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { - MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_PROD, 0, comm ); - if (rank == 0) { - if (lloutbuf[0] != (long long)result[maxsize-1]) { - errs++; - fprintf( stderr, "long long PROD(rank) test failed\n" ); - } - if (lloutbuf[1]) { - errs++; - fprintf( stderr, "long long PROD(0) test failed\n" ); - } - if (size > 1 && lloutbuf[2]) { - errs++; - fprintf( stderr, "long long PROD(>) test failed\n" ); - } - } - } + lloutbuf[0] = 0; + lloutbuf[1] = 1; + lloutbuf[2] = 1; + if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { + MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_PROD, 0, comm); + if (rank == 0) { + if (lloutbuf[0] != (long long) result[maxsize - 1]) { + errs++; + fprintf(stderr, "long long PROD(rank) test failed\n"); + } + if (lloutbuf[1]) { + errs++; + fprintf(stderr, "long long PROD(0) test failed\n"); + } + if (size > 1 && lloutbuf[2]) { + errs++; + fprintf(stderr, "long long PROD(>) test failed\n"); + } + } + } } #endif /* HAVE_LONG_LONG */ - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/coll/opsum.c b/teshsuite/smpi/mpich3-test/coll/opsum.c index c9bd5f8b2f..cad22f36a6 100644 --- a/teshsuite/smpi/mpich3-test/coll/opsum.c +++ b/teshsuite/smpi/mpich3-test/coll/opsum.c @@ -13,36 +13,40 @@ static char MTEST_Descrip[] = "Test MPI_SUM operations on optional datatypes dupported by MPICH"; */ -typedef struct { double r, i; } d_complex; +typedef struct { + double r, i; +} d_complex; #ifdef HAVE_LONG_DOUBLE -typedef struct { long double r, i; } ld_complex; +typedef struct { + long double r, i; +} ld_complex; #endif /* - * This test looks at the handling of logical and for types that are not + * This test looks at the handling of logical and for types that are not * integers or are not required integers (e.g., long long). MPICH allows * these as well. A strict MPI test should not include this test. */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rank, size; - MPI_Comm comm; + MPI_Comm comm; char cinbuf[3], coutbuf[3]; signed char scinbuf[3], scoutbuf[3]; unsigned char ucinbuf[3], ucoutbuf[3]; d_complex dinbuf[3], doutbuf[3]; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); #ifndef USE_STRICT_MPI /* char */ - MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_CHAR\n"); cinbuf[0] = 1; cinbuf[1] = 0; cinbuf[2] = (rank > 0); @@ -50,25 +54,25 @@ int main( int argc, char *argv[] ) coutbuf[0] = 0; coutbuf[1] = 1; coutbuf[2] = 1; - MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_SUM, 0, comm ); + MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_SUM, 0, comm); if (rank == 0) { - if (size < 128 && coutbuf[0] != size) { - errs++; - fprintf( stderr, "char SUM(1) test failed\n" ); - } - if (size < 128 && coutbuf[1] != 0) { - errs++; - fprintf( stderr, "char SUM(0) test failed\n" ); - } - if (size < 128 && coutbuf[2] != size - 1) { - errs++; - fprintf( stderr, "char SUM(>) test failed\n" ); - } + if (size < 128 && coutbuf[0] != size) { + errs++; + fprintf(stderr, "char SUM(1) test failed\n"); + } + if (size < 128 && coutbuf[1] != 0) { + errs++; + fprintf(stderr, "char SUM(0) test failed\n"); + } + if (size < 128 && coutbuf[2] != size - 1) { + errs++; + fprintf(stderr, "char SUM(>) test failed\n"); + } } #endif /* USE_MPI_STRICT */ /* signed char */ - MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n"); scinbuf[0] = 1; scinbuf[1] = 0; scinbuf[2] = (rank > 0); @@ -76,24 +80,24 @@ int main( int argc, char *argv[] ) scoutbuf[0] = 0; scoutbuf[1] = 1; scoutbuf[2] = 1; - MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_SUM, 0, comm ); + MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_SUM, 0, comm); if (rank == 0) { - if (size < 128 && scoutbuf[0] != size) { - errs++; - fprintf( stderr, "signed char SUM(1) test failed\n" ); - } - if (size < 128 && scoutbuf[1] != 0) { - errs++; - fprintf( stderr, "signed char SUM(0) test failed\n" ); - } - if (size < 128 && scoutbuf[2] != size - 1) { - errs++; - fprintf( stderr, "signed char SUM(>) test failed\n" ); - } + if (size < 128 && scoutbuf[0] != size) { + errs++; + fprintf(stderr, "signed char SUM(1) test failed\n"); + } + if (size < 128 && scoutbuf[1] != 0) { + errs++; + fprintf(stderr, "signed char SUM(0) test failed\n"); + } + if (size < 128 && scoutbuf[2] != size - 1) { + errs++; + fprintf(stderr, "signed char SUM(>) test failed\n"); + } } /* unsigned char */ - MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" ); + MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n"); ucinbuf[0] = 1; ucinbuf[1] = 0; ucinbuf[2] = (rank > 0); @@ -101,166 +105,168 @@ int main( int argc, char *argv[] ) ucoutbuf[0] = 0; ucoutbuf[1] = 1; ucoutbuf[2] = 1; - MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_SUM, 0, comm ); + MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_SUM, 0, comm); if (rank == 0) { - if (size < 128 && ucoutbuf[0] != size) { - errs++; - fprintf( stderr, "unsigned char SUM(1) test failed\n" ); - } - if (size < 128 && ucoutbuf[1]) { - errs++; - fprintf( stderr, "unsigned char SUM(0) test failed\n" ); - } - if (size < 128 && ucoutbuf[2] != size - 1) { - errs++; - fprintf( stderr, "unsigned char SUM(>) test failed\n" ); - } + if (size < 128 && ucoutbuf[0] != size) { + errs++; + fprintf(stderr, "unsigned char SUM(1) test failed\n"); + } + if (size < 128 && ucoutbuf[1]) { + errs++; + fprintf(stderr, "unsigned char SUM(0) test failed\n"); + } + if (size < 128 && ucoutbuf[2] != size - 1) { + errs++; + fprintf(stderr, "unsigned char SUM(>) test failed\n"); + } } #ifndef USE_STRICT_MPI /* For some reason, complex is not allowed for sum and prod */ if (MPI_DOUBLE_COMPLEX != MPI_DATATYPE_NULL) { - int dc; -#ifdef HAVE_LONG_DOUBLE - ld_complex ldinbuf[3], ldoutbuf[3]; -#endif - /* Must determine which C type matches this Fortran type */ - MPI_Type_size( MPI_DOUBLE_COMPLEX, &dc ); - if (dc == sizeof(d_complex)) { - MTestPrintfMsg( 10, "Reduce of MPI_DOUBLE_COMPLEX\n" ); - /* double complex; may be null if we do not have Fortran support */ - dinbuf[0].r = 1; - dinbuf[1].r = 0; - dinbuf[2].r = (rank > 0); - dinbuf[0].i = -1; - dinbuf[1].i = 0; - dinbuf[2].i = -(rank > 0); - - doutbuf[0].r = 0; - doutbuf[1].r = 1; - doutbuf[2].r = 1; - doutbuf[0].i = 0; - doutbuf[1].i = 1; - doutbuf[2].i = 1; - MPI_Reduce( dinbuf, doutbuf, 3, MPI_DOUBLE_COMPLEX, MPI_SUM, 0, comm ); - if (rank == 0) { - if (doutbuf[0].r != size || doutbuf[0].i != -size) { - errs++; - fprintf( stderr, "double complex SUM(1) test failed\n" ); - } - if (doutbuf[1].r != 0 || doutbuf[1].i != 0) { - errs++; - fprintf( stderr, "double complex SUM(0) test failed\n" ); - } - if (doutbuf[2].r != size - 1 || doutbuf[2].i != 1 - size) { - errs++; - fprintf( stderr, "double complex SUM(>) test failed\n" ); - } - } - } + int dc; #ifdef HAVE_LONG_DOUBLE - else if (dc == sizeof(ld_complex)) { - MTestPrintfMsg( 10, "Reduce of MPI_DOUBLE_COMPLEX\n" ); - /* double complex; may be null if we do not have Fortran support */ - ldinbuf[0].r = 1; - ldinbuf[1].r = 0; - ldinbuf[2].r = (rank > 0); - ldinbuf[0].i = -1; - ldinbuf[1].i = 0; - ldinbuf[2].i = -(rank > 0); - - ldoutbuf[0].r = 0; - ldoutbuf[1].r = 1; - ldoutbuf[2].r = 1; - ldoutbuf[0].i = 0; - ldoutbuf[1].i = 1; - ldoutbuf[2].i = 1; - MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_DOUBLE_COMPLEX, - MPI_SUM, 0, comm ); - if (rank == 0) { - if (ldoutbuf[0].r != size || ldoutbuf[0].i != -size) { - errs++; - fprintf( stderr, "double complex SUM(1) test failed\n" ); - } - if (ldoutbuf[1].r != 0 || ldoutbuf[1].i != 0) { - errs++; - fprintf( stderr, "double complex SUM(0) test failed\n" ); - } - if (ldoutbuf[2].r != size - 1 || ldoutbuf[2].i != 1 - size) { - errs++; - fprintf( stderr, "double complex SUM(>) test failed\n" ); - } - } - } + ld_complex ldinbuf[3], ldoutbuf[3]; + MTEST_VG_MEM_INIT(ldinbuf, 3 * sizeof(ldinbuf[0])); #endif - /* Implicitly ignore if there is no matching C type */ + /* Must determine which C type matches this Fortran type */ + MPI_Type_size(MPI_DOUBLE_COMPLEX, &dc); + if (dc == sizeof(d_complex)) { + MTestPrintfMsg(10, "Reduce of MPI_DOUBLE_COMPLEX\n"); + /* double complex; may be null if we do not have Fortran support */ + dinbuf[0].r = 1; + dinbuf[1].r = 0; + dinbuf[2].r = (rank > 0); + dinbuf[0].i = -1; + dinbuf[1].i = 0; + dinbuf[2].i = -(rank > 0); + + doutbuf[0].r = 0; + doutbuf[1].r = 1; + doutbuf[2].r = 1; + doutbuf[0].i = 0; + doutbuf[1].i = 1; + doutbuf[2].i = 1; + MPI_Reduce(dinbuf, doutbuf, 3, MPI_DOUBLE_COMPLEX, MPI_SUM, 0, comm); + if (rank == 0) { + if (doutbuf[0].r != size || doutbuf[0].i != -size) { + errs++; + fprintf(stderr, "double complex SUM(1) test failed\n"); + } + if (doutbuf[1].r != 0 || doutbuf[1].i != 0) { + errs++; + fprintf(stderr, "double complex SUM(0) test failed\n"); + } + if (doutbuf[2].r != size - 1 || doutbuf[2].i != 1 - size) { + errs++; + fprintf(stderr, "double complex SUM(>) test failed\n"); + } + } + } +#ifdef HAVE_LONG_DOUBLE + else if (dc == sizeof(ld_complex)) { + MTestPrintfMsg(10, "Reduce of MPI_DOUBLE_COMPLEX\n"); + /* double complex; may be null if we do not have Fortran support */ + ldinbuf[0].r = 1; + ldinbuf[1].r = 0; + ldinbuf[2].r = (rank > 0); + ldinbuf[0].i = -1; + ldinbuf[1].i = 0; + ldinbuf[2].i = -(rank > 0); + + ldoutbuf[0].r = 0; + ldoutbuf[1].r = 1; + ldoutbuf[2].r = 1; + ldoutbuf[0].i = 0; + ldoutbuf[1].i = 1; + ldoutbuf[2].i = 1; + MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_DOUBLE_COMPLEX, MPI_SUM, 0, comm); + if (rank == 0) { + if (ldoutbuf[0].r != size || ldoutbuf[0].i != -size) { + errs++; + fprintf(stderr, "double complex SUM(1) test failed\n"); + } + if (ldoutbuf[1].r != 0 || ldoutbuf[1].i != 0) { + errs++; + fprintf(stderr, "double complex SUM(0) test failed\n"); + } + if (ldoutbuf[2].r != size - 1 || ldoutbuf[2].i != 1 - size) { + errs++; + fprintf(stderr, "double complex SUM(>) test failed\n"); + } + } + } +#endif + /* Implicitly ignore if there is no matching C type */ } #endif /* USE_STRICT_MPI */ #ifdef HAVE_LONG_DOUBLE - { long double ldinbuf[3], ldoutbuf[3]; - /* long double */ - ldinbuf[0] = 1; - ldinbuf[1] = 0; - ldinbuf[2] = (rank > 0); + { + long double ldinbuf[3], ldoutbuf[3]; + MTEST_VG_MEM_INIT(ldinbuf, 3 * sizeof(ldinbuf[0])); + /* long double */ + ldinbuf[0] = 1; + ldinbuf[1] = 0; + ldinbuf[2] = (rank > 0); - ldoutbuf[0] = 0; - ldoutbuf[1] = 1; - ldoutbuf[2] = 1; - if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) { - MTestPrintfMsg( 10, "Reduce of MPI_LONG_DOUBLE\n" ); - MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_SUM, 0, comm ); - if (rank == 0) { - if (ldoutbuf[0] != size) { - errs++; - fprintf( stderr, "long double SUM(1) test failed\n" ); - } - if (ldoutbuf[1] != 0.0) { - errs++; - fprintf( stderr, "long double SUM(0) test failed\n" ); - } - if (ldoutbuf[2] != size - 1) { - errs++; - fprintf( stderr, "long double SUM(>) test failed\n" ); - } - } - } + ldoutbuf[0] = 0; + ldoutbuf[1] = 1; + ldoutbuf[2] = 1; + if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) { + MTestPrintfMsg(10, "Reduce of MPI_LONG_DOUBLE\n"); + MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_SUM, 0, comm); + if (rank == 0) { + if (ldoutbuf[0] != size) { + errs++; + fprintf(stderr, "long double SUM(1) test failed\n"); + } + if (ldoutbuf[1] != 0.0) { + errs++; + fprintf(stderr, "long double SUM(0) test failed\n"); + } + if (ldoutbuf[2] != size - 1) { + errs++; + fprintf(stderr, "long double SUM(>) test failed\n"); + } + } + } } #endif #ifdef HAVE_LONG_LONG { - long long llinbuf[3], lloutbuf[3]; - /* long long */ - llinbuf[0] = 1; - llinbuf[1] = 0; - llinbuf[2] = (rank > 0); + long long llinbuf[3], lloutbuf[3]; + /* long long */ + llinbuf[0] = 1; + llinbuf[1] = 0; + llinbuf[2] = (rank > 0); - lloutbuf[0] = 0; - lloutbuf[1] = 1; - lloutbuf[2] = 1; - if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { - MTestPrintfMsg( 10, "Reduce of MPI_LONG_LONG\n" ); - MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_SUM, 0, comm ); - if (rank == 0) { - if (lloutbuf[0] != size) { - errs++; - fprintf( stderr, "long long SUM(1) test failed\n" ); - } - if (lloutbuf[1] != 0) { - errs++; - fprintf( stderr, "long long SUM(0) test failed\n" ); - } - if (lloutbuf[2] != size - 1) { - errs++; - fprintf( stderr, "long long SUM(>) test failed\n" ); - } - } - } + lloutbuf[0] = 0; + lloutbuf[1] = 1; + lloutbuf[2] = 1; + if (MPI_LONG_LONG != MPI_DATATYPE_NULL) { + MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n"); + MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_SUM, 0, comm); + if (rank == 0) { + if (lloutbuf[0] != size) { + errs++; + fprintf(stderr, "long long SUM(1) test failed\n"); + } + if (lloutbuf[1] != 0) { + errs++; + fprintf(stderr, "long long SUM(0) test failed\n"); + } + if (lloutbuf[2] != size - 1) { + errs++; + fprintf(stderr, "long long SUM(>) test failed\n"); + } + } + } } #endif - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/coll/red3.c b/teshsuite/smpi/mpich3-test/coll/red3.c index 3d23759611..599d0a37ad 100644 --- a/teshsuite/smpi/mpich3-test/coll/red3.c +++ b/teshsuite/smpi/mpich3-test/coll/red3.c @@ -14,9 +14,9 @@ static char MTEST_Descrip[] = "Test MPI_Reduce with non-commutative user-define */ /* * This tests that the reduce operation respects the noncommutative flag. - * See red4.c for a version that can distinguish between P_{root} P_{root+1} + * See red4.c for a version that can distinguish between P_{root} P_{root+1} * ... P_{root-1} and P_0 ... P_{size-1} . The MPI standard clearly - * specifies that the result is P_0 ... P_{size-1}, independent of the root + * specifies that the result is P_0 ... P_{size-1}, independent of the root * (see 4.9.4 in MPI-1) */ @@ -27,190 +27,181 @@ static char MTEST_Descrip[] = "Test MPI_Reduce with non-commutative user-define c(i,j) is cin[j+i*matSize] */ #define MAXCOL 256 -static int matSize = 0; /* Must be < MAXCOL */ -void uop( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype ); -void uop( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype ) +static int matSize = 0; /* Must be < MAXCOL */ +void uop(void *cinPtr, void *coutPtr, int *count, MPI_Datatype * dtype); +void uop(void *cinPtr, void *coutPtr, int *count, MPI_Datatype * dtype) { - const int *cin = (const int *)cinPtr; - int *cout = (int *)coutPtr; + const int *cin = (const int *) cinPtr; + int *cout = (int *) coutPtr; int i, j, k, nmat; int tempCol[MAXCOL]; for (nmat = 0; nmat < *count; nmat++) { - for (j=0; j MAXCOL) { - /* Skip because there are too many processes */ - MTestFreeComm( &comm ); - continue; - } + MPI_Op_create(uop, 0, &op); - /* Only one matrix for now */ - count = 1; + while (MTestGetIntracommGeneral(&comm, minsize, 1)) { + if (comm == MPI_COMM_NULL) + continue; + MPI_Comm_size(comm, &size); + MPI_Comm_rank(comm, &rank); - /* A single matrix, the size of the communicator */ - MPI_Type_contiguous( size*size, MPI_INT, &mattype ); - MPI_Type_commit( &mattype ); - - buf = (int *)malloc( count * size * size * sizeof(int) ); - if (!buf) { - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - bufout = (int *)malloc( count * size * size * sizeof(int) ); - if (!bufout) { - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); + if (size > MAXCOL) { + /* Skip because there are too many processes */ + MTestFreeComm(&comm); + continue; } - for (root = 0; root < size; root ++) { - initMat( comm, buf ); - MPI_Reduce( buf, bufout, count, mattype, op, root, comm ); - if (rank == root) { - errs += isPermutedIdentity( comm, bufout ); - } + /* Only one matrix for now */ + count = 1; - /* Try the same test, but using MPI_IN_PLACE */ - initMat( comm, bufout ); - if (rank == root) { - MPI_Reduce( MPI_IN_PLACE, bufout, count, mattype, op, root, comm ); - } - else { - MPI_Reduce( bufout, NULL, count, mattype, op, root, comm ); - } - if (rank == root) { - errs += isPermutedIdentity( comm, bufout ); - } - } - MPI_Type_free( &mattype ); + /* A single matrix, the size of the communicator */ + MPI_Type_contiguous(size * size, MPI_INT, &mattype); + MPI_Type_commit(&mattype); + + buf = (int *) malloc(count * size * size * sizeof(int)); + if (!buf) + MPI_Abort(MPI_COMM_WORLD, 1); + bufout = (int *) malloc(count * size * size * sizeof(int)); + if (!bufout) + MPI_Abort(MPI_COMM_WORLD, 1); + + for (root = 0; root < size; root++) { + initMat(comm, buf); + MPI_Reduce(buf, bufout, count, mattype, op, root, comm); + if (rank == root) { + errs += isPermutedIdentity(comm, bufout); + } + + /* Try the same test, but using MPI_IN_PLACE */ + initMat(comm, bufout); + if (rank == root) { + MPI_Reduce(MPI_IN_PLACE, bufout, count, mattype, op, root, comm); + } + else { + MPI_Reduce(bufout, NULL, count, mattype, op, root, comm); + } + if (rank == root) { + errs += isPermutedIdentity(comm, bufout); + } + } + MPI_Type_free(&mattype); - free( buf ); - free( bufout ); + free(buf); + free(bufout); - MTestFreeComm( &comm ); + MTestFreeComm(&comm); } - MPI_Op_free( &op ); + MPI_Op_free(&op); - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/coll/red_scat_block.c b/teshsuite/smpi/mpich3-test/coll/red_scat_block.c index 3f35fb39fd..2884708cdc 100644 --- a/teshsuite/smpi/mpich3-test/coll/red_scat_block.c +++ b/teshsuite/smpi/mpich3-test/coll/red_scat_block.c @@ -20,12 +20,9 @@ int main(int argc, char **argv) { int err = 0; - int toterr, size, rank; -#if MTEST_HAVE_MIN_MPI_VERSION(2,2) - int i, sumval; + int toterr, size, rank, i, sumval; int *sendbuf; int *recvbuf; -#endif MPI_Comm comm; MPI_Init(&argc, &argv); @@ -42,14 +39,13 @@ int main(int argc, char **argv) err++; fprintf(stderr, "unable to allocate send/recv buffers, aborting"); MPI_Abort(MPI_COMM_WORLD, 1); - exit(1); } - for (i=0; i x */ -void left(void *a, void *b, int *count, MPI_Datatype *type); -void left(void *a, void *b, int *count, MPI_Datatype *type) +void left(void *a, void *b, int *count, MPI_Datatype * type); +void left(void *a, void *b, int *count, MPI_Datatype * type) { int *in = a; int *inout = b; int i; - for (i = 0; i < *count; ++i) - { + for (i = 0; i < *count; ++i) { if (in[i] > inout[i]) ++err; inout[i] = in[i]; @@ -36,15 +35,14 @@ void left(void *a, void *b, int *count, MPI_Datatype *type) } /* right(x,y) ==> y */ -void right(void *a, void *b, int *count, MPI_Datatype *type); -void right(void *a, void *b, int *count, MPI_Datatype *type) +void right(void *a, void *b, int *count, MPI_Datatype * type); +void right(void *a, void *b, int *count, MPI_Datatype * type) { int *in = a; int *inout = b; int i; - for (i = 0; i < *count; ++i) - { + for (i = 0; i < *count; ++i) { if (in[i] > inout[i]) ++err; inout[i] = inout[i]; @@ -53,67 +51,66 @@ void right(void *a, void *b, int *count, MPI_Datatype *type) /* Just performs a simple sum but can be marked as non-commutative to potentially tigger different logic in the implementation. */ -void nc_sum(void *a, void *b, int *count, MPI_Datatype *type); -void nc_sum(void *a, void *b, int *count, MPI_Datatype *type) +void nc_sum(void *a, void *b, int *count, MPI_Datatype * type); +void nc_sum(void *a, void *b, int *count, MPI_Datatype * type) { int *in = a; int *inout = b; int i; - for (i = 0; i < *count; ++i) - { + for (i = 0; i < *count; ++i) { inout[i] = in[i] + inout[i]; } } #define MAX_BLOCK_SIZE 256 -int main( int argc, char **argv ) +int main(int argc, char **argv) { -#if MTEST_HAVE_MIN_MPI_VERSION(2,2) - int *sendbuf; - int block_size; - int *recvbuf; - int i; - MPI_Op left_op, right_op, nc_sum_op; -#endif - int size, rank; + int *sendbuf; + int block_size; + int *recvbuf; + int size, rank, i; MPI_Comm comm; + MPI_Op left_op, right_op, nc_sum_op; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - MPI_Comm_size( comm, &size ); - MPI_Comm_rank( comm, &rank ); + MPI_Comm_size(comm, &size); + MPI_Comm_rank(comm, &rank); #if MTEST_HAVE_MIN_MPI_VERSION(2,2) /* MPI_Reduce_scatter block was added in MPI-2.2 */ - MPI_Op_create(&left, 0/*non-commutative*/, &left_op); - MPI_Op_create(&right, 0/*non-commutative*/, &right_op); - MPI_Op_create(&nc_sum, 0/*non-commutative*/, &nc_sum_op); + MPI_Op_create(&left, 0 /*non-commutative */ , &left_op); + MPI_Op_create(&right, 0 /*non-commutative */ , &right_op); + MPI_Op_create(&nc_sum, 0 /*non-commutative */ , &nc_sum_op); for (block_size = 1; block_size < MAX_BLOCK_SIZE; block_size *= 2) { - sendbuf = (int *) malloc( block_size * size * sizeof(int) ); - recvbuf = malloc( block_size * sizeof(int) ); + sendbuf = (int *) malloc(block_size * size * sizeof(int)); + recvbuf = malloc(block_size * sizeof(int)); - for (i=0; i<(size*block_size); i++) + for (i = 0; i < (size * block_size); i++) sendbuf[i] = rank + i; - for (i=0; i #include +#include "mpicolltest.h" -int main( int argc, char **argv ) +int main(int argc, char **argv) { - int err = 0, toterr; - int *sendbuf, recvbuf, *recvcounts; - int size, rank, i, sumval; + int err = 0, toterr; + int *sendbuf, recvbuf, *recvcounts; + int size, rank, i, sumval; MPI_Comm comm; - MPI_Init( &argc, &argv ); + MPI_Init(&argc, &argv); comm = MPI_COMM_WORLD; - MPI_Comm_size( comm, &size ); - MPI_Comm_rank( comm, &rank ); - sendbuf = (int *) malloc( size * sizeof(int) ); - for (i=0; i x */ -void left(void *a, void *b, int *count, MPI_Datatype *type); -void left(void *a, void *b, int *count, MPI_Datatype *type) +void left(void *a, void *b, int *count, MPI_Datatype * type); +void left(void *a, void *b, int *count, MPI_Datatype * type) { int *in = a; int *inout = b; int i; - for (i = 0; i < *count; ++i) - { + for (i = 0; i < *count; ++i) { if (in[i] > inout[i]) ++err; inout[i] = in[i]; @@ -36,15 +35,14 @@ void left(void *a, void *b, int *count, MPI_Datatype *type) } /* right(x,y) ==> y */ -void right(void *a, void *b, int *count, MPI_Datatype *type); -void right(void *a, void *b, int *count, MPI_Datatype *type) +void right(void *a, void *b, int *count, MPI_Datatype * type); +void right(void *a, void *b, int *count, MPI_Datatype * type) { int *in = a; int *inout = b; int i; - for (i = 0; i < *count; ++i) - { + for (i = 0; i < *count; ++i) { if (in[i] > inout[i]) ++err; inout[i] = inout[i]; @@ -53,76 +51,79 @@ void right(void *a, void *b, int *count, MPI_Datatype *type) /* Just performs a simple sum but can be marked as non-commutative to potentially tigger different logic in the implementation. */ -void nc_sum(void *a, void *b, int *count, MPI_Datatype *type); -void nc_sum(void *a, void *b, int *count, MPI_Datatype *type) +void nc_sum(void *a, void *b, int *count, MPI_Datatype * type); +void nc_sum(void *a, void *b, int *count, MPI_Datatype * type) { int *in = a; int *inout = b; int i; - for (i = 0; i < *count; ++i) - { + for (i = 0; i < *count; ++i) { inout[i] = in[i] + inout[i]; } } #define MAX_BLOCK_SIZE 256 -int main( int argc, char **argv ) +int main(int argc, char **argv) { - int *sendbuf, *recvcounts; - int block_size; - int *recvbuf; - int size, rank, i; + int *sendbuf, *recvcounts; + int block_size; + int *recvbuf; + int size, rank, i; MPI_Comm comm; MPI_Op left_op, right_op, nc_sum_op; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - MPI_Comm_size( comm, &size ); - MPI_Comm_rank( comm, &rank ); + MPI_Comm_size(comm, &size); + MPI_Comm_rank(comm, &rank); - MPI_Op_create(&left, 0/*non-commutative*/, &left_op); - MPI_Op_create(&right, 0/*non-commutative*/, &right_op); - MPI_Op_create(&nc_sum, 0/*non-commutative*/, &nc_sum_op); + MPI_Op_create(&left, 0 /*non-commutative */ , &left_op); + MPI_Op_create(&right, 0 /*non-commutative */ , &right_op); + MPI_Op_create(&nc_sum, 0 /*non-commutative */ , &nc_sum_op); for (block_size = 1; block_size < MAX_BLOCK_SIZE; block_size *= 2) { - sendbuf = (int *) malloc( block_size * size * sizeof(int) ); - recvbuf = malloc( block_size * sizeof(int) ); + sendbuf = (int *) malloc(block_size * size * sizeof(int)); + recvbuf = malloc(block_size * sizeof(int)); - for (i=0; i<(size*block_size); i++) + for (i = 0; i < (size * block_size); i++) sendbuf[i] = rank + i; - for (i=0; i #include #include "mpitest.h" +#include "mpicolltest.h" /* Limit the number of error reports */ #define MAX_ERRORS 10 -int main( int argc, char **argv ) +int main(int argc, char **argv) { - int err = 0; - int *sendbuf, *recvbuf, *recvcounts; - int size, rank, i, j, idx, mycount, sumval; + int err = 0; + int *sendbuf, *recvbuf, *recvcounts; + int size, rank, i, j, idx, mycount, sumval; MPI_Comm comm; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - MPI_Comm_size( comm, &size ); - MPI_Comm_rank( comm, &rank ); - recvcounts = (int *)malloc( size * sizeof(int) ); + MPI_Comm_size(comm, &size); + MPI_Comm_rank(comm, &rank); + recvcounts = (int *) malloc(size * sizeof(int)); if (!recvcounts) { - fprintf( stderr, "Could not allocate %d ints for recvcounts\n", - size ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); + fprintf(stderr, "Could not allocate %d ints for recvcounts\n", size); + MPI_Abort(MPI_COMM_WORLD, 1); } mycount = (1024 * 1024) / size; - for (i=0; i #include "mpitest.h" -int main( int argc, char **argv ) +int main(int argc, char **argv) { - int err = 0; - int size, rsize, rank, i; - int recvcount, /* Each process receives this much data */ - sendcount, /* Each process contributes this much data */ - basecount; /* Unit of elements - basecount *rsize is recvcount, - etc. */ - int isLeftGroup; + int err = 0; + int size, rsize, rank, i; + int recvcount, /* Each process receives this much data */ + sendcount, /* Each process contributes this much data */ + basecount; /* Unit of elements - basecount *rsize is recvcount, + * etc. */ + int isLeftGroup; long long *sendbuf, *recvbuf; long long sumval; MPI_Comm comm; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; basecount = 1024; - while (MTestGetIntercomm( &comm, &isLeftGroup, 2 )) { - if (comm == MPI_COMM_NULL) continue; - - MPI_Comm_remote_size( comm, &rsize ); - MPI_Comm_size( comm, &size ); - MPI_Comm_rank( comm, &rank ); - - if (0) { - printf( "[%d] %s (%d,%d) remote %d\n", rank, - isLeftGroup ? "L" : "R", - rank, size, rsize ); - } - - recvcount = basecount * rsize; - sendcount = basecount * rsize * size; - - sendbuf = (long long *) malloc( sendcount * sizeof(long long) ); - if (!sendbuf) { - fprintf( stderr, "Could not allocate %d ints for sendbuf\n", - sendcount ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - - for (i=0; i #include "mpitest.h" -int main( int argc, char **argv ) +int main(int argc, char **argv) { - int err = 0; - int *sendbuf, *recvbuf; - int size, rank, i, j, idx, mycount, sumval; + int err = 0; + int *sendbuf, *recvbuf; + int size, rank, i, j, idx, mycount, sumval; MPI_Comm comm; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - MPI_Comm_size( comm, &size ); - MPI_Comm_rank( comm, &rank ); + MPI_Comm_size(comm, &size); + MPI_Comm_rank(comm, &rank); mycount = (1024 * 1024) / size; - sendbuf = (int *) malloc( mycount * size * sizeof(int) ); + sendbuf = (int *) malloc(mycount * size * sizeof(int)); if (!sendbuf) { - fprintf( stderr, "Could not allocate %d ints for sendbuf\n", - mycount * size ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); + fprintf(stderr, "Could not allocate %d ints for sendbuf\n", mycount * size); + MPI_Abort(MPI_COMM_WORLD, 1); } idx = 0; - for (i=0; i #include #include "mpitest.h" +#include "mpicolltest.h" -int main( int argc, char **argv ) +int main(int argc, char **argv) { - int err = 0; - int *recvcounts; - int size, rsize, rank, i; - int recvcount, /* Each process receives this much data */ - sendcount, /* Each process contributes this much data */ - basecount; /* Unit of elements - basecount *rsize is recvcount, - etc. */ - int isLeftGroup; + int err = 0; + int *recvcounts; + int size, rsize, rank, i; + int recvcount, /* Each process receives this much data */ + sendcount, /* Each process contributes this much data */ + basecount; /* Unit of elements - basecount *rsize is recvcount, + * etc. */ + int isLeftGroup; long long *sendbuf, *recvbuf; long long sumval; MPI_Comm comm; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; basecount = 1024; - while (MTestGetIntercomm( &comm, &isLeftGroup, 2 )) { - if (comm == MPI_COMM_NULL) continue; - - MPI_Comm_remote_size( comm, &rsize ); - MPI_Comm_size( comm, &size ); - MPI_Comm_rank( comm, &rank ); - - if (0) { - printf( "[%d] %s (%d,%d) remote %d\n", rank, - isLeftGroup ? "L" : "R", - rank, size, rsize ); - } - - recvcount = basecount * rsize; - sendcount = basecount * rsize * size; - - recvcounts = (int *)malloc( size * sizeof(int) ); - if (!recvcounts) { - fprintf( stderr, "Could not allocate %d int for recvcounts\n", - size ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - for (i=0; i 0 ? count*=2 : count++) { + for (count = 0; count < MAX_BUF_ELEMENTS; count > 0 ? count *= 2 : count++) { for (i = 0; i < count; ++i) { inbuf[i] = i; inoutbuf[i] = i; @@ -64,14 +62,14 @@ int main( int argc, char *argv[] ) for (i = 0; i < count; ++i) if (inbuf[i] != i) { ++errs; - if (inoutbuf[i] != (2*i)) - ++errs; - } + if (inoutbuf[i] != (2 * i)) + ++errs; + } } /* make sure that user-define ops work too */ - MPI_Op_create(&user_op, 0/*!commute*/, &uop); - for (count = 0; count < MAX_BUF_ELEMENTS; count > 0 ? count*=2 : count++) { + MPI_Op_create(&user_op, 0 /*!commute */ , &uop); + for (count = 0; count < MAX_BUF_ELEMENTS; count > 0 ? count *= 2 : count++) { for (i = 0; i < count; ++i) { inbuf[i] = i; inoutbuf[i] = i; @@ -81,9 +79,9 @@ int main( int argc, char *argv[] ) for (i = 0; i < count; ++i) if (inbuf[i] != i) { ++errs; - if (inoutbuf[i] != (3*i)) - ++errs; - } + if (inoutbuf[i] != (3 * i)) + ++errs; + } } MPI_Op_free(&uop); @@ -95,4 +93,3 @@ int main( int argc, char *argv[] ) MPI_Finalize(); return 0; } - diff --git a/teshsuite/smpi/mpich3-test/coll/scantst.c b/teshsuite/smpi/mpich3-test/coll/scantst.c index 1359acc51d..12ddcad89b 100644 --- a/teshsuite/smpi/mpich3-test/coll/scantst.c +++ b/teshsuite/smpi/mpich3-test/coll/scantst.c @@ -7,117 +7,107 @@ #include #include "mpitest.h" -void addem ( int *, int *, int *, MPI_Datatype * ); -void assoc ( int *, int *, int *, MPI_Datatype * ); +void addem(int *, int *, int *, MPI_Datatype *); +void assoc(int *, int *, int *, MPI_Datatype *); -void addem( int *invec, int *inoutvec, int *len, MPI_Datatype *dtype) +void addem(int *invec, int *inoutvec, int *len, MPI_Datatype * dtype) { - int i; - for ( i=0; i<*len; i++ ) - inoutvec[i] += invec[i]; + int i; + for (i = 0; i < *len; i++) + inoutvec[i] += invec[i]; } #define BAD_ANSWER 100000 /* - The operation is inoutvec[i] = invec[i] op inoutvec[i] + The operation is inoutvec[i] = invec[i] op inoutvec[i] (see 4.9.4). The order is important. Note that the computation is in process rank (in the communicator) order, independant of the root. */ -void assoc( int *invec, int *inoutvec, int *len, MPI_Datatype *dtype) +void assoc(int *invec, int *inoutvec, int *len, MPI_Datatype * dtype) { - int i; - for ( i=0; i<*len; i++ ) { - if (inoutvec[i] <= invec[i] ) { - int rank; - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); - fprintf( stderr, "[%d] inout[0] = %d, in[0] = %d\n", - rank, inoutvec[0], invec[0] ); - inoutvec[i] = BAD_ANSWER; - } - else - inoutvec[i] = invec[i]; - } + int i; + for (i = 0; i < *len; i++) { + if (inoutvec[i] <= invec[i]) { + int rank; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + fprintf(stderr, "[%d] inout[0] = %d, in[0] = %d\n", rank, inoutvec[0], invec[0]); + inoutvec[i] = BAD_ANSWER; + } + else + inoutvec[i] = invec[i]; + } } -int main( int argc, char **argv ) +int main(int argc, char **argv) { - int rank, size, i; - int data; - int errors=0; - int result = -100; - int correct_result; - MPI_Op op_assoc, op_addem; - MPI_Comm comm=MPI_COMM_WORLD; - - MPI_Init( &argc, &argv ); - MPI_Op_create( (MPI_User_function *)assoc, 0, &op_assoc ); - MPI_Op_create( (MPI_User_function *)addem, 1, &op_addem ); + int rank, size, i; + int data; + int errors = 0; + int result = -100; + int correct_result; + MPI_Op op_assoc, op_addem; + MPI_Comm comm = MPI_COMM_WORLD; + + MPI_Init(&argc, &argv); + MPI_Op_create((MPI_User_function *) assoc, 0, &op_assoc); + MPI_Op_create((MPI_User_function *) addem, 1, &op_addem); /* Run this for a variety of communicator sizes */ - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); data = rank; - + correct_result = 0; - for (i=0;i<=rank;i++) + for (i = 0; i <= rank; i++) correct_result += i; - - MPI_Scan ( &data, &result, 1, MPI_INT, MPI_SUM, comm ); + + MPI_Scan(&data, &result, 1, MPI_INT, MPI_SUM, comm); if (result != correct_result) { - fprintf( stderr, "[%d] Error suming ints with scan\n", rank ); + fprintf(stderr, "[%d] Error suming ints with scan\n", rank); errors++; } - MPI_Scan ( &data, &result, 1, MPI_INT, MPI_SUM, comm ); + MPI_Scan(&data, &result, 1, MPI_INT, MPI_SUM, comm); if (result != correct_result) { - fprintf( stderr, "[%d] Error summing ints with scan (2)\n", rank ); + fprintf(stderr, "[%d] Error summing ints with scan (2)\n", rank); errors++; } - + data = rank; result = -100; - MPI_Scan ( &data, &result, 1, MPI_INT, op_addem, comm ); + MPI_Scan(&data, &result, 1, MPI_INT, op_addem, comm); if (result != correct_result) { - fprintf( stderr, "[%d] Error summing ints with scan (userop)\n", - rank ); + fprintf(stderr, "[%d] Error summing ints with scan (userop)\n", rank); errors++; } - - MPI_Scan ( &data, &result, 1, MPI_INT, op_addem, comm ); + + MPI_Scan(&data, &result, 1, MPI_INT, op_addem, comm); if (result != correct_result) { - fprintf( stderr, "[%d] Error summing ints with scan (userop2)\n", - rank ); + fprintf(stderr, "[%d] Error summing ints with scan (userop2)\n", rank); errors++; } result = -100; data = rank; - MPI_Scan ( &data, &result, 1, MPI_INT, op_assoc, comm ); + MPI_Scan(&data, &result, 1, MPI_INT, op_assoc, comm); if (result == BAD_ANSWER) { - fprintf( stderr, "[%d] Error scanning with non-commutative op\n", - rank ); + fprintf(stderr, "[%d] Error scanning with non-commutative op\n", rank); errors++; } -#if MTEST_HAVE_MIN_MPI_VERSION(2,2) - MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN); - if (MPI_SUCCESS == MPI_Scan( &data, &data, 1, MPI_INT, op_assoc, comm)) - errors++; -#endif + MPI_Op_free(&op_assoc); + MPI_Op_free(&op_addem); - MPI_Op_free( &op_assoc ); - MPI_Op_free( &op_addem ); - MPI_Finalize(); if (errors) - printf( "[%d] done with ERRORS(%d)!\n", rank, errors ); + printf("[%d] done with ERRORS(%d)!\n", rank, errors); else { - if (rank == 0) - printf(" No Errors\n"); + if (rank == 0) + printf(" No Errors\n"); } return errors; diff --git a/teshsuite/smpi/mpich3-test/coll/scatter2.c b/teshsuite/smpi/mpich3-test/coll/scatter2.c index feac832247..96a55b0ce1 100644 --- a/teshsuite/smpi/mpich3-test/coll/scatter2.c +++ b/teshsuite/smpi/mpich3-test/coll/scatter2.c @@ -13,68 +13,62 @@ /* This example sends a vector and receives individual elements, but the root process does not receive any data */ -int main( int argc, char **argv ) +int main(int argc, char **argv) { MPI_Datatype vec; double *vecin, *vecout, ivalue; - int root, i, n, stride, err = 0; - int rank, size; + int root, i, n, stride, err = 0; + int rank, size; MPI_Aint vextent; - MTest_Init( &argc, &argv ); - - MPI_Comm_size( MPI_COMM_WORLD, &size ); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); + MTest_Init(&argc, &argv); + + MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); n = 12; stride = 10; - vecin = (double *)malloc( n * stride * size * sizeof(double) ); - vecout = (double *)malloc( n * sizeof(double) ); - - MPI_Type_vector( n, 1, stride, MPI_DOUBLE, &vec ); - MPI_Type_commit( &vec ); - MPI_Type_extent( vec, &vextent ); - if (vextent != ((n-1)*(MPI_Aint)stride + 1) * sizeof(double) ) { - err++; - printf( "Vector extent is %ld, should be %ld\n", - (long) vextent, (long)(((n-1)*stride+1)*sizeof(double)) ); + vecin = (double *) malloc(n * stride * size * sizeof(double)); + vecout = (double *) malloc(n * sizeof(double)); + + MPI_Type_vector(n, 1, stride, MPI_DOUBLE, &vec); + MPI_Type_commit(&vec); + MPI_Type_extent(vec, &vextent); + if (vextent != ((n - 1) * (MPI_Aint) stride + 1) * sizeof(double)) { + err++; + printf("Vector extent is %ld, should be %ld\n", + (long) vextent, (long) (((n - 1) * stride + 1) * sizeof(double))); } /* Note that the exted of type vector is from the first to the - last element, not n*stride. - E.g., with n=1, the extent is a single double */ + * last element, not n*stride. + * E.g., with n=1, the extent is a single double */ - for (i=0; i 0) printf( "Found %d errors!\n", err ); - else printf( " No Errors\n" ); + if (err > 0) + printf("Found %d errors!\n", err); + else + printf(" No Errors\n"); } - MPI_Type_free( &vec ); + free(vecin); + free(vecout); + MPI_Type_free(&vec); MPI_Finalize(); return 0; - -} +} diff --git a/teshsuite/smpi/mpich3-test/coll/scatterv.c b/teshsuite/smpi/mpich3-test/coll/scatterv.c index ea80da0f39..3115bfc045 100644 --- a/teshsuite/smpi/mpich3-test/coll/scatterv.c +++ b/teshsuite/smpi/mpich3-test/coll/scatterv.c @@ -8,8 +8,8 @@ #include /* Prototypes for picky compilers */ -void SetData ( double *, double *, int, int, int, int, int, int ); -int CheckData ( double *, int, int, int, int, int, int ); +void SetData(double *, double *, int, int, int, int, int, int); +int CheckData(double *, int, int, int, int, int, int); /* This is an example of using scatterv to send a matrix from one process to all others, with the matrix stored in Fortran order. @@ -21,19 +21,19 @@ int CheckData ( double *, int, int, int, int, int, int ); */ -void SetData( double *sendbuf, double *recvbuf, int nx, int ny, - int myrow, int mycol, int nrow, int ncol ) +void SetData(double *sendbuf, double *recvbuf, int nx, int ny, + int myrow, int mycol, int nrow, int ncol) { int coldim, i, j, m, k; double *p; if (myrow == 0 && mycol == 0) { coldim = nx * nrow; - for (j=0; j #include -/* - * Test user-defined operations with a large number of elements. +/* + * Test user-defined operations with a large number of elements. * Added because a talk at EuroMPI'12 claimed that these failed with * more than 64k elements */ @@ -18,93 +18,92 @@ #define MAX_ERRS 10 #define MAX_COUNT 1200000 -void myop( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype ); +void myop(void *cinPtr, void *coutPtr, int *count, MPI_Datatype * dtype); -/* +/* * myop takes a datatype that is a triple of doubles, and computes * the sum, max, min of the respective elements of the triple. */ -void myop( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype ) +void myop(void *cinPtr, void *coutPtr, int *count, MPI_Datatype * dtype) { int i, n = *count; - double const *cin = (double *)cinPtr; - double *cout = (double *)coutPtr; - - for (i=0; i cin[1]) ? cout[1] : cin[1]; - cout[2] = (cout[2] < cin[2]) ? cout[2] : cin[2]; - cin += 3; - cout += 3; + double const *cin = (double *) cinPtr; + double *cout = (double *) coutPtr; + + for (i = 0; i < n; i++) { + cout[0] += cin[0]; + cout[1] = (cout[1] > cin[1]) ? cout[1] : cin[1]; + cout[2] = (cout[2] < cin[2]) ? cout[2] : cin[2]; + cin += 3; + cout += 3; } } -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int wsize, wrank, i, count; MPI_Datatype tripleType; double *inVal, *outVal; - double maxval, sumval; + double maxval, sumval, minval; MPI_Op op; - MTest_Init( &argc, &argv ); - MPI_Op_create( myop, 0, &op ); - MPI_Type_contiguous( 3, MPI_DOUBLE, &tripleType ); - MPI_Type_commit( &tripleType ); + MTest_Init(&argc, &argv); + MPI_Op_create(myop, 0, &op); + MPI_Type_contiguous(3, MPI_DOUBLE, &tripleType); + MPI_Type_commit(&tripleType); - 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); - for (count=1; count