diff --git a/CMakeLists.txt b/CMakeLists.txt index 87181d9..b760c27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.17) project(kokkos-resilience VERSION 0.1.0) +include(CMakeDependentOption) + INCLUDE(GNUInstallDirs) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules") @@ -8,6 +10,28 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules") add_library(resilience) add_library(Kokkos::resilience ALIAS resilience) +#Expose a variable to linking CMakeLists and as a compile definition. +set(KR_EXPOSED_OPTIONS "") +macro(KR_EXPOSE_OPTION OPT) + list(APPEND KR_EXPOSED_OPTIONS "${OPT}") + + if (${OPT}) + target_compile_definitions(resilience PUBLIC ${OPT}) + endif() +endmacro() + +#Helper for making and exposing a basic option with optional dependencies +#If dependencies are listed, this option is false unless dependencies are met +macro(KR_OPTION OPT DESC DEFAULT) + set(DEPS "${ARGN}") #DEPS gets all extra arguments + if (DEPS) + cmake_dependent_option(${OPT} "${DESC}" ${DEFAULT} "${DEPS}" OFF) + else() + option(${OPT} "${DESC}" ${DEFAULT}) + endif() + KR_EXPOSE_OPTION(${OPT}) +endmacro() + option(KR_ALL_WARNINGS "Enable all warnings" ON) option(KR_WARNINGS_AS_ERRORS "Enable warnings as errors" ON) @@ -31,107 +55,79 @@ target_include_directories(resilience PUBLIC ) find_package(Kokkos 4.0 REQUIRED) +find_package(Boost REQUIRED) set_property(TARGET resilience PROPERTY CXX_STANDARD ${Kokkos_CXX_STANDARD}) +target_link_libraries(resilience PUBLIC Kokkos::kokkos Boost::boost) -target_link_libraries(resilience PUBLIC Kokkos::kokkos) +#Make individual variables for available Kokkos devices +foreach(DEVICE ${Kokkos_DEVICES}) + set(KR_${DEVICE}_DEVICE_ENABLED TRUE) + mark_as_advanced(KR_${DEVICE}_DEVICE_ENABLED) +endforeach() -option(KR_ENABLE_VELOC "use VeloC backend for automatic checkpointing" ON) -option(KR_ENABLE_STDFILE "use StdFile backend for automatic checkpointing" ON) +#Library options +kr_option(KR_ENABLE_TRACING "Enable tracing of resilience functions" OFF) +option(KR_ENABLE_TESTS "Enable tests in the build" ON) +option(KR_ENABLE_EXAMPLES "Enable examples in the build" ON) -include(CMakeDependentOption) +#Automatic checkpointing options +kr_option(KR_ENABLE_AUTOMATIC_CHECKPOINTING "Compile automatic checkpointing contexts and backends" ON) +#Consistency contexts +kr_option(KR_ENABLE_MPI_CONTEXT "Compile MPI checkpointing context" ON KR_ENABLE_AUTOMATIC_CHECKPOINTING) +#Backends +kr_option(KR_ENABLE_VELOC_BACKEND "Compile VeloC checkpointing backend" ON KR_ENABLE_MPI_CONTEXT) +kr_option(KR_VELOC_BAREBONE "Use the barebone branch of VeloC" OFF KR_ENABLE_VELOC) + +#Data space options +kr_option(KR_ENABLE_DATA_SPACES "Enable Kokkos memory spaces for manual view checkpointing" OFF) +kr_option(KR_ENABLE_STDFILE_DATA_SPACE "Enable stdfile-based data space" ON KR_ENABLE_DATA_SPACES) +kr_option(KR_ENABLE_HDF5_DATA_SPACE "Enable HDF5-based data space" OFF KR_ENABLE_DATA_SPACES) +kr_option(KR_ENABLE_HDF5_PARALLEL "use parallel version of HDF5" OFF KR_ENABLE_HDF5_DATA_SPACE) + +#Exec space options +kr_option(KR_ENABLE_EXEC_SPACES "enable resilient execution spaces" OFF) +kr_option(KR_ENABLE_CUDA_EXEC_SPACE "enable the resilient CUDA execution space" ON "KR_ENABLE_EXEC_SPACES;KR_CUDA_DEVICE_ENABLED") +kr_option(KR_ENABLE_OPENMP_EXEC_SPACE "enable the resilient OpenMP execution space" ON "KR_ENABLE_EXEC_SPACES;KR_OPENMP_DEVICE_ENABLED") -cmake_dependent_option(KR_VELOC_BAREBONE "Use the barebone branch of VeloC" OFF "KR_ENABLE_VELOC" OFF) # VeloC backend -if (KR_ENABLE_VELOC) +if (KR_ENABLE_VELOC_BACKEND) find_package(veloc REQUIRED) target_link_libraries(resilience PUBLIC veloc::client) - target_compile_definitions(resilience PUBLIC KR_ENABLE_VELOC) - set(KR_ENABLE_MPI_BACKENDS ON) - - if (KR_VELOC_BAREBONE) - target_compile_definitions(resilience PRIVATE KR_VELOC_BAREBONE) - endif() -endif() - -# StdFile backend -if (KR_ENABLE_STDFILE) - target_compile_definitions(resilience PUBLIC KR_ENABLE_STDFILE) endif() -if (KR_ENABLE_MPI_BACKENDS) - target_compile_definitions(resilience PUBLIC KR_ENABLE_MPI_BACKENDS) -endif() - -# Library options -option(KR_ENABLE_TRACING "Enable tracing of resilience functions" OFF) -if (KR_ENABLE_TRACING) - target_compile_definitions(resilience PUBLIC KR_ENABLE_TRACING) -endif() - -option( KR_ENABLE_STDIO "use stdio for manual checkpoint" OFF ) -option( KR_ENABLE_HDF5 "add HDF5 support" OFF ) -option( KR_ENABLE_HDF5_PARALLEL "use parallel version of HDF5" OFF ) - -if (KR_ENABLE_STDIO) - set(KR_ENABLE_MANUAL_CHECKPOINT ON) -endif() - -if (KR_ENABLE_HDF5_PARALLEL) - set(KR_ENABLE_HDF5 ON) - target_compile_definitions(resilience PUBLIC KR_ENABLE_HDF5_PARALLEL) - set(KR_ENABLE_MANUAL_CHECKPOINT ON) -endif() - -if (KR_ENABLE_HDF5) +if (KR_ENABLE_HDF5_DATA_SPACE) find_package(HDF5 REQUIRED) target_link_libraries(resilience PUBLIC HDF5::HDF5) - target_compile_definitions(resilience PUBLIC KR_ENABLE_HDF5) - set(KR_ENABLE_MANUAL_CHECKPOINT ON) -endif() - -if (KR_ENABLE_MANUAL_CHECKPOINT) - target_compile_definitions(resilience PUBLIC KR_ENABLE_MANUAL_CHECKPOINT) endif() # MPI requirement -if (KR_ENABLE_VELOC OR KR_ENABLE_HDF5_PARALLEL) +if (KR_ENABLE_MPI_CONTEXT OR KR_ENABLE_HDF5_PARALLEL) find_package(MPI REQUIRED) target_link_libraries(resilience PRIVATE MPI::MPI_CXX) endif() -# Devices -list(FIND Kokkos_DEVICES "CUDA" _kokkos_cuda_found) -if (_kokkos_cuda_found GREATER -1) - set(KR_CUDA_DEVICE_ENABLED TRUE) - mark_as_advanced(KR_CUDA_DEVICE_ENABLED) -endif() -list(FIND Kokkos_DEVICES "OPENMP" _kokkos_omp_found) -if (_kokkos_omp_found GREATER -1) - set(KR_OPENMP_DEVICE_ENABLED TRUE) - mark_as_advanced(KR_OPENMP_DEVICE_ENABLED) -endif() - -option(KR_ENABLE_EXEC_SPACES "enable resilient execution spaces" OFF) -cmake_dependent_option(KR_ENABLE_CUDA_EXEC_SPACE "enable the resilient CUDA execution space" ON "KR_ENABLE_EXEC_SPACES;KR_CUDA_DEVICE_ENABLED" OFF) -cmake_dependent_option(KR_ENABLE_OPENMP_EXEC_SPACE "enable the resilient CUDA execution space" ON "KR_ENABLE_EXEC_SPACES;KR_OPENMP_DEVICE_ENABLED" OFF) if (KR_ENABLE_CUDA_EXEC_SPACE) message(STATUS "CUDA resilient execution spaces are enabled") - target_compile_definitions(resilience PUBLIC KR_ENABLE_CUDA_EXEC_SPACE) endif() if (KR_ENABLE_OPENMP_EXEC_SPACE) message(STATUS "OpenMP resilient execution spaces are enabled") endif() -find_package(Boost REQUIRED) - -target_link_libraries(resilience PUBLIC Boost::boost) add_subdirectory(src) + +#Set variable values to expose to resilienceConfig.cmake +set(KR_EXPOSED_OPTION_VALUES "") +foreach (OPT ${KR_EXPOSED_OPTIONS}) + list(APPEND KR_EXPOSED_OPTION_VALUES ${${OPT}}) +endforeach() + + # Export targets for in-tree linking export(TARGETS resilience NAMESPACE Kokkos:: @@ -171,22 +167,8 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/resilienceConfig.cmake install(DIRECTORY src/resilience DESTINATION include FILES_MATCHING PATTERN "*.hpp") -if (KR_ENABLE_HDF5) - install(FILES - ${CMAKE_MODULE_PATH}/FindHDF5.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/resilience/Modules ) - - # Need to install/export HDF5 find module for downstream dependencies - configure_file(cmake/Modules/FindHDF5.cmake Modules/FindHDF5.cmake COPYONLY) -endif() - -configure_file(src/resilience/config/Config.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/src/resilience/config/Config.hpp @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/src/resilience/config/Config.hpp DESTINATION include/resilience/config) # Add subdirectories for examples and tests if they are enabled -option(KR_ENABLE_TESTS "Enable tests in the build" ON) -option(KR_ENABLE_EXAMPLES "Enable examples in the build" ON) - add_subdirectory(tpl) if (KR_ENABLE_TESTS) diff --git a/CMakePresets.json b/CMakePresets.json index ae6b734..d3c180e 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -14,11 +14,7 @@ "type": "BOOL", "value": "OFF" }, - "KR_ENABLE_VELOC": { - "type": "BOOL", - "value": "ON" - }, - "KR_ENABLE_STDFILE": { + "KR_ENABLE_VELOC_BACKEND": { "type": "BOOL", "value": "ON" } diff --git a/cmake/resilienceConfig.cmake.in b/cmake/resilienceConfig.cmake.in index 8ad96eb..3cd2ee2 100644 --- a/cmake/resilienceConfig.cmake.in +++ b/cmake/resilienceConfig.cmake.in @@ -5,11 +5,12 @@ include(CMakeFindDependencyMacro) include("${CMAKE_CURRENT_LIST_DIR}/resilienceTargets.cmake") -set(KR_ENABLE_HDF5 @KR_ENABLE_HDF5@) -set(KR_ENABLE_VELOC @KR_ENABLE_VELOC@) -set(KR_ENABLE_EXEC_SPACES @KR_ENABLE_EXEC_SPACES@) -set(KR_ENABLE_CUDA_EXEC_SPACE @KR_ENABLE_CUDA_EXEC_SPACE@) -set(KR_ENABLE_OPENMP_EXEC_SPACE @KR_ENABLE_OPENMP_EXEC_SPACE@) +#All options defined with kr_option are exposed to linking targets' CMakeLists +set(KR_EXPOSED_OPTIONS @KR_EXPOSED_OPTIONS@) +set(KR_EXPOSED_OPTION_VALUES @KR_EXPOSED_OPTION_VALUES@) +foreach (OPT in ZIP_LISTS KR_EXPOSED_OPTIONS KR_EXPOSED_OPTION_VALUES) + set(${OPT_1} ${OPT_2}) +endforeach() # VeloC needs to add a cmake config... LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/Modules/") @@ -17,13 +18,12 @@ message(STATUS "Module path: ${CMAKE_MODULE_PATH}") find_dependency(Kokkos REQUIRED NO_CMAKE_PACKAGE_REGISTRY HINTS @Kokkos_DIR@) -if (@KR_ENABLE_VELOC@) +if (KR_ENABLE_VELOC_BACKEND) set(veloc_DIR @veloc_DIR@) - set(KR_VELOC_BAREBONE @KR_VELOC_BAREBONE@) find_dependency(veloc REQUIRED) endif() -if (@KR_ENABLE_HDF5@) +if (KR_ENABLE_HDF5_DATA_SPACE) set(HDF5_DIR @HDF5_DIR@) find_dependency(HDF5 REQUIRED) endif() diff --git a/src/resilience/AutomaticCheckpoint.hpp b/src/resilience/AutomaticCheckpoint.hpp index c911257..5c29106 100644 --- a/src/resilience/AutomaticCheckpoint.hpp +++ b/src/resilience/AutomaticCheckpoint.hpp @@ -53,7 +53,7 @@ #include "view_hooks/DynamicViewHooks.hpp" #include "Cref.hpp" -#include "CheckpointFilter.hpp" +#include "context/CheckpointFilter.hpp" // Tracing support #ifdef KR_ENABLE_TRACING diff --git a/src/resilience/CMakeLists.txt b/src/resilience/CMakeLists.txt index 32d88cc..84cb525 100644 --- a/src/resilience/CMakeLists.txt +++ b/src/resilience/CMakeLists.txt @@ -1,39 +1,24 @@ -target_sources(resilience PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/Resilience.cpp - ${CMAKE_CURRENT_LIST_DIR}/AutomaticCheckpoint.cpp - ${CMAKE_CURRENT_LIST_DIR}/Context.cpp - ${CMAKE_CURRENT_LIST_DIR}/Config.cpp - ${CMAKE_CURRENT_LIST_DIR}/Cref.cpp - ${CMAKE_CURRENT_LIST_DIR}/ResilientRef.cpp - ) - -if (KR_ENABLE_MPI_BACKENDS) - target_sources(resilience PRIVATE MPIContext.cpp) -endif() - -add_subdirectory(filesystem) -add_subdirectory(stdio) - -if (KR_ENABLE_VELOC) - add_subdirectory(veloc) +target_sources(resilience PRIVATE ${CMAKE_CURRENT_LIST_DIR}/Resilience.cpp) + +if (KR_ENABLE_AUTOMATIC_CHECKPOINTING) + target_sources(resilience PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/config/Config.cpp + ${CMAKE_CURRENT_LIST_DIR}/Cref.cpp + ) + add_subdirectory(backend) + add_subdirectory(context) endif() -if (KR_ENABLE_STDFILE) - target_sources(resilience PRIVATE StdFileContext.cpp) - add_subdirectory(stdfile) +if (KR_ENABLE_EXEC_SPACES) + add_subdirectory(exec_space) endif() -if (KR_ENABLE_HDF5) - add_subdirectory(hdf5) -endif() - -add_subdirectory(view_hooks) - -if (KR_ENABLE_CUDA_EXEC_SPACE) - add_subdirectory(cuda) +if (KR_ENABLE_AUTOMATIC_CHECKPOINTING OR KR_ENABLE_EXEC_SPACES) + add_subdirectory(view_hooks) endif() -if (KR_ENABLE_OPENMP_EXEC_SPACE) - add_subdirectory(openMP) +if (KR_ENABLE_DATA_SPACES) + add_subdirectory(data_space) endif() +add_subdirectory(util) diff --git a/src/resilience/Resilience.hpp b/src/resilience/Resilience.hpp index 3387629..331857b 100644 --- a/src/resilience/Resilience.hpp +++ b/src/resilience/Resilience.hpp @@ -45,23 +45,10 @@ #include -#include "Context.hpp" -#include "ManualCheckpoint.hpp" - -#ifdef KR_ENABLE_VELOC -#include "veloc/VelocBackend.hpp" -#include "AutomaticCheckpoint.hpp" -#endif - -#ifdef KR_ENABLE_STDFILE -#include "stdfile/StdFileBackend.hpp" -#include "AutomaticCheckpoint.hpp" -#endif - -#ifdef KR_ENABLE_CUDA_EXEC_SPACE -#include "cuda/ResCuda.hpp" -#include "cuda/ResCudaSpace.hpp" -#include "cuda/CudaResParallel.hpp" +#ifdef KR_ENABLE_AUTOMATIC_CHECKPOINTING +#include "resilience/context/Context.hpp" +#include "resilience/backend/Backend.hpp" +#include "resilience/AutomaticCheckpoint.hpp" #endif namespace KokkosResilience { @@ -75,4 +62,12 @@ void set_unrecoverable_data_corruption_handler(unrecoverable_data_corruption_han unrecoverable_data_corruption_handler &get_unrecoverable_data_corruption_handler(); } // namespace KokkosResilience +#ifdef KR_ENABLE_EXEC_SPACES +#include "resilience/exec_space/ExecSpace.hpp" +#endif + +#ifdef KR_ENABLE_DATA_SPACES +#include "resilience/data_space/DataSpace.hpp" +#endif + #endif // INC_RESILIENCE_RESILIENCE_HPP diff --git a/src/resilience/ResilientRef.cpp b/src/resilience/ResilientRef.cpp deleted file mode 100644 index 2c624f5..0000000 --- a/src/resilience/ResilientRef.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * Kokkos v. 3.0 - * Copyright (2020) National Technology & Engineering - * Solutions of Sandia, LLC (NTESS). - * - * Under the terms of Contract DE-NA0003525 with NTESS, - * the U.S. Government retains certain rights in this software. - * - * Kokkos is licensed under 3-clause BSD terms of use: - * - * 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 Corporation nor the names of the - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY NTESS "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 NTESS OR THE - * 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. - * - * Questions? Contact Christian R. Trott (crtrott@sandia.gov) - */ -#include "ResilientRef.hpp" - -namespace KokkosResilience -{ -} \ No newline at end of file diff --git a/src/resilience/ResilientRef.hpp b/src/resilience/ResilientRef.hpp index 86ad307..f90f397 100644 --- a/src/resilience/ResilientRef.hpp +++ b/src/resilience/ResilientRef.hpp @@ -44,10 +44,14 @@ #include #include #include -#include "Utility.hpp" namespace KokkosResilience { + struct in_place_t + { + explicit in_place_t() = default; + }; + template< typename T > class Ref { diff --git a/src/resilience/AutomaticCheckpoint.cpp b/src/resilience/backend/Backend.hpp similarity index 95% rename from src/resilience/AutomaticCheckpoint.cpp rename to src/resilience/backend/Backend.hpp index 64ebbd2..20d4769 100644 --- a/src/resilience/AutomaticCheckpoint.cpp +++ b/src/resilience/backend/Backend.hpp @@ -38,8 +38,9 @@ * * Questions? Contact Christian R. Trott (crtrott@sandia.gov) */ -#include "AutomaticCheckpoint.hpp" -namespace KokkosResilience -{ -} \ No newline at end of file +#include "StdFileBackend.hpp" + +#ifdef KR_ENABLE_VELOC_BACKEND +#include "VelocBackend.hpp" +#endif diff --git a/src/resilience/backend/CMakeLists.txt b/src/resilience/backend/CMakeLists.txt new file mode 100644 index 0000000..520921b --- /dev/null +++ b/src/resilience/backend/CMakeLists.txt @@ -0,0 +1,5 @@ +target_sources(resilience PRIVATE ${CMAKE_CURRENT_LIST_DIR}/StdFileBackend.cpp) + +if (KR_ENABLE_VELOC_BACKEND) + target_sources(resilience PRIVATE ${CMAKE_CURRENT_LIST_DIR}/VelocBackend.cpp) +endif() diff --git a/src/resilience/stdfile/StdFileBackend.cpp b/src/resilience/backend/StdFileBackend.cpp similarity index 100% rename from src/resilience/stdfile/StdFileBackend.cpp rename to src/resilience/backend/StdFileBackend.cpp diff --git a/src/resilience/stdfile/StdFileBackend.hpp b/src/resilience/backend/StdFileBackend.hpp similarity index 97% rename from src/resilience/stdfile/StdFileBackend.hpp rename to src/resilience/backend/StdFileBackend.hpp index 4ce24bf..f815bfe 100644 --- a/src/resilience/stdfile/StdFileBackend.hpp +++ b/src/resilience/backend/StdFileBackend.hpp @@ -48,8 +48,8 @@ #include #include -#include "../Cref.hpp" -#include "../StdFileContext.hpp" +#include "resilience/Cref.hpp" +#include "resilience/context/StdFileContext.hpp" namespace KokkosResilience { diff --git a/src/resilience/veloc/VelocBackend.cpp b/src/resilience/backend/VelocBackend.cpp similarity index 98% rename from src/resilience/veloc/VelocBackend.cpp rename to src/resilience/backend/VelocBackend.cpp index 30d87ea..541a7f6 100644 --- a/src/resilience/veloc/VelocBackend.cpp +++ b/src/resilience/backend/VelocBackend.cpp @@ -45,11 +45,11 @@ #include #include -#include "../MPIContext.hpp" -#include "../AutomaticCheckpoint.hpp" +#include +#include #ifdef KR_ENABLE_TRACING - #include "../util/Trace.hpp" + #include #endif #define VELOC_SAFE_CALL( call ) KokkosResilience::veloc_internal_safe_call( call, #call, __FILE__, __LINE__ ) diff --git a/src/resilience/veloc/VelocBackend.hpp b/src/resilience/backend/VelocBackend.hpp similarity index 100% rename from src/resilience/veloc/VelocBackend.hpp rename to src/resilience/backend/VelocBackend.hpp diff --git a/src/resilience/Config.cpp b/src/resilience/config/Config.cpp similarity index 100% rename from src/resilience/Config.cpp rename to src/resilience/config/Config.cpp diff --git a/src/resilience/Config.hpp b/src/resilience/config/Config.hpp similarity index 100% rename from src/resilience/Config.hpp rename to src/resilience/config/Config.hpp diff --git a/src/resilience/config/Config.hpp.in b/src/resilience/config/Config.hpp.in deleted file mode 100644 index aa4edba..0000000 --- a/src/resilience/config/Config.hpp.in +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef INC_RESILIENCE_CONFIG_CONFIG_HPP -#define INC_RESILIENCE_CONFIG_CONFIG_HPP - -/* Resilience options */ - -#endif // INC_RESILIENCE_CONFIG_CONFIG_HPP diff --git a/src/resilience/context/CMakeLists.txt b/src/resilience/context/CMakeLists.txt new file mode 100644 index 0000000..921ed76 --- /dev/null +++ b/src/resilience/context/CMakeLists.txt @@ -0,0 +1,9 @@ +target_sources(resilience PRIVATE ${CMAKE_CURRENT_LIST_DIR}/Context.cpp) + +if (KR_ENABLE_MPI_BACKENDS) + target_sources(resilience PRIVATE ${CMAKE_CURRENT_LIST_DIR}/MPIContext.cpp) +endif() + +if (KR_ENABLE_STDFILE) + target_sources(resilience PRIVATE ${CMAKE_CURRENT_LIST_DIR}/StdFileContext.cpp) +endif() diff --git a/src/resilience/CheckpointFilter.hpp b/src/resilience/context/CheckpointFilter.hpp similarity index 100% rename from src/resilience/CheckpointFilter.hpp rename to src/resilience/context/CheckpointFilter.hpp diff --git a/src/resilience/Context.cpp b/src/resilience/context/Context.cpp similarity index 100% rename from src/resilience/Context.cpp rename to src/resilience/context/Context.cpp diff --git a/src/resilience/Context.hpp b/src/resilience/context/Context.hpp similarity index 94% rename from src/resilience/Context.hpp rename to src/resilience/context/Context.hpp index 6c9db6e..412b80b 100644 --- a/src/resilience/Context.hpp +++ b/src/resilience/context/Context.hpp @@ -50,18 +50,18 @@ #include #include #include -#include "Config.hpp" -#include "Cref.hpp" +#include "resilience/config/Config.hpp" +#include "resilience/Cref.hpp" #include "CheckpointFilter.hpp" #include -#include "view_hooks/ViewHolder.hpp" -#ifdef KR_ENABLE_MPI_BACKENDS +#include "resilience/view_hooks/ViewHolder.hpp" +#ifdef KR_ENABLE_MPI_CONTEXT #include #endif // Tracing support #ifdef KR_ENABLE_TRACING -#include "util/Trace.hpp" +#include "resilience/util/Trace.hpp" #endif namespace KokkosResilience @@ -112,11 +112,9 @@ namespace KokkosResilience }; std::unique_ptr< ContextBase > make_context( const std::string &config ); -#ifdef KR_ENABLE_MPI_BACKENDS - std::unique_ptr< ContextBase > make_context( MPI_Comm comm, const std::string &config ); -#endif -#ifdef KR_ENABLE_STDFILE std::unique_ptr< ContextBase > make_context( const std::string &filename, const std::string &config ); +#ifdef KR_ENABLE_MPI_CONTEXT + std::unique_ptr< ContextBase > make_context( MPI_Comm comm, const std::string &config ); #endif } diff --git a/src/resilience/MPIContext.cpp b/src/resilience/context/MPIContext.cpp similarity index 96% rename from src/resilience/MPIContext.cpp rename to src/resilience/context/MPIContext.cpp index e593bfd..3a5ada2 100644 --- a/src/resilience/MPIContext.cpp +++ b/src/resilience/context/MPIContext.cpp @@ -39,8 +39,8 @@ * Questions? Contact Christian R. Trott (crtrott@sandia.gov) */ #include "MPIContext.hpp" -#ifdef KR_ENABLE_VELOC -#include "veloc/VelocBackend.hpp" +#ifdef KR_ENABLE_VELOC_BACKEND +#include #endif #include #include @@ -53,7 +53,7 @@ make_context( MPI_Comm comm, const std::string &config ) using fun_type = std::function< std::unique_ptr< ContextBase >() >; static std::unordered_map< std::string, fun_type > backends = { -#ifdef KR_ENABLE_VELOC +#ifdef KR_ENABLE_VELOC_BACKEND { "veloc", [&](){ return std::make_unique< MPIContext< VeloCMemoryBackend > >( comm, cfg ); } }, { "veloc-noop", [&](){ return std::make_unique< MPIContext< VeloCRegisterOnlyBackend > >( comm, cfg ); } } #endif diff --git a/src/resilience/MPIContext.hpp b/src/resilience/context/MPIContext.hpp similarity index 100% rename from src/resilience/MPIContext.hpp rename to src/resilience/context/MPIContext.hpp diff --git a/src/resilience/StdFileContext.cpp b/src/resilience/context/StdFileContext.cpp similarity index 100% rename from src/resilience/StdFileContext.cpp rename to src/resilience/context/StdFileContext.cpp diff --git a/src/resilience/StdFileContext.hpp b/src/resilience/context/StdFileContext.hpp similarity index 100% rename from src/resilience/StdFileContext.hpp rename to src/resilience/context/StdFileContext.hpp diff --git a/src/resilience/data_space/CMakeLists.txt b/src/resilience/data_space/CMakeLists.txt new file mode 100644 index 0000000..6d035e9 --- /dev/null +++ b/src/resilience/data_space/CMakeLists.txt @@ -0,0 +1,14 @@ +if (KR_ENABLE_STDFILE_DATA_SPACE) + target_sources(resilience PRIVATE ${CMAKE_CURRENT_LIST_DIR}/StdFileSpace.cpp) +endif() + +if (KR_ENABLE_HDF5_DATA_SPACE) + target_sources(resilience PRIVATE ${CMAKE_CURRENT_LIST_DIR}/HDF5Space.cpp) + + install(FILES + ${CMAKE_MODULE_PATH}/FindHDF5.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/resilience/Modules) + + # Need to install/export HDF5 find module for downstream dependencies + configure_file(${CMAKE_LIST_DIR}/cmake/Modules/FindHDF5.cmake Modules/FindHDF5.cmake COPYONLY) +endif() diff --git a/src/resilience/ManualCheckpoint.hpp b/src/resilience/data_space/DataSpace.hpp similarity index 92% rename from src/resilience/ManualCheckpoint.hpp rename to src/resilience/data_space/DataSpace.hpp index 40e483c..54017bc 100644 --- a/src/resilience/ManualCheckpoint.hpp +++ b/src/resilience/data_space/DataSpace.hpp @@ -38,10 +38,10 @@ * * Questions? Contact Christian R. Trott (crtrott@sandia.gov) */ -#ifndef INC_RESILIENCE_MANUALCHECKPOINT_HPP -#define INC_RESILIENCE_MANUALCHECKPOINT_HPP +#ifndef INC_RESILIENCE_DATA_SPACE_SPACES_HPP +#define INC_RESILIENCE_DATA_SPACE_SPACES_HPP -#ifdef KR_ENABLE_MANUAL_CHECKPOINT +#ifdef KR_ENABLE_DATA_SPACES #include "resilience/stdio/StdFileSpace.hpp" #ifdef KR_ENABLE_HDF5 @@ -49,4 +49,4 @@ #endif #endif -#endif // INC_RESILIENCE_MANUALCHECKPOINT_HPP +#endif // INC_RESILIENCE_DATA_SPACE_SPACES_HPP diff --git a/src/resilience/hdf5/HDF5Space.cpp b/src/resilience/data_space/HDF5Space.cpp similarity index 100% rename from src/resilience/hdf5/HDF5Space.cpp rename to src/resilience/data_space/HDF5Space.cpp diff --git a/src/resilience/hdf5/HDF5Space.hpp b/src/resilience/data_space/HDF5Space.hpp similarity index 99% rename from src/resilience/hdf5/HDF5Space.hpp rename to src/resilience/data_space/HDF5Space.hpp index c6b0cb3..b79ec56 100644 --- a/src/resilience/hdf5/HDF5Space.hpp +++ b/src/resilience/data_space/HDF5Space.hpp @@ -51,7 +51,6 @@ #include #include #include -#include #include "resilience/filesystem/ExternalIOInterface.hpp" #include diff --git a/src/resilience/stdio/StdFileSpace.cpp b/src/resilience/data_space/StdFileSpace.cpp similarity index 100% rename from src/resilience/stdio/StdFileSpace.cpp rename to src/resilience/data_space/StdFileSpace.cpp diff --git a/src/resilience/stdio/StdFileSpace.hpp b/src/resilience/data_space/StdFileSpace.hpp similarity index 98% rename from src/resilience/stdio/StdFileSpace.hpp rename to src/resilience/data_space/StdFileSpace.hpp index d60f5df..1a4ea20 100644 --- a/src/resilience/stdio/StdFileSpace.hpp +++ b/src/resilience/data_space/StdFileSpace.hpp @@ -48,7 +48,7 @@ #include #include -#include "resilience/filesystem/ExternalIOInterface.hpp" +#include "resilience/util/filesystem/ExternalIOInterface.hpp" #include @@ -295,5 +295,5 @@ template struct DeepCopy< Kokkos::HostSpace , KokkosResil } // Kokkos -#include "resilience/filesystem/DirectoryManagement.hpp" +#include "resilience/util/filesystem/DirectoryManagement.hpp" #endif // INC_RESILIENCE_STDIO_STDFILESPACE_HPP diff --git a/src/resilience/exec_space/CMakeLists.txt b/src/resilience/exec_space/CMakeLists.txt new file mode 100644 index 0000000..fe30615 --- /dev/null +++ b/src/resilience/exec_space/CMakeLists.txt @@ -0,0 +1,7 @@ +if (KR_ENABLE_CUDA_EXEC_SPACE) + add_subdirectory(cuda) +endif() + +if (KR_ENABLE_OPENMP_EXEC_SPACE) + add_subdirectory(openMP) +endif() diff --git a/src/resilience/Utility.hpp b/src/resilience/exec_space/ExecSpace.hpp similarity index 85% rename from src/resilience/Utility.hpp rename to src/resilience/exec_space/ExecSpace.hpp index 1941e77..4dd093f 100644 --- a/src/resilience/Utility.hpp +++ b/src/resilience/exec_space/ExecSpace.hpp @@ -38,15 +38,17 @@ * * Questions? Contact Christian R. Trott (crtrott@sandia.gov) */ -#ifndef INC_KOKKOS_RESILIENCE_UTILITY_HPP -#define INC_KOKKOS_RESILIENCE_UTILITY_HPP -namespace KokkosResilience -{ - struct in_place_t - { - explicit in_place_t() = default; - }; -} -#endif // INC_KOKKOS_RESILIENCE_UTILITY_HPP +#ifdef KR_ENABLE_CUDA_EXEC_SPACE +#include "cuda/ResCuda.hpp" +#include "cuda/ResCudaSpace.hpp" +#include "cuda/CudaResParallel.hpp" +#endif + +#ifdef KR_ENABLE_OPENMP_EXEC_SPACE +#include "openMP/ResOpenMP.hpp" +#include "openMP/OpenMPResParallel.hpp" +#include "openMP/OpenMPResSubscriber.hpp" +#include "openMP/ResHostSpace.hpp" +#endif diff --git a/src/resilience/cuda/CMakeLists.txt b/src/resilience/exec_space/cuda/CMakeLists.txt similarity index 100% rename from src/resilience/cuda/CMakeLists.txt rename to src/resilience/exec_space/cuda/CMakeLists.txt diff --git a/src/resilience/cuda/CudaResParallel.hpp b/src/resilience/exec_space/cuda/CudaResParallel.hpp similarity index 100% rename from src/resilience/cuda/CudaResParallel.hpp rename to src/resilience/exec_space/cuda/CudaResParallel.hpp diff --git a/src/resilience/cuda/ResCuda.cpp b/src/resilience/exec_space/cuda/ResCuda.cpp similarity index 100% rename from src/resilience/cuda/ResCuda.cpp rename to src/resilience/exec_space/cuda/ResCuda.cpp diff --git a/src/resilience/cuda/ResCuda.hpp b/src/resilience/exec_space/cuda/ResCuda.hpp similarity index 100% rename from src/resilience/cuda/ResCuda.hpp rename to src/resilience/exec_space/cuda/ResCuda.hpp diff --git a/src/resilience/cuda/ResCudaSpace.cpp b/src/resilience/exec_space/cuda/ResCudaSpace.cpp similarity index 99% rename from src/resilience/cuda/ResCudaSpace.cpp rename to src/resilience/exec_space/cuda/ResCudaSpace.cpp index d843b87..07d9dee 100644 --- a/src/resilience/cuda/ResCudaSpace.cpp +++ b/src/resilience/exec_space/cuda/ResCudaSpace.cpp @@ -52,7 +52,7 @@ #include #include -#include "../Resilience.hpp" +#include "resilience/Resilience.hpp" #include "ResCudaSpace.hpp" #include diff --git a/src/resilience/cuda/ResCudaSpace.hpp b/src/resilience/exec_space/cuda/ResCudaSpace.hpp similarity index 100% rename from src/resilience/cuda/ResCudaSpace.hpp rename to src/resilience/exec_space/cuda/ResCudaSpace.hpp diff --git a/src/resilience/openMP/CMakeLists.txt b/src/resilience/exec_space/openMP/CMakeLists.txt similarity index 100% rename from src/resilience/openMP/CMakeLists.txt rename to src/resilience/exec_space/openMP/CMakeLists.txt diff --git a/src/resilience/openMP/OpenMPResParallel.hpp b/src/resilience/exec_space/openMP/OpenMPResParallel.hpp similarity index 100% rename from src/resilience/openMP/OpenMPResParallel.hpp rename to src/resilience/exec_space/openMP/OpenMPResParallel.hpp diff --git a/src/resilience/openMP/OpenMPResSubscriber.cpp b/src/resilience/exec_space/openMP/OpenMPResSubscriber.cpp similarity index 97% rename from src/resilience/openMP/OpenMPResSubscriber.cpp rename to src/resilience/exec_space/openMP/OpenMPResSubscriber.cpp index 4359a70..ce61fb0 100644 --- a/src/resilience/openMP/OpenMPResSubscriber.cpp +++ b/src/resilience/exec_space/openMP/OpenMPResSubscriber.cpp @@ -56,4 +56,4 @@ std::unordered_map< ResilientDuplicatesSubscriber::key_type, std::unique_ptr< Co } #endif //defined(KOKKOS_ENABLE_OPENMP) -#endif //INC_RESILIENCE_OPENMP_OPENMPRESSUBSCRIBER_CPP \ No newline at end of file +#endif //INC_RESILIENCE_OPENMP_OPENMPRESSUBSCRIBER_CPP diff --git a/src/resilience/openMP/OpenMPResSubscriber.hpp b/src/resilience/exec_space/openMP/OpenMPResSubscriber.hpp similarity index 100% rename from src/resilience/openMP/OpenMPResSubscriber.hpp rename to src/resilience/exec_space/openMP/OpenMPResSubscriber.hpp diff --git a/src/resilience/openMP/ResHostSpace.hpp b/src/resilience/exec_space/openMP/ResHostSpace.hpp similarity index 100% rename from src/resilience/openMP/ResHostSpace.hpp rename to src/resilience/exec_space/openMP/ResHostSpace.hpp diff --git a/src/resilience/openMP/ResOpenMP.cpp b/src/resilience/exec_space/openMP/ResOpenMP.cpp similarity index 100% rename from src/resilience/openMP/ResOpenMP.cpp rename to src/resilience/exec_space/openMP/ResOpenMP.cpp diff --git a/src/resilience/openMP/ResOpenMP.hpp b/src/resilience/exec_space/openMP/ResOpenMP.hpp similarity index 100% rename from src/resilience/openMP/ResOpenMP.hpp rename to src/resilience/exec_space/openMP/ResOpenMP.hpp diff --git a/src/resilience/hdf5/CMakeLists.txt b/src/resilience/hdf5/CMakeLists.txt deleted file mode 100644 index fb1403b..0000000 --- a/src/resilience/hdf5/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -target_sources(resilience PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/HDF5Space.cpp - ) \ No newline at end of file diff --git a/src/resilience/stdfile/CMakeLists.txt b/src/resilience/stdfile/CMakeLists.txt deleted file mode 100644 index ea46fa9..0000000 --- a/src/resilience/stdfile/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -if (KR_ENABLE_STDFILE) - target_sources(resilience PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/StdFileBackend.cpp - ) -endif() \ No newline at end of file diff --git a/src/resilience/stdio/CMakeLists.txt b/src/resilience/stdio/CMakeLists.txt deleted file mode 100644 index d1f79a6..0000000 --- a/src/resilience/stdio/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -if (KR_ENABLE_STDIO) - target_sources(resilience PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/StdFileSpace.cpp - ) -endif() \ No newline at end of file diff --git a/src/resilience/util/CMakeLists.txt b/src/resilience/util/CMakeLists.txt index dba0ad8..81dba0b 100644 --- a/src/resilience/util/CMakeLists.txt +++ b/src/resilience/util/CMakeLists.txt @@ -1,3 +1,5 @@ target_sources(resilience PRIVATE ${CMAKE_CURRENT_LIST_DIR}/Trace.cpp - ) \ No newline at end of file + ) + +add_subdirectory(filesystem) diff --git a/src/resilience/filesystem/CMakeLists.txt b/src/resilience/util/filesystem/CMakeLists.txt similarity index 100% rename from src/resilience/filesystem/CMakeLists.txt rename to src/resilience/util/filesystem/CMakeLists.txt diff --git a/src/resilience/filesystem/DirectoryManagement.hpp b/src/resilience/util/filesystem/DirectoryManagement.hpp similarity index 100% rename from src/resilience/filesystem/DirectoryManagement.hpp rename to src/resilience/util/filesystem/DirectoryManagement.hpp diff --git a/src/resilience/filesystem/ExternalIOInterface.cpp b/src/resilience/util/filesystem/ExternalIOInterface.cpp similarity index 100% rename from src/resilience/filesystem/ExternalIOInterface.cpp rename to src/resilience/util/filesystem/ExternalIOInterface.cpp diff --git a/src/resilience/filesystem/ExternalIOInterface.hpp b/src/resilience/util/filesystem/ExternalIOInterface.hpp similarity index 100% rename from src/resilience/filesystem/ExternalIOInterface.hpp rename to src/resilience/util/filesystem/ExternalIOInterface.hpp diff --git a/src/resilience/filesystem/Filesystem.cpp b/src/resilience/util/filesystem/Filesystem.cpp similarity index 100% rename from src/resilience/filesystem/Filesystem.cpp rename to src/resilience/util/filesystem/Filesystem.cpp diff --git a/src/resilience/filesystem/Filesystem.hpp b/src/resilience/util/filesystem/Filesystem.hpp similarity index 100% rename from src/resilience/filesystem/Filesystem.hpp rename to src/resilience/util/filesystem/Filesystem.hpp diff --git a/src/resilience/veloc/CMakeLists.txt b/src/resilience/veloc/CMakeLists.txt deleted file mode 100644 index b785764..0000000 --- a/src/resilience/veloc/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -target_sources(resilience PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/VelocBackend.cpp - ) \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 50b992b..c37e0a4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -15,24 +15,24 @@ add_executable(resilience_tests TestDynamicViewHooks.cpp ) -if (KR_ENABLE_VELOC) +if (KR_ENABLE_VELOC_BACKEND) target_sources(resilience_tests PRIVATE TestVelocMemoryBackend.cpp) target_link_libraries(resilience_tests PRIVATE MPI::MPI_CXX) endif() -if (KR_ENABLE_STDFILE) +if (KR_ENABLE_AUTOMATIC_CHECKPOINTING) target_sources(resilience_tests PRIVATE TestStdFileBackend.cpp) endif() -if (KR_ENABLE_STDIO) +if (KR_ENABLE_STDFILE_DATA_SPACE) target_sources(resilience_tests PRIVATE TestViewCheckpoint.cpp ) endif() -if (KR_ENABLE_HDF5) +if (KR_ENABLE_HDF5_DATA_SPACE) target_sources(resilience_tests PRIVATE TestHDF5Configuration.cpp ) diff --git a/tests/TestMain.cpp b/tests/TestMain.cpp index 240159e..fad73ab 100644 --- a/tests/TestMain.cpp +++ b/tests/TestMain.cpp @@ -47,7 +47,7 @@ int main( int argc, char **argv ) { ::testing::InitGoogleTest( &argc, argv ); -#if defined(KR_ENABLE_HDF5_PARALLEL) || defined(KR_ENABLE_VELOC) +#if defined(KR_ENABLE_HDF5_PARALLEL) || defined(KR_ENABLE_VELOC_BACKEND) MPI_Init( &argc, &argv ); #endif @@ -57,9 +57,9 @@ main( int argc, char **argv ) Kokkos::finalize(); -#if defined(KR_ENABLE_HDF5_PARALLEL) || defined(KR_ENABLE_VELOC) +#if defined(KR_ENABLE_HDF5_PARALLEL) || defined(KR_ENABLE_VELOC_BACKEND) MPI_Finalize(); #endif return ret; -} \ No newline at end of file +} diff --git a/tests/TestOpenMPResilientExecution.cpp b/tests/TestOpenMPResilientExecution.cpp index eb21351..51d6461 100644 --- a/tests/TestOpenMPResilientExecution.cpp +++ b/tests/TestOpenMPResilientExecution.cpp @@ -42,8 +42,8 @@ #include "TestCommon.hpp" #include #include -#include -#include +#include +#include #include #include diff --git a/tests/TestStdFileBackend.cpp b/tests/TestStdFileBackend.cpp index e292b29..cd551c0 100644 --- a/tests/TestStdFileBackend.cpp +++ b/tests/TestStdFileBackend.cpp @@ -40,10 +40,10 @@ */ #include "TestCommon.hpp" -#include +#include #include -#include -#include +#include +#include #include diff --git a/tests/TestVelocMemoryBackend.cpp b/tests/TestVelocMemoryBackend.cpp index 8f68755..ff6a95f 100644 --- a/tests/TestVelocMemoryBackend.cpp +++ b/tests/TestVelocMemoryBackend.cpp @@ -40,10 +40,10 @@ */ #include "TestCommon.hpp" -#include +#include #include -#include -#include +#include +#include #include diff --git a/tests/TestViewCheckpoint.cpp b/tests/TestViewCheckpoint.cpp index ba230cd..e9b9115 100644 --- a/tests/TestViewCheckpoint.cpp +++ b/tests/TestViewCheckpoint.cpp @@ -41,7 +41,6 @@ #include #include "TestCommon.hpp" #include -#define KOKKOS_ENABLE_MANUAL_CHECKPOINT #include #ifdef KR_ENABLE_HDF5_PARALLEL