18#include <Kokkos_Complex.hpp>
20#include <heffte_fft3d.h>
21#include <heffte_fft3d_r2c.h>
25#include "Utility/IpplException.h"
28#include "Field/Field.h"
30#include "FieldLayout/FieldLayout.h"
35 struct is_ccomplex<Kokkos::complex<float>> : std::true_type {};
38 struct is_zcomplex<Kokkos::complex<double>> : std::true_type {};
62 enum TransformDirection {
75#if defined(Heffte_ENABLE_FFTW)
78 using backend = heffte::backend::fftw;
79 using backendSine = heffte::backend::fftw_sin;
80 using backendCos = heffte::backend::fftw_cos;
81 using backendCos1 = heffte::backend::fftw_cos1;
83#elif defined(Heffte_ENABLE_MKL)
86 using backend = heffte::backend::mkl;
87 using backendSine = heffte::backend::mkl_sin;
88 using backendCos = heffte::backend::mkl_cos;
92#ifdef Heffte_ENABLE_CUDA
93#ifdef KOKKOS_ENABLE_CUDA
95 struct HeffteBackendType<Kokkos::CudaSpace> {
96 using backend = heffte::backend::cufft;
97 using backendSine = heffte::backend::cufft_sin;
98 using backendCos = heffte::backend::cufft_cos;
99 using backendCos1 = heffte::backend::cufft_cos1;
102#error cuFFT backend is enabled for heFFTe but CUDA is not enabled for Kokkos!
106#ifdef KOKKOS_ENABLE_HIP
107#ifdef Heffte_ENABLE_ROCM
109 struct HeffteBackendType<Kokkos::HIPSpace> {
110 using backend = heffte::backend::rocfft;
111 using backendSine = heffte::backend::rocfft_sin;
112 using backendCos = heffte::backend::rocfft_cos;
113 using backendCos1 = heffte::backend::rocfft_cos1;
117 struct HeffteBackendType<Kokkos::HIPSpace> {
118 using backend = heffte::backend::stock;
119 using backendSine = heffte::backend::stock_sin;
120 using backendCos = heffte::backend::stock_cos;
121 using backendCos1 = heffte::backend::stock_cos1;
126#ifdef KOKKOS_ENABLE_SYCL
132 struct HeffteBackendType<Kokkos::SYCLDeviceUSMSpace> {
133 using backend = heffte::backend::stock;
134 using backendSine = heffte::backend::stock_sin;
135 using backendCos = heffte::backend::stock_cos;
136 using backendCos1 = heffte::backend::stock_cos1;
140#if !defined(Heffte_ENABLE_MKL) && !defined(Heffte_ENABLE_FFTW)
147 using backend = heffte::backend::stock;
148 using backendSine = heffte::backend::stock_sin;
149 using backendCos = heffte::backend::stock_cos;
150 using backendCos1 = heffte::backend::stock_cos1;
156 template <
typename Field,
template <
typename...>
class FFT,
typename Backend,
157 typename BufferType =
typename Field::value_type>
159 constexpr static unsigned Dim = Field::dim;
162 using heffteBackend = Backend;
173 std::array<long long, 3>& high);
174 void setup(
const heffte::box3d<long long>& inbox,
const heffte::box3d<long long>& outbox,
177 std::shared_ptr<FFT<heffteBackend, long long>> heffte_m;
178 workspace_t workspace_m;
180 template <
typename FieldType>
181 using temp_view_type =
182 typename Kokkos::View<
typename FieldType::view_type::data_type, Kokkos::LayoutLeft,
183 typename FieldType::memory_space>::uniform_type;
184 temp_view_type<Field> tempField;
187#define IN_PLACE_FFT_BASE_CLASS(Field, Backend) \
188 FFTBase<Field, heffte::fft3d, \
189 typename detail::HeffteBackendType<typename Field::memory_space>::Backend>
190#define EXT_FFT_BASE_CLASS(Field, Backend, Type) \
191 FFTBase<Field, heffte::fft3d_r2c, \
192 typename detail::HeffteBackendType<typename Field::memory_space>::Backend, \
198 template <
class Transform,
typename Field>
204 template <
typename ComplexField>
205 class FFT<
CCTransform, ComplexField> :
public IN_PLACE_FFT_BASE_CLASS(ComplexField, backend) {
206 constexpr static unsigned Dim = ComplexField::dim;
207 using Base = IN_PLACE_FFT_BASE_CLASS(ComplexField, backend);
210 using Complex_t =
typename ComplexField::value_type;
213 using typename Base::heffteBackend,
typename Base::workspace_t,
typename Base::Layout_t;
219 void warmup(ComplexField& f);
226 void transform(TransformDirection direction, ComplexField& f);
232 template <
typename RealField>
234 :
public EXT_FFT_BASE_CLASS(RealField, backend,
235 Kokkos::complex<typename RealField::value_type>) {
236 constexpr static unsigned Dim = RealField::dim;
237 using Real_t =
typename RealField::value_type;
238 using Base = EXT_FFT_BASE_CLASS(RealField, backend,
239 Kokkos::complex<typename RealField::value_type>);
242 using Complex_t = Kokkos::complex<Real_t>;
243 using ComplexField =
typename Field<Complex_t, Dim,
typename RealField::Mesh_t,
244 typename RealField::Centering_t,
245 typename RealField::execution_space>::uniform_type;
247 using typename Base::heffteBackend,
typename Base::workspace_t,
typename Base::Layout_t;
252 FFT(
const Layout_t& layoutInput,
const Layout_t& layoutOutput,
const ParameterList& params);
259 void warmup(RealField& f, ComplexField& g);
267 void transform(TransformDirection direction, RealField& f, ComplexField& g);
270 typename Base::template temp_view_type<ComplexField> tempFieldComplex;
276 template <
typename Field>
278 constexpr static unsigned Dim = Field::dim;
279 using Base = IN_PLACE_FFT_BASE_CLASS(
Field, backendSine);
283 using typename Base::heffteBackend,
typename Base::workspace_t,
typename Base::Layout_t;
289 void warmup(
Field& f);
296 void transform(TransformDirection direction,
Field& f);
301 template <
typename Field>
303 constexpr static unsigned Dim = Field::dim;
304 using Base = IN_PLACE_FFT_BASE_CLASS(
Field, backendCos);
308 using typename Base::heffteBackend,
typename Base::workspace_t,
typename Base::Layout_t;
314 void warmup(
Field& f);
321 void transform(TransformDirection direction,
Field& f);
326 template <
typename Field>
328 constexpr static unsigned Dim = Field::dim;
329 using Base = IN_PLACE_FFT_BASE_CLASS(
Field, backendCos1);
333 using typename Base::heffteBackend,
typename Base::workspace_t,
typename Base::Layout_t;
339 void warmup(
Field& f);
346 void transform(TransformDirection direction,
Field& f);
350#include "FFT/FFT.hpp"
void domainToBounds(const NDIndex< Dim > &domain, std::array< long long, 3 > &low, std::array< long long, 3 > &high)
Definition FFT.hpp:46
void setup(const heffte::box3d< long long > &inbox, const heffte::box3d< long long > &outbox, const ParameterList ¶ms)
Definition FFT.hpp:66
Definition FieldLayout.h:166
Definition ParameterList.h:29