1#ifndef AMREX_FFT_HELPER_H_
2#define AMREX_FFT_HELPER_H_
3#include <AMReX_Config.H>
23#if defined(AMREX_USE_CUDA)
25# include <cuComplex.h>
26#elif defined(AMREX_USE_HIP)
27# if __has_include(<rocfft/rocfft.h>)
28# include <rocfft/rocfft.h>
32# include <hip/hip_complex.h>
33#elif defined(AMREX_USE_SYCL)
34# if __has_include(<oneapi/mkl/dft.hpp>)
35# include <oneapi/mkl/dft.hpp>
37# define AMREX_USE_MKL_DFTI_2024 1
38# include <oneapi/mkl/dfti.hpp>
72[[nodiscard]]
constexpr int
75#if defined(AMREX_USE_CUDA)
109 int nprocs = std::numeric_limits<int>::max();
181 "amrex::FFT::Info::setOpenBCPaddingNumPrimeFactors: nfactors must be between 3 and 6");
192 auto const& dom = geom.
Domain();
202template <
typename MF>
203void shift_mf (IntVect
const& domain_lo, MF
const& mf, MF& new_mf)
205 BoxArray ba = mf.boxArray();
206 ba.shift(-domain_lo);
207 new_mf.define(ba, mf.DistributionMap(), mf.nComp(), mf.nGrowVect(),
208 MFInfo().SetAlloc(
false));
209 for (MFIter mfi(mf); mfi.isValid(); ++mfi) {
211 fab.shift(-domain_lo);
212 new_mf.setFab(mfi, std::move(fab));
216template <
typename MF>
217void shift_mfs (IntVect
const& domain_lo, MF
const& mf1, MF
const& mf2,
218 MF& new_mf1, MF& new_mf2)
221 mf1.DistributionMap() == mf2.DistributionMap());
222 detail::shift_mf(domain_lo, mf1, new_mf1);
223 detail::shift_mf(domain_lo, mf2, new_mf2);
226inline void next_fast_len_doit (Long target, Long n,
int const* factors,
227 int nfactors,
int ifactor, Long& best)
230 best = std::min(best, n);
234 if (ifactor == nfactors) {
237 Long const max_m3 = std::numeric_limits<int>::max() / 3;
238 Long const max_m2 = std::numeric_limits<int>::max() / 2;
239 for (Long m3 = n; m3 < best; ) {
249 if (!overflow && k < best) {
260 int const factor = factors[ifactor];
261 Long const max_len = std::numeric_limits<int>::max();
262 Long const max_m = max_len / factor;
263 for (Long m = n; m < best; ) {
264 next_fast_len_doit(target, m, factors, nfactors, ifactor+1, best);
285[[nodiscard]]
inline int
289 "amrex::FFT::nextFastLen: target must be positive");
291 "amrex::FFT::nextFastLen: nfactors must be between 3 and 6");
293 int constexpr factors[] = {5, 7, 11, 13, 17};
295 Long const max_len = std::numeric_limits<int>::max();
299 detail::next_fast_len_doit(target,
Long(1), factors, nfactors-2, 0, best);
302 "amrex::FFT::nextFastLen: result exceeds int range");
303 return static_cast<int>(best);
308namespace detail {
void hip_execute (rocfft_plan plan,
void **in,
void **out); }
316inline void assert_no_external_stream ()
320 "SYCL FFT does not support external GPU streams.");
323template <
typename T, Direction direction,
typename P,
typename TI,
typename TO>
324void sycl_execute (P* plan, TI* in, TO* out)
326 assert_no_external_stream();
327#ifndef AMREX_USE_MKL_DFTI_2024
328 std::int64_t workspaceSize = 0;
330 std::size_t workspaceSize = 0;
332 plan->get_value(oneapi::mkl::dft::config_param::WORKSPACE_BYTES,
335 plan->set_workspace(buffer);
337 if (std::is_same_v<TI,TO>) {
339 if constexpr (direction == Direction::forward) {
340 r = oneapi::mkl::dft::compute_forward(*plan, out);
342 r = oneapi::mkl::dft::compute_backward(*plan, out);
345 if constexpr (direction == Direction::forward) {
346 r = oneapi::mkl::dft::compute_forward(*plan, in, out);
348 r = oneapi::mkl::dft::compute_backward(*plan, in, out);
361#if defined(AMREX_USE_CUDA)
364 cuComplex, cuDoubleComplex>;
365#elif defined(AMREX_USE_HIP)
367 using VendorComplex = std::conditional_t<std::is_same_v<float,T>,
369#elif defined(AMREX_USE_SYCL)
370 using mkl_desc_r = oneapi::mkl::dft::descriptor<std::is_same_v<float,T>
371 ? oneapi::mkl::dft::precision::SINGLE
372 : oneapi::mkl::dft::precision::DOUBLE,
373 oneapi::mkl::dft::domain::REAL>;
374 using mkl_desc_c = oneapi::mkl::dft::descriptor<std::is_same_v<float,T>
375 ? oneapi::mkl::dft::precision::SINGLE
376 : oneapi::mkl::dft::precision::DOUBLE,
377 oneapi::mkl::dft::domain::COMPLEX>;
378 using VendorPlan = std::variant<mkl_desc_r*,mkl_desc_c*>;
381 using VendorPlan = std::conditional_t<std::is_same_v<float,T>,
382 fftwf_plan, fftw_plan>;
383 using VendorComplex = std::conditional_t<std::is_same_v<float,T>,
384 fftwf_complex, fftw_complex>;
420#if !defined(AMREX_USE_GPU)
437 template <Direction D>
442 int rank = is_2d_transform ? 2 : 1;
457 int nr = (rank == 1) ? len[0] : len[0]*len[1];
459 int nc = (rank == 1) ? (len[0]/2+1) : (len[1]/2+1)*len[0];
460#if (AMREX_SPACEDIM == 1)
470#if defined(AMREX_USE_CUDA)
474 std::size_t work_size;
476 cufftType fwd_type = std::is_same_v<float,T> ? CUFFT_R2C : CUFFT_D2Z;
478 (cufftMakePlanMany(
plan, rank, len,
nullptr, 1, nr,
nullptr, 1, nc, fwd_type,
howmany, &work_size));
480 cufftType bwd_type = std::is_same_v<float,T> ? CUFFT_C2R : CUFFT_Z2D;
482 (cufftMakePlanMany(
plan, rank, len,
nullptr, 1, nc,
nullptr, 1, nr, bwd_type,
howmany, &work_size));
485#elif defined(AMREX_USE_HIP)
487 auto prec = std::is_same_v<float,T> ? rocfft_precision_single : rocfft_precision_double;
489 std::size_t
length[2] = {std::size_t(len[1]), std::size_t(len[0])};
491 AMREX_ROCFFT_SAFE_CALL
492 (rocfft_plan_create(&
plan, rocfft_placement_notinplace,
493 rocfft_transform_type_real_forward, prec, rank,
496 AMREX_ROCFFT_SAFE_CALL
497 (rocfft_plan_create(&
plan, rocfft_placement_notinplace,
498 rocfft_transform_type_real_inverse, prec, rank,
502#elif defined(AMREX_USE_SYCL)
506 pp =
new mkl_desc_r(len[0]);
508 pp =
new mkl_desc_r({std::int64_t(len[0]), std::int64_t(len[1])});
510#ifndef AMREX_USE_MKL_DFTI_2024
511 pp->set_value(oneapi::mkl::dft::config_param::PLACEMENT,
512 oneapi::mkl::dft::config_value::NOT_INPLACE);
514 pp->set_value(oneapi::mkl::dft::config_param::PLACEMENT, DFTI_NOT_INPLACE);
516 pp->set_value(oneapi::mkl::dft::config_param::NUMBER_OF_TRANSFORMS,
howmany);
517 pp->set_value(oneapi::mkl::dft::config_param::FWD_DISTANCE, nr);
518 pp->set_value(oneapi::mkl::dft::config_param::BWD_DISTANCE, nc);
519 std::vector<std::int64_t> strides;
520 strides.push_back(0);
521 if (rank == 2) { strides.push_back(len[1]); }
522 strides.push_back(1);
523#ifndef AMREX_USE_MKL_DFTI_2024
524 pp->set_value(oneapi::mkl::dft::config_param::FWD_STRIDES, strides);
527 pp->set_value(oneapi::mkl::dft::config_param::FWD_STRIDES, strides.data());
530 pp->set_value(oneapi::mkl::dft::config_param::WORKSPACE,
531 oneapi::mkl::dft::config_value::WORKSPACE_EXTERNAL);
532 detail::assert_no_external_stream();
533 pp->commit(amrex::Gpu::Device::streamQueue());
538 if constexpr (std::is_same_v<float,T>) {
540 plan = fftwf_plan_many_dft_r2c
541 (rank, len,
howmany, pr,
nullptr, 1, nr, pc,
nullptr, 1, nc,
542 FFTW_ESTIMATE | FFTW_DESTROY_INPUT);
544 plan = fftwf_plan_many_dft_c2r
545 (rank, len,
howmany, pc,
nullptr, 1, nc, pr,
nullptr, 1, nr,
546 FFTW_ESTIMATE | FFTW_DESTROY_INPUT);
550 plan = fftw_plan_many_dft_r2c
551 (rank, len,
howmany, pr,
nullptr, 1, nr, pc,
nullptr, 1, nc,
552 FFTW_ESTIMATE | FFTW_DESTROY_INPUT);
554 plan = fftw_plan_many_dft_c2r
555 (rank, len,
howmany, pc,
nullptr, 1, nc, pr,
nullptr, 1, nr,
556 FFTW_ESTIMATE | FFTW_DESTROY_INPUT);
571 template <Direction D,
int M>
589 template <Direction D>
607#if (AMREX_SPACEDIM >= 2)
608 else if (ndims == 2) {
610#if (AMREX_SPACEDIM == 2)
618#if (AMREX_SPACEDIM == 3)
619 else if (ndims == 3) {
629#if defined(AMREX_USE_CUDA)
633 cufftType t = std::is_same_v<float,T> ? CUFFT_C2C : CUFFT_Z2Z;
634 std::size_t work_size;
636 (cufftMakePlanMany(
plan, ndims, len,
nullptr, 1,
n,
nullptr, 1,
n, t,
howmany, &work_size));
638#elif defined(AMREX_USE_HIP)
640 auto prec = std::is_same_v<float,T> ? rocfft_precision_single
641 : rocfft_precision_double;
643 : rocfft_transform_type_complex_inverse;
647 }
else if (ndims == 2) {
655 AMREX_ROCFFT_SAFE_CALL
656 (rocfft_plan_create(&
plan, rocfft_placement_inplace, dir, prec, ndims,
659#elif defined(AMREX_USE_SYCL)
663 pp =
new mkl_desc_c(
n);
664 }
else if (ndims == 2) {
665 pp =
new mkl_desc_c({std::int64_t(len[0]), std::int64_t(len[1])});
667 pp =
new mkl_desc_c({std::int64_t(len[0]), std::int64_t(len[1]), std::int64_t(len[2])});
669#ifndef AMREX_USE_MKL_DFTI_2024
670 pp->set_value(oneapi::mkl::dft::config_param::PLACEMENT,
671 oneapi::mkl::dft::config_value::INPLACE);
673 pp->set_value(oneapi::mkl::dft::config_param::PLACEMENT, DFTI_INPLACE);
675 pp->set_value(oneapi::mkl::dft::config_param::NUMBER_OF_TRANSFORMS,
howmany);
676 pp->set_value(oneapi::mkl::dft::config_param::FWD_DISTANCE,
n);
677 pp->set_value(oneapi::mkl::dft::config_param::BWD_DISTANCE,
n);
678 std::vector<std::int64_t> strides(ndims+1);
681 for (
int i = ndims-1; i >= 1; --i) {
682 strides[i] = strides[i+1] * len[i];
684#ifndef AMREX_USE_MKL_DFTI_2024
685 pp->set_value(oneapi::mkl::dft::config_param::FWD_STRIDES, strides);
686 pp->set_value(oneapi::mkl::dft::config_param::BWD_STRIDES, strides);
688 pp->set_value(oneapi::mkl::dft::config_param::FWD_STRIDES, strides.data());
689 pp->set_value(oneapi::mkl::dft::config_param::BWD_STRIDES, strides.data());
691 pp->set_value(oneapi::mkl::dft::config_param::WORKSPACE,
692 oneapi::mkl::dft::config_value::WORKSPACE_EXTERNAL);
693 detail::assert_no_external_stream();
694 pp->commit(amrex::Gpu::Device::streamQueue());
699 if constexpr (std::is_same_v<float,T>) {
701 plan = fftwf_plan_many_dft
702 (ndims, len,
howmany, p,
nullptr, 1,
n, p,
nullptr, 1,
n, -1,
705 plan = fftwf_plan_many_dft
706 (ndims, len,
howmany, p,
nullptr, 1,
n, p,
nullptr, 1,
n, +1,
711 plan = fftw_plan_many_dft
712 (ndims, len,
howmany, p,
nullptr, 1,
n, p,
nullptr, 1,
n, -1,
715 plan = fftw_plan_many_dft
716 (ndims, len,
howmany, p,
nullptr, 1,
n, p,
nullptr, 1,
n, +1,
724 template <Direction D>
725 fftw_r2r_kind get_fftw_kind (std::pair<Boundary,Boundary>
const& bc)
745 return fftw_r2r_kind{};
757 template <Direction D>
791 template <Direction D>
792 void init_r2r (
Box const& box, T* p, std::pair<Boundary,Boundary>
const& bc,
793 int howmany_initval = 1)
797 kind = get_r2r_kind<D>(bc);
805#if defined(AMREX_USE_GPU)
825 int nc = (nex/2) + 1;
827#if defined (AMREX_USE_CUDA)
831 cufftType fwd_type = std::is_same_v<float,T> ? CUFFT_R2C : CUFFT_D2Z;
832 std::size_t work_size;
834 (cufftMakePlanMany(
plan, 1, &nex,
nullptr, 1, nc*2,
nullptr, 1, nc, fwd_type,
howmany, &work_size));
836#elif defined(AMREX_USE_HIP)
839 auto prec = std::is_same_v<float,T> ? rocfft_precision_single : rocfft_precision_double;
840 const std::size_t
length = nex;
841 AMREX_ROCFFT_SAFE_CALL
842 (rocfft_plan_create(&
plan, rocfft_placement_inplace,
843 rocfft_transform_type_real_forward, prec, 1,
846#elif defined(AMREX_USE_SYCL)
848 auto*
pp =
new mkl_desc_r(nex);
849#ifndef AMREX_USE_MKL_DFTI_2024
850 pp->set_value(oneapi::mkl::dft::config_param::PLACEMENT,
851 oneapi::mkl::dft::config_value::INPLACE);
853 pp->set_value(oneapi::mkl::dft::config_param::PLACEMENT, DFTI_INPLACE);
855 pp->set_value(oneapi::mkl::dft::config_param::NUMBER_OF_TRANSFORMS,
howmany);
856 pp->set_value(oneapi::mkl::dft::config_param::FWD_DISTANCE, nc*2);
857 pp->set_value(oneapi::mkl::dft::config_param::BWD_DISTANCE, nc);
858 std::vector<std::int64_t> strides = {0,1};
859#ifndef AMREX_USE_MKL_DFTI_2024
860 pp->set_value(oneapi::mkl::dft::config_param::FWD_STRIDES, strides);
861 pp->set_value(oneapi::mkl::dft::config_param::BWD_STRIDES, strides);
863 pp->set_value(oneapi::mkl::dft::config_param::FWD_STRIDES, strides.data());
864 pp->set_value(oneapi::mkl::dft::config_param::BWD_STRIDES, strides.data());
866 pp->set_value(oneapi::mkl::dft::config_param::WORKSPACE,
867 oneapi::mkl::dft::config_value::WORKSPACE_EXTERNAL);
868 detail::assert_no_external_stream();
869 pp->commit(amrex::Gpu::Device::streamQueue());
875 auto fftw_kind = get_fftw_kind<D>(bc);
876 if constexpr (std::is_same_v<float,T>) {
877 plan = fftwf_plan_many_r2r
878 (1, &
n,
howmany, p,
nullptr, 1,
n, p,
nullptr, 1,
n, &fftw_kind,
881 plan = fftw_plan_many_r2r
882 (1, &
n,
howmany, p,
nullptr, 1,
n, p,
nullptr, 1,
n, &fftw_kind,
895 template <Direction D>
897 std::pair<Boundary,Boundary>
const& bc)
903#if defined(AMREX_USE_GPU)
905 init_r2r<D>(box, p, bc, 2);
910 kind = get_r2r_kind<D>(bc);
919 auto fftw_kind = get_fftw_kind<D>(bc);
920 if constexpr (std::is_same_v<float,T>) {
921 plan = fftwf_plan_many_r2r
922 (1, &
n,
howmany, p,
nullptr, 2,
n*2, p,
nullptr, 2,
n*2, &fftw_kind,
924 plan2 = fftwf_plan_many_r2r
925 (1, &
n,
howmany, p+1,
nullptr, 2,
n*2, p+1,
nullptr, 2,
n*2, &fftw_kind,
928 plan = fftw_plan_many_r2r
929 (1, &
n,
howmany, p,
nullptr, 2,
n*2, p,
nullptr, 2,
n*2, &fftw_kind,
931 plan2 = fftw_plan_many_r2r
932 (1, &
n,
howmany, p+1,
nullptr, 2,
n*2, p+1,
nullptr, 2,
n*2, &fftw_kind,
943 template <Direction D>
954#if defined(AMREX_USE_CUDA)
957 std::size_t work_size = 0;
964 if constexpr (std::is_same_v<float,T>) {
970 if constexpr (std::is_same_v<float,T>) {
978#elif defined(AMREX_USE_HIP)
979 detail::hip_execute(
plan, (
void**)&pi, (
void**)&po);
980#elif defined(AMREX_USE_SYCL)
981 detail::sycl_execute<T,D>(std::get<0>(
plan), pi, po);
984 if constexpr (std::is_same_v<float,T>) {
995 template <Direction D>
1003#if defined(AMREX_USE_CUDA)
1006 std::size_t work_size = 0;
1013 if constexpr (std::is_same_v<float,T>) {
1020#elif defined(AMREX_USE_HIP)
1021 detail::hip_execute(
plan, (
void**)&p, (
void**)&p);
1022#elif defined(AMREX_USE_SYCL)
1023 detail::sycl_execute<T,D>(std::get<1>(
plan), p, p);
1026 if constexpr (std::is_same_v<float,T>) {
1027 fftwf_execute(
plan);
1049 amrex::Abort(
"FFT: alloc_scratch_space: unsupported kind");
1067 auto*
pdst = (T*) pbuf;
1070 int ostride = (
n+1)*2;
1078 auto batch = ielem /
Long(nex);
1079 auto i =
int(ielem - batch*nex);
1080 for (
int ir = 0; ir < 2; ++ir) {
1081 auto* po =
pdst + (2*batch+ir)*ostride + i;
1082 auto const* pi = psrc + 2*batch*istride + ir;
1086 *po = sign * pi[(2*norig-1-i)*2];
1093 auto batch = ielem /
Long(nex);
1094 auto i =
int(ielem - batch*nex);
1095 auto* po =
pdst + batch*ostride + i;
1096 auto const* pi = psrc + batch*istride;
1100 *po = sign * pi[2*norig-1-i];
1105 int ostride = (2*
n+1)*2;
1113 auto batch = ielem /
Long(nex);
1114 auto i =
int(ielem - batch*nex);
1115 for (
int ir = 0; ir < 2; ++ir) {
1116 auto* po =
pdst + (2*batch+ir)*ostride + i;
1117 auto const* pi = psrc + 2*batch*istride + ir;
1120 }
else if (i < (2*norig-1)) {
1121 *po = pi[(2*norig-2-i)*2];
1122 }
else if (i == (2*norig-1)) {
1124 }
else if (i < (3*norig)) {
1125 *po = -pi[(i-2*norig)*2];
1126 }
else if (i < (4*norig-1)) {
1127 *po = -pi[(4*norig-2-i)*2];
1136 auto batch = ielem /
Long(nex);
1137 auto i =
int(ielem - batch*nex);
1138 auto* po =
pdst + batch*ostride + i;
1139 auto const* pi = psrc + batch*istride;
1142 }
else if (i < (2*norig-1)) {
1143 *po = pi[2*norig-2-i];
1144 }
else if (i == (2*norig-1)) {
1146 }
else if (i < (3*norig)) {
1147 *po = -pi[i-2*norig];
1148 }
else if (i < (4*norig-1)) {
1149 *po = -pi[4*norig-2-i];
1156 int ostride = (2*
n+1)*2;
1164 auto batch = ielem /
Long(nex);
1165 auto i =
int(ielem - batch*nex);
1166 for (
int ir = 0; ir < 2; ++ir) {
1167 auto* po =
pdst + (2*batch+ir)*ostride + i;
1168 auto const* pi = psrc + 2*batch*istride + ir;
1171 }
else if (i == norig) {
1173 }
else if (i < (2*norig+1)) {
1174 *po = -pi[(2*norig-i)*2];
1175 }
else if (i < (3*norig)) {
1176 *po = -pi[(i-2*norig)*2];
1177 }
else if (i == 3*norig) {
1180 *po = pi[(4*norig-i)*2];
1187 auto batch = ielem /
Long(nex);
1188 auto i =
int(ielem - batch*nex);
1189 auto* po =
pdst + batch*ostride + i;
1190 auto const* pi = psrc + batch*istride;
1193 }
else if (i == norig) {
1195 }
else if (i < (2*norig+1)) {
1196 *po = -pi[2*norig-i];
1197 }
else if (i < (3*norig)) {
1198 *po = -pi[i-2*norig];
1199 }
else if (i == 3*norig) {
1202 *po = pi[4*norig-i];
1207 int ostride = (2*
n+1)*2;
1215 auto batch = ielem /
Long(nex);
1216 auto i =
int(ielem - batch*nex);
1217 for (
int ir = 0; ir < 2; ++ir) {
1218 auto* po =
pdst + (2*batch+ir)*ostride + i;
1219 auto const* pi = psrc + 2*batch*istride + ir;
1222 }
else if (i < (2*norig)) {
1223 *po = -pi[(2*norig-1-i)*2];
1224 }
else if (i < (3*norig)) {
1225 *po = -pi[(i-2*norig)*2];
1227 *po = pi[(4*norig-1-i)*2];
1234 auto batch = ielem /
Long(nex);
1235 auto i =
int(ielem - batch*nex);
1236 auto* po =
pdst + batch*ostride + i;
1237 auto const* pi = psrc + batch*istride;
1240 }
else if (i < (2*norig)) {
1241 *po = -pi[2*norig-1-i];
1242 }
else if (i < (3*norig)) {
1243 *po = -pi[i-2*norig];
1245 *po = pi[4*norig-1-i];
1250 int ostride = (2*
n+1)*2;
1258 auto batch = ielem /
Long(nex);
1259 auto i =
int(ielem - batch*nex);
1260 for (
int ir = 0; ir < 2; ++ir) {
1261 auto* po =
pdst + (2*batch+ir)*ostride + i;
1262 auto const* pi = psrc + 2*batch*istride + ir;
1265 }
else if (i < (2*norig)) {
1266 *po = pi[(2*norig-1-i)*2];
1267 }
else if (i < (3*norig)) {
1268 *po = -pi[(i-2*norig)*2];
1270 *po = -pi[(4*norig-1-i)*2];
1277 auto batch = ielem /
Long(nex);
1278 auto i =
int(ielem - batch*nex);
1279 auto* po =
pdst + batch*ostride + i;
1280 auto const* pi = psrc + batch*istride;
1283 }
else if (i < (2*norig)) {
1284 *po = pi[2*norig-1-i];
1285 }
else if (i < (3*norig)) {
1286 *po = -pi[i-2*norig];
1288 *po = -pi[4*norig-1-i];
1293 amrex::Abort(
"FFT: pack_r2r_buffer: unsupported kind");
1315 auto batch = ielem /
Long(norig);
1316 auto k =
int(ielem - batch*norig);
1318 for (
int ir = 0; ir < 2; ++ir) {
1319 auto const& yk = psrc[(2*batch+ir)*istride+k+1];
1320 pdst[2*batch*ostride+ir+k*2] = s * yk.real() - c * yk.imag();
1326 auto batch = ielem /
Long(norig);
1327 auto k =
int(ielem - batch*norig);
1329 auto const& yk = psrc[batch*istride+k+1];
1330 pdst[batch*ostride+k] = s * yk.real() - c * yk.imag();
1334 int istride = 2*
n+1;
1338 auto batch = ielem /
Long(norig);
1339 auto k =
int(ielem - batch*norig);
1341 for (
int ir = 0; ir < 2; ++ir) {
1342 auto const& yk = psrc[(2*batch+ir)*istride+2*k+1];
1343 pdst[2*batch*ostride+ir+k*2] = T(0.5)*(s * yk.real() - c * yk.imag());
1349 auto batch = ielem /
Long(norig);
1350 auto k =
int(ielem - batch*norig);
1352 auto const& yk = psrc[batch*istride+2*k+1];
1353 pdst[batch*ostride+k] = T(0.5)*(s * yk.real() - c * yk.imag());
1361 auto batch = ielem /
Long(norig);
1362 auto k =
int(ielem - batch*norig);
1364 for (
int ir = 0; ir < 2; ++ir) {
1365 auto const& yk = psrc[(2*batch+ir)*istride+k];
1366 pdst[2*batch*ostride+ir+k*2] = c * yk.real() + s * yk.imag();
1372 auto batch = ielem /
Long(norig);
1373 auto k =
int(ielem - batch*norig);
1375 auto const& yk = psrc[batch*istride+k];
1376 pdst[batch*ostride+k] = c * yk.real() + s * yk.imag();
1380 int istride = 2*
n+1;
1384 auto batch = ielem /
Long(norig);
1385 auto k =
int(ielem - batch*norig);
1386 for (
int ir = 0; ir < 2; ++ir) {
1387 auto const& yk = psrc[(2*batch+ir)*istride+2*k+1];
1388 pdst[2*batch*ostride+ir+k*2] = T(0.5) * yk.real();
1394 auto batch = ielem /
Long(norig);
1395 auto k =
int(ielem - batch*norig);
1396 auto const& yk = psrc[batch*istride+2*k+1];
1397 pdst[batch*ostride+k] = T(0.5) * yk.real();
1401 int istride = 2*
n+1;
1405 auto batch = ielem /
Long(norig);
1406 auto k =
int(ielem - batch*norig);
1408 for (
int ir = 0; ir < 2; ++ir) {
1409 auto const& yk = psrc[(2*batch+ir)*istride+2*k+1];
1410 pdst[2*batch*ostride+ir+k*2] = T(0.5) * (c * yk.real() + s * yk.imag());
1416 auto batch = ielem /
Long(norig);
1417 auto k =
int(ielem - batch*norig);
1419 auto const& yk = psrc[batch*istride+2*k+1];
1420 pdst[batch*ostride+k] = T(0.5) * (c * yk.real() + s * yk.imag());
1424 int istride = 2*
n+1;
1428 auto batch = ielem /
Long(norig);
1429 auto k =
int(ielem - batch*norig);
1431 for (
int ir = 0; ir < 2; ++ir) {
1432 auto const& yk = psrc[(2*batch+ir)*istride+2*k+1];
1433 pdst[2*batch*ostride+ir+k*2] = T(0.5) * (s * yk.real() - c * yk.imag());
1439 auto batch = ielem /
Long(norig);
1440 auto k =
int(ielem - batch*norig);
1442 auto const& yk = psrc[batch*istride+2*k+1];
1443 pdst[batch*ostride+k] = T(0.5) * (s * yk.real() - c * yk.imag());
1447 amrex::Abort(
"FFT: unpack_r2r_buffer: unsupported kind");
1455 template <Direction D>
1461#if defined(AMREX_USE_GPU)
1467#if defined(AMREX_USE_CUDA)
1471 std::size_t work_size = 0;
1477 if constexpr (std::is_same_v<float,T>) {
1483#elif defined(AMREX_USE_HIP)
1484 detail::hip_execute(
plan, (
void**)&pscratch, (
void**)&pscratch);
1485#elif defined(AMREX_USE_SYCL)
1486 detail::sycl_execute<T,Direction::forward>(std::get<0>(
plan), (T*)pscratch, (
VendorComplex*)pscratch);
1493#if defined(AMREX_USE_CUDA)
1499 if constexpr (std::is_same_v<float,T>) {
1500 fftwf_execute(
plan);
1515#if defined(AMREX_USE_CUDA)
1517#elif defined(AMREX_USE_HIP)
1518 AMREX_ROCFFT_SAFE_CALL(rocfft_plan_destroy(
plan));
1519#elif defined(AMREX_USE_SYCL)
1520 std::visit([](
auto&& p) {
delete p; },
plan);
1522 if constexpr (std::is_same_v<float,T>) {
1523 fftwf_destroy_plan(
plan);
1525 fftw_destroy_plan(
plan);
1538 PlanD* get_vendor_plan_d (Key
const& key);
1539 PlanF* get_vendor_plan_f (Key
const& key);
1541 void add_vendor_plan_d (Key
const& key, PlanD plan);
1542 void add_vendor_plan_f (Key
const& key, PlanF plan);
1546template <
typename T>
1547template <Direction D,
int M>
1558 for (
auto s : fft_size) { n *= s; }
1561#if defined(AMREX_USE_GPU)
1562 Key key = {fft_size.template expand<3>(), ncomp, D, kind};
1565 if constexpr (std::is_same_v<float,T>) {
1566 cached_plan = detail::get_vendor_plan_f(key);
1568 cached_plan = detail::get_vendor_plan_d(key);
1571 plan = *cached_plan;
1580 for (
int i = 0; i < M; ++i) {
1581 len[i] = fft_size[M-1-i];
1584 int nc = fft_size[0]/2+1;
1585 for (
int i = 1; i < M; ++i) {
1589#if defined(AMREX_USE_CUDA)
1596 type = std::is_same_v<float,T> ? CUFFT_R2C : CUFFT_D2Z;
1600 type = std::is_same_v<float,T> ? CUFFT_C2R : CUFFT_Z2D;
1604 std::size_t work_size;
1606 (cufftMakePlanMany(plan, M, len,
nullptr, 1, n_in,
nullptr, 1, n_out, type, howmany, &work_size));
1608#elif defined(AMREX_USE_HIP)
1610 auto prec = std::is_same_v<float,T> ? rocfft_precision_single : rocfft_precision_double;
1612 for (
int idim = 0; idim < M; ++idim) {
length[idim] = fft_size[idim]; }
1614 AMREX_ROCFFT_SAFE_CALL
1615 (rocfft_plan_create(&plan, rocfft_placement_notinplace,
1616 rocfft_transform_type_real_forward, prec, M,
1617 length, howmany,
nullptr));
1619 AMREX_ROCFFT_SAFE_CALL
1620 (rocfft_plan_create(&plan, rocfft_placement_notinplace,
1621 rocfft_transform_type_real_inverse, prec, M,
1622 length, howmany,
nullptr));
1625#elif defined(AMREX_USE_SYCL)
1629 pp =
new mkl_desc_r(fft_size[0]);
1631 std::vector<std::int64_t> len64(M);
1632 for (
int idim = 0; idim < M; ++idim) {
1633 len64[idim] = len[idim];
1635 pp =
new mkl_desc_r(len64);
1637#ifndef AMREX_USE_MKL_DFTI_2024
1638 pp->set_value(oneapi::mkl::dft::config_param::PLACEMENT,
1639 oneapi::mkl::dft::config_value::NOT_INPLACE);
1641 pp->set_value(oneapi::mkl::dft::config_param::PLACEMENT, DFTI_NOT_INPLACE);
1643 pp->set_value(oneapi::mkl::dft::config_param::NUMBER_OF_TRANSFORMS, howmany);
1644 pp->set_value(oneapi::mkl::dft::config_param::FWD_DISTANCE, n);
1645 pp->set_value(oneapi::mkl::dft::config_param::BWD_DISTANCE, nc);
1646 std::vector<std::int64_t> strides(M+1);
1649 for (
int i = M-1; i >= 1; --i) {
1650 strides[i] = strides[i+1] * fft_size[M-1-i];
1653#ifndef AMREX_USE_MKL_DFTI_2024
1654 pp->set_value(oneapi::mkl::dft::config_param::FWD_STRIDES, strides);
1657 pp->set_value(oneapi::mkl::dft::config_param::FWD_STRIDES, strides.data());
1660 pp->set_value(oneapi::mkl::dft::config_param::WORKSPACE,
1661 oneapi::mkl::dft::config_value::WORKSPACE_EXTERNAL);
1662 detail::assert_no_external_stream();
1663 pp->commit(amrex::Gpu::Device::streamQueue());
1668 if (pf ==
nullptr || pb ==
nullptr) {
1673 if constexpr (std::is_same_v<float,T>) {
1675 plan = fftwf_plan_many_dft_r2c
1676 (M, len, howmany, (
float*)pf,
nullptr, 1, n, (fftwf_complex*)pb,
nullptr, 1, nc,
1679 plan = fftwf_plan_many_dft_c2r
1680 (M, len, howmany, (fftwf_complex*)pb,
nullptr, 1, nc, (
float*)pf,
nullptr, 1, n,
1685 plan = fftw_plan_many_dft_r2c
1686 (M, len, howmany, (
double*)pf,
nullptr, 1, n, (fftw_complex*)pb,
nullptr, 1, nc,
1689 plan = fftw_plan_many_dft_c2r
1690 (M, len, howmany, (fftw_complex*)pb,
nullptr, 1, nc, (
double*)pf,
nullptr, 1, n,
1696#if defined(AMREX_USE_GPU)
1698 if constexpr (std::is_same_v<float,T>) {
1699 detail::add_vendor_plan_f(key, plan);
1701 detail::add_vendor_plan_d(key, plan);
1712 template <
typename FA>
1713 typename FA::FABType::value_type * get_fab (FA& fa)
1715 auto myproc = ParallelContext::MyProcSub();
1716 if (myproc < fa.size()) {
1717 return fa.fabPtr(myproc);
1723 template <
typename FA1,
typename FA2>
1724 std::unique_ptr<char,DataDeleter> make_mfs_share (FA1& fa1, FA2& fa2)
1726 bool not_same_fa =
true;
1727 if constexpr (std::is_same_v<FA1,FA2>) {
1728 not_same_fa = (&fa1 != &fa2);
1730 using FAB1 =
typename FA1::FABType::value_type;
1731 using FAB2 =
typename FA2::FABType::value_type;
1732 using T1 =
typename FAB1::value_type;
1733 using T2 =
typename FAB2::value_type;
1734 auto myproc = ParallelContext::MyProcSub();
1735 bool alloc_1 = (myproc < fa1.size());
1736 bool alloc_2 = (myproc < fa2.size()) && not_same_fa;
1738 if (alloc_1 && alloc_2) {
1739 Box const& box1 = fa1.fabbox(myproc);
1740 Box const& box2 = fa2.fabbox(myproc);
1741 int ncomp1 = fa1.nComp();
1742 int ncomp2 = fa2.nComp();
1744 sizeof(T2)*box2.numPts()*ncomp2));
1745 fa1.setFab(myproc, FAB1(box1, ncomp1, (T1*)p));
1746 fa2.setFab(myproc, FAB2(box2, ncomp2, (T2*)p));
1747 }
else if (alloc_1) {
1748 Box const& box1 = fa1.fabbox(myproc);
1749 int ncomp1 = fa1.nComp();
1751 fa1.setFab(myproc, FAB1(box1, ncomp1, (T1*)p));
1752 }
else if (alloc_2) {
1753 Box const& box2 = fa2.fabbox(myproc);
1754 int ncomp2 = fa2.nComp();
1756 fa2.setFab(myproc, FAB2(box2, ncomp2, (T2*)p));
1760 return std::unique_ptr<char,DataDeleter>((
char*)p, DataDeleter{
The_Arena()});
1769 [[nodiscard]]
constexpr Dim3 operator() (Dim3 i)
const noexcept
1771 return Dim3{.x = i.y, .y = i.x, .z = i.z};
1774 static constexpr Dim3 Inverse (Dim3 i)
1776 return Dim3{.x = i.y, .y = i.x, .z = i.z};
1779 [[nodiscard]]
constexpr IndexType operator() (IndexType it)
const noexcept
1784 static constexpr IndexType Inverse (IndexType it)
1792 [[nodiscard]]
constexpr Dim3 operator() (Dim3 i)
const noexcept
1794 return Dim3{.x = i.z, .y = i.y, .z = i.x};
1797 static constexpr Dim3 Inverse (Dim3 i)
1799 return Dim3{.x = i.z, .y = i.y, .z = i.x};
1802 [[nodiscard]]
constexpr IndexType operator() (IndexType it)
const noexcept
1807 static constexpr IndexType Inverse (IndexType it)
1816 [[nodiscard]]
constexpr Dim3 operator() (Dim3 i)
const noexcept
1818 return Dim3{.x = i.y, .y = i.z, .z = i.x};
1822 static constexpr Dim3 Inverse (Dim3 i)
1824 return Dim3{.x = i.z, .y = i.x, .z = i.y};
1827 [[nodiscard]]
constexpr IndexType operator() (IndexType it)
const noexcept
1832 static constexpr IndexType Inverse (IndexType it)
1841 [[nodiscard]]
constexpr Dim3 operator() (Dim3 i)
const noexcept
1843 return Dim3{.x = i.z, .y = i.x, .z = i.y};
1847 static constexpr Dim3 Inverse (Dim3 i)
1849 return Dim3{.x = i.y, .y = i.z, .z = i.x};
1852 [[nodiscard]]
constexpr IndexType operator() (IndexType it)
const noexcept
1857 static constexpr IndexType Inverse (IndexType it)
1870 explicit SubHelper (Box
const& domain);
1872 [[nodiscard]]
Box make_box (Box
const& box)
const;
1874 [[nodiscard]] Periodicity make_periodicity (Periodicity
const& period)
const;
1876 [[nodiscard]]
bool ghost_safe (IntVect
const& ng)
const;
1879 [[nodiscard]]
IntVect make_iv (IntVect
const& iv)
const;
1882 [[nodiscard]]
IntVect make_safe_ghost (IntVect
const& ng)
const;
1884 [[nodiscard]] BoxArray inverse_boxarray (BoxArray
const& ba)
const;
1886 [[nodiscard]]
IntVect inverse_order (IntVect
const& order)
const;
1888 template <
typename T>
1889 [[nodiscard]] T make_array (T
const& a)
const
1891#if (AMREX_SPACEDIM == 1)
1894#elif (AMREX_SPACEDIM == 2)
1895 if (m_case == case_1n) {
1896 return T{a[1],a[0]};
1901 if (m_case == case_11n) {
1902 return T{a[2],a[0],a[1]};
1903 }
else if (m_case == case_1n1) {
1904 return T{a[1],a[0],a[2]};
1905 }
else if (m_case == case_1nn) {
1906 return T{a[1],a[2],a[0]};
1907 }
else if (m_case == case_n1n) {
1908 return T{a[0],a[2],a[1]};
1915 [[nodiscard]] GpuArray<int,3> xyz_order ()
const;
1917 template <
typename FA>
1918 FA make_alias_mf (FA
const& mf)
1920 BoxList bl = mf.boxArray().boxList();
1921 for (
auto& b : bl) {
1924 auto const& ng = make_iv(mf.nGrowVect());
1925 FA submf(BoxArray(std::move(bl)), mf.DistributionMap(), mf.nComp(), ng, MFInfo{}.SetAlloc(
false));
1926 using FAB =
typename FA::fab_type;
1927 for (MFIter mfi(submf, MFItInfo().DisableDeviceSync()); mfi.isValid(); ++mfi) {
1928 submf.setFab(mfi, FAB(mfi.fabbox(), mf.nComp(), mf[mfi].dataPtr()));
1933#if (AMREX_SPACEDIM == 2)
1934 enum Case { case_1n, case_other };
1935 int m_case = case_other;
1936#elif (AMREX_SPACEDIM == 3)
1937 enum Case { case_11n, case_1n1, case_1nn, case_n1n, case_other };
1938 int m_case = case_other;
#define AMREX_ALWAYS_ASSERT_WITH_MESSAGE(EX, MSG)
Definition AMReX_BLassert.H:49
#define AMREX_ALWAYS_ASSERT(EX)
Definition AMReX_BLassert.H:50
#define AMREX_ENUM(CLASS,...)
Definition AMReX_Enum.H:209
#define AMREX_CUFFT_SAFE_CALL(call)
Definition AMReX_GpuError.H:92
#define AMREX_GPU_DEVICE
Definition AMReX_GpuQualifiers.H:18
amrex::ParmParse pp
Input file parser instance for the given namespace.
Definition AMReX_HypreIJIface.cpp:15
Real * pdst
Definition AMReX_HypreMLABecLap.cpp:1140
#define AMREX_D_TERM(a, b, c)
Definition AMReX_SPACE.H:172
virtual void free(void *pt)=0
A pure virtual function for deleting the arena pointed to by pt.
virtual void * alloc(std::size_t sz)=0
__host__ __device__ IntVectND< dim > length() const noexcept
Return the length of the BoxND.
Definition AMReX_Box.H:155
__host__ __device__ const IntVectND< dim > & smallEnd() const &noexcept
Return the inclusive lower bound of the box.
Definition AMReX_Box.H:112
int CoordInt() const noexcept
Returns the CoordType as an int.
Definition AMReX_CoordSys.H:44
Calculates the distribution of FABs to MPI processes.
Definition AMReX_DistributionMapping.H:43
Rectangular problem domain geometry.
Definition AMReX_Geometry.H:75
const Box & Domain() const noexcept
Returns our rectangular domain.
Definition AMReX_Geometry.H:216
const RealBox & ProbDomain() const noexcept
Returns the problem domain.
Definition AMReX_Geometry.H:176
bool isPeriodic(int dir) const noexcept
Is the domain periodic in the specified direction?
Definition AMReX_Geometry.H:337
static bool usingExternalStream() noexcept
Definition AMReX_GpuDevice.cpp:837
An Integer Vector in dim-Dimensional Space.
Definition AMReX_IntVect.H:149
amrex_long Long
Definition AMReX_INT.H:30
void ParallelForOMP(T n, L const &f) noexcept
Performance-portable kernel launch function with optional OpenMP threading.
Definition AMReX_GpuLaunch.H:328
__host__ __device__ Dim3 length(Array4< T > const &a) noexcept
Return the spatial extents of an Array4 in Dim3 form.
Definition AMReX_Array4.H:1373
Arena * The_Arena()
Definition AMReX_Arena.cpp:820
Definition AMReX_FFT_Helper.H:53
constexpr int FastNumPrimeFactors() noexcept
Return the default factor count used for selecting fast FFT lengths.
Definition AMReX_FFT_Helper.H:73
int nextFastLen(int target, int nfactors=FastNumPrimeFactors())
Return the smallest fast FFT length greater than or equal to target.
Definition AMReX_FFT_Helper.H:286
Direction
Definition AMReX_FFT_Helper.H:55
Boundary
Definition AMReX_FFT_Helper.H:59
DomainStrategy
Definition AMReX_FFT_Helper.H:57
Kind
Definition AMReX_FFT_Helper.H:61
void streamSynchronize() noexcept
Definition AMReX_GpuDevice.H:310
gpuStream_t gpuStream() noexcept
Definition AMReX_GpuDevice.H:291
__host__ __device__ std::pair< double, double > sincospi(double x)
Return sin(pi*x) and cos(pi*x) given x.
Definition AMReX_Math.H:205
@ make_alias
Definition AMReX_MakeType.H:7
__host__ __device__ void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition AMReX.H:139
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:30
__host__ __device__ BoxND< dim > shift(const BoxND< dim > &b, int dir, int nzones) noexcept
Return a BoxND with indices shifted by nzones in dir direction.
Definition AMReX_Box.H:1504
IndexTypeND< 3 > IndexType
IndexType is an alias for amrex::IndexTypeND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:36
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:33
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition AMReX.cpp:241
const int[]
Definition AMReX_BLProfiler.cpp:1664
Definition AMReX_FFT_Helper.H:83
bool twod_mode
Definition AMReX_FFT_Helper.H:94
Info & setNumProcs(int n)
Cap the number of MPI ranks used by FFT.
Definition AMReX_FFT_Helper.H:163
bool oned_mode
Definition AMReX_FFT_Helper.H:103
int batch_size
Batched FFT size. Only support in R2C, not R2X.
Definition AMReX_FFT_Helper.H:106
Info & setOpenBCPadding(bool x)
Enable or disable OpenBCSolver internal FFT padding.
Definition AMReX_FFT_Helper.H:170
Info & setOpenBCPaddingNumPrimeFactors(int n)
Set the factor count used for OpenBCSolver FFT padding.
Definition AMReX_FFT_Helper.H:177
Info & setDomainStrategy(DomainStrategy s)
Select how the domain is decomposed across MPI ranks.
Definition AMReX_FFT_Helper.H:124
DomainStrategy domain_strategy
Domain composition strategy.
Definition AMReX_FFT_Helper.H:85
int nprocs
Max number of processes to use.
Definition AMReX_FFT_Helper.H:109
int pencil_threshold
Definition AMReX_FFT_Helper.H:89
bool openbc_padding
Whether OpenBCSolver pads internal FFT lengths for better performance.
Definition AMReX_FFT_Helper.H:112
Info & setOneDMode(bool x)
Flag the degenerate 2-D mode (nx==1 or ny==1) that still batches along z.
Definition AMReX_FFT_Helper.H:149
Info & setBatchSize(int bsize)
Specify the batch size for FFT.
Definition AMReX_FFT_Helper.H:156
int openbc_padding_nfactors
Definition AMReX_FFT_Helper.H:116
Info & setPencilThreshold(int t)
Override the slab→pencil break-even threshold for the automatic strategy.
Definition AMReX_FFT_Helper.H:131
Info & setTwoDMode(bool x)
Restrict transforms to the first two dimensions (3-D problems only).
Definition AMReX_FFT_Helper.H:138
Definition AMReX_FFT_Helper.H:360
void * pf
Definition AMReX_FFT_Helper.H:395
void unpack_r2r_buffer(T *pdst, void const *pbuf) const
Collapse the spectral R2R result back into the original real layout.
Definition AMReX_FFT_Helper.H:1303
std::conditional_t< std::is_same_v< float, T >, cuComplex, cuDoubleComplex > VendorComplex
Definition AMReX_FFT_Helper.H:364
VendorPlan plan2
Definition AMReX_FFT_Helper.H:394
void init_r2c(IntVectND< M > const &fft_size, void *pbf, void *pbb, bool cache, int ncomp=1)
Initialize an M-dimensional batched real-to-complex plan.
Definition AMReX_FFT_Helper.H:1548
int n
Definition AMReX_FFT_Helper.H:387
void destroy()
Release any vendor FFT plan objects owned by this Plan.
Definition AMReX_FFT_Helper.H:414
bool defined2
Definition AMReX_FFT_Helper.H:392
void init_r2r(Box const &box, VendorComplex *pc, std::pair< Boundary, Boundary > const &bc)
Initialize a real-to-real plan that reads/writes complex storage.
Definition AMReX_FFT_Helper.H:896
void pack_r2r_buffer(void *pbuf, T const *psrc) const
Expand the real R2R input into the symmetry-extended buffer expected by CUFFT/rocFFT.
Definition AMReX_FFT_Helper.H:1065
static void free_scratch_space(void *p)
Release GPU scratch allocated via alloc_scratch_space().
Definition AMReX_FFT_Helper.H:1057
static void destroy_vendor_plan(VendorPlan plan)
Helper that destroys a vendor plan of the appropriate backend type.
Definition AMReX_FFT_Helper.H:1513
Kind get_r2r_kind(std::pair< Boundary, Boundary > const &bc)
Map boundary conditions to the Plan Kind for real-to-real transforms.
Definition AMReX_FFT_Helper.H:758
cufftHandle VendorPlan
Definition AMReX_FFT_Helper.H:362
Kind kind
Definition AMReX_FFT_Helper.H:389
void init_c2c(Box const &box, VendorComplex *p, int ncomp=1, int ndims=1)
Initialize a complex-to-complex plan across 1/2/3 dimensions.
Definition AMReX_FFT_Helper.H:590
int howmany
Definition AMReX_FFT_Helper.H:388
void * pb
Definition AMReX_FFT_Helper.H:396
void init_r2c(Box const &box, T *pr, VendorComplex *pc, bool is_2d_transform=false, int ncomp=1)
Initialize a 1-D or 2-D real-to-complex plan over the supplied Box.
Definition AMReX_FFT_Helper.H:438
void compute_r2r()
Execute the real-to-real plan, including GPU packing/unpacking.
Definition AMReX_FFT_Helper.H:1456
void compute_c2c()
Execute the complex-to-complex plan in place.
Definition AMReX_FFT_Helper.H:996
bool r2r_data_is_complex
Definition AMReX_FFT_Helper.H:390
void * alloc_scratch_space() const
Allocate GPU scratch space large enough to hold packed R2R data.
Definition AMReX_FFT_Helper.H:1040
VendorPlan plan
Definition AMReX_FFT_Helper.H:393
void compute_r2c()
Execute the previously initialized real-to-complex plan.
Definition AMReX_FFT_Helper.H:944
bool defined
Definition AMReX_FFT_Helper.H:391
void set_ptrs(void *p0, void *p1)
Register device pointers used by the forward/backward executions.
Definition AMReX_FFT_Helper.H:405
void init_r2r(Box const &box, T *p, std::pair< Boundary, Boundary > const &bc, int howmany_initval=1)
Initialize a real-to-real (cosine/sine) plan that operates on real buffers.
Definition AMReX_FFT_Helper.H:792
A host / device complex number type, because std::complex doesn't work in device code with Cuda yet.
Definition AMReX_GpuComplex.H:30