-
Notifications
You must be signed in to change notification settings - Fork 38
/
CMakeLists.txt
394 lines (293 loc) · 10 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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
#
# Copyright (c) 2014-23, Lawrence Livermore National Security, LLC
# and Kripke project contributors. See the Kripke/COPYRIGHT file for details.
#
# SPDX-License-Identifier: (BSD-3-Clause)
#
if (ENABLE_HIP)
cmake_minimum_required(VERSION 3.23)
else()
cmake_minimum_required(VERSION 3.20)
endif()
cmake_policy(SET CMP0057 NEW)
project(KRIPKE LANGUAGES CXX)
set(KRIPKE_VERSION "1.2.5-dev")
#
# 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 "")
if (ENABLE_CHAI)
set(ENABLE_RAJA_PLUGIN On CACHE BOOL "")
set(CHAI_ENABLE_RAJA_PLUGIN On CACHE BOOL "")
endif ()
# Use C++14 standard
set(BLT_CXX_STD "c++14" CACHE STRING "")
if (NOT BLT_LOADED)
if (DEFINED BLT_SOURCE_DIR)
message(${BLT_SOURCE_DIR})
if (NOT EXISTS ${BLT_SOURCE_DIR}/SetupBLT.cmake)
message(FATAL_ERROR "Given BLT_SOURCE_DIR does not contain SetupBLT.cmake")
endif()
else ()
set (BLT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/blt" CACHE PATH "")
if (NOT EXISTS ${BLT_SOURCE_DIR}/SetupBLT.cmake)
message(FATAL_ERROR "The BLT submodule is not present.")
endif ()
endif ()
set(BLT_CXX_STD "c++14" CACHE STRING "BLT requires C++14")
set(ENABLE_ALL_WARNINGS OFF CACHE BOOL "")
set(ENABLE_ASTYLE OFF CACHE BOOL "")
set(ENABLE_CLANGFORMAT OFF CACHE BOOL "")
set(ENABLE_UNCRUSTIFY OFF CACHE BOOL "")
set(ENABLE_CPPCHECK OFF CACHE BOOL "")
set(ENABLE_CLANGQUERY OFF CACHE BOOL "")
set(ENABLE_GTEST ON CACHE BOOL "")
set(ENABLE_TESTS ON CACHE BOOL "")
set(ENABLE_FRUIT OFF CACHE BOOL "")
set(ENABLE_FIND_MPI ON CACHE BOOL "")
set(BLT_DOCS_TARGET_NAME "docsBLT" CACHE STRING "")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} CACHE PATH "")
set(TEST_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} CACHE PATH "")
include(${BLT_SOURCE_DIR}/SetupBLT.cmake)
endif()
#
# 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_CUDA_HOST_COMPILER})
endif()
#
# Add googletest (needed by RAJA, etc)
#
#add_subdirectory(tpl/googletest)
#
# Configure CHAI/Umpire for memory management
#
option(ENABLE_CHAI "Enable CHAI/Umpire memory management" Off)
if(ENABLE_CHAI)
# Find camp
if (NOT TARGET camp)
find_package(camp QUIET NO_DEFAULT_PATH HINTS ${CAMP_DIR} ${camp_DIR})
if (camp_FOUND)
message(STATUS "Kripke: Using external CAMP")
set_target_properties(camp PROPERTIES IMPORTED_GLOBAL TRUE)
if (DEFINED RAJA_DIR)
find_package(RAJA REQUIRED)
endif()
list(APPEND KRIPKE_DEPENDS RAJA)
else ()
message(STATUS "Kripke: Using CAMP submodule")
if (NOT EXISTS ${PROJECT_SOURCE_DIR}/tpl/raja/tpl/camp/CMakeLists.txt)
message(FATAL_ERROR "Kripke: CAMP submodule not initialized. Run 'git submodule update --init' in the git repository or set camp_DIR or CAMP_DIR to use an external build of CAMP.")
else ()
message(STATUS "Kripke: Using CAMP in Kripke TPL")
add_subdirectory(${PROJECT_SOURCE_DIR}/tpl/raja/tpl/camp)
endif ()
endif()
endif()
# Set camp backends
if (ENABLE_CUDA)
message(STATUS "Kripke: Setting CAMP_HAVE_CUDA")
blt_add_target_definitions(TO camp
SCOPE INTERFACE
TARGET_DEFINITIONS CAMP_HAVE_CUDA)
endif ()
if (ENABLE_HIP)
# Set CHAI-related HIP variables for single memory address space.
# Use the THIN_GPU_ALLOCATE mode of CHAI on MI250X.
# This is to mirror the expected behavior of El Capitan.
# Requires env variables HSA_XNACK set to 1 and MPICH_GPU_SUPPORT_ENABLED set to 1 to work on the MI250X.
set (CHAI_ENABLE_UM OFF CACHE BOOL "")
set (CHAI_ENABLE_PINNED ON CACHE BOOL "")
set(CHAI_DISABLE_RM ON CACHE BOOL "")
set(CHAI_THIN_GPU_ALLOCATE ON CACHE BOOL "")
message(STATUS "Kripke: Setting CAMP_HAVE_HIP")
blt_add_target_definitions(TO camp
SCOPE INTERFACE
TARGET_DEFINITIONS CAMP_HAVE_HIP)
endif ()
set(UMPIRE_DEPENDS camp)
if (DEFINED umpire_DIR)
find_package(umpire REQUIRED)
if (ENABLE_MPI)
set(UMPIRE_DEPENDS "${UMPIRE_DEPENDS} mpi")
endif()
blt_register_library(
NAME umpire
INCLUDES ${UMPIRE_INCLUDE_DIRS}
LIBRARIES umpire
DEPENDS_ON ${UMPIRE_DEPENDS})
else ()
add_subdirectory(tpl/umpire)
endif()
if (DEFINED chai_DIR)
find_package(chai REQUIRED)
else ()
add_subdirectory(tpl/chai)
endif ()
set(ENABLE_TESTS Off CACHE BOOL "")
set(KRIPKE_USE_CHAI 1)
list(APPEND KRIPKE_DEPENDS chai)
else ()
#
# Configure RAJA (REQUIRED)
#
set(ENABLE_RAJA_PLUGIN Off CACHE BOOL "")
if (DEFINED RAJA_DIR)
find_package(RAJA REQUIRED)
else ()
set(ENABLE_EXAMPLES Off CACHE BOOL "")
set(ENABLE_EXERCISES Off CACHE BOOL "")
add_subdirectory(tpl/raja)
endif ()
list(APPEND KRIPKE_DEPENDS RAJA)
endif ()
#
# 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 HIP
#
if(ENABLE_HIP)
set(KRIPKE_USE_HIP 1)
list(APPEND KRIPKE_DEPENDS hip)
set(KRIPKE_ARCH "HIP")
# 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()
option(ENABLE_CALIPER "Enable Caliper support" FALSE)
if (ENABLE_CALIPER)
if(EXISTS "${PROJECT_SOURCE_DIR}/tpl/caliper/CMakeLists.txt")
set(BUILD_SHARED_LIBS False CACHE BOOL "")
add_subdirectory(tpl/caliper)
include_directories(tpl/caliper/include)
else()
find_package(caliper REQUIRED)
find_package(adiak REQUIRED)
endif()
# blt_register_library(NAME caliper
# INCLUDES ${caliper_INCLUDE_DIR}
# LIBRARIES caliper)
set(KRIPKE_USE_CALIPER TRUE)
list(APPEND KRIPKE_DEPENDS caliper adiak::adiak)
endif()
message(STATUS "Caliper support is ${KRIPKE_USE_CALIPER}")
#
# 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
)