Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to compile without the Kokkos::Serial backend #324

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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