forked from LLNL/RAJA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
347 lines (292 loc) · 10.3 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
###############################################################################
# Copyright (c) 2016-24, Lawrence Livermore National Security, LLC
# and RAJA project contributors. See the RAJA/LICENSE file for details.
# SPDX-License-Identifier: (BSD-3-Clause)
###############################################################################
cmake_policy(SET CMP0042 NEW)
cmake_policy(SET CMP0048 NEW)
if (APPLE)
cmake_policy(SET CMP0025 NEW)
endif()
include(CMakeDependentOption)
# Set version number
set(RAJA_VERSION_MAJOR 2024)
set(RAJA_VERSION_MINOR 07)
set(RAJA_VERSION_PATCHLEVEL 0)
if (RAJA_LOADED AND (NOT RAJA_LOADED STREQUAL "${RAJA_VERSION_MAJOR}.${RAJA_VERSION_MINOR}.${RAJA_VERSION_PATCHLEVEL}"))
message(FATAL_ERROR "You are mixing RAJA versions. Loaded is ${RAJA_LOADED}, expected ${RAJA_VERSION_MAJOR}.${RAJA_VERSION_MINOR}.${RAJA_VERSION_PATCHLEVEL}")
endif()
if (RAJA_LOADED)
return() # Stop processing file, avoids nesting the whole file
endif()
set (RAJA_LOADED "${RAJA_VERSION_MAJOR}.${RAJA_VERSION_MINOR}.${RAJA_VERSION_PATCHLEVEL}")
# Promote RAJA_LOADED to PARENT_SCOPE if it exists, which is only if we are bringing
# in RAJA as a subproject to a larger CMake project
get_directory_property(hasParent PARENT_DIRECTORY)
if(hasParent)
set (RAJA_LOADED ${RAJA_LOADED} PARENT_SCOPE)
endif()
mark_as_advanced(RAJA_LOADED)
# C is required for googletest to find Threads
project(RAJA LANGUAGES CXX C
VERSION ${RAJA_LOADED})
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/thirdparty" ${CMAKE_MODULE_PATH})
include(cmake/SetupRajaOptions.cmake)
cmake_minimum_required(VERSION 3.23)
# Detect C++ standard and add appropriate flag _before_ loading BLT
set(COMPILERS_KNOWN_TO_CMAKE33 AppleClang Clang GNU MSVC)
include(CheckCXXCompilerFlag)
if(NOT DEFINED BLT_CXX_STD)
if("cxx_std_20" IN_LIST CMAKE_CXX_KNOWN_FEATURES)
set(BLT_CXX_STD c++20 CACHE STRING "Version of C++ standard")
message("Using C++ standard: ${BLT_CXX_STD}")
elseif("cxx_std_17" IN_LIST CMAKE_CXX_KNOWN_FEATURES)
set(BLT_CXX_STD c++17 CACHE STRING "Version of C++ standard")
message("Using C++ standard: ${BLT_CXX_STD}")
elseif("cxx_std_14" IN_LIST CMAKE_CXX_KNOWN_FEATURES)
set(BLT_CXX_STD c++14 CACHE STRING "Version of C++ standard")
message("Using C++ standard: ${BLT_CXX_STD}")
elseif("${CMAKE_CXX_COMPILER_ID}" IN_LIST COMPILERS_KNOWN_TO_CMAKE33)
set(BLT_CXX_STD c++14 CACHE STRING "Version of C++ standard")
message("Using C++ standard: ${BLT_CXX_STD}")
else() #cmake has no idea what to do, do it ourselves...
foreach(flag_var "c++17" "c++14" "c++11")
CHECK_CXX_COMPILER_FLAG("-std=${flag_var}" COMPILER_SUPPORTS_${flag_var})
if(COMPILER_SUPPORTS_${flag_var})
set(BLT_CXX_STD ${flag_var} CACHE STRING "Version of C++ standard")
message("Using C++ standard: ${BLT_CXX_STD}")
break()
endif()
endforeach(flag_var)
endif()
else() #check BLT_CXX_STD is high enough by disallowing the only invalid option
if("${BLT_CXX_STD}" STREQUAL "c++98")
message(FATAL_ERROR "RAJA requires minimum C++ standard of c++11")
endif()
endif(NOT DEFINED BLT_CXX_STD)
if (RAJA_ENABLE_DESUL_ATOMICS)
if("${BLT_CXX_STD}" STREQUAL "c++11")
message(FATAL_ERROR "RAJA_ENABLE_DESUL_ATOMICS requires minimum C++ standard of c++14")
endif()
endif()
set(CMAKE_CXX_EXTENSIONS OFF)
if (NOT BLT_LOADED)
if (DEFINED 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. \
If in git repository run the following two commands:\n \
git submodule init\n \
git submodule update")
endif ()
endif ()
include(${BLT_SOURCE_DIR}/SetupBLT.cmake)
endif()
# Setup options that depend on BLT
include(cmake/SetupDependentOptions.cmake)
# Setup basic CMake options
include(cmake/SetupBasics.cmake)
# Find third-party packages
include(cmake/SetupPackages.cmake)
if (RAJA_ENABLE_CUDA)
if (DEFINED CMAKE_CUDA_ARCHITECTURES)
if ("${CMAKE_CUDA_ARCHITECTURES}" STRLESS "35")
message( FATAL_ERROR "RAJA requires minimum CUDA compute architecture of 35")
endif()
else()
message(STATUS "CUDA compute architecture set to RAJA default 35 since it was not specified")
set(CMAKE_CUDA_ARCHITECTURES "35" CACHE STRING "Set CMAKE_CUDA_ARCHITECTURES to RAJA minimum supported" FORCE)
endif()
message(STATUS "CMAKE_CUDA_ARCHITECTURES set to ${CMAKE_CUDA_ARCHITECTURES}")
if ( (CMAKE_CXX_COMPILER_ID MATCHES GNU) AND (CMAKE_SYSTEM_PROCESSOR MATCHES ppc64le) )
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
set (CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler -mno-float128")
endif ()
endif ()
endif()
# Setup vendor-specific compiler flags
include(cmake/SetupCompilers.cmake)
# Macros for building executables and libraries
include (cmake/RAJAMacros.cmake)
set (raja_sources
src/AlignedRangeIndexSetBuilders.cpp
src/DepGraphNode.cpp
src/LockFreeIndexSetBuilders.cpp
src/MemUtils_CUDA.cpp
src/MemUtils_HIP.cpp
src/MemUtils_SYCL.cpp
src/PluginStrategy.cpp)
if (RAJA_ENABLE_RUNTIME_PLUGINS)
set (raja_sources
${raja_sources}
src/RuntimePluginLoader.cpp
src/KokkosPluginLoader.cpp)
endif ()
set (raja_depends)
if (RAJA_ENABLE_OPENMP)
set (raja_depends
openmp)
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17)
message(WARNING "RAJA::simd_exec support requires Intel-17 or greater")
endif()
if(RAJA_ENABLE_CUDA)
if("${CUDA_VERSION_STRING}" VERSION_LESS "9.2")
message(FATAL_ERROR "Trying to use CUDA version ${CUDA_VERSION_STRING}. RAJA dependency Googletest requires CUDA version 9.2.x or newer.")
endif()
endif()
if(RAJA_ENABLE_HIP)
message(STATUS "HIP version: ${hip_VERSION}")
if("${hip_VERSION}" VERSION_LESS "3.5")
message(FATAL_ERROR "Trying to use HIP/ROCm version ${hip_VERSION}. RAJA requires HIP/ROCm version 3.5 or newer. ")
endif()
endif()
if (RAJA_ENABLE_CUDA)
set(raja_depends
${raja_depends}
cuda)
if(RAJA_ENABLE_NV_TOOLS_EXT)
set(raja_depends
${raja_depends}
nvtoolsext)
endif ()
endif ()
if (RAJA_ENABLE_EXTERNAL_CUB)
set(raja_depends
${raja_depends}
cub)
endif ()
if (RAJA_ENABLE_HIP)
set(raja_depends
${raja_depends}
blt::hip)
set(raja_depends
${raja_depends}
blt::hip_runtime)
if(RAJA_ENABLE_ROCTX)
set(raja_depends
${raja_depends}
roctx)
endif()
endif ()
if (RAJA_ENABLE_EXTERNAL_ROCPRIM)
set(raja_depends
${raja_depends}
rocPRIM)
endif ()
if (RAJA_ENABLE_SYCL)
set (RAJA_ENABLE_DESUL_ATOMICS "On")
set (ENABLE_SYCL "On") # Enable SYCL atomics in Desul
set (raja_depends
${raja_depends}
sycl)
endif ()
message(STATUS "Desul Atomics support is ${RAJA_ENABLE_DESUL_ATOMICS}")
if (RAJA_ENABLE_DESUL_ATOMICS)
# NOTE: ENABLE_OPENMP in Desul implies OpenMP OFFLOAD
if (NOT RAJA_ENABLE_TARGET_OPENMP)
set (DESUL_ENABLE_OPENMP Off CACHE BOOL "Disable Desul OpenMP offload atomics to select builtin host atomics")
endif()
add_subdirectory(tpl/desul)
set(raja_depends
${raja_depends}
desul_atomics)
endif ()
if (NOT TARGET camp)
set(EXTERNAL_CAMP_SOURCE_DIR "" CACHE FILEPATH "build with a specific external
camp source repository")
if (EXTERNAL_CAMP_SOURCE_DIR)
message(STATUS "Using external source CAMP from: " ${EXTERNAL_CAMP_SOURCE_DIR})
add_subdirectory(${EXTERNAL_CAMP_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/tpl/camp)
else (EXTERNAL_CAMP_SOURCE_DIR)
if (DEFINED camp_DIR)
find_package(camp REQUIRED
NO_DEFAULT_PATH
PATHS ${camp_DIR}
${camp_DIR}/lib/cmake/camp
)
message(STATUS "Using installed CAMP from: ${camp_INSTALL_PREFIX}")
else ()
message(STATUS "Using RAJA CAMP submodule.")
# propagate setting for sycl since there's no common enable to use
set (CAMP_ENABLE_SYCL ${RAJA_ENABLE_SYCL})
add_subdirectory(tpl/camp)
endif()
endif (EXTERNAL_CAMP_SOURCE_DIR)
if (RAJA_ENABLE_TARGET_OPENMP)
message(STATUS "Setting CAMP_ENABLE_TARGET_OPENMP to ${RAJA_ENABLE_TARGET_OPENMP}")
blt_add_target_definitions(
TO camp
SCOPE INTERFACE
TARGET_DEFINITIONS CAMP_ENABLE_TARGET_OPENMP)
endif()
endif (NOT TARGET camp)
set (raja_defines)
if (COMPILER_FAMILY_IS_MSVC AND NOT BUILD_SHARED_LIBS)
set (raja_defines
${raja_defines}
RAJA_WIN_STATIC_BUILD)
endif ()
blt_add_library(
NAME RAJA
SOURCES ${raja_sources}
DEPENDS_ON ${raja_depends} camp ${CMAKE_DL_LIBS}
DEFINES ${raja_defines})
install(TARGETS RAJA
EXPORT RAJATargets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib
)
install(EXPORT RAJATargets DESTINATION lib/cmake/raja)
target_include_directories(RAJA
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
if (RAJA_ENABLE_CUDA AND NOT RAJA_ENABLE_EXTERNAL_CUB)
target_include_directories(RAJA SYSTEM
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/tpl/cub>)
endif()
if (RAJA_ENABLE_HIP AND NOT RAJA_ENABLE_EXTERNAL_ROCPRIM)
target_include_directories(RAJA SYSTEM
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/tpl/rocPRIM/rocprim/include>)
endif()
install(DIRECTORY include/ DESTINATION include FILES_MATCHING PATTERN *.hpp)
if (RAJA_ENABLE_CUDA AND NOT RAJA_ENABLE_EXTERNAL_CUB)
install(DIRECTORY tpl/cub/cub/ DESTINATION include/cub FILES_MATCHING PATTERN *.cuh)
endif()
if (RAJA_ENABLE_HIP AND NOT RAJA_ENABLE_EXTERNAL_ROCPRIM)
install(DIRECTORY tpl/rocPRIM/rocprim/include/ DESTINATION include FILES_MATCHING PATTERN *.hpp)
endif()
install(FILES
${PROJECT_BINARY_DIR}/include/RAJA/config.hpp
DESTINATION "include/RAJA/")
# Setup internal RAJA configuration options
include(cmake/SetupRajaConfig.cmake)
if(RAJA_ENABLE_TESTS)
add_subdirectory(test)
endif()
if(RAJA_ENABLE_REPRODUCERS)
add_subdirectory(reproducers)
endif()
if(RAJA_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()
if(RAJA_ENABLE_EXERCISES)
add_subdirectory(exercises)
endif()
if (RAJA_ENABLE_DOCUMENTATION)
add_subdirectory(docs)
endif ()
if (RAJA_ENABLE_BENCHMARKS)
add_subdirectory(benchmark)
endif ()