forked from ExCALIBUR-NEPTUNE/NESO-Particles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
293 lines (271 loc) · 13.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
cmake_minimum_required(VERSION 3.24)
project(
NESO-Particles
VERSION 0.7.0
LANGUAGES CXX C)
include(GNUInstallDirs)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/restrict-keyword.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/check-file-list.cmake)
option(NESO_PARTICLES_ENABLE_HDF5 "Add HDF5 to targets." ON)
option(
NESO_PARTICLES_ENABLE_FIND_SYCL
"Enabling search for a SYCL implementation if add_sycl_to_target is not found."
ON)
option(NESO_PARTICLES_LEGACY_DEVICE_SELECTORS
"Option to use SYCL 1.2 selectors if 2020 ones are not supported." OFF)
option(NESO_PARTICLES_ENABLE_PETSC "Look for PETSc." OFF)
option(
NESO_PARTICLES_DEVICE_AWARE_MPI
"Enable device aware MPI by default, i.e. pass device pointers to MPI rather than copying to the host."
OFF)
# Create interface/Header only library
add_library(NESO-Particles INTERFACE)
# Alias the name to the namespaces name. Can use in subdirectory or via Confiig
# files with namespace
add_library(NESO-Particles::NESO-Particles ALIAS NESO-Particles)
# Set standard
set_property(TARGET NESO-Particles PROPERTY CXX_STANDARD 17)
# Create a list of the header files.
set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
set(INCLUDE_DIR_NESO_PARTICLES ${INCLUDE_DIR}/neso_particles)
set(HEADER_FILES
${INCLUDE_DIR}/neso_particles.hpp
${INCLUDE_DIR_NESO_PARTICLES}/access.hpp
${INCLUDE_DIR_NESO_PARTICLES}/boundary_conditions.hpp
${INCLUDE_DIR_NESO_PARTICLES}/cartesian_mesh.hpp
${INCLUDE_DIR_NESO_PARTICLES}/cell_binning.hpp
${INCLUDE_DIR_NESO_PARTICLES}/cell_dat.hpp
${INCLUDE_DIR_NESO_PARTICLES}/cell_dat_compression.hpp
${INCLUDE_DIR_NESO_PARTICLES}/cell_dat_move.hpp
${INCLUDE_DIR_NESO_PARTICLES}/cell_dat_move_impl.hpp
${INCLUDE_DIR_NESO_PARTICLES}/communication.hpp
${INCLUDE_DIR_NESO_PARTICLES}/communication/comm_pair.hpp
${INCLUDE_DIR_NESO_PARTICLES}/communication/communication_edges_counter.hpp
${INCLUDE_DIR_NESO_PARTICLES}/communication/communication_typedefs.hpp
${INCLUDE_DIR_NESO_PARTICLES}/communication/communication_utility.hpp
${INCLUDE_DIR_NESO_PARTICLES}/compute_target.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/blocked_binary_tree.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/cell_dat.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/cell_dat_const.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/cell_data.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/nd_index.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/rng/rng.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/rng/kernel_rng.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/rng/host_rng_common.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/rng/host_per_particle_block_rng.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/rng/host_atomic_block_kernel_rng.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/descendant_products.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/global_array.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/local_array.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/local_memory_block.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/lookup_table.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/nd_local_array.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/product_matrix.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/sym_vector.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/sym_vector_impl.hpp
${INCLUDE_DIR_NESO_PARTICLES}/containers/tuple.hpp
${INCLUDE_DIR_NESO_PARTICLES}/departing_particle_identification.hpp
${INCLUDE_DIR_NESO_PARTICLES}/departing_particle_identification_impl.hpp
${INCLUDE_DIR_NESO_PARTICLES}/device_functions.hpp
${INCLUDE_DIR_NESO_PARTICLES}/device_limits.hpp
${INCLUDE_DIR_NESO_PARTICLES}/domain.hpp
${INCLUDE_DIR_NESO_PARTICLES}/error_propagate.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/common/bounding_box.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/common/common.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/common/coordinate_mapping.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/common/local_claim.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/common/overlay_cartesian_mesh.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/common/dof_mapper_dg.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/common/quadrature_point_mapper.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/petsc/boundary_interaction/boundary_reflection.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/petsc/boundary_interaction/boundary_interaction.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/petsc/boundary_interaction/boundary_interaction_2d.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/petsc/boundary_interaction/boundary_interaction_common.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/petsc/dmplex_cell_serialise.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/petsc/dmplex_helper.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/petsc/dmplex_interface.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/petsc/dmplex_local_mapper.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/petsc/dmplex_project_evaluate.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/petsc/dmplex_utility.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/petsc/petsc_api_redirection.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/petsc/particle_cell_mapping/dmplex_2d_mapper.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/petsc/particle_cell_mapping/dmplex_host_mapper.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/petsc/petsc_common.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/petsc/petsc_utility.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/petsc/petsc_interface.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/petsc/project_evaluate/dmplex_project_evaluate_base.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/petsc/project_evaluate/dmplex_project_evaluate_barycentric.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/petsc/project_evaluate/dmplex_project_evaluate_dg.hpp
${INCLUDE_DIR_NESO_PARTICLES}/external_interfaces/vtk/vtk.hpp
${INCLUDE_DIR_NESO_PARTICLES}/global_mapping.hpp
${INCLUDE_DIR_NESO_PARTICLES}/global_mapping_impl.hpp
${INCLUDE_DIR_NESO_PARTICLES}/global_move.hpp
${INCLUDE_DIR_NESO_PARTICLES}/global_move_exchange.hpp
${INCLUDE_DIR_NESO_PARTICLES}/local_mapping.hpp
${INCLUDE_DIR_NESO_PARTICLES}/local_move.hpp
${INCLUDE_DIR_NESO_PARTICLES}/loop/access_descriptors.hpp
${INCLUDE_DIR_NESO_PARTICLES}/loop/kernel.hpp
${INCLUDE_DIR_NESO_PARTICLES}/loop/particle_loop.hpp
${INCLUDE_DIR_NESO_PARTICLES}/loop/particle_loop_base.hpp
${INCLUDE_DIR_NESO_PARTICLES}/loop/particle_loop_utility.hpp
${INCLUDE_DIR_NESO_PARTICLES}/loop/particle_loop_index.hpp
${INCLUDE_DIR_NESO_PARTICLES}/loop/particle_loop_iteration_set.hpp
${INCLUDE_DIR_NESO_PARTICLES}/loop/pli_particle_dat.hpp
${INCLUDE_DIR_NESO_PARTICLES}/mesh_hierarchy.hpp
${INCLUDE_DIR_NESO_PARTICLES}/mesh_hierarchy_data/mesh_hierarchy_container.hpp
${INCLUDE_DIR_NESO_PARTICLES}/mesh_hierarchy_data/mesh_hierarchy_data.hpp
${INCLUDE_DIR_NESO_PARTICLES}/mesh_hierarchy_data/serial_container.hpp
${INCLUDE_DIR_NESO_PARTICLES}/mesh_hierarchy_data/serial_interface.hpp
${INCLUDE_DIR_NESO_PARTICLES}/mesh_interface.hpp
${INCLUDE_DIR_NESO_PARTICLES}/mesh_interface_local_decomp.hpp
${INCLUDE_DIR_NESO_PARTICLES}/packing_unpacking.hpp
${INCLUDE_DIR_NESO_PARTICLES}/parallel_initialisation.hpp
${INCLUDE_DIR_NESO_PARTICLES}/parameters.hpp
${INCLUDE_DIR_NESO_PARTICLES}/particle_dat.hpp
${INCLUDE_DIR_NESO_PARTICLES}/particle_group.hpp
${INCLUDE_DIR_NESO_PARTICLES}/particle_group_impl.hpp
${INCLUDE_DIR_NESO_PARTICLES}/particle_io.hpp
${INCLUDE_DIR_NESO_PARTICLES}/particle_remover.hpp
${INCLUDE_DIR_NESO_PARTICLES}/particle_set.hpp
${INCLUDE_DIR_NESO_PARTICLES}/particle_spec.hpp
${INCLUDE_DIR_NESO_PARTICLES}/particle_sub_group.hpp
${INCLUDE_DIR_NESO_PARTICLES}/profiling.hpp
${INCLUDE_DIR_NESO_PARTICLES}/sycl_typedefs.hpp
${INCLUDE_DIR_NESO_PARTICLES}/typedefs.hpp
${INCLUDE_DIR_NESO_PARTICLES}/utility.hpp
${INCLUDE_DIR_NESO_PARTICLES}/utility_mesh_hierarchy_plotting.hpp)
# Check that the files added above are not missing any files in the include
# directory.
set(HEADER_FILES_IGNORE "")
check_added_file_list(${INCLUDE_DIR} hpp "${HEADER_FILES}"
"${HEADER_FILES_IGNORE}")
# Makes it easy to install + adds the files to the INCLUDE property of the lib
# i.e. don't need target_include_dir.. also no GLOBS
target_sources(
NESO-Particles
PUBLIC FILE_SET
public_headers
TYPE
HEADERS
BASE_DIRS
${INCLUDE_DIR}
FILES
${HEADER_FILES})
# target_include_directories( NESO-Particles INTERFACE
# $<BUILD_INTERFACE:${INCLUDE_DIR}> $<INSTALL_INTERFACE:include> )
# Don't like this .... TODO: FIXME: Should be a runtime thing?
if(NESO_PARTICLES_DEVICE_TYPE STREQUAL GPU)
target_compile_definitions(NESO-Particles
INTERFACE NESO_PARTICLES_DEVICE_TYPE_GPU)
add_definitions(-DNESO_PARTICLES_DEVICE_TYPE_GPU)
message(STATUS "Using NESO_PARTICLES_DEVICE_TYPE_GPU")
else()
target_compile_definitions(NESO-Particles
INTERFACE NESO_PARTICLES_DEVICE_TYPE_CPU)
message(STATUS "Using NESO_PARTICLES_DEVICE_TYPE_CPU")
endif()
if(NESO_PARTICLES_LEGACY_DEVICE_SELECTORS)
target_compile_definitions(NESO-Particles
INTERFACE NESO_PARTICLES_LEGACY_DEVICE_SELECTORS)
message(STATUS "Using legacy SYCL device selectors")
endif()
if(NESO_PARTICLES_DEVICE_AWARE_MPI)
target_compile_definitions(NESO-Particles
INTERFACE NESO_PARTICLES_DEVICE_AWARE_MPI)
message(STATUS "Using device aware MPI.")
endif()
# Get MPI
find_package(MPI REQUIRED)
target_link_libraries(NESO-Particles INTERFACE MPI::MPI_CXX)
# Get HDF5 if its around
set(NESO_PARTICLES_USING_HDF5 FALSE)
if(NESO_PARTICLES_ENABLE_HDF5)
set(HDF5_PREFER_PARALLEL TRUE)
# HDF5 requires MPI::MPI_C, which is only loaded if C is enabled. See
# https://github.com/HDFGroup/hdf5/issues/3844. Note that this issue only
# arises for certain versions of HDF5.
enable_language(C)
find_package(HDF5 REQUIRED)
if(HDF5_FOUND AND HDF5_IS_PARALLEL)
message(STATUS "Parallel HDF5 found")
target_link_libraries(NESO-Particles INTERFACE HDF5::HDF5 NESO-Particles)
target_compile_definitions(NESO-Particles INTERFACE NESO_PARTICLES_HDF5)
set(NESO_PARTICLES_USING_HDF5 TRUE)
else()
message("HDF5 NOT found")
endif()
endif()
# set the restrict keyword
target_compile_definitions(NESO-Particles INTERFACE RESTRICT=${RESTRICT})
# now look for PETSc
if(NESO_PARTICLES_ENABLE_PETSC)
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PETSC PETSc)
endif()
if(PETSC_FOUND)
message(STATUS "PETSc found")
# TODO CHECK AND CLEANUP
target_compile_definitions(NESO-Particles INTERFACE NESO_PARTICLES_PETSC
${PETSC_DEFINITIONS})
add_definitions(-DNESO_PARTICLES_PETSC ${PETSC_DEFINITIONS})
target_link_libraries(NESO-Particles INTERFACE ${PETSC_LINK_LIBRARIES})
target_include_directories(NESO-Particles INTERFACE ${PETSC_INCLUDE_DIRS})
message(STATUS PETSC_LINK_LIBRARIES ${PETSC_LINK_LIBRARIES})
message(STATUS PETSC_LDFLAGS ${PETSC_LDFLAGS})
message(STATUS PETSC_INCLUDE_DIRS ${PETSC_INCLUDE_DIRS})
message(STATUS PETSC_LIBRARY_DIRS ${PETSC_LIBRARY_DIRS})
message(STATUS PETSC_CFLAGS ${PETSC_CFLAGS})
else()
message(STATUS "PETSc NOT found")
endif()
endif()
# Find SYCL
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/SYCL.cmake)
if(NESO_PARTICLES_ENABLE_FIND_SYCL)
find_sycl_if_required()
endif()
option(NESO_PARTICLES_ENABLE_TESTS "Build unit tests for this project." ON)
# Include the tests
if(NESO_PARTICLES_ENABLE_TESTS)
# set build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
message(STATUS "Set CMAKE_BUILD_TYPE=RelWithDebInfo")
endif()
enable_testing()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test)
endif()
# install the headers
install(
TARGETS NESO-Particles
EXPORT ${PROJECT_NAME}_Targets
FILE_SET public_headers
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(
EXPORT ${PROJECT_NAME}_Targets
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
# create the config.cmake
include(CMakePackageConfigHelpers)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
write_basic_package_version_file(
${PROJECT_NAME}ConfigVersion.cmake
VERSION ${PACKAGE_VERSION}
COMPATIBILITY AnyNewerVersion)
# install the config scripts
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/SYCL.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/restrict-keyword.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/check-file-list.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
export(
EXPORT ${PROJECT_NAME}_Targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Targets.cmake"
NAMESPACE ${PROJECT_NAME}::)