diff --git a/CMakeLists.txt b/CMakeLists.txt index 89463224a89678ee16c84af00e469d88ec185054..0fbada3757ab7ac6375e1d974a64216b3e499a41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,7 @@ if(ADIOS_USE_MPI) endif() option(ADIOS_USE_BZip2 "Enable support for BZip2 transforms" OFF) option(ADIOS_USE_ADIOS1 "Enable support for the ADIOS 1 engine" OFF) +option(ADIOS_USE_HDF5 "Enable support for the HDF5 engine" OFF) # DataMan is not a user-settable option. It will always be enabled if the # platform supports it. @@ -137,5 +138,5 @@ message(" MPI: ${ADIOS_USE_MPI}") message(" BZip2: ${ADIOS_USE_BZip2}") message(" ADIOS1: ${ADIOS_USE_ADIOS1}") message(" DataMan: ${ADIOS_USE_DataMan}") -message(" HDF5: ${ADIOS_USE_PHDF5}") +message(" HDF5: ${ADIOS_USE_HDF5}") message("") diff --git a/cmake/FindADIOS1.cmake b/cmake/FindADIOS1.cmake index 867539a498b8790715137ff3e2d7725fe493b1c7..c40191677ef30d9995f8777c4a4161e64678130d 100644 --- a/cmake/FindADIOS1.cmake +++ b/cmake/FindADIOS1.cmake @@ -83,159 +83,105 @@ ############################################################################### -############################################################################### -# Required cmake version -############################################################################### - -cmake_minimum_required(VERSION 2.8.5) - - ############################################################################### # ADIOS ############################################################################### # get flags for adios_config, -l is the default #-f for fortran, -r for readonly, -s for sequential (nompi) -set(OPTLIST "-l") if(ADIOS1_FIND_COMPONENTS) - foreach(COMP ${ADIOS1_FIND_COMPONENTS}) - string(TOLOWER ${COMP} comp) - if(comp STREQUAL "fortran") - set(OPTLIST "${OPTLIST}f") - elseif(comp STREQUAL "readonly") - set(OPTLIST "${OPTLIST}r") - elseif(comp STREQUAL "sequential") - set(OPTLIST "${OPTLIST}s") - else() - message("ADIOS 1.x component ${COMP} is not supported. Please use fortran, readonly, or sequential") - endif() - endforeach() + foreach(comp IN LISTS ADIOS1_FIND_COMPONENTS) + string(TOLOWER "${comp}" comp) + if(comp STREQUAL "fortran") + set(adios1_config_opt "-f") + elseif(comp STREQUAL "readonly") + set(adios1_config_opt "-r") + elseif(comp STREQUAL "sequential") + set(adios1_config_opt "-s") + else() + message("ADIOS 1.x component ${comp} is not supported. Please use fortran, readonly, or sequential") + endif() + endforeach() endif() -# we start by assuming we found ADIOS and falsify it if some -# dependencies are missing (or if we did not find ADIOS at all) -set(ADIOS1_FOUND TRUE) - +set(adios1_config_hints) +foreach(PREFIX_VAR IN ITEMS ADIOS1_ROOT ADIOS1_DIR INSTALL_PREFIX) + if(${PREFIX_VAR}) + list(APPEND adios1_config_hints "${${PREFIX_VAR}}/bin") + elseif("$ENV{${PREFIX_VAR}}") + list(APPEND adios1_config_hints "$ENV{${PREFIX_VAR}}/bin") + endif() +endforeach() # find `adios_config` program ################################################# -# check the ADIOS1_ROOT and ADIOS1_DIR hint and the normal PATH -find_file(ADIOS1_CONFIG - NAME adios_config - PATHS $ENV{ADIOS1_ROOT}/bin $ENV{ADIOS1_DIR}/bin $ENV{INSTALL_PREFIX}/bin $ENV{PATH}) - -if(ADIOS1_CONFIG) - message(STATUS "Found 'adios_config': ${ADIOS1_CONFIG}") -else(ADIOS1_CONFIG) - set(ADIOS1_FOUND FALSE) - message(STATUS "Can NOT find 'adios_config' - set ADIOS1_ROOT, ADIOS1_DIR or INSTALL_PREFIX, or check your PATH") -endif(ADIOS1_CONFIG) +find_program(ADIOS1_CONFIG NAME adios_config HINTS ${adios1_config_hints}) # check `adios_config` program ################################################ -if(ADIOS1_FOUND) - execute_process(COMMAND ${ADIOS1_CONFIG} ${OPTLIST} - OUTPUT_VARIABLE ADIOS1_LINKFLAGS - RESULT_VARIABLE ADIOS1_CONFIG_RETURN - OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT ADIOS1_CONFIG_RETURN EQUAL 0) - set(ADIOS1_FOUND FALSE) - message(STATUS "Can NOT execute 'adios_config' - check file permissions") - endif() - - # find ADIOS1_ROOT_DIR - execute_process(COMMAND ${ADIOS1_CONFIG} -d - OUTPUT_VARIABLE ADIOS1_ROOT_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT IS_DIRECTORY "${ADIOS1_ROOT_DIR}") - set(ADIOS1_FOUND FALSE) - message(STATUS "The directory provided by 'adios_config -d' does not exist: ${ADIOS1_ROOT_DIR}") - endif() -endif(ADIOS1_FOUND) - -# option: use only static libs ################################################ -if(ADIOS1_USE_STATIC_LIBS) - # carfully: we have to restore the original path in the end - set(_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - set(CMAKE_FIND_LIBRARY_SUFFIXES .a) -endif() - - -# we found something in ADIOS1_ROOT_DIR and adios_config works ################# -if(ADIOS1_FOUND) - # ADIOS headers - find_path(ADIOS1_INCLUDE_DIRS adios.h - HINTS ${ADIOS1_ROOT_DIR}/include - NO_DEFAULT_PATHS - ) - - # check for compiled in dependencies, recomve ";" in ADIOS1_LINKFLAGS (from cmake build) - string(REGEX REPLACE ";" " " ADIOS1_LINKFLAGS "${ADIOS1_LINKFLAGS}") - message(STATUS " ADIOS1 linker flags (unparsed): ${ADIOS1_LINKFLAGS}") - - # find all library paths -L - # note: this can cause trouble if some libs are specified twice from - # different sources (quite unlikely) - # http://www.cmake.org/pipermail/cmake/2008-November/025128.html - set(ADIOS1_LIBRARY_DIRS "") - string(REGEX MATCHALL " -L([A-Za-z_0-9/\\.-]+)" _ADIOS1_LIBDIRS " ${ADIOS1_LINKFLAGS}") - foreach(_LIBDIR ${_ADIOS1_LIBDIRS}) - string(REPLACE " -L" "" _LIBDIR ${_LIBDIR}) - list(APPEND ADIOS1_LIBRARY_DIRS ${_LIBDIR}) +if(ADIOS1_CONFIG) + execute_process(COMMAND ${ADIOS1_CONFIG} ${adios1_config_opt} + OUTPUT_VARIABLE adios1_config_out + RESULT_VARIABLE adios1_config_ret + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(adios1_config_ret EQUAL 0) + string(REGEX MATCH "CFLAGS=([^\n]*)" adios1_match "${adios1_config_out}") + string(REPLACE " " ";" adios1_match "${CMAKE_MATCH_1}") + set(adios1_include_hints) + set(ADIOS1_COMPILE_OPTIONS) + foreach(OPT IN LISTS adios1_match) + if(OPT MATCHES "^-I(.*)") + list(APPEND adios1_include_hints "${CMAKE_MATCH_1}") + else() + list(APPEND ADIOS1_COMPILE_OPTIONS ${OPT}) + endif() endforeach() - # we could append ${CMAKE_PREFIX_PATH} now but that is not really necessary - - #message(STATUS "ADIOS1 DIRS to look for libs: ${ADIOS1_LIBRARY_DIRS}") - - # parse all -lname libraries and find an absolute path for them - string(REGEX MATCHALL " -l([A-Za-z_0-9\\.-]+)" _ADIOS1_LIBS " ${ADIOS1_LINKFLAGS}") - foreach(_LIB ${_ADIOS1_LIBS}) - string(REPLACE " -l" "" _LIB ${_LIB}) - - # find static lib: absolute path in -L then default - find_library(_LIB_DIR NAMES ${_LIB} PATHS ${ADIOS1_LIBRARY_DIRS} CMAKE_FIND_ROOT_PATH_BOTH) - - # found? - if(_LIB_DIR) - if(_LIB STREQUAL "adios") - message(STATUS " Found the main adios library in ${_LIB_DIR}") - set(ADIOS1_LIBRARY_PATH "${_LIB_DIR}") - #message(STATUS " ADIOS1_LIBRARY_PATH set to ${ADIOS1_LIBRARY_PATH}") - else() - message(STATUS " Found ${_LIB} in ${_LIB_DIR}") - list(APPEND ADIOS1_DEPENDENCY_LIBRARIES "${_LIB_DIR}") - endif() - else(_LIB_DIR) - set(ADIOS1_FOUND FALSE) - message(STATUS "ADIOS1: Could NOT find library '${_LIB}'") - endif(_LIB_DIR) - - # clean cached var - unset(_LIB_DIR CACHE) - unset(_LIB_DIR) + string(REGEX MATCH "LDFLAGS=([^\n]*)" adios1_match "${adios1_config_out}") + string(REPLACE " " ";" adios1_match "${CMAKE_MATCH_1}") + set(adios1_libs) + set(adios1_lib_hints) + set(adios1_lib_flags) + foreach(OPT IN LISTS adios1_match) + if(OPT MATCHES "^-L(.*)") + list(APPEND adios1_lib_hints "${CMAKE_MATCH_1}") + elseif(OPT MATCHES "^-l(.*)") + list(APPEND adios1_libs "${CMAKE_MATCH_1}") + else() + list(APPEND adios1_lib_flags "${OPT}") + endif() endforeach() + endif() - #add libraries which are already using cmake format - string(REGEX MATCHALL "/([A-Za-z_0-9/\\.-]+)\\.([a|so]+)" _ADIOS1_LIBS_SUB "${ADIOS1_LINKFLAGS}") - list(APPEND ADIOS1_DEPENDENCY_LIBRARIES "${_ADIOS1_LIBS_SUB}") - - # add the version string - execute_process(COMMAND ${ADIOS1_CONFIG} -v - OUTPUT_VARIABLE ADIOS1_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) - -endif(ADIOS1_FOUND) - -# unset checked variables if not found -if(NOT ADIOS1_FOUND) - unset(ADIOS1_INCLUDE_DIRS) - unset(ADIOS1_DEPENDENCY_LIBRARIES) - unset(ADIOS1_LIBRARY_PATH) -endif(NOT ADIOS1_FOUND) - + # add the version string + execute_process(COMMAND ${ADIOS1_CONFIG} -v + OUTPUT_VARIABLE ADIOS1_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ) +endif() -# restore CMAKE_FIND_LIBRARY_SUFFIXES if manipulated by this module ########### -if(ADIOS1_USE_STATIC_LIBS) - set(CMAKE_FIND_LIBRARY_SUFFIXES ${_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) +# make suree at the very least we find libadios +if(NOT adios1_libs) + set(adios1_libs adios) endif() +# Search for the actual libs and headers to ue based on hints from the config +find_path(ADIOS1_INCLUDE_DIR adios.h HINTS ${adios1_include_hints}) + +set(ADIOS1_LIBRARY) +set(ADIOS1_DEPENDENCIES) +foreach(lib IN LISTS adios1_libs) + find_library(ADIOS1_${lib}_LIBRARY NAME ${lib} HINTS ${adios1_lib_hints}) + if(ADIOS1_${lib}_LIBRARY) + if(lib MATCHES "^adios") + set(ADIOS1_LIBRARY ${ADIOS1_${lib}_LIBRARY}) + else() + list(APPEND ADIOS1_DEPENDENCIES ${ADIOS1_${lib}_LIBRARY}) + endif() + else() + list(APPEND ADIOS1_DEPENDENCIES ${lib}) + endif() +endforeach() + +find_package(Threads REQUIRED) +list(APPEND ADIOS1_DEPENDENCIES ${adios1_lib_flags} ${CMAKE_THREAD_LIBS_INIT}) ############################################################################### # FindPackage Options @@ -244,20 +190,24 @@ endif() # handles the REQUIRED, QUIET and version-related arguments for find_package include(FindPackageHandleStandardArgs) find_package_handle_standard_args(ADIOS1 - REQUIRED_VARS ADIOS1_LIBRARY_PATH ADIOS1_DEPENDENCY_LIBRARIES ADIOS1_INCLUDE_DIRS - VERSION_VAR ADIOS1_VERSION + REQUIRED_VARS ADIOS1_LIBRARY ADIOS1_INCLUDE_DIR + VERSION_VAR ADIOS1_VERSION ) -########################################################################## -# Add target and dependencies to ADIOS2 -########################################################################## -#message(STATUS "ADIOS1 Find ended with ${ADIOS1_FOUND}") - if(ADIOS1_FOUND AND NOT TARGET adios1::adios) - message(STATUS "Add library ADIOS1 to the build") - add_library(adios1::adios UNKNOWN IMPORTED) - set_target_properties(adios1::adios PROPERTIES - IMPORTED_LOCATION "${ADIOS1_LIBRARY_PATH}" - INTERFACE_LINK_LIBRARIES "${ADIOS1_DEPENDENCY_LIBRARIES}" - INTERFACE_INCLUDE_DIRECTORIES "${ADIOS1_INCLUDE_DIRS}" - ) - endif() +if(ADIOS1_FOUND) + set(ADIOS1_INCLUDE_DIRS ${ADIOS1_INCLUDE_DIR}) + set(ADIOS1_LIBRARIES ${ADIOS1_LIBRARY} ${ADIOS1_DEPENDENCIES}) + + ########################################################################## + # Add target and dependencies to ADIOS2 + ########################################################################## + if(NOT TARGET adios1::adios) + add_library(adios1::adios UNKNOWN IMPORTED) + set_target_properties(adios1::adios PROPERTIES + IMPORTED_LOCATION "${ADIOS1_LIBRARY}" + INTERFACE_LINK_LIBRARIES "${ADIOS1_DEPENDENCIES}" + INTERFACE_INCLUDE_DIRECTORIES "${ADIOS1_INCLUDE_DIRS}" + INTERFACE_COMPILE_OPTIONS "${ADIOS1_COMPILE_OPTIONS}" + ) + endif() +endif() diff --git a/examples/heatTransfer/read/CMakeLists.txt b/examples/heatTransfer/read/CMakeLists.txt index 8c2486bb7397a00cc4638dfa06ca00c9392ee8c9..7f3e9c4589874abe0d85fc6b7a065ad2fbc7ed4e 100644 --- a/examples/heatTransfer/read/CMakeLists.txt +++ b/examples/heatTransfer/read/CMakeLists.txt @@ -15,13 +15,6 @@ if(ADIOS_USE_MPI) target_link_libraries(heatTransfer_read_adios1 adios1::adios ${MPI_C_LIBRARIES} ) - - if(ADIOS_BUILD_TESTING) - add_test( - NAME Example::heatTransfer::read::adios1 - COMMAND heatRead_adios1 - ) - endif() endif() endif() diff --git a/examples/heatTransfer/write/CMakeLists.txt b/examples/heatTransfer/write/CMakeLists.txt index eb72a2af9bd234c09be42c8b00a69ffbca7114e4..fb0b9f029cec18bc8b2e020d518254f37965f036 100644 --- a/examples/heatTransfer/write/CMakeLists.txt +++ b/examples/heatTransfer/write/CMakeLists.txt @@ -17,13 +17,6 @@ if(ADIOS_USE_MPI) ) target_link_libraries(heatTransfer_write_adios2 adios2 ${MPI_C_LIBRARIES}) - if(ADIOS_BUILD_TESTING) - add_test( - NAME Example::heatTransfer::write::adios2 - COMMAND heatTransfer_write_adios2 - ) - endif() - if(ADIOS_USE_ADIOS1) find_package(ADIOS1 REQUIRED) find_package(MPI COMPONENTS C REQUIRED) @@ -40,12 +33,5 @@ if(ADIOS_USE_MPI) target_link_libraries(heatTransfer_write_adios1 adios1::adios ${MPI_C_LIBRARIES} ) - - if(ADIOS_BUILD_TESTING) - add_test( - NAME Example::heatTransfer::write::adios1 - COMMAND heatTransfer_write_adios1 - ) - endif() endif() endif() diff --git a/examples/heatTransfer/write/main.cpp b/examples/heatTransfer/write/main.cpp index ff1b6c44c9a5e0cbf836f60b475c3190d7e34e8f..657348f1d77654f6792a57c1ea0bbc0da14c8662 100644 --- a/examples/heatTransfer/write/main.cpp +++ b/examples/heatTransfer/write/main.cpp @@ -10,9 +10,7 @@ * Author: Norbert Podhorszki * */ -#define OMPI_SKIP_MPICXX 1 // workaround for OpenMPI forcing C++ bindings #include <mpi.h> -#undef OMPI_SKIP_MPICXX #include <iostream> #include <memory> diff --git a/examples/hello/CMakeLists.txt b/examples/hello/CMakeLists.txt index 73fa0f560c36f0c1c0f1744cb44a90f7f7df6ba2..6719c2042ff03407a28f5e4e27c7402a2463c5d2 100644 --- a/examples/hello/CMakeLists.txt +++ b/examples/hello/CMakeLists.txt @@ -15,6 +15,6 @@ if(ADIOS_USE_DataMan) add_subdirectory(datamanWriter) endif() -if(ADIOS_USE_PHDF5) +if(ADIOS_USE_HDF5) add_subdirectory(hdf5Writer) endif() diff --git a/examples/hello/adios1Writer/CMakeLists.txt b/examples/hello/adios1Writer/CMakeLists.txt index b38cfb90d3a153197efaa99f88295187debcfc1b..3f7a4f8a90684c40b3e823c50bd8d75f155ec683 100644 --- a/examples/hello/adios1Writer/CMakeLists.txt +++ b/examples/hello/adios1Writer/CMakeLists.txt @@ -5,10 +5,16 @@ if(ADIOS_USE_MPI) find_package(MPI COMPONENTS C REQUIRED) + add_executable(hello_adios1Writer helloADIOS1Writer.cpp) target_include_directories(hello_adios1Writer PRIVATE ${MPI_C_INCLUDE_PATH}) - target_link_libraries(hello_adios1Writer adios2 ${MPI_C_LIBRARIES}) + target_link_libraries(hello_adios1Writer ${MPI_C_LIBRARIES}) +else() + add_executable(hello_adios1Writer helloADIOS1Writer_nompi.cpp) +endif() +target_link_libraries(hello_adios1Writer adios2) + +if(ADIOS_BUILD_TESTING) + add_test( NAME Example::hello::adios1::write COMMAND hello_adios1Writer) endif() -add_executable(hello_adios1Writer_nompi helloADIOS1Writer_nompi.cpp) -target_link_libraries(hello_adios1Writer_nompi adios2) diff --git a/examples/hello/adios1Writer/helloADIOS1Writer.cpp b/examples/hello/adios1Writer/helloADIOS1Writer.cpp index fc6064b27b8fa5ee50be1a86f9c1b001a3227684..e2dd0bf435869c412bc5622f5d43d8357d4bb0b2 100644 --- a/examples/hello/adios1Writer/helloADIOS1Writer.cpp +++ b/examples/hello/adios1Writer/helloADIOS1Writer.cpp @@ -11,9 +11,7 @@ #include <iostream> #include <vector> -#define OMPI_SKIP_MPICXX 1 // workaround for OpenMPI forcing C++ bindings #include <mpi.h> -#undef OMPI_SKIP_MPICXX #include "ADIOS_CPP.h" diff --git a/examples/hello/bpWriter/CMakeLists.txt b/examples/hello/bpWriter/CMakeLists.txt index d208c353979cc633ec57c741583831d27be03081..15de114c3a56e5bf8604b90f7f80232696516823 100644 --- a/examples/hello/bpWriter/CMakeLists.txt +++ b/examples/hello/bpWriter/CMakeLists.txt @@ -3,21 +3,17 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(hello_bpWriter_nompi helloBPWriter_nompi.cpp) -target_link_libraries(hello_bpWriter_nompi adios2_nompi) - -if(ADIOS_BUILD_TESTING) - add_test( NAME Example::hello::bpWriter_nompi COMMAND hello_bpWriter_nompi) -endif() - if(ADIOS_USE_MPI) find_package(MPI COMPONENTS C REQUIRED) + add_executable(hello_bpWriter helloBPWriter.cpp) target_include_directories(hello_bpWriter PRIVATE ${MPI_C_INCLUDE_PATH}) - target_link_libraries(hello_bpWriter adios2 ${MPI_C_LIBRARIES}) - - if(ADIOS_BUILD_TESTING) - add_test( NAME Example::hello::bpWriter COMMAND hello_bpWriter) - endif() + target_link_libraries(hello_bpWriter ${MPI_C_LIBRARIES}) +else() + add_executable(hello_bpWriter helloBPWriter_nompi.cpp) endif() +target_link_libraries(hello_bpWriter adios2) +if(ADIOS_BUILD_TESTING) + add_test( NAME Example::hello::bp::write COMMAND hello_bpWriter) +endif() diff --git a/examples/hello/datamanReader/CMakeLists.txt b/examples/hello/datamanReader/CMakeLists.txt index 34db8ffb63b807a029daa91ad67f80614170c736..41f3cb588c9c2ccd58eae67a8c21ee71ae4089d7 100644 --- a/examples/hello/datamanReader/CMakeLists.txt +++ b/examples/hello/datamanReader/CMakeLists.txt @@ -3,26 +3,17 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(hello_datamanReader_nompi helloDataManReader_nompi.cpp) -target_link_libraries(hello_datamanReader_nompi adios2_nompi) - -if(ADIOS_BUILD_TESTING) - add_test( - NAME Example::hello::datamanReader_nompi - COMMAND hello_datamanReader_nompi - ) -endif() - if(ADIOS_USE_MPI) find_package(MPI COMPONENTS C REQUIRED) add_executable(hello_datamanReader helloDataManReader.cpp) - target_link_libraries(hello_datamanReader adios2) target_include_directories(hello_datamanReader PRIVATE ${MPI_C_INCLUDE_PATH}) - target_link_libraries(hello_datamanReader adios2 ${MPI_C_LIBRARIES}) + target_link_libraries(hello_datamanReader ${MPI_C_LIBRARIES}) +else() + add_executable(hello_datamanReader helloDataManReader_nompi.cpp) +endif() +target_link_libraries(hello_datamanReader adios2) - if(ADIOS_BUILD_TESTING) - add_test(NAME Example::hello::datamanReader COMMAND hello_datamanReader) - endif() +if(ADIOS_BUILD_TESTING) + add_test(NAME Example::hello::dataman::read COMMAND hello_datamanReader) endif() - diff --git a/examples/hello/datamanWriter/CMakeLists.txt b/examples/hello/datamanWriter/CMakeLists.txt index c9268d31c761aac93069bee68adcae9fa2289530..eac85b42342826010cd4ee8a03c98f3902b375c7 100644 --- a/examples/hello/datamanWriter/CMakeLists.txt +++ b/examples/hello/datamanWriter/CMakeLists.txt @@ -3,26 +3,17 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(hello_datamanWriter_nompi helloDataManWriter_nompi.cpp) -target_link_libraries(hello_datamanWriter_nompi adios2_nompi) - -if(ADIOS_BUILD_TESTING) - add_test( - NAME Example::hello::datamanWriter_nompi - COMMAND hello_datamanWriter_nompi - ) -endif() - if(ADIOS_USE_MPI) find_package(MPI COMPONENTS C REQUIRED) add_executable(hello_datamanWriter helloDataManWriter.cpp) - target_link_libraries(hello_datamanWriter adios2) target_include_directories(hello_datamanWriter PRIVATE ${MPI_C_INCLUDE_PATH}) - target_link_libraries(hello_datamanWriter adios2 ${MPI_C_LIBRARIES}) - - if(ADIOS_BUILD_TESTING) - add_test(NAME Example::hello::datamanWriter COMMAND hello_datamanWriter) - endif() + target_link_libraries(hello_datamanWriter ${MPI_C_LIBRARIES}) +else() + add_executable(hello_datamanWriter helloDataManWriter_nompi.cpp) endif() +target_link_libraries(hello_datamanWriter adios2) +if(ADIOS_BUILD_TESTING) + add_test(NAME Example::hello::dataman::write COMMAND hello_datamanWriter) +endif() diff --git a/examples/hello/hdf5Writer/CMakeLists.txt b/examples/hello/hdf5Writer/CMakeLists.txt index 2f7d7fc0cbc69fc167f32a60b4aa030b44174bd1..1c3b030382190579703d21034077d99ed91f929e 100644 --- a/examples/hello/hdf5Writer/CMakeLists.txt +++ b/examples/hello/hdf5Writer/CMakeLists.txt @@ -3,28 +3,17 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -#add_executable(hello_hdf5Writer_nompi helloHDF5Writer_nompi.cpp) -message(" HDF5: ${HDF5_INCLUDE_DIRS}") -include_directories(${HDF5_INCLUDE_DIRS}) -#target_link_libraries(hello_hdf5Writer_nompi adios2_nompi) - -if(ADIOS_BUILD_TESTING) - #add_test( - # NAME Example::hello::hdf5Writer_nompi - # COMMAND hello_hdf5Writer_nompi - #) -endif() - if(ADIOS_USE_MPI) find_package(MPI COMPONENTS C REQUIRED) add_executable(hello_hdf5Writer helloHDF5Writer.cpp) - target_link_libraries(hello_hdf5Writer adios2) target_include_directories(hello_hdf5Writer PRIVATE ${MPI_C_INCLUDE_PATH}) - target_link_libraries(hello_hdf5Writer adios2 ${MPI_C_LIBRARIES}) - - if(ADIOS_BUILD_TESTING) - add_test(NAME Example::hello::hdf5Writer COMMAND hello_hdf5Writer) - endif() + target_link_libraries(hello_hdf5Writer ${MPI_C_LIBRARIES}) +else() + add_executable(hello_hdf5Writer helloHDF5Writer_nompi.cpp) endif() +target_link_libraries(hello_hdf5Writer adios2) +if(ADIOS_BUILD_TESTING) + add_test(NAME Example::hello::hdf5::write COMMAND hello_hdf5Writer) +endif() diff --git a/examples/hello/hdf5Writer/helloHDF5Writer_nompi.cpp b/examples/hello/hdf5Writer/helloHDF5Writer_nompi.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6f19e961f16d0cdb4b02e9507f3fb5fbc3309a2e --- /dev/null +++ b/examples/hello/hdf5Writer/helloHDF5Writer_nompi.cpp @@ -0,0 +1,130 @@ +/* + * HDF5Writer.cpp + * + * Created on: March 20, 2017 + * Author: Junmin + */ + +#include <iostream> +#include <vector> + +#include "ADIOS_CPP.h" + +int main(int argc, char *argv[]) +{ + const bool adiosDebug = true; + adios::ADIOS adios(adios::Verbose::INFO, adiosDebug); + + // Application variable + const std::size_t intDim1 = 4; + const std::size_t intDim2 = 3; + std::vector<int> myInts = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21}; + + std::vector<double> myDoubles = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + const std::size_t Nx = myDoubles.size(); + + std::vector<std::complex<float>> myCFloats; + const std::size_t CFloatSize = 3; + myCFloats.reserve(CFloatSize); + myCFloats.emplace_back(1, 3); + myCFloats.emplace_back(2, 2); + myCFloats.emplace_back(3, 1); + + std::vector<std::complex<double>> myCDoubles; + const std::size_t CDoubleSize = 3; + myCDoubles.reserve(CDoubleSize); + myCDoubles.emplace_back(1, 3); + myCDoubles.emplace_back(2, 2); + myCDoubles.emplace_back(3, 1); + + std::size_t doubleVCount = Nx / size; + std::size_t floatCount = CFloatSize / size; + std::size_t intCountDim1 = intDim1 / size; + + std::size_t doubleVOffset = rank * doubleVCount; + std::size_t floatOffset = rank * floatCount; + std::size_t intOffsetDim1 = rank * intCountDim1; + std::size_t intOffsetDim2 = 0; + + if ((size > 1) && (rank == size - 1)) + { + doubleVCount = Nx - rank * (Nx / size); + floatCount = CFloatSize - rank * (CFloatSize / size); + intCountDim1 = intDim1 - rank * (intDim1 / size); + } + + try + { + // Define variable and local size + // auto& ioMyDoubles = adios.DefineVariable<double>( "myDoubles", {Nx}, + // {Nx} ); + // auto& ioMyCFloats = adios.DefineVariable<std::complex<float>>( + // "myCFloats", {3}, {3} ); + // auto& ioMyInts = adios.DefineVariable<int>( "myInts", {4,3}, {4,3} ); + + auto &ioMyDoubles = adios.DefineVariable<double>( + "myDoubles", {doubleVCount}, {Nx}, {doubleVOffset}); + auto &ioMyCFloats = adios.DefineVariable<std::complex<float>>( + "myCFloats", {floatCount}, {3}, {floatOffset}); + auto &ioMyCDoubles = adios.DefineVariable<std::complex<double>>( + "myCDoubles", {floatCount}, {3}, {floatOffset}); + auto &ioMyInts = + adios.DefineVariable<int>("myInts", {intCountDim1, intDim2}, {4, 3}, + {intOffsetDim1, intOffsetDim2}); + + // Define method for engine creation, it is basically straight-forward + // parameters + adios::Method &HDF5Settings = + adios.DeclareMethod("HDF5Writer"); // default method type is Writer + HDF5Settings.SetParameters("chunck=yes", "collectiveIO=yes"); + // HDF5Settings.AddTransport( "Mdtm", "localIP=128.0.0.0.1", + // "remoteIP=128.0.0.0.2", "tolerances=1,2,3" ); + + // Create engine smart pointer to HDF5 Engine due to polymorphism, + // Open returns a smart pointer to Engine containing the Derived class + // HDF5 + auto HDF5Writer = adios.Open("test.bp", "w", HDF5Settings); + + if (HDF5Writer == nullptr) + throw std::ios_base::failure( + "ERROR: failed to create HDF5 I/O engine at Open\n"); + + HDF5Writer->Write(ioMyDoubles, myDoubles.data() + + doubleVOffset); // Base class Engine + // own the Write<T> + // that will call + // overloaded Write + // from Derived + HDF5Writer->Write(ioMyInts, + myInts.data() + (intOffsetDim1 * intDim2 * rank)); + HDF5Writer->Write(ioMyCFloats, myCFloats.data()); + HDF5Writer->Write(ioMyCDoubles, myCDoubles.data()); + HDF5Writer->Close(); + } + catch (std::invalid_argument &e) + { + if (rank == 0) + { + std::cout << "Invalid argument exception, STOPPING PROGRAM\n"; + std::cout << e.what() << "\n"; + } + } + catch (std::ios_base::failure &e) + { + if (rank == 0) + { + std::cout << "System exception, STOPPING PROGRAM\n"; + std::cout << e.what() << "\n"; + } + } + catch (std::exception &e) + { + if (rank == 0) + { + std::cout << "Exception, STOPPING PROGRAM\n"; + std::cout << e.what() << "\n"; + } + } + + return 0; +} diff --git a/examples/hello/timeBP/CMakeLists.txt b/examples/hello/timeBP/CMakeLists.txt index 949e8145e18683463df84e4b555e065901bc9e03..f077e9e80ab72e6174b342938ed6add902eb1dae 100644 --- a/examples/hello/timeBP/CMakeLists.txt +++ b/examples/hello/timeBP/CMakeLists.txt @@ -3,24 +3,17 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(hello_timeBPWriter_nompi timeBPWriter_nompi.cpp) -target_link_libraries(hello_timeBPWriter_nompi adios2_nompi) - -if(ADIOS_BUILD_TESTING) - add_test( - NAME Example::hello::timeBPWriter_nompi - COMMAND hello_timeBPWriter_nompi - ) -endif() - if(ADIOS_USE_MPI) find_package(MPI COMPONENTS C REQUIRED) + add_executable(hello_timeBPWriter timeBPWriter.cpp) - target_link_libraries(hello_timeBPWriter adios2) target_include_directories(hello_timeBPWriter PRIVATE ${MPI_C_INCLUDE_PATH}) - target_link_libraries(hello_timeBPWriter adios2 ${MPI_C_LIBRARIES}) + target_link_libraries(hello_timeBPWriter ${MPI_C_LIBRARIES}) +else() + add_executable(hello_timeBPWriter timeBPWriter_nompi.cpp) +endif() +target_link_libraries(hello_timeBPWriter adios2) - if(ADIOS_BUILD_TESTING) - add_test(NAME Example::hello::timeBPWriter COMMAND hello_timeBPWriter) - endif() +if(ADIOS_BUILD_TESTING) + add_test(NAME Example::hello::timeBP::write COMMAND hello_timeBPWriter) endif() diff --git a/include/engine/adios1/ADIOS1Writer.h b/include/engine/adios1/ADIOS1Writer.h index 11a9eb313440eda2e2deba1c820d1f61989bc05a..c13eee78201bc3b797e7bbe654c1fe7d1a3e9be1 100644 --- a/include/engine/adios1/ADIOS1Writer.h +++ b/include/engine/adios1/ADIOS1Writer.h @@ -18,13 +18,7 @@ namespace adios { -#ifndef ADIOS_HAVE_MPI -#define _NOMPI -#endif #include "adios.h" // this is adios 1.x header file -#ifndef ADIOS_HAVE_MPI -#undef _NOMPI -#endif class ADIOS1Writer : public Engine { diff --git a/source/ADIOS.cpp b/source/ADIOS.cpp index 30aac797cd4d6533626106baef0dcab3eeed529b..ac6eb562639c56fd3b43fc904a026e00ce6ca4f8 100644 --- a/source/ADIOS.cpp +++ b/source/ADIOS.cpp @@ -36,12 +36,10 @@ #include "engine/adios1/ADIOS1Writer.h" #endif -#ifdef ADIOS_HAVE_PHDF5 // external dependencies -#ifdef ADIOS_HAVE_MPI +#ifdef ADIOS_HAVE_HDF5 // external dependencies #include "engine/hdf5/HDF5ReaderP.h" #include "engine/hdf5/HDF5WriterP.h" #endif -#endif namespace adios { @@ -194,7 +192,7 @@ std::shared_ptr<Engine> ADIOS::Open(const std::string &name, } else if (type == "HDF5Writer") // -junmin { -#if defined(ADIOS_HAVE_PHDF5) && defined(ADIOS_HAVE_MPI) +#ifdef ADIOS_HAVE_HDF5 return std::make_shared<HDF5Writer>(*this, name, accessMode, mpiComm, method); #else diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 62a642e966648cd5d2d73c4473146429920fa58a..993366d5fcc6656a64a47c24699aeb3d6805843f 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -3,107 +3,104 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -set(adios2_targets adios2_nompi) -if(ADIOS_USE_MPI) - list(APPEND adios2_targets adios2) -endif() - -foreach(adios2_target IN LISTS adios2_targets) - add_library(${adios2_target} - ADIOS.cpp ADIOS.tcc - #ADIOS_C.cpp +add_library(adios2 + ADIOS.cpp ADIOS.tcc + #ADIOS_C.cpp - capsule/heap/STLVector.cpp - capsule/shmem/ShmSystemV.cpp + capsule/heap/STLVector.cpp + capsule/shmem/ShmSystemV.cpp - core/Capsule.cpp - core/Engine.cpp - core/Method.cpp - core/Support.cpp - core/Transform.cpp - core/Transport.cpp + core/Capsule.cpp + core/Engine.cpp + core/Method.cpp + core/Support.cpp + core/Transform.cpp + core/Transport.cpp - engine/bp/BPFileReader.cpp - engine/bp/BPFileWriter.cpp + engine/bp/BPFileReader.cpp + engine/bp/BPFileWriter.cpp - utilities/format/bp1/BP1Base.cpp - utilities/format/bp1/BP1Aggregator.cpp - utilities/format/bp1/BP1Writer.cpp + utilities/format/bp1/BP1Base.cpp + utilities/format/bp1/BP1Aggregator.cpp + utilities/format/bp1/BP1Writer.cpp - utilities/profiling/iochrono/Timer.cpp - - functions/adiosFunctions.cpp + utilities/profiling/iochrono/Timer.cpp + + functions/adiosFunctions.cpp - transport/file/FStream.cpp - transport/file/FileDescriptor.cpp - transport/file/FilePointer.cpp + transport/file/FStream.cpp + transport/file/FileDescriptor.cpp + transport/file/FilePointer.cpp - utilities/format/bp1/BP1Base.cpp - utilities/format/bp1/BP1Aggregator.cpp - utilities/format/bp1/BP1Writer.cpp - utilities/format/bp1/BP1Writer.tcc + utilities/format/bp1/BP1Base.cpp + utilities/format/bp1/BP1Aggregator.cpp + utilities/format/bp1/BP1Writer.cpp + utilities/format/bp1/BP1Writer.tcc - utilities/profiling/iochrono/Timer.cpp - ) - target_include_directories(${adios2_target} - PUBLIC ${ADIOS_SOURCE_DIR}/include - ) + utilities/profiling/iochrono/Timer.cpp +) +target_include_directories(adios2 + PUBLIC ${ADIOS_SOURCE_DIR}/include +) - if(ADIOS_USE_DataMan) - target_sources(${adios2_target} PRIVATE - engine/dataman/DataManReader.cpp - engine/dataman/DataManWriter.cpp - transport/wan/MdtmMan.cpp - utilities/realtime/dataman/DataManBase.cpp - utilities/realtime/dataman/DataMan.cpp - ) - target_compile_definitions(${adios2_target} PRIVATE ADIOS_HAVE_DATAMAN) - target_link_libraries(${adios2_target} PRIVATE ${CMAKE_DL_LIBS}) - endif() +if(ADIOS_USE_DataMan) + target_sources(adios2 PRIVATE + engine/dataman/DataManReader.cpp + engine/dataman/DataManWriter.cpp + transport/wan/MdtmMan.cpp + utilities/realtime/dataman/DataManBase.cpp + utilities/realtime/dataman/DataMan.cpp + ) + target_compile_definitions(adios2 PRIVATE ADIOS_HAVE_DATAMAN) + target_link_libraries(adios2 PRIVATE ${CMAKE_DL_LIBS}) +endif() - if(ADIOS_USE_BZip2) - find_package(BZip2 REQUIRED) - target_sources(${adios2_target} PRIVATE transform/BZip2.cpp) - target_compile_definitions(${adios2_target} PRIVATE ADIOS_HAVE_BZIP2) - target_link_libraries(${adios2_target} PRIVATE BZip2::BZip2) - endif() -endforeach() - -target_sources(adios2_nompi PRIVATE mpidummy.cpp) -if(CMAKE_CXX_COMPILER_WRAPPER STREQUAL CrayPrgEnv) - target_compile_options(adios2_nompi PRIVATE --cray-bypass-pkgconfig) +if(ADIOS_USE_BZip2) + find_package(BZip2 REQUIRED) + target_sources(adios2 PRIVATE transform/BZip2.cpp) + target_compile_definitions(adios2 PRIVATE ADIOS_HAVE_BZIP2) + target_link_libraries(adios2 PRIVATE BZip2::BZip2) endif() + if(ADIOS_USE_MPI) find_package(MPI COMPONENTS C REQUIRED) target_include_directories(adios2 PUBLIC ${MPI_C_INCLUDE_PATH}) target_compile_definitions(adios2 PUBLIC ADIOS_HAVE_MPI) target_link_libraries(adios2 PUBLIC ${MPI_C_LIBRARIES}) +else() + target_sources(adios2 PRIVATE mpidummy.cpp) +endif() - if(ADIOS_USE_ADIOS1) +if(ADIOS_USE_ADIOS1) + if(ADIOS_USE_MPI) find_package(ADIOS1 REQUIRED) - target_sources(adios2 PRIVATE - engine/adios1/ADIOS1Reader.cpp - engine/adios1/ADIOS1Writer.cpp - ) - target_compile_definitions(adios2 PRIVATE ADIOS_HAVE_ADIOS1) - target_link_libraries(adios2 PRIVATE adios1::adios) + else() + find_package(ADIOS1 COMPONENTS sequential REQUIRED) endif() - if(ADIOS_USE_PHDF5) - find_package(HDF5 REQUIRED) - message(" HDF5 ROOT: ${HDF5_ROOT}") - message(" HDF5 include: ${HDF5_INCLUDE_DIRS} is paralle? ${HDF5_IS_PARALLEL}") - - target_include_directories(adios2 PRIVATE ${HDF5_INCLUDE_DIRS}) + target_sources(adios2 PRIVATE + engine/adios1/ADIOS1Reader.cpp + engine/adios1/ADIOS1Writer.cpp + ) + target_compile_definitions(adios2 PRIVATE ADIOS_HAVE_ADIOS1) + target_link_libraries(adios2 PRIVATE adios1::adios) +endif() - target_sources(adios2 PRIVATE - engine/hdf5/HDF5ReaderP.cpp - engine/hdf5/HDF5WriterP.cpp - ) - target_compile_definitions(adios2 PRIVATE ADIOS_HAVE_PHDF5) - target_link_libraries(adios2 PRIVATE ${HDF5_C_LIBRARIES}) +if(ADIOS_USE_HDF5) + find_package(HDF5 REQUIRED) + if(ADIOS_USE_MPI AND (NOT HDF5_IS_PARALLEL)) + message(FATAL_ERROR "A sequential version of HDF5 was detected but the parallel version of ADIOS is being built, which requires a parallel HDF5.") + elseif((NOT ADIOS_USE_MPI) AND HDF5_IS_PARALLEL) + message(FATAL_ERROR "A parallel version of HDF5 was detected but the sequential version of ADIOS is being built, which requires a sequential HDF5.") endif() + target_include_directories(adios2 PRIVATE ${HDF5_INCLUDE_DIRS}) + target_sources(adios2 PRIVATE + engine/hdf5/HDF5ReaderP.cpp + engine/hdf5/HDF5WriterP.cpp + ) + target_compile_definitions(adios2 PRIVATE ADIOS_HAVE_HDF5) + target_link_libraries(adios2 PRIVATE ${HDF5_C_LIBRARIES}) endif() diff --git a/source/engine/hdf5/HDF5WriterP.cpp b/source/engine/hdf5/HDF5WriterP.cpp index 05656e2babf1170f368702b2cd0d309d47800a8c..b75a447b4b9383575f58e0e36d9275f2a494bef7 100644 --- a/source/engine/hdf5/HDF5WriterP.cpp +++ b/source/engine/hdf5/HDF5WriterP.cpp @@ -78,7 +78,9 @@ void HDF5Writer::Init() _plist_id = H5Pcreate(H5P_FILE_ACCESS); +#ifdef ADIOS_HAVE_MPI H5Pset_fapl_mpio(_plist_id, m_MPIComm, MPI_INFO_NULL); +#endif /* * Create a new file collectively and release property list identifier. @@ -340,8 +342,9 @@ void HDF5Writer::UseHDFWrite(Variable<T> &variable, const T *values, // Create property list for collective dataset write. _plist_id = H5Pcreate(H5P_DATASET_XFER); +#ifdef ADIOS_HAVE_MPI H5Pset_dxpl_mpio(_plist_id, H5FD_MPIO_COLLECTIVE); - +#endif herr_t status; status =