From ae0c16d1f2025683ad7fa6d4da2cc290f9c633d9 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 8 Jul 2019 12:21:11 -0500 Subject: HDFFV-10581 fix locations for static pdb files --- config/cmake_ext_mod/HDFMacros.cmake | 34 ++++++++++++++++------------------ fortran/src/CMakeLists.txt | 4 ++-- hl/c++/src/CMakeLists.txt | 2 +- hl/fortran/src/CMakeLists.txt | 4 ++-- hl/src/CMakeLists.txt | 2 +- src/CMakeLists.txt | 2 +- tools/lib/CMakeLists.txt | 2 +- 7 files changed, 24 insertions(+), 26 deletions(-) diff --git a/config/cmake_ext_mod/HDFMacros.cmake b/config/cmake_ext_mod/HDFMacros.cmake index 9da5006..52b96fc 100644 --- a/config/cmake_ext_mod/HDFMacros.cmake +++ b/config/cmake_ext_mod/HDFMacros.cmake @@ -78,7 +78,7 @@ macro (INSTALL_TARGET_PDB libtarget targetdestination targetcomponent) if (${libtype} MATCHES "SHARED") set (targetfilename $) else () - get_property (target_name TARGET ${libtarget} PROPERTY OUTPUT_NAME_RELWITHDEBINFO) + get_property (target_name TARGET ${libtarget} PROPERTY $,OUTPUT_NAME_DEBUG,OUTPUT_NAME_RELWITHDEBINFO>) set (targetfilename $/${target_name}.pdb) endif () install ( @@ -86,9 +86,10 @@ macro (INSTALL_TARGET_PDB libtarget targetdestination targetcomponent) ${targetfilename} DESTINATION ${targetdestination} - CONFIGURATIONS RelWithDebInfo + CONFIGURATIONS $ COMPONENT ${targetcomponent} - ) + OPTIONAL + ) endif () endmacro () @@ -100,9 +101,10 @@ macro (INSTALL_PROGRAM_PDB progtarget targetdestination targetcomponent) $ DESTINATION ${targetdestination} - CONFIGURATIONS RelWithDebInfo + CONFIGURATIONS $ COMPONENT ${targetcomponent} - ) + OPTIONAL + ) endif () endmacro () @@ -126,19 +128,6 @@ macro (HDF_SET_LIB_OPTIONS libtarget libname libtype) endif () endif () - set_target_properties (${libtarget} - PROPERTIES - OUTPUT_NAME - ${LIB_RELEASE_NAME} - OUTPUT_NAME_DEBUG - ${LIB_DEBUG_NAME} - OUTPUT_NAME_RELEASE - ${LIB_RELEASE_NAME} - OUTPUT_NAME_MINSIZEREL - ${LIB_RELEASE_NAME} - OUTPUT_NAME_RELWITHDEBINFO - ${LIB_RELEASE_NAME} - ) if (${libtype} MATCHES "STATIC") if (WIN32) set_target_properties (${libtarget} @@ -378,6 +367,15 @@ macro (HDF_DIR_PATHS package_prefix) set (CMAKE_PREFIX_PATH ${ADDITIONAL_CMAKE_PREFIX_PATH} ${CMAKE_PREFIX_PATH}) endif () + #set the default debug suffix for all library targets + if(NOT CMAKE_DEBUG_POSTFIX) + if (WIN32) + set (CMAKE_DEBUG_POSTFIX "_D") + else () + set (CMAKE_DEBUG_POSTFIX "_debug") + endif () + endif () + SET_HDF_BUILD_TYPE() #----------------------------------------------------------------------------- diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index b01e4d4..774ed8c 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -439,8 +439,8 @@ if (HDF5_EXPORTED_TARGETS) #INSTALL_TARGET_PDB (${HDF5_F90_LIBSH_TARGET} ${HDF5_INSTALL_BIN_DIR} fortlibraries) endif () if (NOT ONLY_SHARED_LIBS) - INSTALL_TARGET_PDB (${HDF5_F90_C_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} fortlibraries) - #INSTALL_TARGET_PDB (${HDF5_F90_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} fortlibraries) + INSTALL_TARGET_PDB (${HDF5_F90_C_LIB_TARGET} ${HDF5_INSTALL_LIB_DIR} fortlibraries) + #INSTALL_TARGET_PDB (${HDF5_F90_LIB_TARGET} ${HDF5_INSTALL_LIB_DIR} fortlibraries) endif () install ( diff --git a/hl/c++/src/CMakeLists.txt b/hl/c++/src/CMakeLists.txt index eb83d8c..1911d62 100644 --- a/hl/c++/src/CMakeLists.txt +++ b/hl/c++/src/CMakeLists.txt @@ -59,7 +59,7 @@ if (HDF5_EXPORTED_TARGETS) INSTALL_TARGET_PDB (${HDF5_HL_CPP_LIBSH_TARGET} ${HDF5_INSTALL_BIN_DIR} hlcpplibraries) endif () if (NOT ONLY_SHARED_LIBS) - INSTALL_TARGET_PDB (${HDF5_HL_CPP_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} hlcpplibraries) + INSTALL_TARGET_PDB (${HDF5_HL_CPP_LIB_TARGET} ${HDF5_INSTALL_LIB_DIR} hlcpplibraries) endif () install ( diff --git a/hl/fortran/src/CMakeLists.txt b/hl/fortran/src/CMakeLists.txt index a684088..b63b5c6 100644 --- a/hl/fortran/src/CMakeLists.txt +++ b/hl/fortran/src/CMakeLists.txt @@ -294,8 +294,8 @@ if (HDF5_EXPORTED_TARGETS) #INSTALL_TARGET_PDB (${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_INSTALL_BIN_DIR} hlfortlibraries) endif () if (NOT ONLY_SHARED_LIBS) - INSTALL_TARGET_PDB (${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} hlfortlibraries) - #INSTALL_TARGET_PDB (${HDF5_HL_F90_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} hlfortlibraries) + INSTALL_TARGET_PDB (${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_INSTALL_LIB_DIR} hlfortlibraries) + #INSTALL_TARGET_PDB (${HDF5_HL_F90_LIB_TARGET} ${HDF5_INSTALL_LIB_DIR} hlfortlibraries) endif () install ( diff --git a/hl/src/CMakeLists.txt b/hl/src/CMakeLists.txt index 7125403..3cce7e4 100644 --- a/hl/src/CMakeLists.txt +++ b/hl/src/CMakeLists.txt @@ -83,7 +83,7 @@ if (HDF5_EXPORTED_TARGETS) INSTALL_TARGET_PDB (${HDF5_HL_LIBSH_TARGET} ${HDF5_INSTALL_BIN_DIR} hllibraries) endif () if (NOT ONLY_SHARED_LIBS) - INSTALL_TARGET_PDB (${HDF5_HL_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} hllibraries) + INSTALL_TARGET_PDB (${HDF5_HL_LIB_TARGET} ${HDF5_INSTALL_LIB_DIR} hllibraries) endif () install ( diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4cf4965..a0a10a5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1192,7 +1192,7 @@ if (HDF5_EXPORTED_TARGETS) INSTALL_TARGET_PDB (${HDF5_LIBSH_TARGET} ${HDF5_INSTALL_BIN_DIR} libraries) endif () if (NOT ONLY_SHARED_LIBS) - INSTALL_TARGET_PDB (${HDF5_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} libraries) + INSTALL_TARGET_PDB (${HDF5_LIB_TARGET} ${HDF5_INSTALL_LIB_DIR} libraries) endif () install ( diff --git a/tools/lib/CMakeLists.txt b/tools/lib/CMakeLists.txt index e9dfcaa..75ed627 100644 --- a/tools/lib/CMakeLists.txt +++ b/tools/lib/CMakeLists.txt @@ -85,7 +85,7 @@ if (HDF5_EXPORTED_TARGETS) INSTALL_TARGET_PDB (${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_INSTALL_BIN_DIR} toolslibraries) endif () if (NOT ONLY_SHARED_LIBS) - INSTALL_TARGET_PDB (${HDF5_TOOLS_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} toolslibraries) + INSTALL_TARGET_PDB (${HDF5_TOOLS_LIB_TARGET} ${HDF5_INSTALL_LIB_DIR} toolslibraries) endif () install ( -- cgit v0.12 From 3dd7137430c05153d5cc6a692ef66f9e5ceea91f Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 8 Jul 2019 13:46:25 -0500 Subject: HDFFV-10581 remove special name checking --- java/examples/datasets/CMakeLists.txt | 2 +- java/examples/datatypes/CMakeLists.txt | 2 +- java/examples/groups/CMakeLists.txt | 2 +- java/examples/intro/CMakeLists.txt | 2 +- java/test/CMakeLists.txt | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/java/examples/datasets/CMakeLists.txt b/java/examples/datasets/CMakeLists.txt index c327c86..1f46bbd 100644 --- a/java/examples/datasets/CMakeLists.txt +++ b/java/examples/datasets/CMakeLists.txt @@ -72,7 +72,7 @@ foreach (HDFJAVA_JAR ${CMAKE_JAVA_INCLUDE_PATH}) endforeach () macro (ADD_H5_TEST resultfile resultcode) - set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$:_DEBUG>>;") + set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$;") add_test ( NAME JAVA_datasets-${resultfile} COMMAND "${CMAKE_COMMAND}" diff --git a/java/examples/datatypes/CMakeLists.txt b/java/examples/datatypes/CMakeLists.txt index 0fef370..8d4b0af 100644 --- a/java/examples/datatypes/CMakeLists.txt +++ b/java/examples/datatypes/CMakeLists.txt @@ -57,7 +57,7 @@ foreach (HDFJAVA_JAR ${CMAKE_JAVA_INCLUDE_PATH}) endforeach () MACRO (ADD_H5_TEST resultfile resultcode) - set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$:_DEBUG>>;") + set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$;") add_test ( NAME JAVA_datatypes-${resultfile} COMMAND "${CMAKE_COMMAND}" diff --git a/java/examples/groups/CMakeLists.txt b/java/examples/groups/CMakeLists.txt index b31a186..bab2eff 100644 --- a/java/examples/groups/CMakeLists.txt +++ b/java/examples/groups/CMakeLists.txt @@ -56,7 +56,7 @@ endforeach () add_custom_target(H5Ex_G_Visit_files ALL COMMENT "Copying files needed by H5Ex_G_Visit tests" DEPENDS ${H5Ex_G_Visit_files_list}) macro (ADD_H5_TEST resultfile resultcode) - set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$:_DEBUG>>;") + set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$;") add_test ( NAME JAVA_groups-${resultfile} COMMAND "${CMAKE_COMMAND}" diff --git a/java/examples/intro/CMakeLists.txt b/java/examples/intro/CMakeLists.txt index 8c94a09..2504337 100644 --- a/java/examples/intro/CMakeLists.txt +++ b/java/examples/intro/CMakeLists.txt @@ -58,7 +58,7 @@ foreach (example ${HDF_JAVA_OBJECT_EXAMPLES}) endforeach () MACRO (ADD_H5_TEST resultfile resultcode) - set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$:_DEBUG>>;") + set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$;") add_test ( NAME JAVA_intro-${resultfile} COMMAND "${CMAKE_COMMAND}" diff --git a/java/test/CMakeLists.txt b/java/test/CMakeLists.txt index 937b129..eb1f715 100644 --- a/java/test/CMakeLists.txt +++ b/java/test/CMakeLists.txt @@ -88,7 +88,7 @@ else () set (CMAKE_JAVA_INCLUDE_FLAG_SEP ":") endif () -set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$:_DEBUG>>;") +set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$;") foreach (test_file ${HDF5_JAVA_TEST_SOURCES}) -- cgit v0.12 From 1878e68558b83bb2d822c298aa7b8373a2bde273 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 8 Jul 2019 13:52:05 -0500 Subject: Move before null check --- java/src/jni/h5lImp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/src/jni/h5lImp.c b/java/src/jni/h5lImp.c index 7413023..7eee3d4 100644 --- a/java/src/jni/h5lImp.c +++ b/java/src/jni/h5lImp.c @@ -508,11 +508,11 @@ Java_hdf_hdf5lib_H5_H5Lget_1value_1by_1idx UNUSED(clss); + infobuf.type = H5L_TYPE_ERROR; + if (NULL == name) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lget_val_by_idx: group name is NULL"); - infobuf.type = H5L_TYPE_ERROR; - PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Lget_val_by_idx: group name not pinned"); /* Get the length of the link value */ -- cgit v0.12 From 8eadaf34081902f2080cdcac3a568ff5169b4ea7 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 8 Jul 2019 13:59:35 -0500 Subject: Change how name is retrieved --- java/examples/datasets/CMakeLists.txt | 3 ++- java/examples/datatypes/CMakeLists.txt | 3 ++- java/examples/groups/CMakeLists.txt | 3 ++- java/examples/intro/CMakeLists.txt | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/java/examples/datasets/CMakeLists.txt b/java/examples/datasets/CMakeLists.txt index 1f46bbd..9e5c45c 100644 --- a/java/examples/datasets/CMakeLists.txt +++ b/java/examples/datasets/CMakeLists.txt @@ -72,7 +72,8 @@ foreach (HDFJAVA_JAR ${CMAKE_JAVA_INCLUDE_PATH}) endforeach () macro (ADD_H5_TEST resultfile resultcode) - set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$;") + get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY $,OUTPUT_NAME_DEBUG,OUTPUT_NAME_RELWITHDEBINFO>) + set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=${target_name};") add_test ( NAME JAVA_datasets-${resultfile} COMMAND "${CMAKE_COMMAND}" diff --git a/java/examples/datatypes/CMakeLists.txt b/java/examples/datatypes/CMakeLists.txt index 8d4b0af..c939985 100644 --- a/java/examples/datatypes/CMakeLists.txt +++ b/java/examples/datatypes/CMakeLists.txt @@ -57,7 +57,8 @@ foreach (HDFJAVA_JAR ${CMAKE_JAVA_INCLUDE_PATH}) endforeach () MACRO (ADD_H5_TEST resultfile resultcode) - set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$;") + get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY $,OUTPUT_NAME_DEBUG,OUTPUT_NAME_RELWITHDEBINFO>) + set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=${target_name};") add_test ( NAME JAVA_datatypes-${resultfile} COMMAND "${CMAKE_COMMAND}" diff --git a/java/examples/groups/CMakeLists.txt b/java/examples/groups/CMakeLists.txt index bab2eff..489dab3 100644 --- a/java/examples/groups/CMakeLists.txt +++ b/java/examples/groups/CMakeLists.txt @@ -56,7 +56,8 @@ endforeach () add_custom_target(H5Ex_G_Visit_files ALL COMMENT "Copying files needed by H5Ex_G_Visit tests" DEPENDS ${H5Ex_G_Visit_files_list}) macro (ADD_H5_TEST resultfile resultcode) - set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$;") + get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY $,OUTPUT_NAME_DEBUG,OUTPUT_NAME_RELWITHDEBINFO>) + set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=${target_name};") add_test ( NAME JAVA_groups-${resultfile} COMMAND "${CMAKE_COMMAND}" diff --git a/java/examples/intro/CMakeLists.txt b/java/examples/intro/CMakeLists.txt index 2504337..1801749 100644 --- a/java/examples/intro/CMakeLists.txt +++ b/java/examples/intro/CMakeLists.txt @@ -58,7 +58,8 @@ foreach (example ${HDF_JAVA_OBJECT_EXAMPLES}) endforeach () MACRO (ADD_H5_TEST resultfile resultcode) - set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$;") + get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY $,OUTPUT_NAME_DEBUG,OUTPUT_NAME_RELWITHDEBINFO>) + set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=${target_name};") add_test ( NAME JAVA_intro-${resultfile} COMMAND "${CMAKE_COMMAND}" -- cgit v0.12 From 8583d608ef094237e5f484e0b4a7bb147fa9c6b5 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 8 Jul 2019 15:10:12 -0500 Subject: Correct test use of library name --- java/test/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/java/test/CMakeLists.txt b/java/test/CMakeLists.txt index eb1f715..05bfd8d 100644 --- a/java/test/CMakeLists.txt +++ b/java/test/CMakeLists.txt @@ -88,7 +88,8 @@ else () set (CMAKE_JAVA_INCLUDE_FLAG_SEP ":") endif () -set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$;") +get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY $,OUTPUT_NAME_DEBUG,OUTPUT_NAME_RELWITHDEBINFO>) +set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=${target_name};") foreach (test_file ${HDF5_JAVA_TEST_SOURCES}) -- cgit v0.12 From c88caec5aeaf4011e6577967d4f382e77b8a012f Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 8 Jul 2019 15:33:31 -0500 Subject: Declaration needed for parallel standalone --- tools/test/perform/pio_standalone.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/test/perform/pio_standalone.c b/tools/test/perform/pio_standalone.c index dd6a61a..022e390 100644 --- a/tools/test/perform/pio_standalone.c +++ b/tools/test/perform/pio_standalone.c @@ -162,4 +162,8 @@ print_version(const char *progname) H5_VERS_SUBRELEASE[0] ? "-" : "", H5_VERS_SUBRELEASE); } +#ifdef H5_HAVE_PARALLEL +MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */ +#endif + -- cgit v0.12 From c424877351842145679f0b8194cc10a03a4e0e7c Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 8 Jul 2019 15:37:58 -0500 Subject: perf program can only be built on unix platforms --- tools/test/perform/CMakeLists.txt | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tools/test/perform/CMakeLists.txt b/tools/test/perform/CMakeLists.txt index 5995b60..38dd605 100644 --- a/tools/test/perform/CMakeLists.txt +++ b/tools/test/perform/CMakeLists.txt @@ -133,20 +133,22 @@ endif () set_target_properties (zip_perf PROPERTIES FOLDER perform) if (H5_HAVE_PARALLEL AND BUILD_TESTING) - #-- Adding test for perf - set (perf_SOURCES - ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/perf.c - ) - add_executable (perf ${perf_SOURCES}) - target_include_directories (perf PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") - if (NOT BUILD_SHARED_LIBS) - TARGET_C_PROPERTIES (perf STATIC) - target_link_libraries (perf PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) - else () - TARGET_C_PROPERTIES (perf SHARED) - target_link_libraries (perf PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + if (UNIX) + #-- Adding test for perf - only on unix systems + set (perf_SOURCES + ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/perf.c + ) + add_executable (perf ${perf_SOURCES}) + target_include_directories (perf PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") + if (NOT BUILD_SHARED_LIBS) + TARGET_C_PROPERTIES (perf STATIC) + target_link_libraries (perf PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) + else () + TARGET_C_PROPERTIES (perf SHARED) + target_link_libraries (perf PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + endif () + set_target_properties (perf PROPERTIES FOLDER perform) endif () - set_target_properties (perf PROPERTIES FOLDER perform) #-- Adding test for h5perf set (h5perf_SOURCES -- cgit v0.12 From f241ff8ad95b9087b6606d0d1698c14538c582a6 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 8 Jul 2019 15:50:14 -0500 Subject: Fix compile error with ifdef H5_HAVE_GETHOSTNAME --- testpar/t_mpi.c | 1543 +++++++++++++++++++++++++++---------------------------- 1 file changed, 757 insertions(+), 786 deletions(-) diff --git a/testpar/t_mpi.c b/testpar/t_mpi.c index 3d501c9..157a09f 100644 --- a/testpar/t_mpi.c +++ b/testpar/t_mpi.c @@ -28,149 +28,143 @@ #include "testpar.h" /* FILENAME and filenames must have the same number of names */ -const char *FILENAME[2]={ - "MPItest", - NULL}; -char filenames[2][200]; -int nerrors = 0; -hid_t fapl; /* file access property list */ +const char *FILENAME[2] = { "MPItest", NULL }; +char filenames[2][200]; +int nerrors = 0; +hid_t fapl; /* file access property list */ /* protocols */ static int errors_sum(int nerrs); #define MPIO_TEST_WRITE_SIZE 1024*1024 /* 1 MB */ -static int -test_mpio_overlap_writes(char *filename) -{ +static int test_mpio_overlap_writes(char *filename) { int mpi_size, mpi_rank; MPI_Comm comm; MPI_Info info = MPI_INFO_NULL; int color, mrc; - MPI_File fh; + MPI_File fh; int i; int vrfyerrs, nerrs; - unsigned char buf[4093]; /* use some prime number for size */ + unsigned char buf[4093]; /* use some prime number for size */ int bufsize = sizeof(buf); - MPI_Offset stride; - MPI_Offset mpi_off; - MPI_Status mpi_stat; - + MPI_Offset stride; + MPI_Offset mpi_off; + MPI_Status mpi_stat; if (VERBOSE_MED) - printf("MPIO independent overlapping writes test on file %s\n", - filename); + printf("MPIO independent overlapping writes test on file %s\n", + filename); nerrs = 0; /* set up MPI parameters */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* Need at least 2 processes */ if (mpi_size < 2) { - if (MAINPROCESS) - printf("Need at least 2 processes to run MPIO test.\n"); - printf(" -SKIP- \n"); - return 0; + if (MAINPROCESS) + printf("Need at least 2 processes to run MPIO test.\n"); + printf(" -SKIP- \n"); + return 0; } /* splits processes 0 to n-2 into one comm. and the last one into another */ color = ((mpi_rank < (mpi_size - 1)) ? 0 : 1); - mrc = MPI_Comm_split (MPI_COMM_WORLD, color, mpi_rank, &comm); - VRFY((mrc==MPI_SUCCESS), "Comm_split succeeded"); - - if (color==0){ - /* First n-1 processes (color==0) open a file and write it */ - mrc = MPI_File_open(comm, filename, MPI_MODE_CREATE|MPI_MODE_RDWR, - info, &fh); - VRFY((mrc==MPI_SUCCESS), ""); - - stride = 1; - mpi_off = mpi_rank*stride; - while (mpi_off < MPIO_TEST_WRITE_SIZE){ - /* make sure the write does not exceed the TEST_WRITE_SIZE */ - if (mpi_off+stride > MPIO_TEST_WRITE_SIZE) - stride = MPIO_TEST_WRITE_SIZE - mpi_off; - - /* set data to some trivial pattern for easy verification */ - for (i=0; i bufsize) - stride = bufsize; - mpi_off += mpi_rank*stride; - } - - /* close file and free the communicator */ - mrc = MPI_File_close(&fh); - VRFY((mrc==MPI_SUCCESS), "MPI_FILE_CLOSE"); - mrc = MPI_Comm_free(&comm); - VRFY((mrc==MPI_SUCCESS), "MPI_Comm_free"); - - /* sync with the other waiting processes */ - mrc = MPI_Barrier(MPI_COMM_WORLD); - VRFY((mrc==MPI_SUCCESS), "Sync after writes"); - }else{ - /* last process waits till writes are done, - * then opens file to verify data. - */ - mrc = MPI_Barrier(MPI_COMM_WORLD); - VRFY((mrc==MPI_SUCCESS), "Sync after writes"); - - mrc = MPI_File_open(comm, filename, MPI_MODE_RDONLY, - info, &fh); - VRFY((mrc==MPI_SUCCESS), ""); - - stride = bufsize; - for (mpi_off=0; mpi_off < MPIO_TEST_WRITE_SIZE; mpi_off += bufsize){ - /* make sure it does not read beyond end of data */ - if (mpi_off+stride > MPIO_TEST_WRITE_SIZE) - stride = MPIO_TEST_WRITE_SIZE - mpi_off; - mrc = MPI_File_read_at(fh, mpi_off, buf, (int)stride, MPI_BYTE, - &mpi_stat); - VRFY((mrc==MPI_SUCCESS), ""); - vrfyerrs=0; - for (i=0; i MAX_ERR_REPORT && !VERBOSE_MED) - printf("proc %d: [more errors ...]\n", mpi_rank); - - nerrs += vrfyerrs; - } - - /* close file and free the communicator */ - mrc = MPI_File_close(&fh); - VRFY((mrc==MPI_SUCCESS), "MPI_FILE_CLOSE"); - mrc = MPI_Comm_free(&comm); - VRFY((mrc==MPI_SUCCESS), "MPI_Comm_free"); + mrc = MPI_Comm_split(MPI_COMM_WORLD, color, mpi_rank, &comm); + VRFY((mrc == MPI_SUCCESS), "Comm_split succeeded"); + + if (color == 0) { + /* First n-1 processes (color==0) open a file and write it */ + mrc = MPI_File_open(comm, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, + info, &fh); + VRFY((mrc == MPI_SUCCESS), ""); + + stride = 1; + mpi_off = mpi_rank * stride; + while (mpi_off < MPIO_TEST_WRITE_SIZE) { + /* make sure the write does not exceed the TEST_WRITE_SIZE */ + if (mpi_off + stride > MPIO_TEST_WRITE_SIZE) + stride = MPIO_TEST_WRITE_SIZE - mpi_off; + + /* set data to some trivial pattern for easy verification */ + for (i = 0; i < stride; i++) + buf[i] = (unsigned char) (mpi_off + i); + mrc = MPI_File_write_at(fh, mpi_off, buf, (int) stride, MPI_BYTE, + &mpi_stat); + VRFY((mrc == MPI_SUCCESS), ""); + + /* move the offset pointer to last byte written by all processes */ + mpi_off += (mpi_size - 1 - mpi_rank) * stride; + + /* Increase chunk size without exceeding buffer size. */ + /* Then move the starting offset for next write. */ + stride *= 2; + if (stride > bufsize) + stride = bufsize; + mpi_off += mpi_rank * stride; + } + + /* close file and free the communicator */ + mrc = MPI_File_close(&fh); + VRFY((mrc == MPI_SUCCESS), "MPI_FILE_CLOSE"); + mrc = MPI_Comm_free(&comm); + VRFY((mrc == MPI_SUCCESS), "MPI_Comm_free"); + + /* sync with the other waiting processes */ + mrc = MPI_Barrier(MPI_COMM_WORLD); + VRFY((mrc == MPI_SUCCESS), "Sync after writes"); + } else { + /* last process waits till writes are done, + * then opens file to verify data. + */ + mrc = MPI_Barrier(MPI_COMM_WORLD); + VRFY((mrc == MPI_SUCCESS), "Sync after writes"); + + mrc = MPI_File_open(comm, filename, MPI_MODE_RDONLY, info, &fh); + VRFY((mrc == MPI_SUCCESS), ""); + + stride = bufsize; + for (mpi_off = 0; mpi_off < MPIO_TEST_WRITE_SIZE; mpi_off += bufsize) { + /* make sure it does not read beyond end of data */ + if (mpi_off + stride > MPIO_TEST_WRITE_SIZE) + stride = MPIO_TEST_WRITE_SIZE - mpi_off; + mrc = MPI_File_read_at(fh, mpi_off, buf, (int) stride, MPI_BYTE, + &mpi_stat); + VRFY((mrc == MPI_SUCCESS), ""); + vrfyerrs = 0; + for (i = 0; i < stride; i++) { + unsigned char expected; + expected = (unsigned char) (mpi_off + i); + if ((expected != buf[i]) + && (vrfyerrs++ < MAX_ERR_REPORT || VERBOSE_MED)) { + printf( + "proc %d: found data error at [%ld], expect %u, got %u\n", + mpi_rank, (long) (mpi_off + i), expected, buf[i]); + } + } + if (vrfyerrs > MAX_ERR_REPORT && !VERBOSE_MED) + printf("proc %d: [more errors ...]\n", mpi_rank); + + nerrs += vrfyerrs; + } + + /* close file and free the communicator */ + mrc = MPI_File_close(&fh); + VRFY((mrc == MPI_SUCCESS), "MPI_FILE_CLOSE"); + mrc = MPI_Comm_free(&comm); + VRFY((mrc == MPI_SUCCESS), "MPI_Comm_free"); } /* - * one more sync to ensure all processes have done reading - * before ending this test. - */ + * one more sync to ensure all processes have done reading + * before ending this test. + */ mrc = MPI_Barrier(MPI_COMM_WORLD); - VRFY((mrc==MPI_SUCCESS), "Sync before leaving test"); + VRFY((mrc == MPI_SUCCESS), "Sync before leaving test"); return (nerrs); } - #define MB 1048576 /* 1024*1024 == 2**20 */ #define GB 1073741824 /* 1024**3 == 2**30 */ #define TWO_GB_LESS1 2147483647 /* 2**31 - 1 */ @@ -186,30 +180,28 @@ test_mpio_overlap_writes(char *filename) * Then reads the file back in by reverse order, that is process 0 * reads the data of process n-1 and vice versa. */ -static int -test_mpio_gb_file(char *filename) -{ +static int test_mpio_gb_file(char *filename) { int mpi_size, mpi_rank; MPI_Info info = MPI_INFO_NULL; int mrc; - MPI_File fh; + MPI_File fh; int i, j, n; int vrfyerrs; - int writerrs; /* write errors */ + int writerrs; /* write errors */ int nerrs; - int ntimes; /* how many times */ - char *buf = NULL; - char expected; - MPI_Offset size; - MPI_Offset mpi_off; - MPI_Offset mpi_off_old; - MPI_Status mpi_stat; + int ntimes; /* how many times */ + char *buf = NULL; + char expected; + MPI_Offset size; + MPI_Offset mpi_off; + MPI_Offset mpi_off_old; + MPI_Status mpi_stat; int is_signed, sizeof_mpi_offset; nerrs = 0; /* set up MPI parameters */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); if (VERBOSE_MED) printf("MPI_Offset range test\n"); @@ -217,196 +209,207 @@ test_mpio_gb_file(char *filename) /* figure out the signness and sizeof MPI_Offset */ mpi_off = 0; is_signed = ((MPI_Offset)(mpi_off - 1)) < 0; - sizeof_mpi_offset = (int)(sizeof(MPI_Offset)); + sizeof_mpi_offset = (int) (sizeof(MPI_Offset)); /* - * Verify the sizeof MPI_Offset and correctness of handling multiple GB - * sizes. - */ - if (MAINPROCESS){ /* only process 0 needs to check it*/ - printf("MPI_Offset is %s %d bytes integeral type\n", - is_signed ? "signed" : "unsigned", (int)sizeof(MPI_Offset)); - if (sizeof_mpi_offset <= 4 && is_signed){ - printf("Skipped 2GB range test " - "because MPI_Offset cannot support it\n"); - }else { - /* verify correctness of assigning 2GB sizes */ - mpi_off = 2 * 1024 * (MPI_Offset)MB; - INFO((mpi_off>0), "2GB OFFSET assignment no overflow"); - INFO((mpi_off-1)==TWO_GB_LESS1, "2GB OFFSET assignment succeed"); - - /* verify correctness of increasing from below 2 GB to above 2GB */ - mpi_off = TWO_GB_LESS1; - for (i=0; i < 3; i++){ - mpi_off_old = mpi_off; - mpi_off = mpi_off + 1; - /* no overflow */ - INFO((mpi_off>0), "2GB OFFSET increment no overflow"); - /* correct inc. */ - INFO((mpi_off-1)==mpi_off_old, "2GB OFFSET increment succeed"); - } - } - - if (sizeof_mpi_offset <= 4){ - printf("Skipped 4GB range test " - "because MPI_Offset cannot support it\n"); - }else { - /* verify correctness of assigning 4GB sizes */ - mpi_off = 4 * 1024 * (MPI_Offset)MB; - INFO((mpi_off>0), "4GB OFFSET assignment no overflow"); - INFO((mpi_off-1)==FOUR_GB_LESS1, "4GB OFFSET assignment succeed"); - - /* verify correctness of increasing from below 4 GB to above 4 GB */ - mpi_off = FOUR_GB_LESS1; - for (i=0; i < 3; i++){ - mpi_off_old = mpi_off; - mpi_off = mpi_off + 1; - /* no overflow */ - INFO((mpi_off>0), "4GB OFFSET increment no overflow"); - /* correct inc. */ - INFO((mpi_off-1)==mpi_off_old, "4GB OFFSET increment succeed"); - } - } + * Verify the sizeof MPI_Offset and correctness of handling multiple GB + * sizes. + */ + if (MAINPROCESS) { /* only process 0 needs to check it*/ + printf("MPI_Offset is %s %d bytes integeral type\n", + is_signed ? "signed" : "unsigned", (int) sizeof(MPI_Offset)); + if (sizeof_mpi_offset <= 4 && is_signed) { + printf("Skipped 2GB range test " + "because MPI_Offset cannot support it\n"); + } else { + /* verify correctness of assigning 2GB sizes */ + mpi_off = 2 * 1024 * (MPI_Offset) MB; + INFO((mpi_off > 0), "2GB OFFSET assignment no overflow"); + INFO((mpi_off-1)==TWO_GB_LESS1, "2GB OFFSET assignment succeed"); + + /* verify correctness of increasing from below 2 GB to above 2GB */ + mpi_off = TWO_GB_LESS1; + for (i = 0; i < 3; i++) { + mpi_off_old = mpi_off; + mpi_off = mpi_off + 1; + /* no overflow */ + INFO((mpi_off > 0), "2GB OFFSET increment no overflow"); + /* correct inc. */ + INFO((mpi_off - 1) == mpi_off_old, + "2GB OFFSET increment succeed"); + } + } + + if (sizeof_mpi_offset <= 4) { + printf("Skipped 4GB range test " + "because MPI_Offset cannot support it\n"); + } else { + /* verify correctness of assigning 4GB sizes */ + mpi_off = 4 * 1024 * (MPI_Offset) MB; + INFO((mpi_off > 0), "4GB OFFSET assignment no overflow"); + INFO((mpi_off-1)==FOUR_GB_LESS1, "4GB OFFSET assignment succeed"); + + /* verify correctness of increasing from below 4 GB to above 4 GB */ + mpi_off = FOUR_GB_LESS1; + for (i = 0; i < 3; i++) { + mpi_off_old = mpi_off; + mpi_off = mpi_off + 1; + /* no overflow */ + INFO((mpi_off > 0), "4GB OFFSET increment no overflow"); + /* correct inc. */ + INFO((mpi_off - 1) == mpi_off_old, + "4GB OFFSET increment succeed"); + } + } } /* - * Verify if we can write to a file of multiple GB sizes. - */ + * Verify if we can write to a file of multiple GB sizes. + */ if (VERBOSE_MED) - printf("MPIO GB file test %s\n", filename); - - if (sizeof_mpi_offset <= 4){ - printf("Skipped GB file range test " - "because MPI_Offset cannot support it\n"); - }else{ - buf = (char *)HDmalloc(MB); - VRFY((buf!=NULL), "malloc succeed"); - - /* open a new file. Remove it first in case it exists. */ - /* Must delete because MPI_File_open does not have a Truncate mode. */ - /* Don't care if it has error. */ - MPI_File_delete(filename, MPI_INFO_NULL); - MPI_Barrier(MPI_COMM_WORLD); /* prevent racing condition */ - - mrc = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE|MPI_MODE_RDWR, - info, &fh); - VRFY((mrc==MPI_SUCCESS), "MPI_FILE_OPEN"); - - printf("MPIO GB file write test %s\n", filename); - - /* instead of writing every bytes of the file, we will just write - * some data around the 2 and 4 GB boundaries. That should cover - * potential integer overflow and filesystem size limits. - */ - writerrs = 0; - for (n=2; n <= 4; n+=2){ - ntimes = GB/MB*n/mpi_size + 1; - for (i=ntimes-2; i <= ntimes; i++){ - mpi_off = (i*mpi_size + mpi_rank)*(MPI_Offset)MB; - if (VERBOSE_MED) - HDfprintf(stdout,"proc %d: write to mpi_off=%016llx, %lld\n", - mpi_rank, mpi_off, mpi_off); - /* set data to some trivial pattern for easy verification */ - for (j=0; j0){ - printf("proc %d: Skip read test due to previous write errors\n", - mpi_rank); - goto finish; - } - mrc = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, info, &fh); - VRFY((mrc==MPI_SUCCESS), ""); - - /* Only read back parts of the file that have been written. */ - for (n=2; n <= 4; n+=2){ - ntimes = GB/MB*n/mpi_size + 1; - for (i=ntimes-2; i <= ntimes; i++){ - mpi_off = (i*mpi_size + (mpi_size - mpi_rank - 1))*(MPI_Offset)MB; - if (VERBOSE_MED) - HDfprintf(stdout,"proc %d: read from mpi_off=%016llx, %lld\n", - mpi_rank, mpi_off, mpi_off); - mrc = MPI_File_read_at(fh, mpi_off, buf, MB, MPI_BYTE, &mpi_stat); - INFO((mrc==MPI_SUCCESS), "GB size file read"); - expected = i*mpi_size + (mpi_size - mpi_rank - 1); - vrfyerrs=0; - for (j=0; j MAX_ERR_REPORT && !VERBOSE_MED) - printf("proc %d: [more errors ...]\n", mpi_rank); - - nerrs += vrfyerrs; - } - } - - /* close file and free the communicator */ - mrc = MPI_File_close(&fh); - VRFY((mrc==MPI_SUCCESS), "MPI_FILE_CLOSE"); - - /* - * one more sync to ensure all processes have done reading - * before ending this test. - */ - mrc = MPI_Barrier(MPI_COMM_WORLD); - VRFY((mrc==MPI_SUCCESS), "Sync before leaving test"); + printf("MPIO GB file test %s\n", filename); + + if (sizeof_mpi_offset <= 4) { + printf("Skipped GB file range test " + "because MPI_Offset cannot support it\n"); + } else { + buf = (char *) HDmalloc(MB); + VRFY((buf != NULL), "malloc succeed"); + + /* open a new file. Remove it first in case it exists. */ + /* Must delete because MPI_File_open does not have a Truncate mode. */ + /* Don't care if it has error. */ + MPI_File_delete(filename, MPI_INFO_NULL); + MPI_Barrier(MPI_COMM_WORLD); /* prevent racing condition */ + + mrc = MPI_File_open(MPI_COMM_WORLD, filename, + MPI_MODE_CREATE | MPI_MODE_RDWR, info, &fh); + VRFY((mrc == MPI_SUCCESS), "MPI_FILE_OPEN"); + + printf("MPIO GB file write test %s\n", filename); + + /* instead of writing every bytes of the file, we will just write + * some data around the 2 and 4 GB boundaries. That should cover + * potential integer overflow and filesystem size limits. + */ + writerrs = 0; + for (n = 2; n <= 4; n += 2) { + ntimes = GB / MB * n / mpi_size + 1; + for (i = ntimes - 2; i <= ntimes; i++) { + mpi_off = (i * mpi_size + mpi_rank) * (MPI_Offset) MB; + if (VERBOSE_MED) + HDfprintf(stdout, + "proc %d: write to mpi_off=%016llx, %lld\n", + mpi_rank, mpi_off, mpi_off); + /* set data to some trivial pattern for easy verification */ + for (j = 0; j < MB; j++) + *(buf + j) = i * mpi_size + mpi_rank; + if (VERBOSE_MED) + HDfprintf(stdout, + "proc %d: writing %d bytes at offset %lld\n", + mpi_rank, MB, mpi_off); + mrc = MPI_File_write_at(fh, mpi_off, buf, MB, MPI_BYTE, + &mpi_stat); + INFO((mrc == MPI_SUCCESS), "GB size file write"); + if (mrc != MPI_SUCCESS) + writerrs++; + } + } + + /* close file and free the communicator */ + mrc = MPI_File_close(&fh); + VRFY((mrc == MPI_SUCCESS), "MPI_FILE_CLOSE"); + + mrc = MPI_Barrier(MPI_COMM_WORLD); + VRFY((mrc == MPI_SUCCESS), "Sync after writes"); + + /* + * Verify if we can read the multiple GB file just created. + */ + /* open it again to verify the data written */ + /* but only if there was no write errors */ + printf("MPIO GB file read test %s\n", filename); + if (errors_sum(writerrs) > 0) { + printf("proc %d: Skip read test due to previous write errors\n", + mpi_rank); + goto finish; + } + mrc = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, info, + &fh); + VRFY((mrc == MPI_SUCCESS), ""); + + /* Only read back parts of the file that have been written. */ + for (n = 2; n <= 4; n += 2) { + ntimes = GB / MB * n / mpi_size + 1; + for (i = ntimes - 2; i <= ntimes; i++) { + mpi_off = (i * mpi_size + (mpi_size - mpi_rank - 1)) + * (MPI_Offset) MB; + if (VERBOSE_MED) + HDfprintf(stdout, + "proc %d: read from mpi_off=%016llx, %lld\n", + mpi_rank, mpi_off, mpi_off); + mrc = MPI_File_read_at(fh, mpi_off, buf, MB, MPI_BYTE, + &mpi_stat); + INFO((mrc == MPI_SUCCESS), "GB size file read"); + expected = i * mpi_size + (mpi_size - mpi_rank - 1); + vrfyerrs = 0; + for (j = 0; j < MB; j++) { + if ((*(buf + j) != expected) + && (vrfyerrs++ < MAX_ERR_REPORT || VERBOSE_MED)) { + printf( + "proc %d: found data error at [%ld+%d], expect %d, got %d\n", + mpi_rank, (long) mpi_off, j, expected, + *(buf + j)); + } + } + if (vrfyerrs > MAX_ERR_REPORT && !VERBOSE_MED) + printf("proc %d: [more errors ...]\n", mpi_rank); + + nerrs += vrfyerrs; + } + } + + /* close file and free the communicator */ + mrc = MPI_File_close(&fh); + VRFY((mrc == MPI_SUCCESS), "MPI_FILE_CLOSE"); + + /* + * one more sync to ensure all processes have done reading + * before ending this test. + */ + mrc = MPI_Barrier(MPI_COMM_WORLD); + VRFY((mrc == MPI_SUCCESS), "Sync before leaving test"); printf("Test if MPI_File_get_size works correctly with %s\n", filename); - mrc = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, info, &fh); - VRFY((mrc==MPI_SUCCESS), ""); + mrc = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, info, + &fh); + VRFY((mrc == MPI_SUCCESS), ""); - if (MAINPROCESS){ /* only process 0 needs to check it*/ + if (MAINPROCESS) { /* only process 0 needs to check it*/ mrc = MPI_File_get_size(fh, &size); - VRFY((mrc==MPI_SUCCESS), ""); - VRFY((size == mpi_off+MB), "MPI_File_get_size doesn't return correct file size."); + VRFY((mrc == MPI_SUCCESS), ""); + VRFY((size == mpi_off+MB), + "MPI_File_get_size doesn't return correct file size."); } - /* close file and free the communicator */ - mrc = MPI_File_close(&fh); - VRFY((mrc==MPI_SUCCESS), "MPI_FILE_CLOSE"); + /* close file and free the communicator */ + mrc = MPI_File_close(&fh); + VRFY((mrc == MPI_SUCCESS), "MPI_FILE_CLOSE"); - /* - * one more sync to ensure all processes have done reading - * before ending this test. - */ - mrc = MPI_Barrier(MPI_COMM_WORLD); - VRFY((mrc==MPI_SUCCESS), "Sync before leaving test"); + /* + * one more sync to ensure all processes have done reading + * before ending this test. + */ + mrc = MPI_Barrier(MPI_COMM_WORLD); + VRFY((mrc == MPI_SUCCESS), "Sync before leaving test"); } -finish: - if (buf) - HDfree(buf); + finish: if (buf) + HDfree(buf); return (nerrs); } - /* * MPI-IO Test: One writes, Many reads. * Verify if only one process writes some data and then all other @@ -424,191 +427,190 @@ finish: * Each process writes something, then reads all data back. */ -#define DIMSIZE 32 /* Dimension size. */ +#define DIMSIZE 32 /* Dimension size. */ #define PRINTID printf("Proc %d: ", mpi_rank) #define USENONE 0 -#define USEATOM 1 /* request atomic I/O */ -#define USEFSYNC 2 /* request file_sync */ +#define USEATOM 1 /* request atomic I/O */ +#define USEFSYNC 2 /* request file_sync */ - -static int -test_mpio_1wMr(char *filename, int special_request) -{ +static int test_mpio_1wMr(char *filename, int special_request) { char hostname[128]; - int mpi_size, mpi_rank; + int mpi_size, mpi_rank; MPI_File fh; char mpi_err_str[MPI_MAX_ERROR_STRING]; - int mpi_err_strlen; - int mpi_err; + int mpi_err_strlen; + int mpi_err; unsigned char writedata[DIMSIZE], readdata[DIMSIZE]; unsigned char expect_val; - int i, irank; - int nerrs = 0; /* number of errors */ - int atomicity; - MPI_Offset mpi_off; - MPI_Status mpi_stat; + int i, irank; + int nerrs = 0; /* number of errors */ + int atomicity; + MPI_Offset mpi_off; + MPI_Status mpi_stat; MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - if (MAINPROCESS && VERBOSE_MED){ + if (MAINPROCESS && VERBOSE_MED) { printf("Testing one process writes, all processes read.\n"); - printf("Using %d processes accessing file %s\n", mpi_size, filename); + printf("Using %d processes accessing file %s\n", mpi_size, filename); printf(" (Filename can be specified via program argument)\n"); } /* show the hostname so that we can tell where the processes are running */ - if (VERBOSE_DEF){ - if (gethostname(hostname, 128) < 0){ - PRINTID; - printf("gethostname failed\n"); - return 1; - } - PRINTID; - printf("hostname=%s\n", hostname); + if (VERBOSE_DEF) { +#ifdef H5_HAVE_GETHOSTNAME + if(HDgethostname(hostname, sizeof(host_name)) < 0) { + printf("gethostname failed\n"); + hostname[0] = '\0'; + } + #else + printf("gethostname unavailable\n"); + hostname[0] = '\0'; +#endif + PRINTID; + printf("hostname=%s\n", hostname); } /* Delete any old file in order to start anew. */ /* Must delete because MPI_File_open does not have a Truncate mode. */ /* Don't care if it has error. */ MPI_File_delete(filename, MPI_INFO_NULL); - MPI_Barrier(MPI_COMM_WORLD); /* prevent racing condition */ + MPI_Barrier(MPI_COMM_WORLD); /* prevent racing condition */ if ((mpi_err = MPI_File_open(MPI_COMM_WORLD, filename, - MPI_MODE_RDWR | MPI_MODE_CREATE , - MPI_INFO_NULL, &fh)) - != MPI_SUCCESS){ - MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - PRINTID; - printf("MPI_File_open failed (%s)\n", mpi_err_str); - return 1; + MPI_MODE_RDWR | MPI_MODE_CREATE, MPI_INFO_NULL, &fh)) + != MPI_SUCCESS) { + MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); + PRINTID; + printf("MPI_File_open failed (%s)\n", mpi_err_str); + return 1; } -if (special_request & USEATOM){ - /* ================================================== - * Set atomcity to true (1). A POSIX compliant filesystem - * should not need this. - * ==================================================*/ - if ((mpi_err = MPI_File_get_atomicity(fh, &atomicity)) != MPI_SUCCESS){ - MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - PRINTID; - printf("MPI_File_get_atomicity failed (%s)\n", mpi_err_str); - } - if (VERBOSE_HI) - printf("Initial atomicity = %d\n", atomicity); - if ((mpi_err = MPI_File_set_atomicity(fh, 1)) != MPI_SUCCESS){ - MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - PRINTID; - printf("MPI_File_set_atomicity failed (%s)\n", mpi_err_str); - } - if ((mpi_err = MPI_File_get_atomicity(fh, &atomicity)) != MPI_SUCCESS){ - MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - PRINTID; - printf("MPI_File_get_atomicity failed (%s)\n", mpi_err_str); + if (special_request & USEATOM) { + /* ================================================== + * Set atomcity to true (1). A POSIX compliant filesystem + * should not need this. + * ==================================================*/ + if ((mpi_err = MPI_File_get_atomicity(fh, &atomicity)) != MPI_SUCCESS) { + MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); + PRINTID; + printf("MPI_File_get_atomicity failed (%s)\n", mpi_err_str); + } + if (VERBOSE_HI) + printf("Initial atomicity = %d\n", atomicity); + if ((mpi_err = MPI_File_set_atomicity(fh, 1)) != MPI_SUCCESS) { + MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); + PRINTID; + printf("MPI_File_set_atomicity failed (%s)\n", mpi_err_str); + } + if ((mpi_err = MPI_File_get_atomicity(fh, &atomicity)) != MPI_SUCCESS) { + MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); + PRINTID; + printf("MPI_File_get_atomicity failed (%s)\n", mpi_err_str); + } + if (VERBOSE_HI) + printf("After set_atomicity atomicity = %d\n", atomicity); } - if (VERBOSE_HI) - printf("After set_atomicity atomicity = %d\n", atomicity); -} /* This barrier is not necessary but do it anyway. */ MPI_Barrier(MPI_COMM_WORLD); - if (VERBOSE_HI){ - PRINTID; - printf("between MPI_Barrier and MPI_File_write_at\n"); + if (VERBOSE_HI) { + PRINTID; + printf("between MPI_Barrier and MPI_File_write_at\n"); } /* ================================================== - * Each process calculates what to write but - * only process irank(0) writes. - * ==================================================*/ - irank=0; - for (i=0; i < DIMSIZE; i++) - writedata[i] = irank*DIMSIZE + i; - mpi_off = irank*DIMSIZE; + * Each process calculates what to write but + * only process irank(0) writes. + * ==================================================*/ + irank = 0; + for (i = 0; i < DIMSIZE; i++) + writedata[i] = irank * DIMSIZE + i; + mpi_off = irank * DIMSIZE; /* Only one process writes */ - if (mpi_rank==irank){ - if (VERBOSE_HI){ - PRINTID; printf("wrote %d bytes at %ld\n", DIMSIZE, (long)mpi_off); - } - if ((mpi_err = MPI_File_write_at(fh, mpi_off, writedata, DIMSIZE, - MPI_BYTE, &mpi_stat)) - != MPI_SUCCESS){ - MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - PRINTID; - printf("MPI_File_write_at offset(%ld), bytes (%d), failed (%s)\n", - (long) mpi_off, DIMSIZE, mpi_err_str); - return 1; - }; + if (mpi_rank == irank) { + if (VERBOSE_HI) { + PRINTID; + printf("wrote %d bytes at %ld\n", DIMSIZE, (long) mpi_off); + } + if ((mpi_err = MPI_File_write_at(fh, mpi_off, writedata, DIMSIZE, + MPI_BYTE, &mpi_stat)) != MPI_SUCCESS) { + MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); + PRINTID; + printf("MPI_File_write_at offset(%ld), bytes (%d), failed (%s)\n", + (long) mpi_off, DIMSIZE, mpi_err_str); + return 1; + }; }; /* Bcast the return code and */ /* make sure all writing are done before reading. */ MPI_Bcast(&mpi_err, 1, MPI_INT, irank, MPI_COMM_WORLD); - if (VERBOSE_HI){ - PRINTID; - printf("MPI_Bcast: mpi_err = %d\n", mpi_err); + if (VERBOSE_HI) { + PRINTID; + printf("MPI_Bcast: mpi_err = %d\n", mpi_err); } -if (special_request & USEFSYNC){ - /* ================================================== - * Do a file sync. A POSIX compliant filesystem - * should not need this. - * ==================================================*/ - if (VERBOSE_HI) - printf("Apply MPI_File_sync\n"); - /* call file_sync to force the write out */ - if ((mpi_err = MPI_File_sync(fh)) != MPI_SUCCESS){ - MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - PRINTID; - printf("MPI_File_sync failed (%s)\n", mpi_err_str); - } - MPI_Barrier(MPI_COMM_WORLD); - /* call file_sync to force the write out */ - if ((mpi_err = MPI_File_sync(fh)) != MPI_SUCCESS){ - MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - PRINTID; - printf("MPI_File_sync failed (%s)\n", mpi_err_str); + if (special_request & USEFSYNC) { + /* ================================================== + * Do a file sync. A POSIX compliant filesystem + * should not need this. + * ==================================================*/ + if (VERBOSE_HI) + printf("Apply MPI_File_sync\n"); + /* call file_sync to force the write out */ + if ((mpi_err = MPI_File_sync(fh)) != MPI_SUCCESS) { + MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); + PRINTID; + printf("MPI_File_sync failed (%s)\n", mpi_err_str); + } + MPI_Barrier(MPI_COMM_WORLD); + /* call file_sync to force the write out */ + if ((mpi_err = MPI_File_sync(fh)) != MPI_SUCCESS) { + MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); + PRINTID; + printf("MPI_File_sync failed (%s)\n", mpi_err_str); + } } -} /* This barrier is not necessary because the Bcase or File_sync above */ /* should take care of it. Do it anyway. */ MPI_Barrier(MPI_COMM_WORLD); - if (VERBOSE_HI){ - PRINTID; - printf("after MPI_Barrier\n"); + if (VERBOSE_HI) { + PRINTID; + printf("after MPI_Barrier\n"); } /* ================================================== - * Each process reads what process 0 wrote and verify. - * ==================================================*/ - irank=0; - mpi_off = irank*DIMSIZE; + * Each process reads what process 0 wrote and verify. + * ==================================================*/ + irank = 0; + mpi_off = irank * DIMSIZE; if ((mpi_err = MPI_File_read_at(fh, mpi_off, readdata, DIMSIZE, MPI_BYTE, - &mpi_stat)) - != MPI_SUCCESS){ - MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - PRINTID; - printf("MPI_File_read_at offset(%ld), bytes (%d), failed (%s)\n", - (long) mpi_off, DIMSIZE, mpi_err_str); - return 1; + &mpi_stat)) != MPI_SUCCESS) { + MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); + PRINTID; + printf("MPI_File_read_at offset(%ld), bytes (%d), failed (%s)\n", + (long) mpi_off, DIMSIZE, mpi_err_str); + return 1; }; - for (i=0; i < DIMSIZE; i++){ - expect_val = irank*DIMSIZE + i; - if (readdata[i] != expect_val){ - PRINTID; - printf("read data[%d:%d] got %02x, expect %02x\n", irank, i, - readdata[i], expect_val); - nerrs++; - } + for (i = 0; i < DIMSIZE; i++) { + expect_val = irank * DIMSIZE + i; + if (readdata[i] != expect_val) { + PRINTID; + printf("read data[%d:%d] got %02x, expect %02x\n", irank, i, + readdata[i], expect_val); + nerrs++; + } } MPI_File_close(&fh); - if (VERBOSE_HI){ - PRINTID; - printf("%d data errors detected\n", nerrs); + if (VERBOSE_HI) { + PRINTID; + printf("%d data errors detected\n", nerrs); } mpi_err = MPI_Barrier(MPI_COMM_WORLD); @@ -617,272 +619,268 @@ if (special_request & USEFSYNC){ /* -Function: test_mpio_derived_dtype - -Test Whether the Displacement of MPI derived datatype -(+ File_set_view + MPI_write)works or not on this MPI-IO package -and this platform. - -1. Details for the test: -1) Create two derived datatypes with MPI_Type_create_hindexed: - datatype1: - count = 1, blocklens = 1, offsets = 0, - base type = MPI_BYTE(essentially a char) - datatype2: - count = 1, blocklens = 1, offsets = 1(byte), - base type = MPI_BYTE - -2) Using these two derived datatypes, - Build another derived datatype with MPI_Type_create_struct: - advtype: derived from datatype1 and datatype2 - advtype: - count = 2, blocklens[0] = 1, blocklens[1]=1, - offsets[0] = 0, offsets[1] = 1(byte), - bas_type[0]=datatype1, - bas_type[1] = datatype2; - -3) Setting MPI file view with advtype -4) Writing 2 bytes 1 to 2 using MPI_File_write to a file -5) File content: -Suppose the fill value of the file is 0(most machines indeed do so) -and Fill value is embraced with "() in the following output: -Expected output should be: -1,0,2 - - - -However, at some platforms, for example, IBM AIX(at March 23rd, 2005): -the following values were obtained: -1,2,0 - -The problem is that the displacement of the second derived datatype(datatype2) which formed the final derived datatype(advtype) + Function: test_mpio_derived_dtype + + Test Whether the Displacement of MPI derived datatype + (+ File_set_view + MPI_write)works or not on this MPI-IO package + and this platform. + + 1. Details for the test: + 1) Create two derived datatypes with MPI_Type_create_hindexed: + datatype1: + count = 1, blocklens = 1, offsets = 0, + base type = MPI_BYTE(essentially a char) + datatype2: + count = 1, blocklens = 1, offsets = 1(byte), + base type = MPI_BYTE + + 2) Using these two derived datatypes, + Build another derived datatype with MPI_Type_create_struct: + advtype: derived from datatype1 and datatype2 + advtype: + count = 2, blocklens[0] = 1, blocklens[1]=1, + offsets[0] = 0, offsets[1] = 1(byte), + bas_type[0]=datatype1, + bas_type[1] = datatype2; + + 3) Setting MPI file view with advtype + 4) Writing 2 bytes 1 to 2 using MPI_File_write to a file + 5) File content: + Suppose the fill value of the file is 0(most machines indeed do so) + and Fill value is embraced with "() in the following output: + Expected output should be: + 1,0,2 + + + + However, at some platforms, for example, IBM AIX(at March 23rd, 2005): + the following values were obtained: + 1,2,0 + + The problem is that the displacement of the second derived datatype(datatype2) which formed the final derived datatype(advtype) has been put after the basic datatype(MPI_BYTE) of datatype2. This is a bug. -2. This test will verify whether the complicated derived datatype is working on -the current platform. + 2. This test will verify whether the complicated derived datatype is working on + the current platform. -If this bug has been fixed in the previous not-working package, this test will issue a printf message to tell the developer to change -the configuration specific file of HDF5 so that we can change our configurationsetting to support collective IO for irregular selections. + If this bug has been fixed in the previous not-working package, this test will issue a printf message to tell the developer to change + the configuration specific file of HDF5 so that we can change our configurationsetting to support collective IO for irregular selections. -If it turns out that the previous working MPI-IO package no longer works, this test will also issue a message to inform the corresponding failure so that -we can turn off collective IO support for irregular selections. -*/ + If it turns out that the previous working MPI-IO package no longer works, this test will also issue a message to inform the corresponding failure so that + we can turn off collective IO support for irregular selections. + */ static int test_mpio_derived_dtype(char *filename) { MPI_File fh; char mpi_err_str[MPI_MAX_ERROR_STRING]; - int mpi_err_strlen; - int mpi_err; - int i; - MPI_Datatype etype,filetype; - MPI_Datatype adv_filetype,bas_filetype[2]; - MPI_Datatype filetypenew; - MPI_Offset disp; - MPI_Status Status; - MPI_Aint adv_disp[2]; - MPI_Aint offsets[1]; - int blocklens[1],adv_blocklens[2]; - int count,outcount; - int retcode; - - int mpi_rank,mpi_size; - - char buf[3],outbuf[3] = {0}; + int mpi_err_strlen; + int mpi_err; + int i; + MPI_Datatype etype, filetype; + MPI_Datatype adv_filetype, bas_filetype[2]; + MPI_Datatype filetypenew; + MPI_Offset disp; + MPI_Status Status; + MPI_Aint adv_disp[2]; + MPI_Aint offsets[1]; + int blocklens[1], adv_blocklens[2]; + int count, outcount; + int retcode; + + int mpi_rank, mpi_size; + + char buf[3], outbuf[3] = { 0 }; MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); retcode = 0; - for(i=0;i<3;i++) - buf[i] = i+1; - + for (i = 0; i < 3; i++) + buf[i] = i + 1; if ((mpi_err = MPI_File_open(MPI_COMM_WORLD, filename, - MPI_MODE_RDWR | MPI_MODE_CREATE, - MPI_INFO_NULL, &fh)) - != MPI_SUCCESS){ - MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - printf("MPI_File_open failed (%s)\n", mpi_err_str); - return 1; + MPI_MODE_RDWR | MPI_MODE_CREATE, MPI_INFO_NULL, &fh)) + != MPI_SUCCESS) { + MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); + printf("MPI_File_open failed (%s)\n", mpi_err_str); + return 1; } - disp = 0; + disp = 0; etype = MPI_BYTE; count = 1; blocklens[0] = 1; - offsets[0] = 0; + offsets[0] = 0; - if((mpi_err= MPI_Type_create_hindexed(count,blocklens,offsets,MPI_BYTE,&filetype)) - != MPI_SUCCESS){ - MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - printf("MPI_Type_contiguous failed (%s)\n", mpi_err_str); - return 1; + if ((mpi_err = MPI_Type_create_hindexed(count, blocklens, offsets, MPI_BYTE, + &filetype)) != MPI_SUCCESS) { + MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); + printf("MPI_Type_contiguous failed (%s)\n", mpi_err_str); + return 1; } - if((mpi_err=MPI_Type_commit(&filetype))!=MPI_SUCCESS){ + if ((mpi_err = MPI_Type_commit(&filetype)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - printf("MPI_Type_commit failed (%s)\n", mpi_err_str); - return 1; + printf("MPI_Type_commit failed (%s)\n", mpi_err_str); + return 1; } count = 1; - blocklens[0]=1; + blocklens[0] = 1; offsets[0] = 1; - if((mpi_err= MPI_Type_create_hindexed(count,blocklens,offsets,MPI_BYTE,&filetypenew)) - != MPI_SUCCESS){ - MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - printf("MPI_Type_contiguous failed (%s)\n", mpi_err_str); - return 1; + if ((mpi_err = MPI_Type_create_hindexed(count, blocklens, offsets, MPI_BYTE, + &filetypenew)) != MPI_SUCCESS) { + MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); + printf("MPI_Type_contiguous failed (%s)\n", mpi_err_str); + return 1; } - if((mpi_err=MPI_Type_commit(&filetypenew))!=MPI_SUCCESS){ + if ((mpi_err = MPI_Type_commit(&filetypenew)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - printf("MPI_Type_commit failed (%s)\n", mpi_err_str); - return 1; + printf("MPI_Type_commit failed (%s)\n", mpi_err_str); + return 1; } - outcount = 2; + outcount = 2; adv_blocklens[0] = 1; adv_blocklens[1] = 1; - adv_disp[0] = 0; - adv_disp[1] = 1; - bas_filetype[0] = filetype; - bas_filetype[1] = filetypenew; - - if((mpi_err= MPI_Type_create_struct(outcount,adv_blocklens,adv_disp,bas_filetype,&adv_filetype)) - != MPI_SUCCESS){ - MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - printf("MPI_Type_create_struct failed (%s)\n", mpi_err_str); - return 1; + adv_disp[0] = 0; + adv_disp[1] = 1; + bas_filetype[0] = filetype; + bas_filetype[1] = filetypenew; + + if ((mpi_err = MPI_Type_create_struct(outcount, adv_blocklens, adv_disp, + bas_filetype, &adv_filetype)) != MPI_SUCCESS) { + MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); + printf("MPI_Type_create_struct failed (%s)\n", mpi_err_str); + return 1; } - if((mpi_err=MPI_Type_commit(&adv_filetype))!=MPI_SUCCESS){ + if ((mpi_err = MPI_Type_commit(&adv_filetype)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - printf("MPI_Type_commit failed (%s)\n", mpi_err_str); - return 1; + printf("MPI_Type_commit failed (%s)\n", mpi_err_str); + return 1; } - - if((mpi_err = MPI_File_set_view(fh,disp,etype,adv_filetype,"native",MPI_INFO_NULL))!= MPI_SUCCESS){ - MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - printf("MPI_File_set_view failed (%s)\n", mpi_err_str); - return 1; + if ((mpi_err = MPI_File_set_view(fh, disp, etype, adv_filetype, "native", + MPI_INFO_NULL)) != MPI_SUCCESS) { + MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); + printf("MPI_File_set_view failed (%s)\n", mpi_err_str); + return 1; } - if((mpi_err = MPI_File_write(fh,buf,3,MPI_BYTE,&Status))!= MPI_SUCCESS){ + if ((mpi_err = MPI_File_write(fh, buf, 3, MPI_BYTE, &Status)) + != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - printf("MPI_File_write failed (%s)\n", mpi_err_str); - return 1; - ; + printf("MPI_File_write failed (%s)\n", mpi_err_str); + return 1; } - - if((mpi_err = MPI_File_close(&fh)) != MPI_SUCCESS){ - MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - printf("MPI_File_close failed (%s)\n", mpi_err_str); - return 1; + if ((mpi_err = MPI_File_close(&fh)) != MPI_SUCCESS) { + MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); + printf("MPI_File_close failed (%s)\n", mpi_err_str); + return 1; } - - if((mpi_err = MPI_File_open(MPI_COMM_WORLD,filename,MPI_MODE_RDONLY,MPI_INFO_NULL,&fh)) != MPI_SUCCESS){ - MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - printf("MPI_File_open failed (%s)\n", mpi_err_str); - return 1; + if ((mpi_err = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, + MPI_INFO_NULL, &fh)) != MPI_SUCCESS) { + MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); + printf("MPI_File_open failed (%s)\n", mpi_err_str); + return 1; } - if((mpi_err = MPI_File_set_view(fh,0,MPI_BYTE,MPI_BYTE,"native",MPI_INFO_NULL))!= MPI_SUCCESS){ + if ((mpi_err = MPI_File_set_view(fh, 0, MPI_BYTE, MPI_BYTE, "native", + MPI_INFO_NULL)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - printf("MPI_File_set_view failed (%s)\n", mpi_err_str); - return 1; + printf("MPI_File_set_view failed (%s)\n", mpi_err_str); + return 1; } - if((mpi_err = MPI_File_read(fh,outbuf,3,MPI_BYTE,&Status))!=MPI_SUCCESS){ - MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - printf("MPI_File_read failed (%s)\n", mpi_err_str); - return 1; + if ((mpi_err = MPI_File_read(fh, outbuf, 3, MPI_BYTE, &Status)) + != MPI_SUCCESS) { + MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); + printf("MPI_File_read failed (%s)\n", mpi_err_str); + return 1; } - if(outbuf[2]==2) { - retcode = 0; - } - else { -/* if(mpi_rank == 0) { - printf("complicated derived datatype is NOT working at this platform\n"); - printf("go back to hdf5/config and find the corresponding\n"); - printf("configure-specific file and change ?????\n"); - } -*/ - retcode = -1; - } - - if((mpi_err = MPI_File_close(&fh)) != MPI_SUCCESS){ - MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - printf("MPI_File_close failed (%s)\n", mpi_err_str); - return 1; + if (outbuf[2] == 2) { + retcode = 0; + } else { + /* if(mpi_rank == 0) { + printf("complicated derived datatype is NOT working at this platform\n"); + printf("go back to hdf5/config and find the corresponding\n"); + printf("configure-specific file and change ?????\n"); + } + */ + retcode = -1; } + if ((mpi_err = MPI_File_close(&fh)) != MPI_SUCCESS) { + MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); + printf("MPI_File_close failed (%s)\n", mpi_err_str); + return 1; + } mpi_err = MPI_Barrier(MPI_COMM_WORLD); - if(retcode == -1) { - if(mpi_rank == 0) { - printf("Complicated derived datatype is NOT working at this platform\n"); - printf(" Please report to help@hdfgroup.org about this problem.\n"); - } - retcode = 1; + if (retcode == -1) { + if (mpi_rank == 0) { + printf( + "Complicated derived datatype is NOT working at this platform\n"); + printf(" Please report to help@hdfgroup.org about this problem.\n"); + } + retcode = 1; } return retcode; } /* -Function: test_mpio_special_collective + Function: test_mpio_special_collective -Test Whether collective IO is still working when more than one process -has no contribution to IO. To properly test this case, at least FOUR -processes are needed. + Test Whether collective IO is still working when more than one process + has no contribution to IO. To properly test this case, at least FOUR + processes are needed. -1. Details for the test: -1) Create one derived datatype with MPI_Type_create_hindexed: + 1. Details for the test: + 1) Create one derived datatype with MPI_Type_create_hindexed: -2) Choosing at least two processes to contribute none for IO with - the buf size inside MPI_Write_at_all to 0. -3) Choosing at least two processes to have real contributions for IO. -4) Do collective IO. + 2) Choosing at least two processes to contribute none for IO with + the buf size inside MPI_Write_at_all to 0. + 3) Choosing at least two processes to have real contributions for IO. + 4) Do collective IO. -2. This test will fail with the MPI-IO package that doesn't support this. For example, -mpich 1.2.6. + 2. This test will fail with the MPI-IO package that doesn't support this. For example, + mpich 1.2.6. -If this bug has been fixed in the previous not-working package, this test will issue a printf message to tell the developer to change -the configuration specific file of HDF5 so that we can change our configurationsetting to support special collective IO; currently only special collective IO. + If this bug has been fixed in the previous not-working package, this test will issue a printf message to tell the developer to change + the configuration specific file of HDF5 so that we can change our configurationsetting to support special collective IO; currently only special collective IO. -If it turns out that the previous working MPI-IO package no longer works, this test will also issue a message to inform the corresponding failure so that -we can turn off the support for special collective IO; currently only special collective IO. -*/ + If it turns out that the previous working MPI-IO package no longer works, this test will also issue a message to inform the corresponding failure so that + we can turn off the support for special collective IO; currently only special collective IO. + */ -static int -test_mpio_special_collective(char *filename) -{ - int mpi_size, mpi_rank; +static int test_mpio_special_collective(char *filename) { + int mpi_size, mpi_rank; MPI_File fh; - MPI_Datatype etype,buftype,filetype; + MPI_Datatype etype, buftype, filetype; char mpi_err_str[MPI_MAX_ERROR_STRING]; - int mpi_err_strlen; - int mpi_err; - char writedata[2*DIMSIZE]; + int mpi_err_strlen; + int mpi_err; + char writedata[2 * DIMSIZE]; char filerep[7] = "native"; - int i; - int count,bufcount; + int i; + int count, bufcount; int blocklens[2]; MPI_Aint offsets[2]; - MPI_Offset mpi_off = 0; - MPI_Status mpi_stat; - int retcode = 0; + MPI_Offset mpi_off = 0; + MPI_Status mpi_stat; + int retcode = 0; MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* create MPI data type */ etype = MPI_BYTE; - if(mpi_rank == 0 || mpi_rank == 1) { + if (mpi_rank == 0 || mpi_rank == 1) { count = DIMSIZE; bufcount = 1; } /* end if */ @@ -892,38 +890,32 @@ test_mpio_special_collective(char *filename) } /* end else */ blocklens[0] = count; - offsets[0] = mpi_rank*count; + offsets[0] = mpi_rank * count; blocklens[1] = count; - offsets[1] = (mpi_size+mpi_rank)*count; - - if(count !=0) { - if((mpi_err = MPI_Type_create_hindexed(2, - blocklens, - offsets, - etype, - &filetype)) != MPI_SUCCESS) { + offsets[1] = (mpi_size + mpi_rank) * count; + + if (count != 0) { + if ((mpi_err = MPI_Type_create_hindexed(2, blocklens, offsets, etype, + &filetype)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); printf("MPI_Type_contiguous failed (%s)\n", mpi_err_str); return 1; } /* end if */ - if((mpi_err = MPI_Type_commit(&filetype)) != MPI_SUCCESS) { + if ((mpi_err = MPI_Type_commit(&filetype)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); printf("MPI_Type_commit failed (%s)\n", mpi_err_str); return 1; } /* end if */ - if((mpi_err = MPI_Type_create_hindexed(2, - blocklens, - offsets, - etype, - &buftype)) != MPI_SUCCESS) { + if ((mpi_err = MPI_Type_create_hindexed(2, blocklens, offsets, etype, + &buftype)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); printf("MPI_Type_contiguous failed (%s)\n", mpi_err_str); return 1; } /* end if */ - if((mpi_err = MPI_Type_commit(&buftype)) != MPI_SUCCESS) { + if ((mpi_err = MPI_Type_commit(&buftype)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); printf("MPI_Type_commit failed (%s)\n", mpi_err_str); return 1; @@ -931,46 +923,36 @@ test_mpio_special_collective(char *filename) } /* end if */ else { filetype = MPI_BYTE; - buftype = MPI_BYTE; + buftype = MPI_BYTE; } /* end else */ /* Open a file */ - if ((mpi_err = MPI_File_open(MPI_COMM_WORLD, - filename, - MPI_MODE_RDWR | MPI_MODE_CREATE, - MPI_INFO_NULL, - &fh)) != MPI_SUCCESS) { + if ((mpi_err = MPI_File_open(MPI_COMM_WORLD, filename, + MPI_MODE_RDWR | MPI_MODE_CREATE, MPI_INFO_NULL, &fh)) + != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); printf("MPI_File_open failed (%s)\n", mpi_err_str); return 1; } /* end if */ /* each process writes some data */ - for (i=0; i < 2*DIMSIZE; i++) - writedata[i] = (char)(mpi_rank*DIMSIZE + i); + for (i = 0; i < 2 * DIMSIZE; i++) + writedata[i] = (char) (mpi_rank * DIMSIZE + i); /* Set the file view */ - if((mpi_err = MPI_File_set_view(fh, - mpi_off, - MPI_BYTE, - filetype, - filerep, - MPI_INFO_NULL)) != MPI_SUCCESS) { + if ((mpi_err = MPI_File_set_view(fh, mpi_off, MPI_BYTE, filetype, filerep, + MPI_INFO_NULL)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); printf("MPI_File_set_view failed (%s)\n", mpi_err_str); return 1; } /* end if */ /* Collectively write into the file */ - if ((mpi_err = MPI_File_write_at_all(fh, - mpi_off, - writedata, - bufcount, - buftype, - &mpi_stat)) != MPI_SUCCESS) { + if ((mpi_err = MPI_File_write_at_all(fh, mpi_off, writedata, bufcount, + buftype, &mpi_stat)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); printf("MPI_File_write_at offset(%ld), bytes (%d), failed (%s)\n", - (long) mpi_off, bufcount, mpi_err_str); + (long) mpi_off, bufcount, mpi_err_str); return 1; } /* end if */ @@ -983,8 +965,8 @@ test_mpio_special_collective(char *filename) /* Perform a barrier */ mpi_err = MPI_Barrier(MPI_COMM_WORLD); - if(retcode != 0) { - if(mpi_rank == 0) { + if (retcode != 0) { + if (mpi_rank == 0) { printf("special collective IO is NOT working at this platform\n"); printf(" Please report to help@hdfgroup.org about this problem.\n"); } /* end if */ @@ -998,71 +980,69 @@ test_mpio_special_collective(char *filename) /* * parse the command line options */ -static int -parse_options(int argc, char **argv) -{ - while (--argc){ - if (**(++argv) != '-'){ - break; - }else{ - switch(*(*argv+1)){ - case 'v': if (*((*argv+1)+1)) - ParseTestVerbosity((*argv+1)+1); - else - SetTestVerbosity(VERBO_MED); - break; - case 'f': if (--argc < 1) { - nerrors++; - return(1); - } - if (**(++argv) == '-') { - nerrors++; - return(1); - } - paraprefix = *argv; - break; - case 'h': /* print help message--return with nerrors set */ - return(1); - default: nerrors++; - return(1); - } - } +static int parse_options(int argc, char **argv) { + while (--argc) { + if (**(++argv) != '-') { + break; + } else { + switch (*(*argv + 1)) { + case 'v': + if (*((*argv + 1) + 1)) + ParseTestVerbosity((*argv + 1) + 1); + else + SetTestVerbosity(VERBO_MED); + break; + case 'f': + if (--argc < 1) { + nerrors++; + return (1); + } + if (**(++argv) == '-') { + nerrors++; + return (1); + } + paraprefix = *argv; + break; + case 'h': /* print help message--return with nerrors set */ + return (1); + default: + nerrors++; + return (1); + } + } } /*while*/ /* compose the test filenames */ { - int i, n; - hid_t plist; - - plist = H5Pcreate (H5P_FILE_ACCESS); - H5Pset_fapl_mpio(plist, MPI_COMM_WORLD, MPI_INFO_NULL); - n = sizeof(FILENAME)/sizeof(FILENAME[0]) - 1; /* exclude the NULL */ - - for (i=0; i < n; i++) - if (h5_fixname(FILENAME[i],plist,filenames[i],sizeof(filenames[i])) - == NULL){ - printf("h5_fixname failed\n"); - nerrors++; - return(1); - } - H5Pclose(plist); - if (VERBOSE_MED){ - printf("Test filenames are:\n"); - for (i=0; i < n; i++) - printf(" %s\n", filenames[i]); - } + int i, n; + hid_t plist; + + plist = H5Pcreate(H5P_FILE_ACCESS); + H5Pset_fapl_mpio(plist, MPI_COMM_WORLD, MPI_INFO_NULL); + n = sizeof(FILENAME) / sizeof(FILENAME[0]) - 1; /* exclude the NULL */ + + for (i = 0; i < n; i++) + if (h5_fixname(FILENAME[i], plist, filenames[i], + sizeof(filenames[i])) == NULL) { + printf("h5_fixname failed\n"); + nerrors++; + return (1); + } + H5Pclose(plist); + if (VERBOSE_MED) { + printf("Test filenames are:\n"); + for (i = 0; i < n; i++) + printf(" %s\n", filenames[i]); + } } - return(0); + return (0); } - /* * Show command usage */ -static void -usage(void) -{ +static void usage(void) { printf("Usage: t_mpi [-v] [-f ]\n"); printf("\t-v\tset verbose level (0-9,l,m,h)\n"); printf("\t-f \tfilename prefix\n"); @@ -1072,19 +1052,14 @@ usage(void) /* * return the sum of all errors. */ -static int -errors_sum(int nerrs) -{ +static int errors_sum(int nerrs) { int temp; MPI_Allreduce(&nerrs, &temp, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); - return(temp); + return (temp); } - -int -main(int argc, char **argv) -{ - int mpi_size, mpi_rank; /* mpi variables */ +int main(int argc, char **argv) { + int mpi_size, mpi_rank; /* mpi variables */ int ret_code; MPI_Init(&argc, &argv); @@ -1092,78 +1067,76 @@ main(int argc, char **argv) MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* Attempt to turn off atexit post processing so that in case errors - * happen during the test and the process is aborted, it will not get - * hang in the atexit post processing in which it may try to make MPI - * calls. By then, MPI calls may not work. - */ - if (H5dont_atexit() < 0){ - printf("Failed to turn off atexit processing. Continue.\n"); + * happen during the test and the process is aborted, it will not get + * hang in the atexit post processing in which it may try to make MPI + * calls. By then, MPI calls may not work. + */ + if (H5dont_atexit() < 0) { + printf("Failed to turn off atexit processing. Continue.\n"); }; H5open(); - if (parse_options(argc, argv) != 0){ - if (MAINPROCESS) - usage(); - goto finish; + if (parse_options(argc, argv) != 0) { + if (MAINPROCESS) + usage(); + goto finish; } - if (MAINPROCESS){ - printf("===================================\n"); - printf("MPI functionality tests\n"); - printf("===================================\n"); + if (MAINPROCESS) { + printf("===================================\n"); + printf("MPI functionality tests\n"); + printf("===================================\n"); } if (VERBOSE_MED) - h5_show_hostname(); + h5_show_hostname(); - fapl = H5Pcreate (H5P_FILE_ACCESS); + fapl = H5Pcreate(H5P_FILE_ACCESS); H5Pset_fapl_mpio(fapl, MPI_COMM_WORLD, MPI_INFO_NULL); /* set alarm. */ ALARM_ON; - /*======================================= - * MPIO 1 write Many read test - *=======================================*/ + * MPIO 1 write Many read test + *=======================================*/ MPI_BANNER("MPIO 1 write Many read test..."); ret_code = test_mpio_1wMr(filenames[0], USENONE); ret_code = errors_sum(ret_code); - if (mpi_rank==0 && ret_code > 0){ - printf("***FAILED with %d total errors\n", ret_code); - nerrors += ret_code; + if (mpi_rank == 0 && ret_code > 0) { + printf("***FAILED with %d total errors\n", ret_code); + nerrors += ret_code; } /* test atomicity and file sync in high verbose mode only */ /* since they often hang when broken and PHDF5 does not use them. */ - if (VERBOSE_HI){ - MPI_BANNER("MPIO 1 write Many read test with atomicity..."); - ret_code = test_mpio_1wMr(filenames[0], USEATOM); - ret_code = errors_sum(ret_code); - if (mpi_rank==0 && ret_code > 0){ - printf("***FAILED with %d total errors\n", ret_code); - nerrors += ret_code; - } - - MPI_BANNER("MPIO 1 write Many read test with file sync..."); - ret_code = test_mpio_1wMr(filenames[0], USEFSYNC); - ret_code = errors_sum(ret_code); - if (mpi_rank==0 && ret_code > 0){ - printf("***FAILED with %d total errors\n", ret_code); - nerrors += ret_code; - } - } + if (VERBOSE_HI) { + MPI_BANNER("MPIO 1 write Many read test with atomicity..."); + ret_code = test_mpio_1wMr(filenames[0], USEATOM); + ret_code = errors_sum(ret_code); + if (mpi_rank == 0 && ret_code > 0) { + printf("***FAILED with %d total errors\n", ret_code); + nerrors += ret_code; + } + MPI_BANNER("MPIO 1 write Many read test with file sync..."); + ret_code = test_mpio_1wMr(filenames[0], USEFSYNC); + ret_code = errors_sum(ret_code); + if (mpi_rank == 0 && ret_code > 0) { + printf("***FAILED with %d total errors\n", ret_code); + nerrors += ret_code; + } + } /*======================================= - * MPIO MPIO File size range test - *=======================================*/ + * MPIO MPIO File size range test + *=======================================*/ MPI_BANNER("MPIO File size range test..."); #ifndef H5_HAVE_WIN32_API ret_code = test_mpio_gb_file(filenames[0]); ret_code = errors_sum(ret_code); - if (mpi_rank==0 && ret_code > 0){ - printf("***FAILED with %d total errors\n", ret_code); - nerrors += ret_code; + if (mpi_rank == 0 && ret_code > 0) { + printf("***FAILED with %d total errors\n", ret_code); + nerrors += ret_code; } #else if (mpi_rank==0) @@ -1171,30 +1144,30 @@ main(int argc, char **argv) #endif /*======================================= - * MPIO independent overlapping writes - *=======================================*/ + * MPIO independent overlapping writes + *=======================================*/ MPI_BANNER("MPIO independent overlapping writes..."); ret_code = test_mpio_overlap_writes(filenames[0]); ret_code = errors_sum(ret_code); - if (mpi_rank==0 && ret_code > 0){ - printf("***FAILED with %d total errors\n", ret_code); - nerrors += ret_code; + if (mpi_rank == 0 && ret_code > 0) { + printf("***FAILED with %d total errors\n", ret_code); + nerrors += ret_code; } /*======================================= - * MPIO complicated derived datatype test - *=======================================*/ + * MPIO complicated derived datatype test + *=======================================*/ MPI_BANNER("MPIO complicated derived datatype test..."); ret_code = test_mpio_derived_dtype(filenames[0]); ret_code = errors_sum(ret_code); - if (mpi_rank==0 && ret_code > 0){ - printf("***FAILED with %d total errors\n", ret_code); - nerrors += ret_code; + if (mpi_rank == 0 && ret_code > 0) { + printf("***FAILED with %d total errors\n", ret_code); + nerrors += ret_code; } /*======================================= - * MPIO special collective IO test - *=======================================*/ + * MPIO special collective IO test + *=======================================*/ if (mpi_size < 4) { MPI_BANNER("MPIO special collective io test SKIPPED."); if (mpi_rank == 0) @@ -1206,28 +1179,26 @@ main(int argc, char **argv) MPI_BANNER("MPIO special collective io test..."); ret_code = test_mpio_special_collective(filenames[0]); -sc_finish: - ret_code = errors_sum(ret_code); - if (mpi_rank==0 && ret_code > 0){ - printf("***FAILED with %d total errors\n", ret_code); - nerrors += ret_code; + sc_finish: ret_code = errors_sum(ret_code); + if (mpi_rank == 0 && ret_code > 0) { + printf("***FAILED with %d total errors\n", ret_code); + nerrors += ret_code; } - -finish: + finish: /* make sure all processes are finished before final report, cleanup - * and exit. - */ + * and exit. + */ MPI_Barrier(MPI_COMM_WORLD); - if (MAINPROCESS){ /* only process 0 reports */ - printf("===================================\n"); - if (nerrors){ - printf("***MPI tests detected %d errors***\n", nerrors); - } - else{ - printf("MPI tests finished with no errors\n"); - } - printf("===================================\n"); + if (MAINPROCESS) { /* only process 0 reports */ + printf("===================================\n"); + if (nerrors) { + printf("***MPI tests detected %d errors***\n", nerrors); + } + else { + printf("MPI tests finished with no errors\n"); + } + printf("===================================\n"); } /* turn off alarm */ @@ -1240,6 +1211,6 @@ finish: MPI_Finalize(); /* cannot just return (nerrors) because exit code is limited to 1byte */ - return(nerrors!=0); + return (nerrors != 0); } -- cgit v0.12 From 88ab4b144bcf8454be9eff8800706c0abb404de1 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 9 Jul 2019 12:07:41 -0500 Subject: fix var name --- testpar/t_mpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testpar/t_mpi.c b/testpar/t_mpi.c index 157a09f..41acf7a 100644 --- a/testpar/t_mpi.c +++ b/testpar/t_mpi.c @@ -460,7 +460,7 @@ static int test_mpio_1wMr(char *filename, int special_request) { /* show the hostname so that we can tell where the processes are running */ if (VERBOSE_DEF) { #ifdef H5_HAVE_GETHOSTNAME - if(HDgethostname(hostname, sizeof(host_name)) < 0) { + if(HDgethostname(hostname, sizeof(hostname)) < 0) { printf("gethostname failed\n"); hostname[0] = '\0'; } -- cgit v0.12