-
Notifications
You must be signed in to change notification settings - Fork 15
/
CMakeLists.txt
146 lines (122 loc) · 3.74 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
cmake_minimum_required (VERSION 3.17)
foreach(policy
CMP0074 # CMake 3.12
CMP0104 # CMAKE_CUDA_ARCHITECTURES
)
if(POLICY ${policy})
cmake_policy(SET ${policy} NEW)
endif()
endforeach()
project(PSC)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(cmake/CPM.cmake)
include(CTest)
function(psc_option name description default)
set(PSC_USE_${name} ${default} CACHE STRING "${description}")
set_property(CACHE PSC_USE_${name} PROPERTY
STRINGS "ON;TRUE;AUTO;OFF;FALSE"
)
endfunction()
set(PSC_GPU "host" CACHE STRING "Build with GPU supoort (host/cuda/hip)")
set_property(CACHE PSC_GPU PROPERTY STRINGS "host;cuda;hip")
option(USE_VPIC "Interface with VPIC" OFF)
option(USE_GTEST_DISCOVER_TESTS "Run tests to discover contained googletest cases" OFF)
psc_option(ADIOS2 "Build with adios2 support" AUTO)
option(PSC_USE_NVTX "Build with NVTX support" OFF)
option(PSC_USE_RMM "Build with RMM memory manager support" OFF)
option(PSC_BOUNDS_CHECK "Turn on bounds-checking" OFF)
option(PSC_USE_PERFETTO "Turn on perfetto-based tracing" OFF)
option(USE_CUDA "Build CUDA components" OFF)
if (USE_CUDA)
set(PSC_GPU "cuda" CACHE STRING "Build with GPU supoort (none/cuda/hip)")
endif()
if(PSC_GPU STREQUAL "cuda")
# This is needed on Summit when not using modules (in a spack build) to
# make sure that nvcc uses the same host compiler that was otherwise
# specified
set(CMAKE_CUDA_HOST_COMPILER "${CMAKE_CXX_COMPILER}")
enable_language(CUDA)
find_package(Thrust 1.10.0 REQUIRED)
thrust_create_target(Thrust)
set(USE_CUDA ON)
elseif(PSC_GPU STREQUAL "hip")
set(USE_CUDA ON)
else()
set(USE_CUDA OFF)
endif()
set(GTENSOR_DEVICE "${PSC_GPU}" CACHE STRING "")
CPMAddPackage(
NAME gtensor
GITHUB_REPOSITORY wdmapp/gtensor
GIT_TAG main
VERSION 0.0.0
)
if (BUILD_TESTING)
CPMAddPackage(
NAME GTest
GITHUB_REPOSITORY google/googletest
VERSION 1.14.0
OPTIONS
"INSTALL_GTEST OFF"
"gtest_force_shared_crt ON"
)
if (GTest_ADDED)
add_library(GTest::gtest ALIAS gtest)
add_library(GTest::gtest_main ALIAS gtest_main)
endif()
include(GoogleTest)
endif()
set(MPI_CXX_SKIP_MPICXX ON)
find_package(MPI REQUIRED)
# ADIOS2
if(PSC_USE_ADIOS2 STREQUAL AUTO)
find_package(ADIOS2 CONFIG)
elseif(PSC_USE_ADIOS2)
find_package(ADIOS2 CONFIG REQUIRED)
endif()
if(ADIOS2_FOUND)
set(PSC_HAVE_ADIOS2 1)
endif()
# NVTX
if (PSC_USE_NVTX)
find_package(CUDAToolkit REQUIRED)
set(PSC_HAVE_NVTX 1)
endif()
# RMM
if (PSC_USE_RMM)
find_package(rmm 0.18.0 CONFIG REQUIRED)
set(PSC_HAVE_RMM 1)
endif()
if (PSC_USE_PERFETTO)
CPMAddPackage("gh:google/perfetto@24.2")
find_package(Threads REQUIRED)
add_library(perfetto STATIC ${perfetto_SOURCE_DIR}/sdk/perfetto.cc)
add_library(perfetto::perfetto ALIAS perfetto)
target_include_directories(perfetto PUBLIC ${perfetto_SOURCE_DIR}/sdk)
target_link_libraries(perfetto PRIVATE Threads::Threads)
endif()
function(GenerateHeaderConfig)
set(PSC_CONFIG_DEFINES)
foreach(OPT IN LISTS ARGN)
string(APPEND PSC_CONFIG_DEFINES "
/* CMake Option: PSC_USE_${OPT}=${PSC_USE_${OPT}} */
#cmakedefine PSC_HAVE_${OPT}
")
endforeach()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/include/PscConfig.h.in
${CMAKE_CURRENT_BINARY_DIR}/src/include/PscConfig.h.in
)
configure_file(
${CMAKE_CURRENT_BINARY_DIR}/src/include/PscConfig.h.in
${CMAKE_CURRENT_BINARY_DIR}/src/include/PscConfig.h
)
endfunction()
# FIXME, unify USE_CUDA, USE_VPIC options / autodetect
# FIXME, mv helpers into separate file
GenerateHeaderConfig(ADIOS2 NVTX RMM)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src/include)
# FIXME, this seems too ugly to find mrc_config.h
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src/libmrc/include)
add_subdirectory(src/libmrc)
add_subdirectory(src)