-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
199 lines (153 loc) · 6.52 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
cmake_minimum_required(VERSION 3.17)
project(kokkos-resilience VERSION 0.1.0)
INCLUDE(GNUInstallDirs)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
add_library(resilience)
add_library(Kokkos::resilience ALIAS resilience)
option(KR_ALL_WARNINGS "Enable all warnings" ON)
option(KR_WARNINGS_AS_ERRORS "Enable warnings as errors" ON)
if (KR_ALL_WARNINGS)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(resilience PRIVATE "-Wall")
endif()
endif()
if (KR_WARNINGS_AS_ERRORS)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(resilience PRIVATE "-Werror")
endif()
endif()
target_include_directories(resilience PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/src>
$<INSTALL_INTERFACE:include>
)
find_package(Kokkos 4.0 REQUIRED)
set_property(TARGET resilience PROPERTY CXX_STANDARD ${Kokkos_CXX_STANDARD})
target_link_libraries(resilience PUBLIC Kokkos::kokkos)
option(KR_ENABLE_VELOC "use VeloC backend for automatic checkpointing" ON)
option(KR_ENABLE_STDFILE "use StdFile backend for automatic checkpointing" ON)
include(CMakeDependentOption)
cmake_dependent_option(KR_VELOC_BAREBONE "Use the barebone branch of VeloC" OFF "KR_ENABLE_VELOC" OFF)
# VeloC backend
if (KR_ENABLE_VELOC)
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)
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)
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)
# Export targets for in-tree linking
export(TARGETS resilience
NAMESPACE Kokkos::
FILE resilienceTargets.cmake
)
# Set up find_package config and version file
# Allow same major version compatibility
# Possibly in the future find_package(Kokkos REQUIRED COMPONENTS reslience)
include(CMakePackageConfigHelpers)
configure_package_config_file(cmake/resilienceConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/resilienceConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/cmake)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/resilienceConfigVersion.cmake
COMPATIBILITY SameMajorVersion
)
# Set install rules
install(TARGETS resilience EXPORT resilienceTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(EXPORT resilienceTargets
FILE resilienceTargets.cmake
NAMESPACE Kokkos::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/resilience
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/resilienceConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/resilienceConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/resilience
)
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)
enable_testing()
add_subdirectory(tests)
endif()
if (KR_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()