From 928cb52bf51cd915da94ea098149065af6aca18a Mon Sep 17 00:00:00 2001 From: Thomas Padioleau Date: Tue, 5 Mar 2024 15:15:04 +0100 Subject: [PATCH] Allow to compile without the Kokkos::Serial backend --- CMakeLists.txt | 5 ++++- include/ddc/kernels/fft.hpp | 8 ++++---- tests/fft.cpp | 8 ++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff48c959c..3aae10543 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -218,7 +218,10 @@ install( if( FFTW_FOUND ) target_link_libraries( DDC INTERFACE FFTW::Float ) target_link_libraries( DDC INTERFACE FFTW::Double ) - target_compile_definitions(DDC INTERFACE fftw_AVAIL) +endif() + +if( FFTW_FOUND AND "${Kokkos_ENABLE_SERIAL}") + target_compile_definitions(DDC INTERFACE fftw_serial_AVAIL) endif() if( FFTW_FOUND AND "${Kokkos_ENABLE_OPENMP}") diff --git a/include/ddc/kernels/fft.hpp b/include/ddc/kernels/fft.hpp index a86894e52..0b0d67347 100644 --- a/include/ddc/kernels/fft.hpp +++ b/include/ddc/kernels/fft.hpp @@ -13,7 +13,7 @@ #include -#if fftw_AVAIL +#if fftw_serial_AVAIL || fftw_omp_AVAIL #include #endif @@ -35,7 +35,7 @@ #include #endif -#if fftw_AVAIL +#if fftw_serial_AVAIL || fftw_omp_AVAIL static_assert(sizeof(fftwf_complex) == sizeof(Kokkos::complex)); static_assert(alignof(fftwf_complex) <= alignof(Kokkos::complex)); @@ -145,7 +145,7 @@ struct transform_type, Kokkos::complex> template constexpr TransformType transform_type_v = transform_type::value; -#if fftw_AVAIL +#if fftw_serial_AVAIL || fftw_omp_AVAIL // _fftw_type : compatible with both single and double precision template struct _fftw_type @@ -384,7 +384,7 @@ void core( if constexpr (false) { } // Trick to get only else if -#if fftw_AVAIL +#if fftw_serial_AVAIL else if constexpr (std::is_same_v) { _fftw_plan plan = _fftw_plan_many_dft( kwargs.direction == ddc::FFT_Direction::FORWARD ? FFTW_FORWARD : FFTW_BACKWARD, diff --git a/tests/fft.cpp b/tests/fft.cpp index 856b6f2fb..2e0df5b63 100644 --- a/tests/fft.cpp +++ b/tests/fft.cpp @@ -191,6 +191,7 @@ struct RDimX; struct RDimY; struct RDimZ; +#if fftw_serial_AVAIL TEST(FFTNorm, OFF) { test_fft_norm< @@ -268,6 +269,7 @@ TEST(FFTSerialHost, R2C_3D) RDimY, RDimZ>(); } +#endif #if fftw_omp_AVAIL TEST(FFTParallelHost, R2C_1D) @@ -332,6 +334,7 @@ TEST(FFTParallelDevice, R2C_3D) RDimZ>(); } +#if fftw_serial_AVAIL TEST(FFTSerialHost, C2C_1D) { test_fft< @@ -364,6 +367,7 @@ TEST(FFTSerialHost, C2C_3D) RDimY, RDimZ>(); } +#endif #if fftw_omp_AVAIL TEST(FFTParallelHost, C2C_1D) @@ -433,6 +437,7 @@ TEST(FFTParallelDevice, C2C_3D) RDimZ>(); } +#if fftw_serial_AVAIL TEST(FFTSerialHost, D2Z_1D) { test_fft< @@ -465,6 +470,7 @@ TEST(FFTSerialHost, D2Z_3D) RDimY, RDimZ>(); } +#endif #if fftw_omp_AVAIL TEST(FFTParallelHost, D2Z_1D) @@ -534,6 +540,7 @@ TEST(FFTParallelDevice, D2Z_3D) RDimZ>(); } +#if fftw_serial_AVAIL TEST(FFTSerialHost, Z2Z_1D) { test_fft< @@ -566,6 +573,7 @@ TEST(FFTSerialHost, Z2Z_3D) RDimY, RDimZ>(); } +#endif #if fftw_omp_AVAIL TEST(FFTParallelHost, Z2Z_1D)