Skip to content

Commit

Permalink
Allow to compile without the Kokkos::Serial backend
Browse files Browse the repository at this point in the history
  • Loading branch information
tpadioleau committed Mar 14, 2024
1 parent bf3b4e9 commit 928cb52
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
8 changes: 4 additions & 4 deletions include/ddc/kernels/fft.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include <Kokkos_Core.hpp>

#if fftw_AVAIL
#if fftw_serial_AVAIL || fftw_omp_AVAIL
#include <fftw3.h>
#endif

Expand All @@ -35,7 +35,7 @@
#include <hipfft/hipfft.h>
#endif

#if fftw_AVAIL
#if fftw_serial_AVAIL || fftw_omp_AVAIL
static_assert(sizeof(fftwf_complex) == sizeof(Kokkos::complex<float>));
static_assert(alignof(fftwf_complex) <= alignof(Kokkos::complex<float>));

Expand Down Expand Up @@ -145,7 +145,7 @@ struct transform_type<Kokkos::complex<T1>, Kokkos::complex<T2>>
template <typename T1, typename T2>
constexpr TransformType transform_type_v = transform_type<T1, T2>::value;

#if fftw_AVAIL
#if fftw_serial_AVAIL || fftw_omp_AVAIL
// _fftw_type : compatible with both single and double precision
template <typename T>
struct _fftw_type
Expand Down Expand Up @@ -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<ExecSpace, Kokkos::Serial>) {
_fftw_plan<Tin> plan = _fftw_plan_many_dft<Tin, Tout>(
kwargs.direction == ddc::FFT_Direction::FORWARD ? FFTW_FORWARD : FFTW_BACKWARD,
Expand Down
8 changes: 8 additions & 0 deletions tests/fft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ struct RDimX;
struct RDimY;
struct RDimZ;

#if fftw_serial_AVAIL
TEST(FFTNorm, OFF)
{
test_fft_norm<
Expand Down Expand Up @@ -268,6 +269,7 @@ TEST(FFTSerialHost, R2C_3D)
RDimY,
RDimZ>();
}
#endif

#if fftw_omp_AVAIL
TEST(FFTParallelHost, R2C_1D)
Expand Down Expand Up @@ -332,6 +334,7 @@ TEST(FFTParallelDevice, R2C_3D)
RDimZ>();
}

#if fftw_serial_AVAIL
TEST(FFTSerialHost, C2C_1D)
{
test_fft<
Expand Down Expand Up @@ -364,6 +367,7 @@ TEST(FFTSerialHost, C2C_3D)
RDimY,
RDimZ>();
}
#endif

#if fftw_omp_AVAIL
TEST(FFTParallelHost, C2C_1D)
Expand Down Expand Up @@ -433,6 +437,7 @@ TEST(FFTParallelDevice, C2C_3D)
RDimZ>();
}

#if fftw_serial_AVAIL
TEST(FFTSerialHost, D2Z_1D)
{
test_fft<
Expand Down Expand Up @@ -465,6 +470,7 @@ TEST(FFTSerialHost, D2Z_3D)
RDimY,
RDimZ>();
}
#endif

#if fftw_omp_AVAIL
TEST(FFTParallelHost, D2Z_1D)
Expand Down Expand Up @@ -534,6 +540,7 @@ TEST(FFTParallelDevice, D2Z_3D)
RDimZ>();
}

#if fftw_serial_AVAIL
TEST(FFTSerialHost, Z2Z_1D)
{
test_fft<
Expand Down Expand Up @@ -566,6 +573,7 @@ TEST(FFTSerialHost, Z2Z_3D)
RDimY,
RDimZ>();
}
#endif

#if fftw_omp_AVAIL
TEST(FFTParallelHost, Z2Z_1D)
Expand Down

0 comments on commit 928cb52

Please sign in to comment.