diff --git a/CMakeLists.txt b/CMakeLists.txt index 240c0554fa3d27d6e03b4e638a2fc353171b9092..5d3f59d51f93ab3df10fec779ab7360547354ddd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,7 @@ if(ADIOS_ENABLE_PIC) set(CMAKE_POSITION_INDEPENDENT_CODE OFF) endif() -option(ADIOS_USE_MPI "Enable the MPI version of ADIOS" ON) +option(ADIOS_USE_MPI "Enable the MPI version of ADIOS" OFF) if(ADIOS_USE_MPI) # Workaround for OpenMPI forcing the link of C++ bindings add_definitions(-DOMPI_SKIP_MPICXX) diff --git a/Contributing.md b/Contributing.md index d3824aa0d9a89c0968f7b0d4bfe29fcd21e701f4..0348aa104ab0aedfc0070c6da3859fcd7c54351e 100644 --- a/Contributing.md +++ b/Contributing.md @@ -12,34 +12,38 @@ To setup your local repository for development: 1. Fork the main repository on GitHub: 1. Navigate to https://github.com/ornladios/adios2 in your browser. 1. Click the `[Fork]` button in the upper right-hand side of the page. - 2. Clone your fork to your local machine: + 2. Clone the upstream repository to your local machine: ``` -[chuck@hal9000 Code]$ mkdir adios -[chuck@hal9000 Code]$ cd adios -[chuck@hal9000 adios]$ git clone git@github.com:<your-GitHub-username-here>/adios2.git source +$ mkdir adios +$ cd adios +$ git clone https://github.com/ornladios/adios2.git source Cloning into 'source'... -remote: Counting objects: 4535, done. -remote: Compressing objects: 100% (223/223), done. -remote: Total 4535 (delta 64), reused 0 (delta 0), pack-reused 4301 -Receiving objects: 100% (4535/4535), 1.27 MiB | 0 bytes/s, done. -Resolving deltas: 100% (2607/2607), done. +remote: Counting objects: 4632, done. +remote: Compressing objects: 100% (80/80), done. +remote: Total 4632 (delta 33), reused 0 (delta 0), pack-reused 4549 +Receiving objects: 100% (4632/4632), 1.23 MiB | 224.00 KiB/s, done. +Resolving deltas: 100% (2738/2738), done. Checking connectivity... done. -[chuck.atkins@hal9000 adios]$ +$ ``` 3. Run the `scripts/development/setup.sh` script. The script will configure an `upstream` remote and link your local master branch to the upstream. ``` -[chuck.atkins@hal9000 adios]$ cd source/ -$ ./scripts/developer/setup.sh -Checking GitHub username... -Using GitHub user <your-GitHub-username-here> -Adding upstream remote... +$ cd source/ +$ ./scripts/developer/setup.sh +Enter your GitHub username: chuckatkins +Setup SSH push access? [(y)/n] y +Re-configuring local master branch to use upstream Fetching origin +remote: Counting objects: 6, done. +remote: Compressing objects: 100% (6/6), done. +remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0 +Unpacking objects: 100% (6/6), done. +From https://github.com/chuckatkins/adios2 Fetching upstream From https://github.com/ornladios/adios2 + * [new branch] master -> upstream/master * [new branch] dashboard -> upstream/dashboard * [new branch] hooks -> upstream/hooks - * [new branch] master -> upstream/master -Re-configuring local master branch to use upstream Setting up git aliases... Setting up git hooks... $ @@ -109,4 +113,5 @@ That will apply the formatting rules used by the ADIOS project. 1. Lines no longer than 80 characters. 1. Always use braces { and }, even for 1 line if blocks. 1. Use 4 spaces for indentation. + There are more formatting rules but these three should at least get you close and prevent any drastic re-writes from the re-formatting tools. More details can be found by looking at the .clang-format config file n the root of the repository and by looking at the clang-format documentation http://releases.llvm.org/3.8.0/tools/clang/docs/ClangFormatStyleOptions.html. While the formatting rules are a bit more involved, the main points are: diff --git a/cmake/FindADIOS1.cmake b/cmake/FindADIOS1.cmake new file mode 100644 index 0000000000000000000000000000000000000000..da0fdd08dbf1ae6c6f0f3257c719a9a8734d01d1 --- /dev/null +++ b/cmake/FindADIOS1.cmake @@ -0,0 +1,260 @@ +# - Find ADIOS 1.x library, routines for scientific, parallel IO +# https://www.olcf.ornl.gov/center-projects/adios/ +# +# Use this module by invoking find_package with the form: +# find_package(ADIOS1 +# [version] [EXACT] # Minimum or EXACT version, e.g. 1.6.0 +# [REQUIRED] # Fail with an error if ADIOS or a required +# # component is not found +# [QUIET] # ... +# [COMPONENTS <...>] # Compiled in components: fortran, readonly, + # sequential (all are case insentative) +# ) +# +# Module that finds the includes and libraries for a working ADIOS 1.x install. +# This module invokes the `adios_config` script that should be installed with +# the other ADIOS tools. +# +# To provide a hint to the module where to find the ADIOS installation, +# set the ADIOS1_ROOT or ADIOS1_DIR environment variable. +# +# If this variable is not set, make sure that at least the according `bin/` +# directory of ADIOS 1.x is in your PATH environment variable. +# +# Set the following CMake variables BEFORE calling find_packages to +# influence this module: +# ADIOS1_USE_STATIC_LIBS - Set to ON to force the use of static +# libraries. Default: OFF +# +# This module will define the following variables: +# ADIOS1_INCLUDE_DIRS - Include directories for the ADIOS 1.x headers. +# ADIOS1_LIBRARY_PATH - Full path of the libadios library (.a or .so file) +# ADIOS1_DEPENDENCY_LIBRARIES - ADIOS 1.x dependency libraries. +# ADIOS1_FOUND - TRUE if FindADIOS1 found a working install +# ADIOS1_VERSION - Version in format Major.Minor.Patch +# +# Not used for now: +# ADIOS1_DEFINITIONS - Compiler definitions you should add with +# add_definitions(${ADIOS1_DEFINITIONS}) +# +# Example to find ADIOS 1.x (default) +# find_package(ADIOS1) +# if(ADIOS1_FOUND) +# include_directories(${ADIOS1_INCLUDE_DIRS}) +# add_executable(foo foo.c) +# target_link_libraries(foo ${ADIOS1_LIBRARY_PATH} ADIOS1_DEPENDENCY_LIBRARIES) +# endif() + +# Example to find ADIOS 1.x using component +# find_package(ADIOS1 COMPONENTS fortran) +# if(ADIOS1_FOUND) +# include_directories(${ADIOS1_INCLUDE_DIRS}) +# add_executable(foo foo.c) +# target_link_libraries(foo ${ADIOS1_LIBRARY_PATH} ${ADIOS1_DEPENDENCY_LIBRARIES}) +# endif() +############################################################################### +#Copyright (c) 2014, Axel Huebl and Felix Schmitt from http://picongpu.hzdr.de +#All rights reserved. + +#Redistribution and use in source and binary forms, with or without +#modification, are permitted provided that the following conditions are met: + +#1. Redistributions of source code must retain the above copyright notice, this +#list of conditions and the following disclaimer. + +#2. Redistributions in binary form must reproduce the above copyright notice, +#this list of conditions and the following disclaimer in the documentation +#and/or other materials provided with the distribution. + +#3. Neither the name of the copyright holder nor the names of its contributors +#may be used to endorse or promote products derived from this software without +#specific prior written permission. + +#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +#AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +#IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +#FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +#DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +#SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +#OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +############################################################################### + + +############################################################################### +# 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() +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) + + +# 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) + +# 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 + list(APPEND ADIOS1_INCLUDE_DIRS ${ADIOS1_ROOT_DIR}/include) + + # 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}) + 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) + endforeach() + + #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) + + +# 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}) +endif() + + +############################################################################### +# FindPackage Options +############################################################################### + +# 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 +) + +########################################################################## +# 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() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index ffe6d00e4d8057f0e861d7e2209d16b7f2b26fe6..59d0aaef3e1741211ad8274c17dc9f2b361b879b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -4,3 +4,4 @@ #------------------------------------------------------------------------------# add_subdirectory(hello) +add_subdirectory(heatTransfer) diff --git a/examples/heatTransfer/CMakeLists.txt b/examples/heatTransfer/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..02e4cd30c850a0af1b3cd322cd386cb61a766109 --- /dev/null +++ b/examples/heatTransfer/CMakeLists.txt @@ -0,0 +1,7 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +add_subdirectory(write) +add_subdirectory(read) diff --git a/examples/heatTransfer/IO_adios2.cpp b/examples/heatTransfer/IO_adios2.cpp index 26d83c1bf674acbe96ff59f8c27e81b02b0de547..aea0493ca7dfbbea62f9568f63c4a289bbaa1bba 100644 --- a/examples/heatTransfer/IO_adios2.cpp +++ b/examples/heatTransfer/IO_adios2.cpp @@ -60,6 +60,8 @@ IO::IO(const Settings &s, MPI_Comm comm) bpWriter = ad->Open(m_outputfilename, "w", comm, bpWriterSettings); + // ad->Open(m_outputfilename, "w", comm, bpWriterSettings); + if (bpWriter == nullptr) throw std::ios_base::failure("ERROR: failed to open ADIOS bpWriter\n"); } diff --git a/examples/heatTransfer/read/CMakeLists.txt b/examples/heatTransfer/read/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..c82cf01a868db9bfbd2b445abef274c5cb866ece --- /dev/null +++ b/examples/heatTransfer/read/CMakeLists.txt @@ -0,0 +1,27 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +if(ADIOS_USE_MPI) + if(ADIOS_USE_ADIOS1) + find_package(ADIOS1 REQUIRED) + find_package(MPI COMPONENTS C REQUIRED) + + add_executable(headTransfer_read_adios1 heatRead_adios1.cpp PrintData.cpp) + target_include_directories(headTransfer_read_adios1 + PRIVATE ${MPI_C_INCLUDE_PATH} + ) + target_link_libraries(headTransfer_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/read/PrintData.cpp b/examples/heatTransfer/read/PrintData.cpp new file mode 100644 index 0000000000000000000000000000000000000000..030fa561f1cc1a6e3dc62b24d8cf45f98583bfcd --- /dev/null +++ b/examples/heatTransfer/read/PrintData.cpp @@ -0,0 +1,54 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * PrintData.cpp + * + * Created on: Apr 2017 + * Author: Norbert Podhorszki + */ + +#include "PrintData.h" +#include <fstream> +#include <iomanip> +#include <iostream> +#include <string> + +void printData(double *xy, uint64_t *size, uint64_t *offset, int rank, + int steps) +{ + std::ofstream myfile; + std::string filename = "data." + std::to_string(rank); + myfile.open(filename); + double *data = xy; + uint64_t nelems = size[0] * size[1]; + for (int step = 0; step < steps; step++) + { + myfile << "rank=" << rank << " size=" << size[0] << "x" << size[1] + << " offsets=" << offset[0] << ":" << offset[1] + << " step=" << step << std::endl; + + myfile << " time row columns " << offset[1] << "..." + << offset[1] + size[1] - 1 << std::endl; + myfile << " "; + for (int j = 0; j < size[1]; j++) + { + myfile << std::setw(9) << offset[1] + j; + } + myfile << std::endl; + myfile << "------------------------------------------------------------" + "--\n"; + for (int i = 0; i < size[0]; i++) + { + myfile << std::setw(5) << step << std::setw(5) << offset[0] + i; + for (int j = 0; j < size[1]; j++) + { + myfile << std::setw(9) << std::setprecision(2) + << data[i * size[1] + j]; + } + myfile << std::endl; + } + data += nelems; + } + myfile.close(); +} diff --git a/examples/heatTransfer/read/PrintData.h b/examples/heatTransfer/read/PrintData.h new file mode 100644 index 0000000000000000000000000000000000000000..308ace34007f88c15498464b1555b5cca3ed1f6b --- /dev/null +++ b/examples/heatTransfer/read/PrintData.h @@ -0,0 +1,19 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * PrintData.h + * + * Created on: Apr 2017 + * Author: Norbert Podhorszki + */ + +#ifndef PRINTDATA_H_ +#define PRINTDATA_H_ + +#include <cstdint> + +void printData(double *xy, uint64_t *size, uint64_t *offset, int rank, + int steps); + +#endif /* PRINTDATA_H_ */ diff --git a/examples/heatTransfer/read/heatRead_adios1.cpp b/examples/heatTransfer/read/heatRead_adios1.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bcedac6d5a84b700b9e7045eee1b222146b29341 --- /dev/null +++ b/examples/heatTransfer/read/heatRead_adios1.cpp @@ -0,0 +1,102 @@ + +#include <mpi.h> + +#include "adios_read.h" +#include <cstdint> +#include <iomanip> +#include <iostream> +#include <math.h> +#include <memory> +#include <stdexcept> +#include <string> + +#include "PrintData.h" + +int main(int argc, char *argv[]) +{ + MPI_Init(&argc, &argv); + + if (argc < 2) + { + std::cout << "Not enough arguments: need an input file\n"; + return 1; + } + const char *inputfile = argv[1]; + + /* World comm spans all applications started with the same aprun command + on a Cray XK6. So we have to split and create the local + 'world' communicator for the reader only. + In normal start-up, the communicator will just equal the MPI_COMM_WORLD. + */ + + int wrank, wnproc; + MPI_Comm_rank(MPI_COMM_WORLD, &wrank); + MPI_Comm_size(MPI_COMM_WORLD, &wnproc); + MPI_Barrier(MPI_COMM_WORLD); + + const unsigned int color = 2; + MPI_Comm mpiReaderComm; + MPI_Comm_split(MPI_COMM_WORLD, color, wrank, &mpiReaderComm); + + int rank, nproc; + MPI_Comm_rank(mpiReaderComm, &rank); + MPI_Comm_size(mpiReaderComm, &nproc); + + adios_read_init_method(ADIOS_READ_METHOD_BP, mpiReaderComm, "verbose=3"); + + ADIOS_FILE *f; + f = adios_read_open_file(inputfile, ADIOS_READ_METHOD_BP, mpiReaderComm); + if (f == NULL) + { + std::cout << adios_errmsg() << std::endl; + return -1; + } + + ADIOS_VARINFO *vgndx = adios_inq_var(f, "gndx"); + ADIOS_VARINFO *vgndy = adios_inq_var(f, "gndy"); + + unsigned int gndx = *(unsigned int *)vgndx->value; + unsigned int gndy = *(unsigned int *)vgndy->value; + + if (rank == 0) + { + std::cout << "gndx = " << gndx << std::endl; + std::cout << "gndy = " << gndy << std::endl; + } + adios_free_varinfo(vgndx); + adios_free_varinfo(vgndy); + + // 1D decomposition of the columns, which is inefficient for reading! + uint64_t readsize[2] = {gndx, gndy / nproc}; + uint64_t offset[2] = {0LL, rank * readsize[1]}; + if (rank == nproc - 1) + { + // last process should read all the rest of columns + readsize[1] = gndy - readsize[1] * (nproc - 1); + } + + std::cout << "rank " << rank << " reads " << readsize[1] + << " columns from offset " << offset[1] << std::endl; + + ADIOS_VARINFO *vT = adios_inq_var(f, "T"); + + double *T = new double[vT->nsteps * readsize[0] * readsize[1]]; + + // Create a 2D selection for the subset + ADIOS_SELECTION *sel = adios_selection_boundingbox(2, offset, readsize); + + // Arrays are read by scheduling one or more of them + // and performing the reads at once + adios_schedule_read(f, sel, "T", 0, vT->nsteps, T); + adios_perform_reads(f, 1); + + printData(T, readsize, offset, rank, vT->nsteps); + adios_read_close(f); + adios_free_varinfo(vT); + delete[] T; + // Terminate + adios_selection_delete(sel); + adios_read_finalize_method(ADIOS_READ_METHOD_BP); + MPI_Finalize(); + return 0; +} diff --git a/examples/heatTransfer/write/CMakeLists.txt b/examples/heatTransfer/write/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..eb72a2af9bd234c09be42c8b00a69ffbca7114e4 --- /dev/null +++ b/examples/heatTransfer/write/CMakeLists.txt @@ -0,0 +1,51 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +if(ADIOS_USE_MPI) + find_package(MPI COMPONENTS C REQUIRED) + + add_executable(heatTransfer_write_adios2 + main.cpp + HeatTransfer.cpp + Settings.cpp + IO_adios2.cpp + ) + target_include_directories(heatTransfer_write_adios2 + PRIVATE ${MPI_C_INCLUDE_PATH} + ) + 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) + + add_executable(heatTransfer_write_adios1 + main.cpp + HeatTransfer.cpp + Settings.cpp + IO_adios1.cpp + ) + target_include_directories(heatTransfer_write_adios1 + PRIVATE ${MPI_C_INCLUDE_PATH} + ) + 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/HeatTransfer.cpp b/examples/heatTransfer/write/HeatTransfer.cpp similarity index 99% rename from examples/heatTransfer/HeatTransfer.cpp rename to examples/heatTransfer/write/HeatTransfer.cpp index ac706e4c66d75c5e342faa915ae2edb8aa4519e2..29283fa776a39650cec330d1688402a6b7f83299 100644 --- a/examples/heatTransfer/HeatTransfer.cpp +++ b/examples/heatTransfer/write/HeatTransfer.cpp @@ -10,7 +10,6 @@ * Author: Norbert Podhorszki * */ -#include <mpi.h> #include <iomanip> #include <iostream> diff --git a/examples/heatTransfer/HeatTransfer.h b/examples/heatTransfer/write/HeatTransfer.h similarity index 99% rename from examples/heatTransfer/HeatTransfer.h rename to examples/heatTransfer/write/HeatTransfer.h index 7d48eb558d2db274218e8b0030ad53cc2aa0f7f3..a52acbb742ba6cd617bcd2b7f94e8ec760c13cb9 100644 --- a/examples/heatTransfer/HeatTransfer.h +++ b/examples/heatTransfer/write/HeatTransfer.h @@ -12,6 +12,7 @@ #define HEATTRANSFER_H_ #include <mpi.h> + #include <vector> #include "Settings.h" diff --git a/examples/heatTransfer/IO.h b/examples/heatTransfer/write/IO.h similarity index 100% rename from examples/heatTransfer/IO.h rename to examples/heatTransfer/write/IO.h index 999866112e471e46f2136f804ed2ee5226bb0a0a..53caaf599fe4e1c2aac8f4cd58c216c7888adf6e 100644 --- a/examples/heatTransfer/IO.h +++ b/examples/heatTransfer/write/IO.h @@ -13,11 +13,11 @@ #include "HeatTransfer.h" #include "Settings.h" + #include <mpi.h> class IO { - public: IO(const Settings &s, MPI_Comm comm); ~IO(); diff --git a/examples/heatTransfer/IO_adios1.cpp b/examples/heatTransfer/write/IO_adios1.cpp similarity index 100% rename from examples/heatTransfer/IO_adios1.cpp rename to examples/heatTransfer/write/IO_adios1.cpp diff --git a/examples/heatTransfer/write/IO_adios2.cpp b/examples/heatTransfer/write/IO_adios2.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8af454f718bb406174c7e116018eafb000eb28e4 --- /dev/null +++ b/examples/heatTransfer/write/IO_adios2.cpp @@ -0,0 +1,114 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * IO_ADIOS2.cpp + * + * Created on: Feb 2017 + * Author: Norbert Podhorszki + */ + +#include "IO.h" +#include "ADIOS_CPP.h" + +#include <string> + +static int rank_saved; +adios::ADIOS *ad = nullptr; +std::shared_ptr<adios::Engine> bpWriter; +adios::Variable<double> *varT = nullptr; + +IO::IO(const Settings &s, MPI_Comm comm) +{ + rank_saved = s.rank; + m_outputfilename = s.outputfile + ".bp"; + ad = new adios::ADIOS("adios2.xml", comm, adios::Verbose::INFO); + + // Define method for engine creation + // 1. Get method def from config file or define new one + + adios::Method &bpWriterSettings = ad->DeclareMethod("output"); + if (!bpWriterSettings.isUserDefined()) + { + // if not defined by user, we can change the default settings + bpWriterSettings.SetEngine("BPFileWriter"); // BP is the default engine + bpWriterSettings.AllowThreads( + 1); // allow 1 extra thread for data processing + bpWriterSettings.AddTransport( + "File", "lucky=yes"); // ISO-POSIX file is the default transport + // Passing parameters to the transport + bpWriterSettings.SetParameters( + "have_metadata_file", + "yes"); // Passing parameters to the engine + bpWriterSettings.SetParameters( + "Aggregation", + std::to_string((s.nproc + 1) / 2)); // number of aggregators + } + + // define T as 2D global array + varT = &ad->DefineVariable<double>( + "T", + // Global dimensions + {s.gndx, s.gndy}, + // local size, could be defined later using SetSelection() + {s.ndx, s.ndy}, + // offset of the local array in the global space + {s.offsx, s.offsy}); + + // add transform to variable + // adios::Transform tr = adios::transform::BZIP2( ); + // varT.AddTransform( tr, "" ); + // varT.AddTransform( tr,"accuracy=0.001" ); // for ZFP + + bpWriter = ad->Open(m_outputfilename, "w", comm, bpWriterSettings, + adios::IOMode::COLLECTIVE); + + if (bpWriter == nullptr) + throw std::ios_base::failure("ERROR: failed to open ADIOS bpWriter\n"); +} + +IO::~IO() +{ + bpWriter->Close(); + delete ad; +} + +void IO::write(int step, const HeatTransfer &ht, const Settings &s, + MPI_Comm comm) +{ +#if 1 + + /* This selection is redundant and not required, since we defined + * the selection already in DefineVariable(). It is here just as an example. + */ + // Make a selection to describe the local dimensions of the variable we + // write and its offsets in the global spaces. This could have been done in + // adios.DefineVariable() + adios::SelectionBoundingBox sel({s.offsx, s.offsy}, {s.ndx, s.ndy}); + varT->SetSelection(sel); + + /* Select the area that we want to write from the data pointer we pass to + the + writer. + Think HDF5 memspace, just not hyperslabs, only a bounding box selection. + Engine will copy this bounding box from the data pointer into the output + buffer. + Size of the bounding box should match the "space" selection which was + given + above. + Default memspace is always the full selection. + */ + adios::SelectionBoundingBox memspace = + adios::SelectionBoundingBox({s.ndx, s.ndy}, {1, 1}); + varT->SetMemorySelection(memspace); + + bpWriter->Write<double>(*varT, ht.data()); + bpWriter->Advance(); + +#else + + bpWriter->Write<double>(*varT, ht.data_noghost().data()); + bpWriter->Advance(); + +#endif +} diff --git a/examples/heatTransfer/IO_ascii.cpp b/examples/heatTransfer/write/IO_ascii.cpp similarity index 100% rename from examples/heatTransfer/IO_ascii.cpp rename to examples/heatTransfer/write/IO_ascii.cpp diff --git a/examples/heatTransfer/IO_hdf5_a.cpp b/examples/heatTransfer/write/IO_hdf5_a.cpp similarity index 100% rename from examples/heatTransfer/IO_hdf5_a.cpp rename to examples/heatTransfer/write/IO_hdf5_a.cpp diff --git a/examples/heatTransfer/Settings.cpp b/examples/heatTransfer/write/Settings.cpp similarity index 98% rename from examples/heatTransfer/Settings.cpp rename to examples/heatTransfer/write/Settings.cpp index 4337a00a33f7b3865bceb1feeb569537f1e6271c..4922afd5fdf640d258c110a8b1f3adc38ef613f0 100644 --- a/examples/heatTransfer/Settings.cpp +++ b/examples/heatTransfer/write/Settings.cpp @@ -11,6 +11,8 @@ #include <cstdlib> #include <errno.h> +#include <stdexcept> + #include "Settings.h" static unsigned int convertToUint(std::string varName, char *arg) @@ -80,5 +82,3 @@ Settings::Settings(int argc, char *argv[], int rank, int nproc) : rank{rank} else rank_down = rank + npx; } - -Settings::~Settings() {} diff --git a/examples/heatTransfer/Settings.h b/examples/heatTransfer/write/Settings.h similarity index 98% rename from examples/heatTransfer/Settings.h rename to examples/heatTransfer/write/Settings.h index 97e85ea310adcd55a2ccc10ca8333346461b3949..20f83f395ce322b97da39edfff0afdd121c2d9e5 100644 --- a/examples/heatTransfer/Settings.h +++ b/examples/heatTransfer/write/Settings.h @@ -11,7 +11,7 @@ #ifndef SETTINGS_H_ #define SETTINGS_H_ -#include <memory> +#include <string> class Settings { @@ -48,7 +48,6 @@ public: int rank_down; Settings(int argc, char *argv[], int rank, int nproc); - ~Settings(); }; #endif /* SETTINGS_H_ */ diff --git a/examples/heatTransfer/main.cpp b/examples/heatTransfer/write/main.cpp similarity index 92% rename from examples/heatTransfer/main.cpp rename to examples/heatTransfer/write/main.cpp index 1d1372f401ff641f3dc0da71a1b175b9b5c5b1fb..ff1b6c44c9a5e0cbf836f60b475c3190d7e34e8f 100644 --- a/examples/heatTransfer/main.cpp +++ b/examples/heatTransfer/write/main.cpp @@ -10,7 +10,9 @@ * 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> @@ -64,10 +66,10 @@ int main(int argc, char *argv[]) IO io(settings, mpiHeatTransferComm); ht.init(true); - ht.printT("Initialized T:", mpiHeatTransferComm); + // ht.printT("Initialized T:", mpiHeatTransferComm); ht.heatEdges(); - // ht.exchange( mpiHeatTransferComm ); - ht.printT("Heated T:", mpiHeatTransferComm); + ht.exchange(mpiHeatTransferComm); + // ht.printT("Heated T:", mpiHeatTransferComm); io.write(0, ht, settings, mpiHeatTransferComm); for (unsigned int t = 1; t <= settings.steps; ++t) diff --git a/examples/hello/adios1Writer/CMakeLists.txt b/examples/hello/adios1Writer/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..b38cfb90d3a153197efaa99f88295187debcfc1b --- /dev/null +++ b/examples/hello/adios1Writer/CMakeLists.txt @@ -0,0 +1,14 @@ +#------------------------------------------------------------------------------# +# Distributed under the OSI-approved Apache License, Version 2.0. See +# accompanying file Copyright.txt for details. +#------------------------------------------------------------------------------# + +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}) +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 2a7803ab6edac9adc2618699fb3be45c3960b6c7..87101533b4795379e3b2c94966c44d01fea83403 100644 --- a/examples/hello/adios1Writer/helloADIOS1Writer.cpp +++ b/examples/hello/adios1Writer/helloADIOS1Writer.cpp @@ -11,7 +11,9 @@ #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/adios1Writer/helloADIOS1Writer_nompi.cpp b/examples/hello/adios1Writer/helloADIOS1Writer_nompi.cpp index 44d4d5547050e79ef4a3cb3b0222b4d21433438f..5955b33436df32cd835391a75c85bf2bc8f7f53b 100644 --- a/examples/hello/adios1Writer/helloADIOS1Writer_nompi.cpp +++ b/examples/hello/adios1Writer/helloADIOS1Writer_nompi.cpp @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) { const bool adiosDebug = true; - adios::ADIOS adios(adiosDebug); + adios::ADIOS adios(adios::Verbose::INFO, adiosDebug); // Application variable std::vector<double> myDoubles = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; diff --git a/examples/hello/bpWriter/CMakeLists.txt b/examples/hello/bpWriter/CMakeLists.txt index 67e193342b05fe0c7d99881038a69e5233706fda..d208c353979cc633ec57c741583831d27be03081 100644 --- a/examples/hello/bpWriter/CMakeLists.txt +++ b/examples/hello/bpWriter/CMakeLists.txt @@ -3,6 +3,13 @@ # 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) @@ -12,12 +19,5 @@ if(ADIOS_USE_MPI) if(ADIOS_BUILD_TESTING) add_test( NAME Example::hello::bpWriter COMMAND hello_bpWriter) endif() -else() - add_executable(hello_bpWriter_nompi helloBPWriter_nompi.cpp) - target_link_libraries(hello_bpWriter_nompi adios2) - - if(ADIOS_BUILD_TESTING) - add_test( NAME Example::hello::bpWriter_nompi COMMAND hello_bpWriter_nompi) - endif() endif() diff --git a/examples/hello/datamanReader/CMakeLists.txt b/examples/hello/datamanReader/CMakeLists.txt index 3aa3e264ad829cf697e9cd91a6336d6fcf8b668d..34db8ffb63b807a029daa91ad67f80614170c736 100644 --- a/examples/hello/datamanReader/CMakeLists.txt +++ b/examples/hello/datamanReader/CMakeLists.txt @@ -3,6 +3,16 @@ # 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) @@ -14,15 +24,5 @@ if(ADIOS_USE_MPI) if(ADIOS_BUILD_TESTING) add_test(NAME Example::hello::datamanReader COMMAND hello_datamanReader) endif() -else() - add_executable(hello_datamanReader_nompi helloDataManReader_nompi.cpp) - target_link_libraries(hello_datamanReader_nompi adios2) - - if(ADIOS_BUILD_TESTING) - add_test( - NAME Example::hello::datamanReader_nompi - COMMAND hello_datamanReader_nompi - ) - endif() endif() diff --git a/examples/hello/datamanWriter/CMakeLists.txt b/examples/hello/datamanWriter/CMakeLists.txt index 7defd6c40b3bd2eba1802a4e6e99dd41f5de1697..c9268d31c761aac93069bee68adcae9fa2289530 100644 --- a/examples/hello/datamanWriter/CMakeLists.txt +++ b/examples/hello/datamanWriter/CMakeLists.txt @@ -3,6 +3,16 @@ # 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) @@ -14,15 +24,5 @@ if(ADIOS_USE_MPI) if(ADIOS_BUILD_TESTING) add_test(NAME Example::hello::datamanWriter COMMAND hello_datamanWriter) endif() -else() - add_executable(hello_datamanWriter_nompi helloDataManWriter_nompi.cpp) - target_link_libraries(hello_datamanWriter_nompi adios2) - - if(ADIOS_BUILD_TESTING) - add_test( - NAME Example::hello::datamanWriter_nompi - COMMAND hello_datamanWriter_nompi - ) - endif() endif() diff --git a/examples/hello/timeBP/CMakeLists.txt b/examples/hello/timeBP/CMakeLists.txt index d86828c90625a3a4e34952730fcd6ed9631c2949..949e8145e18683463df84e4b555e065901bc9e03 100644 --- a/examples/hello/timeBP/CMakeLists.txt +++ b/examples/hello/timeBP/CMakeLists.txt @@ -3,6 +3,16 @@ # 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) @@ -13,14 +23,4 @@ if(ADIOS_USE_MPI) if(ADIOS_BUILD_TESTING) add_test(NAME Example::hello::timeBPWriter COMMAND hello_timeBPWriter) endif() -else() - add_executable(hello_timeBPWriter_nompi timeBPWriter_nompi.cpp) - target_link_libraries(hello_timeBPWriter_nompi adios2) - - if(ADIOS_BUILD_TESTING) - add_test( - NAME Example::hello::timeBPWriter_nompi - COMMAND hello_timeBPWriter_nompi - ) - endif() endif() diff --git a/include/core/VariableBase.h b/include/core/VariableBase.h index fb223613bc157057d50123f1540bc6b2a10f3f74..49bb98a1e45e55f95664ec18d84326d220f6bf70 100644 --- a/include/core/VariableBase.h +++ b/include/core/VariableBase.h @@ -12,14 +12,16 @@ #define VARIABLEBASE_H_ /// \cond EXCLUDE_FROM_DOXYGEN +#include <exception> #include <iterator> #include <sstream> #include <string> #include <vector> /// \endcond -#include "functions/adiosFunctions.h" //GetTotalSize, DimsToCSV -#include "functions/adiosTemplates.h" //GetType<T> +#include "functions/adiosFunctions.h" //GetTotalSize, DimsToCSV, ConvertUint64VectorToSizetVector +#include "functions/adiosTemplates.h" //GetType<T> +#include "selection/SelectionBoundingBox.h" //Selection namespace adios { @@ -42,10 +44,13 @@ public: Dims m_LocalDimensions; ///< dimensions per rank (MPI) Dims m_GlobalDimensions; ///< total dimensions across MPI Dims m_Offsets; ///< selections offset + Dims m_MemoryDimensions; ///< array of memory dimensions + Dims m_MemoryOffsets; ///< array of memory offsets bool m_IsScalar = false; const bool m_IsDimension = false; + const bool m_DebugMode = false; - VariableBase(const std::string name, const std::string type, + VariableBase(const std::string &name, const std::string type, const std::size_t elementSize, const Dims localDimensions, const Dims globalDimensions, const Dims offsets, const bool debugMode) @@ -80,9 +85,55 @@ public: return GetTotalSize(m_LocalDimensions); } - // protected: off for now - const bool m_DebugMode = false; + /** + * Set the local dimension and global offset of the variable using a + * selection + * Only bounding boxes are allowed + */ + void SetSelection(const SelectionBoundingBox &sel) + { + if (m_GlobalDimensions.size() == 0) + { + throw std::invalid_argument("Variable.SetSelection() is an invalid " + "call for single value variables\n"); + } + if (m_GlobalDimensions.size() != sel.m_Count.size()) + { + throw std::invalid_argument("Variable.SetSelection() bounding box " + "dimension must equal the global " + "dimension of the variable\n"); + } + + ConvertUint64VectorToSizetVector(sel.m_Count, m_LocalDimensions); + ConvertUint64VectorToSizetVector(sel.m_Start, m_Offsets); + } + + /** + * Set the local dimension and global offset of the variable using a + * selection + * Only bounding boxes are allowed + */ + void SetMemorySelection(const SelectionBoundingBox &sel) + { + if (m_GlobalDimensions.size() == 0) + { + throw std::invalid_argument( + "Variable.SetMemorySelection() is an invalid " + "call for single value variables\n"); + } + if (m_GlobalDimensions.size() != sel.m_Count.size()) + { + throw std::invalid_argument( + "Variable.SetMemorySelection() bounding box " + "dimension must equal the global " + "dimension of the variable\n"); + } + + ConvertUint64VectorToSizetVector(sel.m_Count, m_MemoryDimensions); + ConvertUint64VectorToSizetVector(sel.m_Start, m_MemoryOffsets); + } }; -} + +} // end namespace #endif /* VARIABLEBASE_H_ */ diff --git a/include/engine/adios1/ADIOS1Reader.h b/include/engine/adios1/ADIOS1Reader.h index e2abe89bef8c73d2d398be33644a099c0ff83566..53fb32bec3f8cf8c09ef7584c4f06213ed47bfba 100644 --- a/include/engine/adios1/ADIOS1Reader.h +++ b/include/engine/adios1/ADIOS1Reader.h @@ -23,6 +23,14 @@ namespace adios { +#ifndef ADIOS_HAVE_MPI +#define _NOMPI 1 +#endif +#include "adios_read_v2.h" // this is adios 1.x header file +#ifndef ADIOS_HAVE_MPI +#undef _NOMPI +#endif + class ADIOS1Reader : public Engine { @@ -44,65 +52,40 @@ public: ~ADIOS1Reader(); - Variable<void> *InquireVariable(const std::string &variableName, + Variable<void> *InquireVariable(const std::string &name, const bool readIn = true); - - Variable<char> *InquireVariableChar(const std::string &variableName, + Variable<char> *InquireVariableChar(const std::string &name, const bool readIn = true); - - Variable<unsigned char> * - InquireVariableUChar(const std::string &variableName, - const bool readIn = true); - - Variable<short> *InquireVariableShort(const std::string &variableName, + Variable<unsigned char> *InquireVariableUChar(const std::string &name, + const bool readIn = true); + Variable<short> *InquireVariableShort(const std::string &name, const bool readIn = true); - - Variable<unsigned short> * - InquireVariableUShort(const std::string &variableName, - const bool readIn = true); - - Variable<int> *InquireVariableInt(const std::string &variableName, + Variable<unsigned short> *InquireVariableUShort(const std::string &name, + const bool readIn = true); + Variable<int> *InquireVariableInt(const std::string &name, const bool readIn = true); - - Variable<unsigned int> *InquireVariableUInt(const std::string &variableName, + Variable<unsigned int> *InquireVariableUInt(const std::string &name, const bool readIn = true); - - Variable<long int> *InquireVariableLInt(const std::string &variableName, + Variable<long int> *InquireVariableLInt(const std::string &name, const bool readIn = true); - - Variable<unsigned long int> * - InquireVariableULInt(const std::string &variableName, - const bool readIn = true); - - Variable<long long int> * - InquireVariableLLInt(const std::string &variableName, - const bool readIn = true); - + Variable<unsigned long int> *InquireVariableULInt(const std::string &name, + const bool readIn = true); + Variable<long long int> *InquireVariableLLInt(const std::string &name, + const bool readIn = true); Variable<unsigned long long int> * - InquireVariableULLInt(const std::string &variableName, - const bool readIn = true); - - Variable<float> *InquireVariableFloat(const std::string &variableName, + InquireVariableULLInt(const std::string &name, const bool readIn = true); + Variable<float> *InquireVariableFloat(const std::string &name, const bool readIn = true); - - Variable<double> *InquireVariableDouble(const std::string &variableName, + Variable<double> *InquireVariableDouble(const std::string &name, const bool readIn = true); - - Variable<long double> * - InquireVariableLDouble(const std::string &variableName, - const bool readIn = true); - + Variable<long double> *InquireVariableLDouble(const std::string &name, + const bool readIn = true); Variable<std::complex<float>> * - InquireVariableCFloat(const std::string &variableName, - const bool readIn = true); - + InquireVariableCFloat(const std::string &name, const bool readIn = true); Variable<std::complex<double>> * - InquireVariableCDouble(const std::string &variableName, - const bool readIn = true); - + InquireVariableCDouble(const std::string &name, const bool readIn = true); Variable<std::complex<long double>> * - InquireVariableCLDouble(const std::string &variableName, - const bool readIn = true); + InquireVariableCLDouble(const std::string &name, const bool readIn = true); /** * Not implemented @@ -110,32 +93,20 @@ public: * @param readIn * @return */ - VariableCompound *InquireVariableCompound(const std::string name, + VariableCompound *InquireVariableCompound(const std::string &name, const bool readIn = true); void Close(const int transportIndex = -1); private: - capsule::STLVector - m_Buffer; ///< heap capsule, contains data and metadata buffers - // format::BP1Writer m_BP1Writer; ///< format object will provide the - // required - // BP functionality to be applied on m_Buffer and m_Transports - - void Init(); ///< calls InitCapsules and InitTransports based on Method, - /// called from constructor - void InitCapsules(); - void InitTransports(); ///< from Transports - - std::string - GetMdtmParameter(const std::string parameter, - const std::map<std::string, std::string> &mdtmParameters); + void Init(); ///< called from constructor, gets the selected ADIOS1 + /// transport method from settings template <class T> - Variable<T> *InquireVariableCommon(const std::string name, + Variable<T> *InquireVariableCommon(const std::string &name, const bool readIn) { - std::cout << "Hello BPReaderCommon\n"; + std::cout << "Hello ADIOS1Reader::InquireVariableCommon\n"; // here read variable metadata (dimensions, type, etc.)...then create a // Variable like below: @@ -144,8 +115,10 @@ private: // return &variable; //return address if success return nullptr; // on failure } + + enum ADIOS_READ_METHOD read_method = ADIOS_READ_METHOD_BP; }; } // end namespace adios -#endif /* BPFILEREADER_H_ */ +#endif /* ADIOS1READER_H_ */ diff --git a/include/engine/adios1/ADIOS1Writer.h b/include/engine/adios1/ADIOS1Writer.h index d783c02f7bf675d4db4d11ae84211151cafae6d8..17553a885b454697507d8645a767fbf72c39ed2b 100644 --- a/include/engine/adios1/ADIOS1Writer.h +++ b/include/engine/adios1/ADIOS1Writer.h @@ -18,11 +18,11 @@ namespace adios { -#ifdef ADIOS_NOMPI +#ifndef ADIOS_HAVE_MPI #define _NOMPI #endif #include "adios.h" // this is adios 1.x header file -#ifdef ADIOS_NOMPI +#ifndef ADIOS_HAVE_MPI #undef _NOMPI #endif diff --git a/include/external/adios_selection.h b/include/external/adios_selection.h new file mode 100644 index 0000000000000000000000000000000000000000..551d72ee5f8ea6297f5367e12b3759abdb6fdb1a --- /dev/null +++ b/include/external/adios_selection.h @@ -0,0 +1,240 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + */ + +/* + * Streaming/Chunking/Selection Read API in C for ADIOS BP format + * + * A SELECTION is the data ranges resulting from a QUERY over a file and + * variable(s). + * + * A SELECTION can be a list of bounding boxes and point-sets. Other data + * structures + * are not supported. Any query will result in such a selection. + * Other selections are the write-block and auto. + * + * Write block is a block of data written + * by a writer process, it is identified by an index. If each writer outputs + * one block + * then the index equals to the rank of the write process. With multi-var + * writing and + * multiple steps in a file, index runs from 0 as rank 0 process' first block. + * + * Auto selection lets the read method to automatically choose what to return. + * It will + * be a block / blocks of selected writers. + * + * If a query is a simple bounding box, the selection is the bounding box + * itself, so + * the application does not need to retrieve the selection to work on the read + * data. + */ +#ifndef __ADIOS_SELECTION_C_H__ +#define __ADIOS_SELECTION_C_H__ + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************/ +/* Types used in the API */ +/*************************/ + +typedef struct ADIOS_SELECTION_STRUCT ADIOS_SELECTION; + +/* Type of selection */ +enum ADIOS_SELECTION_TYPE +{ + ADIOS_SELECTION_BOUNDINGBOX = 0, /* Contiguous block of data defined by + offsets and counts in each dimension */ + ADIOS_SELECTION_POINTS = 1, /* List of individual points */ + ADIOS_SELECTION_WRITEBLOCK = + 2, /* Selection of an individual block written by a writer process */ + ADIOS_SELECTION_AUTO = 3 /* Let the method decide what to return */ +}; + +/* A Bounding Box */ +typedef struct +{ + int ndim; + uint64_t *start; + uint64_t *count; +} ADIOS_SELECTION_BOUNDINGBOX_STRUCT; + +/* A list of points. + * It is a 1D array of indices, linearized for all dimension + * (e.g. [i1,j1,k1,i2,j2,k2,...,in,jn,kn] for n points in a 3D space. + * If a container selection is given, points are relative coordinates/offsets in + * the + * container box/writeblock. + * 1D offsets in N-dimensional container are allowed. Such selections are + * returned by + * FASTBIT and ALACRITY query method. File reading is supported for such + * selections. + * adios_selection_points_1DtoND() can be used to convert 1D to N-D points. + */ +typedef struct +{ + int ndim; + int _free_points_on_delete; // user provided points are not copied, won't + // free either + uint64_t npoints; + uint64_t *points; + ADIOS_SELECTION + *container_selection; // a writeblock, a bounding box, or NULL +} ADIOS_SELECTION_POINTS_STRUCT; + +/* A selected block produced by a writer + * Identified with an index in current versions. + */ +typedef struct +{ + int index; + + /* NCSU ALACRITY-ADIOS: + * Adding timestep-relative vs. absolute writeblock selections, as + * well as sub-PG selection support. Both of these are currently only + * used by the transform layer + */ + int is_absolute_index; /* 0 if 'index' is relative to the current timestep, + != 0 + otherwise (i.e., absolute index) */ + int is_sub_pg_selection; /* Whether this writeblock selection contains + sub-PG bounds. + The following fields only matter if this is != 0 + */ + + /* Reads the linear range of elements in [element_offset, element_offset + + * nelements) */ + uint64_t element_offset; + uint64_t nelements; +} ADIOS_SELECTION_WRITEBLOCK_STRUCT; + +/* Let the read method decide what to return to each reading client. + * Hints are method-dependent parameters to influence what and how to + * return (e.g. the ordering of returned chunks, decomposition among + * read processes, etc.) + */ +typedef struct +{ + char *hints; +} ADIOS_SELECTION_AUTO_STRUCT; + +/** Selection for reading a subset of a variable. + * A selection is an additive list of bounding boxes and point-sets + */ +struct ADIOS_SELECTION_STRUCT +{ + enum ADIOS_SELECTION_TYPE type; /* Type of selection */ + union { + ADIOS_SELECTION_BOUNDINGBOX_STRUCT bb; + ADIOS_SELECTION_POINTS_STRUCT points; + ADIOS_SELECTION_WRITEBLOCK_STRUCT block; + ADIOS_SELECTION_AUTO_STRUCT autosel; + } u; + // ADIOS_SELECTION *next; +}; + +#ifndef __INCLUDED_FROM_FORTRAN_API__ + +/** Boundingbox selection to read a subset of a non-scalar variable. + * IN: + * ndim Number of dimensions + * start array of offsets to start reading in each dimension + * count number of data elements to read in each dimension + * RETURN: A selection which can be used to read variables + */ +ADIOS_SELECTION *adios_selection_boundingbox(int ndim, const uint64_t *start, + const uint64_t *count); + +/** Selection for a selection of an enumeration of positions. + * IN: + * ndim Number of dimensions + * npoints Number of points of the selection + * points 1D array of indices, compacted for all dimension + * (e.g. [i1,j1,k1,i2,j2,k2,...,in,jn,kn] for + * n points in a 3D space. + */ +ADIOS_SELECTION *adios_selection_points(int ndim, uint64_t npoints, + const uint64_t *points); + +/** Selection for a block of data coming from a certain producer. + * + * IN: + * index Identifier of the written block, starting from 0 for the + * first block + * written by producer rank 0. If each writer outputs one block + * then the index equals to the rank of the write process. + * With multi-var writing and multiple steps in a file, index + * should be + * calculated by the reading application using outside + * information beyond + * what is provided by the ADIOS Read API. + */ +ADIOS_SELECTION *adios_selection_writeblock(int index); + +/** Let the method decide what data gets to what reader process. + * This selection enables each reading method to provide an 'optimal' + * data transfer from writers to readers. It depends on the method and the + * circumstances, what this selection actually means. + * + * E.g. in situ processing: readers on a compute node will receive all data + * from the writers on the same compute node. + * + * IN: + * hints Method dependent parameters to influence what and how to + * return (e.g. decomposition; ordering of returned chunks) + */ +ADIOS_SELECTION *adios_selection_auto(char *hints); + +/** Make a strided hyperslab selection the same way as in HDF5. + * IN: + * ndim Number of dimentsions + * start array of offsets to start reading in each dimension + * strides striding steps, NULL=1 in all dimensions (= boundingbox) + * count number of data elements to read in each dimension + * blocks block size at each stride, NULL=1 in all dimensions + */ +/* + No support: Klasky, Podhorszki + Support: + +ADIOS_SELECTION* adios_selection_hyperslab (uint64_t ndim, uint64_t *start, +uint64_t *strides, + uint64_t *count, uint64_t *blocks); +*/ + +/** Delete a selection and free up memory used by the selection. + * IN: selection + * RESULT: None + * The ADIOS_SELECTION object can be simply freed by free(), too. + */ +void adios_selection_delete(ADIOS_SELECTION *selection); + +/* Convert one selection of 1D point offsets in a bounding box, + * returned by FASTBIT and ALACRITY query methods, to N-dimensional points. + * This function works only if there is a bounding box in + * pointsinbox1D->u.points.container! + * It allocates memory for the result selection, after which the original can be + * freed. + * Return: + * If global==0, the points will be relative to the container, if not, the + * points will be + * global coordinates (container's starting offsets added to each point) and + * result's container + * will be NULL. + */ +ADIOS_SELECTION *adios_selection_points_1DtoND(ADIOS_SELECTION *pointsinbox1D, + int global); + +#endif /*__INCLUDED_FROM_FORTRAN_API__*/ + +#ifdef __cplusplus +} +#endif + +#endif /*__ADIOS_SELECTION_C_H__*/ diff --git a/include/functions/adiosFunctions.h b/include/functions/adiosFunctions.h index c9b88a03ed124a5c828d85709630b0b6e3790b6f..418a075781663a6e0abcfd60094fb4f73bccf141 100644 --- a/include/functions/adiosFunctions.h +++ b/include/functions/adiosFunctions.h @@ -182,6 +182,12 @@ BuildParametersMap(const std::vector<std::string> ¶meters, */ std::vector<int> CSVToVectorInt(const std::string csv); +/** Convert a vector of uint64_t elements to a vector of std::size_t elements + * @param input vector of uint64_t elements + * @param output vector of std::size_t elements + */ +void ConvertUint64VectorToSizetVector(const std::vector<std::uint64_t> &in, + std::vector<std::size_t> &out); /** * Converts a vector of dimensions to a CSV string * @param dims vector of dimensions @@ -197,7 +203,8 @@ std::string DimsToCSV(const std::vector<std::size_t> &dims); * buffers ( default = 1.5 ) * @param maxBufferSize user provided maximum buffer size * @param buffer to be reallocated - * @return true: must do a transport flush, false: buffer sizes are enough to + * @return true: must do a transport flush, false: buffer sizes are enough + * to * contain incoming data, no need for transport flush */ bool CheckBufferAllocation(const std::size_t newSize, const float growthFactor, diff --git a/include/selection/Selection.h b/include/selection/Selection.h new file mode 100644 index 0000000000000000000000000000000000000000..70d4c831409cb0e1cd7beeee0e121470acf39d1f --- /dev/null +++ b/include/selection/Selection.h @@ -0,0 +1,70 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + */ + +/* + * Selection API in C++ + * + * A SELECTION is the data ranges resulting from a QUERY over a file and + * variable(s). + * + * A SELECTION can be a list of bounding boxes and point-sets. Other data + * structures + * are not supported. Any query will result in such a selection. + * Other selections are the write-block and auto. + * + * Write block is a block of data written + * by a writer process, it is identified by an index. If each writer outputs + * one block + * then the index equals to the rank of the write process. With multi-var + * writing and + * multiple steps in a file, index runs from 0 as rank 0 process' first block. + * + * Auto selection lets the read method to automatically choose what to return. + * It will + * be a block / blocks of selected writers. + * + * If a query is a simple bounding box, the selection is the bounding box + * itself, so + * the application does not need to retrieve the selection to work on the read + * data. + */ +#ifndef __ADIOS_SELECTION_H__ +#define __ADIOS_SELECTION_H__ + +/// \cond EXCLUDE_FROM_DOXYGEN +#include "external/adios_selection.h" +#include <stdint.h> +/// \endcond + +namespace adios +{ + +/*************************/ +/* Types used in the API */ +/*************************/ +/* Type of selection */ +enum class SelectionType +{ + // Contiguous block of data defined by offsets and counts in each + // dimension + BoundingBox = ADIOS_SELECTION_BOUNDINGBOX, + // List of individual points + Points = ADIOS_SELECTION_POINTS, + // Selection of an individual block written by a writer process + WriteBlock = ADIOS_SELECTION_WRITEBLOCK, + // Let the method decide what to return + Auto = ADIOS_SELECTION_AUTO +}; + +class Selection +{ +public: + Selection(const SelectionType t) : m_Type(t){}; + const SelectionType m_Type; +}; + +} // namespace adios + +#endif /*__ADIOS_SELECTION_H__*/ diff --git a/include/selection/SelectionBoundingBox.h b/include/selection/SelectionBoundingBox.h new file mode 100644 index 0000000000000000000000000000000000000000..b110fd96e517a2ee7854db1bad92d422dfd3d5e1 --- /dev/null +++ b/include/selection/SelectionBoundingBox.h @@ -0,0 +1,38 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + */ + +#ifndef __ADIOS_SELECTION_BOUNDINGBOX_H__ +#define __ADIOS_SELECTION_BOUNDINGBOX_H__ + +/// \cond EXCLUDE_FROM_DOXYGEN +#include <cstdint> +/// \endcond + +#include "selection/Selection.h" + +namespace adios +{ + +/** Boundingbox selection to read a subset of a non-scalar variable. + * @param start array of offsets to start reading in each dimension + * @param count number of data elements to read in each dimension + */ +class SelectionBoundingBox : public Selection +{ +public: + SelectionBoundingBox(const std::vector<std::uint64_t> start, + const std::vector<std::uint64_t> count) + : Selection(SelectionType::BoundingBox), m_Start(start), m_Count(count) + { + } + ~SelectionBoundingBox(){}; + + std::vector<std::uint64_t> m_Start; + std::vector<std::uint64_t> m_Count; +}; + +} // namespace adios + +#endif /*__ADIOS_SELECTION_BOUNDINGBOX_H__*/ diff --git a/include/selection/SelectionPoints.h b/include/selection/SelectionPoints.h new file mode 100644 index 0000000000000000000000000000000000000000..13fa951cbaa587c2f1592e64dd9eeb46601d29cd --- /dev/null +++ b/include/selection/SelectionPoints.h @@ -0,0 +1,55 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + */ + +#ifndef __ADIOS_SELECTION_POINTS_H__ +#define __ADIOS_SELECTION_POINTS_H__ + +/// \cond EXCLUDE_FROM_DOXYGEN +#include <cstdint> +/// \endcond + +#include "selection/Selection.h" +#include "selection/SelectionBoundingBox.h" + +namespace adios +{ + +/** Selection for a selection of an enumeration of positions. + * @param ndim Number of dimensions + * @param npoints Number of points of the selection + * @param points 1D array of indices, compacted for all dimension + * (e.g. [i1,j1,k1,i2,j2,k2,...,in,jn,kn] for + * n points in a 3D space. + */ +class SelectionPoints : public Selection +{ +public: + SelectionPoints(std::size_t ndim, std::size_t npoints, + std::vector<std::uint64_t> &points) + : Selection(SelectionType::Points), m_Ndim(ndim), m_Npoints(npoints), + m_Points(points) + { + } + + ///< C-style constructor to be used in the C-to-C++ wrapper + SelectionPoints(std::size_t ndim, std::size_t npoints, uint64_t *points) + : Selection(SelectionType::Points), m_Ndim(ndim), m_Npoints(npoints), + m_Points(std::vector<std::uint64_t>()), m_PointsC(points) + { + } + + ~SelectionPoints(){}; + + const std::size_t m_Ndim; + const std::size_t m_Npoints; + std::vector<std::uint64_t> &m_Points; + ///< C-to-C++ wrapper needs a pointer to hold the points created by the C + /// application + std::uint64_t *m_PointsC = nullptr; +}; + +} // namespace adios + +#endif /*__ADIOS_SELECTION_POINTS_H__*/ diff --git a/scripts/developer/git/setup-aliases b/scripts/developer/git/setup-aliases index 2d996582b0284debddf288a85708702053f53270..bf2f6c298365f828675fe64fd687482d4592534f 100755 --- a/scripts/developer/git/setup-aliases +++ b/scripts/developer/git/setup-aliases @@ -1,15 +1,15 @@ #!/usr/bin/env bash echo "Setting up git aliases..." -if ! which clang-format 2>1 1>/dev/null +if ! which clang-format 1>/dev/null 2>&1 then echo "Warning: ADIOS uses clang-format to enforce style guidelines but no" - echo " clang-format binary was found in tyour path" + echo " clang-format binary was found in your path" fi if ! git config alias.clang-format "!scripts/developer/git/git-clang-format" then - echo "Error adding clang-format alias" + echo "Waring: Error adding clang-format alias" fi exit 0 diff --git a/scripts/developer/git/setup-remotes b/scripts/developer/git/setup-remotes index 17cac1b31d0abba2b48886f23ba531eb21616776..1071260393482dd3f3d084b43d02b5b2c186c459 100755 --- a/scripts/developer/git/setup-remotes +++ b/scripts/developer/git/setup-remotes @@ -1,27 +1,50 @@ #!/usr/bin/env bash -echo "Checking GitHub username..." -GHUSER=$(git remote get-url origin | sed 's|.*[:/]\([^/]*\)/adios2.git|\1|') -if [ -z "${GHUSER}" ] +GH_UPSTREAM_URL=$(git remote show origin | grep "Fetch URL" | sed 's|.*: \(.*\)|\1|') +BRANCH="$(git branch | sed -n 's|^\* \(.*\)|\1|p')" +if [ "${GH_UPSTREAM_URL}" != "https://github.com/ornladios/adios2.git" ] || \ + [ "${BRANCH}" != "master" ] then - echo " Warning: Unable to determine GitHub username. Are you sure you" - echo " cloned your fork?" + echo " Warning: This script is intended to run off of the master branch" + echo " of the upstream repository. Setup might not work as" + echo " expected otherwise." +fi + +read -p "Enter your GitHub username: " GH_USERNAME +if [ -z "${GH_USERNAME}" ] +then + echo " Error: GitHub username cannot be empty." exit 1 fi -echo "Using GitHub user ${GHUSER}" +git remote set-url origin https://github.com/${GH_USERNAME}/adios2.git +read -p "Setup SSH push access? [(y)/n] " GH_USE_SSH +GH_USE_SSH="${GH_USE_SSH,,}" +if [ -z "${GH_USE_SSH}" ] +then + echo " Empty entry. Using 'y' as default" + GH_USE_SSH="y" +elif [ "${GH_USE_SSH}" != "y" ] && [ "${GH_USE_SSH}" != "n" ] +then + echo " Invalid entry. Using 'y' by default" + GH_USE_SSH="y" +fi +if [ "${GH_USE_SSH}" == "y" ] +then + git config remote.origin.pushurl "git@github.com:${GH_USERNAME}/adios2.git" +fi + -echo "Adding upstream remote..." if git remote show upstream > /dev/null 2>&1 then - echo " Warning: upstream remote already exists; skipping" -else - git remote add upstream https://github.com/ornladios/adios2.git + echo " Warning: upstream remote already exists; replacing..." + git remote rm upstream fi -git fetch --all -p +git remote add upstream https://github.com/ornladios/adios2.git echo "Re-configuring local master branch to use upstream" git config branch.master.remote upstream git config branch.master.mergeOptions "--ff-only" git config merge.log 100 +git fetch --all -p exit 0 diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 611c256c9213d76580bd770496c162a3a9e9a000..766c5dec17a3689dfdac3c9d55faa5b4827b6064 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -2,71 +2,81 @@ # Distributed under the OSI-approved Apache License, Version 2.0. See # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# - -add_library(adios2 - ADIOS.cpp ADIOS_inst.cpp - #ADIOS_C.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 - - engine/bp/BPFileReader.cpp - engine/bp/BPFileWriter.cpp - - utilities/format/bp1/BP1Base.cpp - utilities/format/bp1/BP1Aggregator.cpp - utilities/format/bp1/BP1Writer.cpp - utilities/profiling/iochrono/Timer.cpp - - functions/adiosFunctions.cpp +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_inst.cpp + #ADIOS_C.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 + + engine/bp/BPFileReader.cpp + engine/bp/BPFileWriter.cpp + + format/BP1.cpp + format/BP1Aggregator.cpp + format/BP1Writer.cpp + + functions/adiosFunctions.cpp + + transport/file/FStream.cpp + transport/file/FileDescriptor.cpp + transport/file/FilePointer.cpp + ) + target_include_directories(${adios2_target} + PUBLIC ${ADIOS_SOURCE_DIR}/include + ) + + if(ADIOS_USE_DataMan) + find_package(DataMan REQUIRED) + target_sources(${adios2_target} PRIVATE + engine/dataman/DataManReader.cpp + engine/dataman/DataManWriter.cpp + transport/wan/MdtmMan.cpp + ) + target_compile_definitions(${adios2_target} PRIVATE ADIOS_HAVE_DATAMAN) + target_link_libraries(${adios2_target} PRIVATE DataMan::DataMan) + 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() - transport/file/FStream.cpp - transport/file/FileDescriptor.cpp - transport/file/FilePointer.cpp -) -target_include_directories(adios2 PUBLIC ${ADIOS_SOURCE_DIR}/include) +target_sources(adios2_nompi PRIVATE mpidummy.cpp) +if(CMAKE_CXX_COMPILER_WRAPPER STREQUAL CrayPrgEnv) + target_compile_options(adios2_nompi PRIVATE --cray-bypass-pkgconfig) +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) - find_package(ADIOS 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 adios::adios) -endif() - -if(ADIOS_USE_DataMan) - find_package(DataMan REQUIRED) - target_sources(adios2 PRIVATE - engine/dataman/DataManReader.cpp - engine/dataman/DataManWriter.cpp - transport/wan/MdtmMan.cpp - ) - target_compile_definitions(adios2 PRIVATE ADIOS_HAVE_DATAMAN) - target_link_libraries(adios2 PRIVATE DataMan::DataMan) -endif() -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) + if(ADIOS_USE_ADIOS1) + 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) + endif() endif() diff --git a/source/engine/adios1/ADIOS1Reader.cpp b/source/engine/adios1/ADIOS1Reader.cpp index a840d404a869e093bd1413fd735fa1844a315a01..55a745a0e7370a437665321105cc3ecafd5e9f26 100644 --- a/source/engine/adios1/ADIOS1Reader.cpp +++ b/source/engine/adios1/ADIOS1Reader.cpp @@ -22,8 +22,7 @@ ADIOS1Reader::ADIOS1Reader(ADIOS &adios, const std::string &name, const std::string accessMode, MPI_Comm mpiComm, const Method &method) : Engine(adios, "BPFileReader", name, accessMode, mpiComm, method, - " BPFileReader constructor (or call to ADIOS Open).\n"), - m_Buffer(accessMode, m_RankMPI, m_DebugMode) + " BPFileReader constructor (or call to ADIOS Open).\n") { Init(); } @@ -170,15 +169,9 @@ void BPFileReader::Init() ", in call to ADIOS Open or BPFileReader constructor\n"); } - InitCapsules(); InitTransports(); } -void BPFileReader::InitCapsules() -{ - // here init memory capsules -} - void BPFileReader::InitTransports() // maybe move this? { if (m_DebugMode == true) diff --git a/source/functions/adiosFunctions.cpp b/source/functions/adiosFunctions.cpp index dcd7ece82e64b26677570205196da389e5bdac1b..47ab64cac7c6d82195b1449fc954900249052c31 100644 --- a/source/functions/adiosFunctions.cpp +++ b/source/functions/adiosFunctions.cpp @@ -650,6 +650,17 @@ std::string DimsToCSV(const std::vector<std::size_t> &dims) return dimsCSV; } +void ConvertUint64VectorToSizetVector(const std::vector<std::uint64_t> &in, + std::vector<std::size_t> &out) +{ + out.clear(); + out.reserve(in.size()); + for (const auto inElement : in) + { + out.push_back(static_cast<std::size_t>(inElement)); + } +} + bool CheckBufferAllocation(const std::size_t newSize, const float growthFactor, const std::size_t maxBufferSize, std::vector<char> &buffer)