-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
300 lines (253 loc) · 9.35 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
# set minimal version the one requested by kokkos
cmake_minimum_required(VERSION 3.18)
#
# default local cmake macro repository
#
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
#
# Prevent from build in source tree
#
include(preventBuildInSource)
#
# Create project version (using git info ?)
# TODO
#
#
# Init build type: Release, Debug, ...
#
include(initBuildType)
# options
option (EULER_KOKKOS_BUILD_DOC "Enable / disable documentation build (sphinx/html)" OFF)
option (EULER_KOKKOS_USE_SPHINX_EXHALE "Enable / disable building API documentation (very long)" OFF)
option (EULER_KOKKOS_USE_MPI "Activate / want MPI build" OFF)
option (EULER_KOKKOS_USE_VTK "Activate / want VTK build" OFF)
option (EULER_KOKKOS_USE_DOUBLE "build with double precision" ON)
option (EULER_KOKKOS_USE_HDF5 "build HDF5 input/output support" OFF)
option (EULER_KOKKOS_USE_PNETCDF "build PNETCDF input/output support (MPI required)" OFF)
option (EULER_KOKKOS_USE_FPE_DEBUG "build with floating point Nan tracing (signal handler)" OFF)
option (EULER_KOKKOS_USE_MPI_CUDA_AWARE_ENFORCED "Some MPI cuda-aware implementation are not well detected; use this to enforce" OFF)
# disable base languages
unset(PROJECT_LANGUAGES)
set(PROJECT_LANGUAGES ${PROJECT_LANGUAGES} C CXX)
project(euler_kokkos
LANGUAGES ${PROJECT_LANGUAGES})
# Documentation type
if(EULER_KOKKOS_BUILD_DOC)
set(EULER_KOKKOS_DOC_TYPE "Undefined" CACHE STRING
"The documentation type to generate. Available values are html and doxygen")
# Set the possible values for documentation type
set_property(CACHE EULER_KOKKOS_DOC_TYPE PROPERTY STRINGS "html" "doxygen" "Undefined")
add_subdirectory(doc)
return()
endif()
# always export compile commands database
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# C++17 is for Kokkos
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
#
# Write a small header with build data, git version, etc...
#
include(write_version)
#####################################################################
# External packages: MPI, ...
#####################################################################
#####################################################################
#find_package(MPI REQUIRED)
find_package(MPI)
if (EULER_KOKKOS_USE_MPI)
if(MPI_CXX_FOUND)
message(STATUS "MPI support found")
message(STATUS "MPI compile flags: " ${MPI_CXX_COMPILE_FLAGS})
message(STATUS "MPI include path: " ${MPI_CXX_INCLUDE_PATH})
message(STATUS "MPI LINK flags path: " ${MPI_CXX_LINK_FLAGS})
message(STATUS "MPI libraries: " ${MPI_CXX_LIBRARIES})
#set(CMAKE_EXE_LINKER_FLAGS ${MPI_CXX_LINK_FLAGS})
find_program(OMPI_INFO
NAMES ompi_info
HINTS ${MPI_CXX_LIBRARIES}/../bin)
# Full command line to probe if cuda support in MPI implementation is enabled
# ompi_info --parsable --all | grep mpi_built_with_cuda_support:value
if (OMPI_INFO)
execute_process(COMMAND ${OMPI_INFO}
OUTPUT_VARIABLE _output)
if ( (_output MATCHES "smcuda") OR (EULER_KOKKOS_USE_MPI_CUDA_AWARE_ENFORCED) )
set(MPI_CUDA_AWARE_ENABLED True)
message(STATUS "Found OpenMPI with CUDA support built.")
else()
set(MPI_CUDA_AWARE_ENABLED False)
message(WARNING "OpenMPI found, but it is not built with CUDA support.")
add_compile_options(-DMPI_CUDA_AWARE_OFF)
endif()
endif()
else()
message(WARNING "Not compiling with MPI. Suppress this warning with -DEULER_KOKKOS_USE_MPI=OFF")
set(EULER_KOKKOS_USE_MPI OFF)
endif()
endif()
if (EULER_KOKKOS_USE_VTK)
# look for VTK only if requested; VTK macro might even be not present
# on the target platform
find_package(VTK COMPONENTS
CommonCore
CommonDataModel
CommonExecutionModel
CommonMath
CommonMisc
CommonSystem
CommonTransforms
IOCore
IOGeometry
IOImage
IOLegacy
IOXML
IOXMLParser
ParallelCore
ParallelMPI
IOParallelXML)
if (VTK_FOUND)
message("VTK version: ${VTK_VERSION}")
else()
message ("VTK NOT FOUND")
endif()
endif(EULER_KOKKOS_USE_VTK)
#####################################################################
# HDF5
#####################################################################
# prefer using parallel HDF5 when build with mpi
if (EULER_KOKKOS_USE_MPI)
set(HDF5_PREFER_PARALLEL TRUE)
endif(EULER_KOKKOS_USE_MPI)
if (EULER_KOKKOS_USE_HDF5)
find_package(HDF5)
if(HDF5_FOUND)
include_directories(${HDF5_INCLUDE_DIRS})
set(my_hdf5_libs hdf5 hdf5_cpp)
add_compile_options(-DUSE_HDF5)
if (HDF5_IS_PARALLEL)
add_compile_options(-DUSE_HDF5_PARALLEL)
endif()
endif(HDF5_FOUND)
endif(EULER_KOKKOS_USE_HDF5)
#####################################################################
# PNETCDF
#####################################################################
if (EULER_KOKKOS_USE_MPI)
if (EULER_KOKKOS_USE_PNETCDF)
find_package(PNETCDF)
if (PNETCDF_FOUND)
add_compile_options(-DUSE_PNETCDF)
include_directories(${PNETCDF_INCLUDE_DIRS})
endif(PNETCDF_FOUND)
endif(EULER_KOKKOS_USE_PNETCDF)
endif(EULER_KOKKOS_USE_MPI)
#
# Kokkos : https://github.com/kokkos/kokkos
#
include(build_or_find_kokkos)
#
# if MPI is enabled and kokkos backend is cuda, we need a cuda aware implementation
#
if (EULER_KOKKOS_USE_MPI)
if ( MPI_FOUND AND (EULER_KOKKOS_BACKEND MATCHES "Cuda") AND (NOT MPI_CUDA_AWARE_ENABLED) )
message(FATAL_ERROR "You must use a cuda-aware MPI implementation.")
endif()
endif()
#
# common flags
#
if (EULER_KOKKOS_USE_DOUBLE)
add_compile_options(-DUSE_DOUBLE)
endif()
if (EULER_KOKKOS_USE_MPI)
add_compile_options(-DUSE_MPI)
endif()
if (EULER_KOKKOS_USE_FPE_DEBUG)
add_compile_options(-DUSE_FPE_DEBUG)
endif()
##
## Using flags -Wextra, it's to strong for Kokkos, too many warnings
## But -Wall is really a minimum
##
#add_definitions(-Wall -Wextra -Wconversion -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wcast-qual -Wunused -Woverloaded-virtual -pedantic )
#add_definitions( -Wall -Wextra )
add_definitions( -Wall )
#
# sources
#
add_subdirectory(test)
add_subdirectory(src)
##################### PRINT CONFIGURE STATUS ######################
message("//===================================================")
message("// ${PROJECT_NAME} build configuration:")
message("//===================================================")
message("")
message(" CMake version : ${CMAKE_VERSION}")
if (NOT CMAKE_BUILD_TYPE)
message(" CMake build type : NOT SET !")
else()
message(" CMake build type : ${CMAKE_BUILD_TYPE}")
endif()
message(" CMake install prefix : ${CMAKE_INSTALL_PREFIX}")
message(" CMake system processor : ${CMAKE_SYSTEM_PROCESSOR}")
message(" CMake system name (OS) : ${CMAKE_SYSTEM_NAME}")
message("")
message(" C++ Compiler : ${CMAKE_CXX_COMPILER_ID} "
"${CMAKE_CXX_COMPILER_VERSION} "
"${CMAKE_CXX_COMPILER_WRAPPER}")
message(" ${CMAKE_CXX_COMPILER}")
message(" MPI enabled = ${EULER_KOKKOS_USE_MPI}")
message(" Kokkos version = ${Kokkos_VERSION}")
message(" Kokkos_CXX_COMPILER = ${Kokkos_CXX_COMPILER}")
message(" Kokkos_CXX_COMPILER_ID = ${Kokkos_CXX_COMPILER_ID}")
message(" Kokkos_CXX_STANDARD = ${Kokkos_CXX_STANDARD}")
message(" Kokkos_OPTIONS = ${Kokkos_OPTIONS}")
message(" Kokkos_TPLS = ${Kokkos_TPLS}")
message(" Kokkos_DIRS = ${Kokkos_DIR}")
if(Kokkos_ENABLE_OPENMP)
message(" Kokkos_ENABLE_OPENMP = ${Kokkos_ENABLE_OPENMP}")
endif()
if(Kokkos_ENABLE_CUDA)
message(" Kokkos_ENABLE_CUDA = ${Kokkos_ENABLE_CUDA}")
if( (${Kokkos_CUDA_LAMBDA_ENABLED}) OR (${Kokkos_ENABLE_CUDA_LAMBDA}))
message(" Kokkos_ENABLE_CUDA_LAMBDA = ON")
else()
message(" Kokkos_ENABLE_CUDA_LAMBDA = OFF")
endif()
if( (${Kokkos_CUDA_CONSTEXPR_ENABLED}) OR (${Kokkos_ENABLE_CUDA_CONSTEXPR}))
message(" Kokkos_ENABLE_CUDA_CONSTEXPR = ON")
else()
message(" Kokkos_ENABLE_CUDA_CONSTEXPR = OFF")
endif()
if( (${Kokkos_CUDA_UVM_ENABLED}) OR (${Kokkos_ENABLE_CUDA_UVM}))
message(" Kokkos_ENABLE_CUDA_UVM = ON")
else()
message(" Kokkos_ENABLE_CUDA_UVM = OFF")
endif()
message(" Kokkos CUDA flags = ${KOKKOS_CUDA_OPTIONS}")
#message(" CUDA Compiler : ${CMAKE_CUDA_COMPILER}")
#message(" CUDA Compiler exec : ${CUDA_NVCC_EXECUTABLE}")
#message(" CUDA Compile flags : ${CUDA_NVCC_FLAGS}")
endif(Kokkos_ENABLE_CUDA)
if(Kokkos_ENABLE_HIP)
message(" Kokkos_ENABLE_HIP = ${Kokkos_ENABLE_HIP}")
endif(Kokkos_ENABLE_HIP)
if ( (${Kokkos_TPLS_HWLOC_ENABLED}) OR (${Kokkos_ENABLE_HWLOC}) )
message(" Kokkos_ENABLE_HWLOC = ON")
else()
message(" Kokkos_ENABLE_HWLOC = OFF")
endif()
message(" Kokkos architecture = ${Kokkos_ARCH}")
if (HDF5_FOUND)
message(" HDF5_VERSION = ${HDF5_VERSION}")
message(" HDF5_DEFINITIONS = ${HDF5_DEFINITIONS}")
message(" HDF5_IS_PARALLEL = ${HDF5_IS_PARALLEL}")
message(" HDF5_INCLUDE_DIRS = ${HDF5_INCLUDE_DIRS}")
message(" HDF5_LIBRARIES = ${HDF5_LIBRARIES}")
endif(HDF5_FOUND)
if (PNETCDF_FOUND)
message(" PNETCDF_VERSION_STRING = ${PNETCDF_VERSION_STRING}")
message(" PNETCDF_INCLUDE_DIRS = ${PNETCDF_INCLUDE_DIRS}")
message(" PNETCDF_LIBRARIES = ${PNETCDF_LIBRARIES}")
endif(PNETCDF_FOUND)
message("")