forked from LLNL/Kripke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
262 lines (160 loc) · 5.29 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
cmake_minimum_required(VERSION 3.8)
cmake_policy(SET CMP0057 NEW)
project(KRIPKE LANGUAGES CXX)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH})
set(KRIPKE_VERSION "1.2.3")
#
# Initialize the BLT build system
#
set(ENABLE_GTEST Off CACHE Bool "")
set(ENABLE_TESTS Off CACHE Bool "")
set(ENABLE_TBB Off CACHE Bool "")
set(ENABLE_EXAMPLES Off CACHE Bool "")
set(ENABLE_DOCUMENTATION Off CACHE Bool "")
# Use C++14 standard
set(BLT_CXX_STD "c++14" CACHE STRING "")
set(chai_DIR ${CURRENT_SOURCE_DIR}/tpl/chai)
set(zfp_DIR ${PROJECT_BINARY_DIR}/tpl/zfp)
include(blt/SetupBLT.cmake)
#
# Default Arch and Layout selection
# Sequential by default, but will be overriden if OpenMP or CUDA are enabled
#
set(KRIPKE_ARCH "Sequential")
set(KRIPKE_LAYOUT DGZ)
#
# Add CMake CUDA language support
#
if(ENABLE_CUDA)
# Native CMake support
enable_language(CUDA)
# Make sure we use nvcc with our selected host compiler to link executables
set(CMAKE_CUDA_LINK_EXECUTABLE "${CMAKE_CUDA_COMPILER} -ccbin <CMAKE_CXX_COMPILER> <CMAKE_CUDA_LINK_FLAGS> <FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
# Use nvcc as the linker
set(CMAKE_LINKER "${CMAKE_CUDA_COMPILER}" CACHE STRING "")
# Pass nvcc the -cubin to point at our C++ compiler
set(CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER})
endif()
#
# Configure CHAI/Umpire for memory management
#
option(ENABLE_CHAI "Enable CHAI/Umpire memory management" Off)
if(ENABLE_CHAI)
# Add CHAI (which brings in Umpire as a submodule)
add_subdirectory(tpl/chai)
set(ENABLE_TESTS Off CACHE Bool "")
set(KRIPKE_USE_CHAI 1)
list(APPEND KRIPKE_DEPENDS chai)
endif()
#
# Configure ZFP
#
option(ENABLE_ZFP "Enable ZFP compressed arrays" Off)
if(ENABLE_ZFP)
add_subdirectory(tpl/zfp)
set(KRIPKE_USE_ZFP 1)
list(APPEND KRIPKE_DEPENDS zfp)
endif()
#
# Configure RAJA (REQUIRED)
#
set(RAJA_ENABLE_TESTS Off CACHE Bool "")
add_subdirectory(tpl/raja)
list(APPEND KRIPKE_DEPENDS RAJA)
#
# Configure OpenMP (CPU threading, not target offload)
#
if(ENABLE_OPENMP)
set(KRIPKE_USE_OPENMP 1)
list(APPEND KRIPKE_DEPENDS openmp)
set(KRIPKE_ARCH "OpenMP")
endif()
#
# Configure CUDA
#
if(ENABLE_CUDA)
set(KRIPKE_USE_CUDA 1)
list(APPEND KRIPKE_DEPENDS cuda)
set(KRIPKE_ARCH "CUDA")
# Make sure that nvcc turns on the host compiler OpenMP flag
if(ENABLE_OPENMP)
list(APPEND CUDA_NVCC_FLAGS -Xcompiler ${OpenMP_CXX_FLAGS})
endif()
# Pass on compiler info to KripkeConfig.h
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER)
set(KRIPKE_NVCC_COMPILER "${CMAKE_CUDA_COMPILER}")
set(KRIPKE_NVCC_FLAGS "${CMAKE_CUDA_FLAGS} ${CMAKE_CUDA_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}")
endif()
#
# Configure MPI
#
# Use ENABLE_MPI=On if you want CMake to automatically figure out MPI
# using FindMPI
#
# Use ENABLE_MPI_WRAPPER if you want to use mpi compiler wrappers for CC/CXX
#
if(ENABLE_MPI)
set(KRIPKE_USE_MPI 1)
list(APPEND KRIPKE_DEPENDS mpi)
endif()
if(ENABLE_MPI_WRAPPER)
set(KRIPKE_USE_MPI 1)
endif()
#
# Display/Configure our default ArchLayout
#
message(STATUS "Kripke selected default architecture: '${KRIPKE_ARCH}'")
message(STATUS "Kripke selected default layout: '${KRIPKE_LAYOUT}'")
set(KRIPKE_ARCHV_DEFAULT ArchV_${KRIPKE_ARCH})
set(KRIPKE_LAYOUTV_DEFAULT LayoutV_${KRIPKE_LAYOUT})
#
# Pass compiler options to our KripkeConfig.h file so we can print them at
# runtime
#
set(KRIPKE_CXX_COMPILER "${CMAKE_CXX_COMPILER}")
set(KRIPKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${KRIPKE_BUILD_TYPE}}")
set(KRIPKE_LINK_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE}}")
#
# Create KripkeConfig.h file
#
configure_file(${PROJECT_SOURCE_DIR}/src/KripkeConfig.h.in
${PROJECT_BINARY_DIR}/include/KripkeConfig.h)
#
# Define build targets for Kripke
#
blt_add_library(
NAME kripke
SOURCES "src/Kripke/Core/BaseVar.cpp"
"src/Kripke/Core/DataStore.cpp"
"src/Kripke/Core/DomainVar.cpp"
"src/Kripke/Generate.cpp"
"src/Kripke/Generate/Data.cpp"
"src/Kripke/Generate/Decomp.cpp"
"src/Kripke/Generate/Energy.cpp"
"src/Kripke/Generate/Quadrature.cpp"
"src/Kripke/Generate/Space.cpp"
"src/Kripke/InputVariables.cpp"
"src/Kripke/Kernel/LPlusTimes.cpp"
"src/Kripke/Kernel/LTimes.cpp"
"src/Kripke/Kernel/Population.cpp"
"src/Kripke/Kernel/Scattering.cpp"
"src/Kripke/Kernel/Source.cpp"
"src/Kripke/Kernel/SweepSubdomain.cpp"
"src/Kripke/ParallelComm/BlockJacobiComm.cpp"
"src/Kripke/ParallelComm/SweepComm.cpp"
"src/Kripke/ParallelComm.cpp"
"src/Kripke/Core/PartitionSpace.cpp"
"src/Kripke/Core/Set.cpp"
"src/Kripke/SteadyStateSolver.cpp"
"src/Kripke/SweepSolver.cpp"
"src/Kripke/Timing.cpp"
DEPENDS_ON ${KRIPKE_DEPENDS}
)
target_include_directories(kripke PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>)
blt_add_executable(
NAME kripke.exe
SOURCES "src/kripke.cpp"
DEPENDS_ON ${KRIPKE_DEPENDS} kripke
)