Skip to content

Commit 47bfe00

Browse files
Fix Cabana integration (#5076)
Resolve compatibility issues between external libraries.
2 parents af7634e + 92aa591 commit 47bfe00

File tree

14 files changed

+52
-33
lines changed

14 files changed

+52
-33
lines changed

.gitlab-ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ fedora:41:
149149
myconfig: 'maxset'
150150
make_check_python: 'true'
151151
with_stokesian_dynamics: 'true'
152+
with_fftw: 'false'
152153
cmake_params: '-D CMAKE_INCLUDE_PATH=/usr/include/mpich-x86_64 -D CMAKE_PREFIX_PATH=/usr/lib64/mpich/lib/'
153154
script:
154155
- bash maintainer/CI/build_cmake.sh
@@ -219,7 +220,7 @@ cuda12-coverage:
219220
with_scafacos: 'true'
220221
with_walberla: 'true'
221222
with_stokesian_dynamics: 'true'
222-
with_cabana: 'true'
223+
with_shared_memory_parallelism: 'true'
223224
script:
224225
- bash maintainer/CI/build_cmake.sh
225226
timeout: 90m
@@ -246,7 +247,7 @@ cuda12-maxset:
246247
with_walberla_avx: 'true'
247248
with_stokesian_dynamics: 'true'
248249
with_caliper: 'true'
249-
with_cabana: 'true'
250+
with_shared_memory_parallelism: 'true'
250251
script:
251252
- bash maintainer/CI/build_cmake.sh
252253
artifacts:

CMakeLists.txt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,13 @@ FetchContent_Declare(
116116
heffte
117117
GIT_REPOSITORY https://github.com/icl-utk-edu/heffte.git
118118
GIT_TAG v2.4.1
119+
PATCH_COMMAND patch -p0 < ${CMAKE_CURRENT_SOURCE_DIR}/cmake/heffte.patch
119120
)
120121
FetchContent_Declare(
121122
cabana
122123
GIT_REPOSITORY https://github.com/ECP-copa/Cabana.git
123124
GIT_TAG 7914d28708b1c67b40d5743c1fbc09e221144dd3
124-
PATCH_COMMAND patch -p0 < ${CMAKE_CURRENT_SOURCE_DIR}/cmake/patch_cabana_doxygen.diff
125+
PATCH_COMMAND patch -p0 < ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cabana.patch
125126
)
126127
# cmake-format: on
127128

@@ -143,7 +144,8 @@ option(ESPRESSO_BUILD_WITH_WALBERLA
143144
option(ESPRESSO_BUILD_WITH_WALBERLA_AVX
144145
"Build waLBerla lattice-Boltzmann with AVX vectorization" OFF)
145146
option(ESPRESSO_BUILD_WITH_WALBERLA_FFT "Build waLBerla with FFT support" OFF)
146-
option(ESPRESSO_BUILD_WITH_CABANA "Build with Cabana and Kokkos packages" OFF)
147+
option(ESPRESSO_BUILD_WITH_SHARED_MEMORY_PARALLELISM
148+
"Build with shared memory parallelism support" OFF)
147149
option(ESPRESSO_BUILD_BENCHMARKS "Enable benchmarks" OFF)
148150
option(ESPRESSO_BUILD_WITH_VALGRIND "Build with Valgrind instrumentation" OFF)
149151
option(ESPRESSO_BUILD_WITH_CALIPER "Build with Caliper instrumentation" OFF)
@@ -482,19 +484,13 @@ endif()
482484
# Libraries
483485
#
484486

485-
if(ESPRESSO_BUILD_WITH_CABANA)
486-
# Find kokkos
487-
if(NOT EXISTS Kokkos_DIR)
488-
message(
489-
FATAL_ERROR
490-
"Kokkos_DIR not set. Please set it to the directory containing KokkosConfig.cmake (typically the Kokkos build folder)"
491-
)
492-
endif()
493-
494-
# Fetch Cabana 0.7.0 Cabana already uses find_package(Kokkos) internally
487+
if(ESPRESSO_BUILD_WITH_SHARED_MEMORY_PARALLELISM)
488+
FetchContent_GetProperties(cabana)
489+
set(Cabana_REQUIRE_HEFFTE OFF CACHE BOOL "")
495490
if(NOT cabana_POPULATED)
496491
FetchContent_MakeAvailable(cabana)
497492
endif()
493+
find_package(Kokkos REQUIRED)
498494
endif()
499495

500496
if(ESPRESSO_BUILD_WITH_FFTW)

cmake/patch_cabana_doxygen.diff renamed to cmake/cabana.patch

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
diff --git a/CMakeLists.txt b/CMakeLists.txt
2-
index c228d50a..00693256 100644
3-
--- a/CMakeLists.txt
4-
+++ b/CMakeLists.txt
5-
@@ -216,12 +216,6 @@ if(Cabana_ENABLE_TESTING)
1+
https://github.com/ECP-copa/Cabana/pull/815
2+
--- CMakeLists.txt
3+
+++ CMakeLists.txt
4+
@@ -216,12 +216,6 @@
65
enable_testing()
76
endif()
87

cmake/espresso_cmake_config.cmakein

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#cmakedefine ESPRESSO_BUILD_WITH_FPE
2525

26-
#cmakedefine ESPRESSO_BUILD_WITH_CABANA
26+
#cmakedefine ESPRESSO_BUILD_WITH_SHARED_MEMORY_PARALLELISM
2727

2828
#define PACKAGE_NAME "${PROJECT_NAME}"
2929

cmake/espresso_unit_test.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ function(ESPRESSO_UNIT_TEST)
7171
if(NOT TEST_NUM_PROC AND ESPRESSO_MPIEXEC_GUARD_SINGLETON_NUMA AND "${TEST_DEPENDS}" MATCHES "(^|;)([Bb]oost::mpi|MPI::MPI_CXX)($|;)")
7272
list(APPEND TEST_ENV_VARIABLES "OMPI_MCA_hwloc_base_binding_policy=none")
7373
endif()
74+
list(APPEND TEST_ENV_VARIABLES "OMP_PROC_BIND=false")
7475
set_tests_properties(
7576
${TEST_NAME} PROPERTIES ENVIRONMENT "${TEST_ENV_VARIABLES}")
7677

cmake/heffte.patch

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
https://github.com/icl-utk-edu/heffte/issues/83
2+
--- cmake/FindHeffteFFTW.cmake
3+
+++ cmake/FindHeffteFFTW.cmake
4+
@@ -129,4 +129,6 @@
5+
# create imported target
6+
+if(NOT TARGET Heffte::FFTW)
7+
add_library(Heffte::FFTW INTERFACE IMPORTED GLOBAL)
8+
target_link_libraries(Heffte::FFTW INTERFACE ${FFTW_LIBRARIES})
9+
set_target_properties(Heffte::FFTW PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${FFTW_INCLUDES})
10+
+endif()

doc/sphinx/installation.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,8 @@ using a CMake flag (see :ref:`Options and Variables`).
642642
- ``STOKESIAN_DYNAMICS`` Enables the Stokesian Dynamics feature
643643
(see :ref:`Stokesian Dynamics`). Requires BLAS and LAPACK.
644644

645+
- ``SHARED_MEMORY_PARALLELISM`` Enables shared-memory parallelism.
646+
645647

646648

647649
.. _Configuring:
@@ -804,6 +806,7 @@ The following options control features from external libraries:
804806
* ``ESPRESSO_BUILD_WITH_SCAFACOS``: Build with ScaFaCoS support.
805807
* ``ESPRESSO_BUILD_WITH_GSL``: Build with GSL support.
806808
* ``ESPRESSO_BUILD_WITH_STOKESIAN_DYNAMICS`` Build with Stokesian Dynamics support.
809+
* ``ESPRESSO_BUILD_WITH_SHARED_MEMORY_PARALLELISM``: Build with shared-memory parallelism support (OpenMP, Cabana, Kokkos, etc.)
807810
* ``ESPRESSO_BUILD_WITH_WALBERLA``: Build with waLBerla support.
808811
* ``ESPRESSO_BUILD_WITH_WALBERLA_FFT``: Build waLBerla with FFT and PFFT support, used in FFT-based electrokinetics.
809812
* ``ESPRESSO_BUILD_WITH_WALBERLA_AVX``: Build waLBerla with AVX kernels instead of regular kernels.

maintainer/CI/build_cmake.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ set_default_value with_asan false
101101
set_default_value with_static_analysis false
102102
set_default_value with_caliper false
103103
set_default_value with_fpe false
104-
set_default_value with_cabana false
104+
set_default_value with_shared_memory_parallelism false
105105
set_default_value myconfig "default"
106106
set_default_value build_procs ${ci_procs}
107107
set_default_value check_procs ${build_procs}
@@ -150,6 +150,7 @@ cmake_params="${cmake_params} -D ESPRESSO_BUILD_BENCHMARKS=${make_check_benchmar
150150
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_CCACHE=${with_ccache}"
151151
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_CALIPER=${with_caliper}"
152152
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_FPE=${with_fpe}"
153+
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_SHARED_MEMORY_PARALLELISM=${with_shared_memory_parallelism}"
153154
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_HDF5=${with_hdf5}"
154155
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_FFTW=${with_fftw}"
155156
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_GSL=${with_gsl}"

src/config/features.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,4 @@ WALBERLA_FFT external
116116
VALGRIND external
117117
CALIPER external
118118
FPE external
119-
CABANA external
119+
SHARED_MEMORY_PARALLELISM external

src/core/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,11 @@ install(TARGETS espresso_core
8282
LIBRARY DESTINATION ${ESPRESSO_INSTALL_PYTHON}/espressomd)
8383

8484
target_link_libraries(
85-
espresso_core PRIVATE espresso::config espresso::utils::mpi espresso::shapes
86-
espresso::cpp_flags
85+
espresso_core
86+
PRIVATE
87+
espresso::config espresso::utils::mpi espresso::shapes espresso::cpp_flags
88+
$<$<BOOL:${ESPRESSO_BUILD_WITH_SHARED_MEMORY_PARALLELISM}>:Kokkos::kokkos>
89+
$<$<BOOL:${ESPRESSO_BUILD_WITH_SHARED_MEMORY_PARALLELISM}>:Cabana::Core>
8790
PUBLIC espresso::utils MPI::MPI_CXX Random123 espresso::particle_observables
8891
Boost::serialization Boost::mpi espresso::instrumentation)
8992

@@ -101,10 +104,6 @@ if(ESPRESSO_BUILD_WITH_FFTW)
101104
add_subdirectory(p3m)
102105
endif()
103106

104-
if(ESPRESSO_BUILD_WITH_CABANA)
105-
target_link_libraries(espresso_core PRIVATE Cabana::Core)
106-
endif()
107-
108107
add_subdirectory(accumulators)
109108
add_subdirectory(analysis)
110109
add_subdirectory(bond_breakage)

src/core/communication.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include <walberla_bridge/walberla_init.hpp>
3131
#endif
3232

33-
#ifdef CABANA
33+
#ifdef SHARED_MEMORY_PARALLELISM
3434
#include <Cabana_Core.hpp>
3535
#include <Kokkos_Core.hpp>
3636
#endif
@@ -90,15 +90,15 @@ void init(std::shared_ptr<boost::mpi::environment> mpi_env) {
9090
cuda_on_program_start();
9191
#endif
9292

93-
#ifdef CABANA
93+
#ifdef SHARED_MEMORY_PARALLELISM
9494
Kokkos::initialize();
9595
#endif
9696
}
9797

9898
void deinit() {
9999
Communication::m_callbacks.reset();
100100

101-
#ifdef CABANA
101+
#ifdef SHARED_MEMORY_PARALLELISM
102102
Kokkos::finalize();
103103
#endif
104104
}

src/core/p3m/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ if(ESPRESSO_BUILD_WITH_FFTW)
3838
)
3939
target_link_libraries(
4040
espresso_p3m
41-
PRIVATE Heffte espresso::cpp_flags espresso::p3m::cpp_flags espresso::utils
42-
espresso::config espresso::instrumentation MPI::MPI_CXX Boost::mpi)
41+
PRIVATE
42+
Heffte espresso::cpp_flags espresso::p3m::cpp_flags espresso::utils
43+
espresso::config espresso::instrumentation MPI::MPI_CXX Boost::mpi
44+
$<$<BOOL:${ESPRESSO_BUILD_WITH_SHARED_MEMORY_PARALLELISM}>:Kokkos::kokkos>
45+
$<$<BOOL:${ESPRESSO_BUILD_WITH_SHARED_MEMORY_PARALLELISM}>:Cabana::Core>)
4346
set_target_properties(espresso_p3m PROPERTIES POSITION_INDEPENDENT_CODE ON)
4447
target_link_libraries(espresso_core PUBLIC espresso_p3m)
4548
install(TARGETS espresso_p3m

src/python/pypresso.cmakein

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ else
1313
PYTHONPATH="@ESPRESSO_PYTHON_DIR@"
1414
fi
1515
export PYTHONPATH
16+
if test -z "$OMP_PROC_BIND"; then
17+
export OMP_PROC_BIND=false
18+
fi
1619

1720
espresso_parse_cmake_boolean_value() {
1821
local varname="${2}"

testsuite/python/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,12 @@ function(python_test)
117117
list(APPEND TEST_LABELS "parallel_odd")
118118
endif()
119119

120+
# cmake-format: off
120121
set_tests_properties(
121122
${TEST_NAME} PROPERTIES PROCESSORS ${TEST_NUM_PROC} SKIP_RETURN_CODE 5
123+
ENVIRONMENT "OMP_PROC_BIND=false"
122124
DEPENDS "${TEST_DEPENDS}" LABELS "${TEST_LABELS}")
125+
# cmake-format: on
123126

124127
set(python_tests ${python_tests} ${TEST_FILE_CONFIGURED} PARENT_SCOPE)
125128
endfunction(python_test)

0 commit comments

Comments
 (0)