Cabana 0.8.0-dev
 
Loading...
Searching...
No Matches
Cabana_Grid_FastFourierTransform.hpp
Go to the documentation of this file.
1/****************************************************************************
2 * Copyright (c) 2018-2023 by the Cabana authors *
3 * All rights reserved. *
4 * *
5 * This file is part of the Cabana library. Cabana is distributed under a *
6 * BSD 3-clause license. For the licensing terms see the LICENSE file in *
7 * the top-level directory. *
8 * *
9 * SPDX-License-Identifier: BSD-3-Clause *
10 ****************************************************************************/
11
16#ifndef CABANA_GRID_FASTFOURIERTRANSFORM_HPP
17#define CABANA_GRID_FASTFOURIERTRANSFORM_HPP
18
19#include <Cabana_Grid_Array.hpp>
20#include <Cabana_Grid_Types.hpp>
21
22#include <Kokkos_Core.hpp>
23#include <Kokkos_Profiling_ScopedRegion.hpp>
24
25#include <heffte_fft3d.h>
26
27#include <array>
28#include <memory>
29#include <type_traits>
30
31namespace Cabana
32{
33namespace Grid
34{
35namespace Experimental
36{
37//---------------------------------------------------------------------------//
38
41{
42};
43
45{
46};
47
49{
50};
51
54{
55};
56
58{
59};
60
61namespace Impl
62{
64struct FFTBackendDefault
65{
66};
68} // namespace Impl
69
71template <class ArrayEntity, class ArrayMesh, class ArrayMemorySpace,
72 class ArrayScalar, class Entity, class Mesh, class MemorySpace,
73 class Scalar, typename SFINAE = void>
74struct is_matching_array : public std::false_type
75{
76 static_assert( std::is_same<ArrayEntity, Entity>::value,
77 "Array entity type must match FFT entity type." );
78 static_assert( std::is_same<ArrayMesh, Mesh>::value,
79 "Array mesh type must match FFT mesh type." );
80 static_assert( std::is_same<ArrayMemorySpace, MemorySpace>::value,
81 "Array memory space must match FFT memory space." );
82};
83
85template <class ArrayEntity, class ArrayMesh, class ArrayMemorySpace,
86 class ArrayScalar, class Entity, class Mesh, class MemorySpace,
87 class Scalar>
89 ArrayEntity, ArrayMesh, ArrayMemorySpace, ArrayScalar, Entity, Mesh,
90 MemorySpace, Scalar,
91 typename std::enable_if<
92 std::is_same<ArrayEntity, Entity>::value &&
93 std::is_same<ArrayMesh, Mesh>::value &&
94 std::is_same<ArrayMemorySpace, MemorySpace>::value>::type>
95 : public std::true_type
96{
97};
98
102enum class FFTCommPattern : unsigned int
103{
104 alltoallv = 0u,
105 p2p = 1u,
106 alltoall = 2u,
107 p2p_plined = 3u
108};
109
110//---------------------------------------------------------------------------//
115{
116 FFTCommPattern FFTcomm = FFTCommPattern::alltoallv;
117 bool pencils = true;
118 bool reorder = true;
119
120 public:
125 void setAlltoAll( FFTCommPattern value ) { FFTcomm = value; }
130 void setAlltoAll( bool value )
131 {
132 if ( value )
133 FFTcomm = FFTCommPattern::alltoallv;
134 else
135 FFTcomm = FFTCommPattern::p2p;
136 }
137
141 void setPencils( bool value ) { pencils = value; }
147 void setReorder( bool value ) { reorder = value; }
152 FFTCommPattern getAlltoAll() const { return FFTcomm; }
157 bool getPencils() const { return pencils; }
163 bool getReorder() const { return reorder; }
164};
165
166//---------------------------------------------------------------------------//
170template <class EntityType, class MeshType, class Scalar, class MemorySpace,
171 class Derived>
173{
174 public:
176 using entity_type = EntityType;
178 using mesh_type = MeshType;
180 using value_type = Scalar;
181
182 // FIXME: extracting the self type for backwards compatibility with previous
183 // template on DeviceType. Should simply be MemorySpace after next release.
185 using memory_space = typename MemorySpace::memory_space;
186 // FIXME: replace warning with memory space assert after next release.
187 static_assert(
188 Cabana::Impl::deprecated( Kokkos::is_device<MemorySpace>() ) );
189
191 using execution_space = typename memory_space::execution_space;
193 using exec_space [[deprecated]] = execution_space;
195 using device_type [[deprecated]] = typename memory_space::device_type;
196
198 static constexpr std::size_t num_space_dim = mesh_type::num_space_dim;
199
201 std::array<int, num_space_dim> global_high;
203 std::array<int, num_space_dim> global_low;
204
210 {
211 checkArrayDofs( layout.dofsPerEntity() );
212
213 // Get the local dimensions of the problem.
214 auto entity_space =
215 layout.localGrid()->indexSpace( Own(), EntityType(), Local() );
216 // Get the global grid.
217 const auto& global_grid = layout.localGrid()->globalGrid();
218
219 for ( std::size_t d = 0; d < num_space_dim; ++d )
220 {
221 // Get the low corner of the global index space on this rank.
222 global_low[d] =
223 (int)global_grid.globalOffset( num_space_dim - d - 1 );
224
225 // Get the high corner of the global index space on this rank.
226 int local_num_entity =
227 (int)entity_space.extent( num_space_dim - d - 1 );
228 global_high[d] = global_low[d] + local_num_entity - 1;
229 }
230 }
231
236 inline void checkArrayDofs( const int dof )
237 {
238 if ( 2 != dof )
239 throw std::logic_error(
240 "Cabana::Grid::Experimental::FastFourierTransform::"
241 "checkArrayDofs: Only 1 complex value per entity allowed in "
242 "FFT" );
243 }
244
250 template <class Array_t, class ScaleType>
252 const Array_t& x, const ScaleType scaling,
253 typename std::enable_if<
256 typename Array_t::entity_type, typename Array_t::mesh_type,
257 typename Array_t::memory_space, typename Array_t::value_type,
259 int>::type* = 0 )
260 {
261 Kokkos::Profiling::ScopedRegion region( "Cabana::FFT::forward" );
262
263 checkArrayDofs( x.layout()->dofsPerEntity() );
264 static_cast<Derived*>( this )->forwardImpl( x, scaling );
265 }
266
272 template <class Array_t, class ScaleType>
274 const Array_t& x, const ScaleType scaling,
275 typename std::enable_if<
278 typename Array_t::entity_type, typename Array_t::mesh_type,
279 typename Array_t::memory_space, typename Array_t::value_type,
281 int>::type* = 0 )
282 {
283 Kokkos::Profiling::ScopedRegion region( "Cabana::FFT::reverse" );
284
285 checkArrayDofs( x.layout()->dofsPerEntity() );
286 static_cast<Derived*>( this )->reverseImpl( x, scaling );
287 }
288
292 template <class ExecutionSpace, class IndexSpaceType, class LViewType,
293 class LGViewType, std::size_t NSD = num_space_dim>
294 std::enable_if_t<3 == NSD, void>
295 copyToLocal( ExecutionSpace exec_space, const IndexSpaceType own_space,
296 LViewType& l_view, const LGViewType lg_view )
297 {
298 Kokkos::parallel_for(
299 "Cabana::Grid::FastFourierTransform::copyTo",
300 createExecutionPolicy( own_space, exec_space ),
301 KOKKOS_LAMBDA( const int i, const int j, const int k ) {
302 auto iw = i - own_space.min( Dim::I );
303 auto jw = j - own_space.min( Dim::J );
304 auto kw = k - own_space.min( Dim::K );
305 l_view( iw, jw, kw, 0 ) = lg_view( i, j, k, 0 );
306 l_view( iw, jw, kw, 1 ) = lg_view( i, j, k, 1 );
307 } );
308 }
309
313 template <class ExecutionSpace, class IndexSpaceType, class LViewType,
314 class LGViewType, std::size_t NSD = num_space_dim>
315 std::enable_if_t<2 == NSD, void>
316 copyToLocal( ExecutionSpace space, const IndexSpaceType own_space,
317 LViewType& l_view, const LGViewType lg_view )
318 {
319 Kokkos::parallel_for(
320 "Cabana::Grid::FastFourierTransform::copyTo",
321 createExecutionPolicy( own_space, space ),
322 KOKKOS_LAMBDA( const int i, const int j ) {
323 auto iw = i - own_space.min( Dim::I );
324 auto jw = j - own_space.min( Dim::J );
325 l_view( iw, jw, 0 ) = lg_view( i, j, 0 );
326 l_view( iw, jw, 1 ) = lg_view( i, j, 1 );
327 } );
328 }
329
333 template <class ExecutionSpace, class IndexSpaceType, class LViewType,
334 class LGViewType, std::size_t NSD = num_space_dim>
335 std::enable_if_t<3 == NSD, void>
336 copyFromLocal( ExecutionSpace space, const IndexSpaceType own_space,
337 const LViewType l_view, LGViewType& lg_view )
338 {
339 Kokkos::parallel_for(
340 "Cabana::Grid::FastFourierTransform::copyFrom",
341 createExecutionPolicy( own_space, space ),
342 KOKKOS_LAMBDA( const int i, const int j, const int k ) {
343 auto iw = i - own_space.min( Dim::I );
344 auto jw = j - own_space.min( Dim::J );
345 auto kw = k - own_space.min( Dim::K );
346 lg_view( i, j, k, 0 ) = l_view( iw, jw, kw, 0 );
347 lg_view( i, j, k, 1 ) = l_view( iw, jw, kw, 1 );
348 } );
349 }
350
354 template <class ExecutionSpace, class IndexSpaceType, class LViewType,
355 class LGViewType, std::size_t NSD = num_space_dim>
356 std::enable_if_t<2 == NSD, void>
357 copyFromLocal( ExecutionSpace space, const IndexSpaceType own_space,
358 const LViewType l_view, LGViewType& lg_view )
359 {
360 Kokkos::parallel_for(
361 "Cabana::Grid::FastFourierTransform::copyFrom",
362 createExecutionPolicy( own_space, space ),
363 KOKKOS_LAMBDA( const int i, const int j ) {
364 auto iw = i - own_space.min( Dim::I );
365 auto jw = j - own_space.min( Dim::J );
366 lg_view( i, j, 0 ) = l_view( iw, jw, 0 );
367 lg_view( i, j, 1 ) = l_view( iw, jw, 1 );
368 } );
369 }
370};
371
372//---------------------------------------------------------------------------//
373// heFFTe
374//---------------------------------------------------------------------------//
375namespace Impl
376{
378template <class ExecutionSpace, class BackendType>
379struct HeffteBackendTraits
380{
381};
382#ifdef Heffte_ENABLE_MKL
383template <class ExecutionSpace>
384struct HeffteBackendTraits<ExecutionSpace, FFTBackendMKL>
385{
386 using backend_type = heffte::backend::mkl;
387};
388#endif
389#ifdef Heffte_ENABLE_FFTW
390template <class ExecutionSpace>
391struct HeffteBackendTraits<ExecutionSpace, FFTBackendFFTW>
392{
393 using backend_type = heffte::backend::fftw;
394};
395#endif
396#ifdef Heffte_ENABLE_FFTW
397template <class ExecutionSpace>
398struct HeffteBackendTraits<ExecutionSpace, Impl::FFTBackendDefault>
399{
400 using backend_type = heffte::backend::fftw;
401};
402#else
403#ifdef Heffte_ENABLE_MKL
404template <class ExecutionSpace>
405struct HeffteBackendTraits<ExecutionSpace, Impl::FFTBackendDefault>
406{
407 using backend_type = heffte::backend::mkl;
408};
409#else
410throw std::runtime_error( "Cabana::Grid::FastFourierTransform: Must enable at "
411 "least one heFFTe host backend." );
412#endif
413#endif
414#ifdef Heffte_ENABLE_CUDA
415#ifdef KOKKOS_ENABLE_CUDA
416template <>
417struct HeffteBackendTraits<Kokkos::Cuda, Impl::FFTBackendDefault>
418{
419 using backend_type = heffte::backend::cufft;
420};
421#endif
422#endif
423#ifdef Heffte_ENABLE_ROCM
424#ifdef KOKKOS_ENABLE_HIP
425template <>
426struct HeffteBackendTraits<Kokkos::Experimental::HIP, Impl::FFTBackendDefault>
427{
428 using backend_type = heffte::backend::rocfft;
429};
430#endif
431#endif
432#ifdef Heffte_ENABLE_ONEAPI
433#ifdef KOKKOS_ENABLE_SYCL
434template <>
435struct HeffteBackendTraits<Kokkos::Experimental::SYCL, Impl::FFTBackendDefault>
436{
437 using backend_type = heffte::backend::onemkl;
438};
439#endif
440#endif
441
442template <class ScaleType>
443struct HeffteScalingTraits
444{
445};
446template <>
447struct HeffteScalingTraits<FFTScaleNone>
448{
449 static const auto scaling_type = heffte::scale::none;
450};
451template <>
452struct HeffteScalingTraits<FFTScaleFull>
453{
454 static const auto scaling_type = heffte::scale::full;
455};
456template <>
457struct HeffteScalingTraits<FFTScaleSymmetric>
458{
459 static const auto scaling_type = heffte::scale::symmetric;
460};
461
462#ifdef KOKKOS_ENABLE_SYCL
463// Overload for SYCL.
464template <class ExecSpace, class HeffteBackendType>
465auto createHeffteFft3d(
466 ExecSpace exec_space, HeffteBackendType, heffte::box3d<> inbox,
467 heffte::box3d<> outbox, MPI_Comm comm, heffte::plan_options params,
468 typename std::enable_if<
469 std::is_same<HeffteBackendType, heffte::backend::onemkl>::value,
470 int>::type* = 0 )
471{
472 // Set FFT options from given parameters
473 // heFFTe correctly handles 2D or 3D FFTs within "fft3d"
474 sycl::queue& q = exec_space.sycl_queue();
475 return std::make_shared<heffte::fft3d<HeffteBackendType>>( q, inbox, outbox,
476 comm, params );
477}
478#endif
479
480template <class ExecSpace, class HeffteBackendType>
481auto createHeffteFft3d(
482 ExecSpace, HeffteBackendType, heffte::box3d<> inbox, heffte::box3d<> outbox,
483 MPI_Comm comm, heffte::plan_options params,
484 typename std::enable_if<
485 std::is_same<HeffteBackendType, heffte::backend::fftw>::value ||
486 std::is_same<HeffteBackendType, heffte::backend::mkl>::value ||
487 std::is_same<HeffteBackendType, heffte::backend::cufft>::value ||
488 std::is_same<HeffteBackendType, heffte::backend::rocfft>::value,
489 int>::type* = 0 )
490{
491 // Set FFT options from given parameters
492 // heFFTe correctly handles 2D or 3D FFTs within "fft3d"
493 return std::make_shared<heffte::fft3d<HeffteBackendType>>( inbox, outbox,
494 comm, params );
495}
496
498} // namespace Impl
499
500//---------------------------------------------------------------------------//
504template <class EntityType, class MeshType, class Scalar, class MemorySpace,
505 class ExecSpace, class BackendType>
507 : public FastFourierTransform<
508 EntityType, MeshType, Scalar, MemorySpace,
509 HeffteFastFourierTransform<EntityType, MeshType, Scalar, MemorySpace,
510 ExecSpace, BackendType>>
511{
512 public:
514 using value_type = Scalar;
515
516 // FIXME: extracting the self type for backwards compatibility with previous
517 // template on DeviceType. Should simply be MemorySpace after next release.
519 using memory_space = typename MemorySpace::memory_space;
520 // FIXME: replace warning with memory space assert after next release.
521 static_assert(
522 Cabana::Impl::deprecated( Kokkos::is_device<MemorySpace>() ) );
523
525 using execution_space = ExecSpace;
527 using exec_space [[deprecated]] = execution_space;
529 using device_type [[deprecated]] = typename memory_space::device_type;
531 using backend_type = BackendType;
533 using mesh_type = MeshType;
534
536 static constexpr std::size_t num_space_dim = mesh_type::num_space_dim;
537
540 typename Impl::HeffteBackendTraits<execution_space,
542
545
554 const FastFourierTransformParams& params )
556 EntityType, MeshType, Scalar, MemorySpace,
557 HeffteFastFourierTransform<EntityType, MeshType, Scalar,
558 MemorySpace, ExecSpace, BackendType>>(
559 layout )
560 , heffte_execution_space( exec_space )
561 {
562 // heFFTe correctly handles 2D or 3D domains within "box3d"
563 heffte::box3d<> inbox = { this->global_low, this->global_high };
564 heffte::box3d<> outbox = { this->global_low, this->global_high };
565
566 heffte::plan_options heffte_params =
567 heffte::default_options<heffte_backend_type>();
568 auto FFTcomm = params.getAlltoAll();
569 switch ( FFTcomm )
570 {
571 case Cabana::Grid::Experimental::FFTCommPattern::p2p:
572 heffte_params.algorithm = heffte::reshape_algorithm::p2p;
573 break;
574 case Cabana::Grid::Experimental::FFTCommPattern::alltoallv:
575 heffte_params.algorithm = heffte::reshape_algorithm::alltoallv;
576 break;
577 case Cabana::Grid::Experimental::FFTCommPattern::alltoall:
578 heffte_params.algorithm = heffte::reshape_algorithm::alltoall;
579 break;
580 case Cabana::Grid::Experimental::FFTCommPattern::p2p_plined:
581 heffte_params.algorithm = heffte::reshape_algorithm::p2p_plined;
582 break;
583 default:
584 heffte_params.algorithm = heffte::reshape_algorithm::alltoallv;
585 break;
586 }
587
588 heffte_params.use_pencils = params.getPencils();
589 heffte_params.use_reorder = params.getReorder();
590
591 // Create the heFFTe main class (separated to handle SYCL queue
592 // correctly).
593 _fft = Impl::createHeffteFft3d(
595 layout.localGrid()->globalGrid().comm(), heffte_params );
596 long long fftsize = std::max( _fft->size_outbox(), _fft->size_inbox() );
597
598 // Check the size.
599 auto entity_space =
600 layout.localGrid()->indexSpace( Own(), EntityType(), Local() );
601 if ( fftsize < (int)entity_space.size() )
602 throw std::logic_error(
603 "Cabana::Grid::Experimental::HeffteFastFourierTransform: "
604 "Expected FFT allocation size smaller "
605 "than local grid size" );
606
607 _fft_work = Kokkos::View<Scalar*, memory_space>(
608 Kokkos::ViewAllocateWithoutInitializing( "fft_work" ),
609 2 * fftsize );
610 _workspace = Kokkos::View<Scalar* [2], memory_space>(
611 Kokkos::ViewAllocateWithoutInitializing( "workspace" ),
612 _fft->size_workspace() );
613 }
614
620 template <class Array_t, class ScaleType>
621 void forwardImpl( const Array_t& x, const ScaleType )
622 {
623 compute( x, 1, Impl::HeffteScalingTraits<ScaleType>().scaling_type );
624 }
625
631 template <class Array_t, class ScaleType>
632 void reverseImpl( const Array_t& x, const ScaleType )
633 {
634 compute( x, -1, Impl::HeffteScalingTraits<ScaleType>().scaling_type );
635 }
636
643 template <class Array_t>
644 void compute( const Array_t& x, const int flag, const heffte::scale scale )
645 {
646 // Create a subview of the work array to write the local data into.
647 auto own_space =
648 x.layout()->localGrid()->indexSpace( Own(), EntityType(), Local() );
649 auto local_view_space = appendDimension( own_space, 2 );
651 local_view_space, _fft_work.data() );
652
653 // TODO: pull this out to template function
654 // Copy to the work array. The work array only contains owned data.
655 auto localghost_view = x.view();
656
657 this->copyToLocal( heffte_execution_space, own_space, local_view,
658 localghost_view );
659
660 if ( flag == 1 )
661 {
662 _fft->forward(
663 reinterpret_cast<std::complex<Scalar>*>( _fft_work.data() ),
664 reinterpret_cast<std::complex<Scalar>*>( _fft_work.data() ),
665 reinterpret_cast<std::complex<Scalar>*>( _workspace.data() ),
666 scale );
667 }
668 else if ( flag == -1 )
669 {
670 _fft->backward(
671 reinterpret_cast<std::complex<Scalar>*>( _fft_work.data() ),
672 reinterpret_cast<std::complex<Scalar>*>( _fft_work.data() ),
673 reinterpret_cast<std::complex<Scalar>*>( _workspace.data() ),
674 scale );
675 }
676 else
677 {
678 throw std::logic_error(
679 "Cabana::Grid::Experimental::HeffteFastFourierTransform::"
680 "compute: Only 1:forward and -1:backward are allowed as "
681 "compute flag" );
682 }
683
684 // Copy back to output array.
685 this->copyFromLocal( heffte_execution_space, own_space, local_view,
686 localghost_view );
687 }
688
689 private:
690 // heFFTe correctly handles 2D or 3D FFTs within "fft3d"
691 std::shared_ptr<heffte::fft3d<heffte_backend_type>> _fft;
692 Kokkos::View<Scalar*, memory_space> _fft_work;
693 Kokkos::View<Scalar* [2], memory_space> _workspace;
694};
695
696//---------------------------------------------------------------------------//
697// heFFTe creation
698//---------------------------------------------------------------------------//
703template <class Scalar, class MemorySpace, class BackendType, class EntityType,
704 class MeshType, class ExecSpace>
706 ExecSpace exec_space, const ArrayLayout<EntityType, MeshType>& layout,
707 const FastFourierTransformParams& params )
708{
709 return std::make_shared<HeffteFastFourierTransform<
710 EntityType, MeshType, Scalar, MemorySpace, ExecSpace, BackendType>>(
711 exec_space, layout, params );
712}
713
718template <class Scalar, class MemorySpace, class EntityType, class MeshType,
719 class ExecSpace>
721 ExecSpace exec_space, const ArrayLayout<EntityType, MeshType>& layout,
722 const FastFourierTransformParams& params )
723{
724 return createHeffteFastFourierTransform<Scalar, MemorySpace,
725 Impl::FFTBackendDefault>(
726 exec_space, layout, params );
727}
728
733template <class Scalar, class MemorySpace, class BackendType, class EntityType,
734 class MeshType, class ExecSpace>
736 ExecSpace exec_space, const ArrayLayout<EntityType, MeshType>& layout )
737{
738 using heffte_backend_type =
739 typename Impl::HeffteBackendTraits<ExecSpace,
740 BackendType>::backend_type;
741
742 // use default heFFTe params for this backend
743 const heffte::plan_options heffte_params =
744 heffte::default_options<heffte_backend_type>();
746 params.setAlltoAll( FFTCommPattern::alltoallv );
747 params.setPencils( heffte_params.use_pencils );
748 params.setReorder( heffte_params.use_reorder );
749
750 return std::make_shared<HeffteFastFourierTransform<
751 EntityType, MeshType, Scalar, MemorySpace, ExecSpace, BackendType>>(
752 exec_space, layout, params );
753}
754
759template <class Scalar, class MemorySpace, class EntityType, class MeshType,
760 class ExecSpace>
762 ExecSpace exec_space, const ArrayLayout<EntityType, MeshType>& layout )
763{
765 Scalar, MemorySpace, Impl::FFTBackendDefault, EntityType, MeshType>(
766 exec_space, layout );
767}
768
772template <class Scalar, class MemorySpace, class BackendType, class EntityType,
773 class MeshType>
776 const FastFourierTransformParams& params )
777{
778 using exec_space = typename MemorySpace::execution_space;
779 return createHeffteFastFourierTransform<Scalar, MemorySpace, BackendType,
780 EntityType, MeshType>(
781 exec_space{}, layout, params );
782}
783
787template <class Scalar, class MemorySpace, class EntityType, class MeshType>
790 const FastFourierTransformParams& params )
791{
792 using exec_space = typename MemorySpace::execution_space;
794 Scalar, MemorySpace, Impl::FFTBackendDefault, EntityType, MeshType>(
795 exec_space{}, layout, params );
796}
797
801template <class Scalar, class MemorySpace, class BackendType, class EntityType,
802 class MeshType>
805{
806 using exec_space = typename MemorySpace::execution_space;
807 return createHeffteFastFourierTransform<Scalar, MemorySpace, BackendType,
808 EntityType, MeshType>( exec_space{},
809 layout );
810}
811
815template <class Scalar, class MemorySpace, class EntityType, class MeshType>
818{
819 using exec_space = typename MemorySpace::execution_space;
821 Scalar, MemorySpace, Impl::FFTBackendDefault, EntityType, MeshType>(
822 exec_space{}, layout );
823}
824
825//---------------------------------------------------------------------------//
826
827} // end namespace Experimental
828} // namespace Grid
829} // namespace Cabana
830
831#endif // end CABANA_GRID_FASTFOURIERTRANSFORM_HPP
Grid field arrays.
FFTCommPattern
Choices of heFFTe MPI communication patterns.
Definition Cabana_Grid_FastFourierTransform.hpp:103
auto createHeffteFastFourierTransform(ExecSpace exec_space, const ArrayLayout< EntityType, MeshType > &layout, const FastFourierTransformParams &params)
Definition Cabana_Grid_FastFourierTransform.hpp:705
Kokkos::RangePolicy< ExecutionSpace > createExecutionPolicy(const IndexSpace< 1 > &index_space, const ExecutionSpace &)
Create a multi-dimensional execution policy over an index space.
Definition Cabana_Grid_IndexSpace.hpp:175
Kokkos::View< Scalar *, Params... > createView(const std::string &label, const IndexSpace< 1 > &index_space)
Given an index space create a view over the extent of that index space.
Definition Cabana_Grid_IndexSpace.hpp:235
IndexSpace< N+1 > appendDimension(const IndexSpace< N > &index_space, const long size)
Given an N-dimensional index space append an additional dimension with the given size.
Definition Cabana_Grid_IndexSpace.hpp:442
Grid type tags.
Entity layout for array data on the local mesh.
Definition Cabana_Grid_Array.hpp:46
int dofsPerEntity() const
Get the number of degrees-of-freedom on each grid entity.
Definition Cabana_Grid_Array.hpp:77
const std::shared_ptr< LocalGrid< MeshType > > localGrid() const
Get the local grid over which this layout is defined.
Definition Cabana_Grid_Array.hpp:71
Parameters controlling details for fast Fourier transforms.
Definition Cabana_Grid_FastFourierTransform.hpp:115
bool getReorder() const
Get data handling (contiguous or strided memory).
Definition Cabana_Grid_FastFourierTransform.hpp:163
void setAlltoAll(bool value)
Set MPI communication strategy.
Definition Cabana_Grid_FastFourierTransform.hpp:130
FFTCommPattern getAlltoAll() const
Get MPI communication strategy.
Definition Cabana_Grid_FastFourierTransform.hpp:152
bool getPencils() const
Get data exchange type (pencil or slab).
Definition Cabana_Grid_FastFourierTransform.hpp:157
void setReorder(bool value)
Set data handling (contiguous or strided memory).
Definition Cabana_Grid_FastFourierTransform.hpp:147
void setAlltoAll(FFTCommPattern value)
Set MPI communication strategy.
Definition Cabana_Grid_FastFourierTransform.hpp:125
void setPencils(bool value)
Set data exchange type (pencil or slab).
Definition Cabana_Grid_FastFourierTransform.hpp:141
typename memory_space::execution_space execution_space
Kokkos execution space.
Definition Cabana_Grid_FastFourierTransform.hpp:191
FastFourierTransform(const ArrayLayout< EntityType, MeshType > &layout)
Constructor.
Definition Cabana_Grid_FastFourierTransform.hpp:209
std::enable_if_t< 3==NSD, void > copyToLocal(ExecutionSpace exec_space, const IndexSpaceType own_space, LViewType &l_view, const LGViewType lg_view)
Copy owned data for FFT.
Definition Cabana_Grid_FastFourierTransform.hpp:295
typename MemorySpace::memory_space memory_space
Kokkos memory space.
Definition Cabana_Grid_FastFourierTransform.hpp:185
MeshType mesh_type
Mesh type.
Definition Cabana_Grid_FastFourierTransform.hpp:178
static constexpr std::size_t num_space_dim
Spatial dimension.
Definition Cabana_Grid_FastFourierTransform.hpp:198
void forward(const Array_t &x, const ScaleType scaling, typename std::enable_if<(is_array< Array_t >::value &&is_matching_array< typename Array_t::entity_type, typename Array_t::mesh_type, typename Array_t::memory_space, typename Array_t::value_type, entity_type, mesh_type, memory_space, value_type >::value), int >::type *=0)
Do a forward FFT.
Definition Cabana_Grid_FastFourierTransform.hpp:251
EntityType entity_type
Array entity type.
Definition Cabana_Grid_FastFourierTransform.hpp:176
std::enable_if_t< 3==NSD, void > copyFromLocal(ExecutionSpace space, const IndexSpaceType own_space, const LViewType l_view, LGViewType &lg_view)
Copy owned data back after FFT.
Definition Cabana_Grid_FastFourierTransform.hpp:336
void reverse(const Array_t &x, const ScaleType scaling, typename std::enable_if<(is_array< Array_t >::value &&is_matching_array< typename Array_t::entity_type, typename Array_t::mesh_type, typename Array_t::memory_space, typename Array_t::value_type, entity_type, mesh_type, memory_space, value_type >::value), int >::type *=0)
Do a reverse FFT.
Definition Cabana_Grid_FastFourierTransform.hpp:273
void checkArrayDofs(const int dof)
Ensure the FFT compute array has the correct DoFs.
Definition Cabana_Grid_FastFourierTransform.hpp:236
std::array< int, num_space_dim > global_low
Global low box corner.
Definition Cabana_Grid_FastFourierTransform.hpp:203
std::array< int, num_space_dim > global_high
Global high box corner.
Definition Cabana_Grid_FastFourierTransform.hpp:201
std::enable_if_t< 2==NSD, void > copyToLocal(ExecutionSpace space, const IndexSpaceType own_space, LViewType &l_view, const LGViewType lg_view)
Copy owned data for FFT.
Definition Cabana_Grid_FastFourierTransform.hpp:316
Scalar value_type
Scalar value type.
Definition Cabana_Grid_FastFourierTransform.hpp:180
std::enable_if_t< 2==NSD, void > copyFromLocal(ExecutionSpace space, const IndexSpaceType own_space, const LViewType l_view, LGViewType &lg_view)
Copy owned data back after FFT.
Definition Cabana_Grid_FastFourierTransform.hpp:357
Interface to heFFTe fast Fourier transform library.
Definition Cabana_Grid_FastFourierTransform.hpp:511
execution_space heffte_execution_space
Stored execution space used by heFFTe.
Definition Cabana_Grid_FastFourierTransform.hpp:544
ExecSpace execution_space
Kokkos execution space.
Definition Cabana_Grid_FastFourierTransform.hpp:525
void forwardImpl(const Array_t &x, const ScaleType)
Do a forward FFT.
Definition Cabana_Grid_FastFourierTransform.hpp:621
typename MemorySpace::memory_space memory_space
Kokkos memory space.
Definition Cabana_Grid_FastFourierTransform.hpp:519
static constexpr std::size_t num_space_dim
Spatial dimension.
Definition Cabana_Grid_FastFourierTransform.hpp:536
HeffteFastFourierTransform(execution_space exec_space, const ArrayLayout< EntityType, MeshType > &layout, const FastFourierTransformParams &params)
Constructor.
Definition Cabana_Grid_FastFourierTransform.hpp:552
void reverseImpl(const Array_t &x, const ScaleType)
Do a reverse FFT.
Definition Cabana_Grid_FastFourierTransform.hpp:632
typename Impl::HeffteBackendTraits< execution_space, backend_type >::backend_type heffte_backend_type
heFFTe backend type.
Definition Cabana_Grid_FastFourierTransform.hpp:539
Scalar value_type
Scalar value type.
Definition Cabana_Grid_FastFourierTransform.hpp:514
BackendType backend_type
FFT backend type.
Definition Cabana_Grid_FastFourierTransform.hpp:531
void compute(const Array_t &x, const int flag, const heffte::scale scale)
Do the FFT.
Definition Cabana_Grid_FastFourierTransform.hpp:644
MeshType mesh_type
Mesh type.
Definition Cabana_Grid_FastFourierTransform.hpp:533
Core: particle data structures and algorithms.
Definition Cabana_AoSoA.hpp:36
Tag specifying FFTW backend for FFT (host default).
Definition Cabana_Grid_FastFourierTransform.hpp:54
Tag specifying MKL backend for FFT.
Definition Cabana_Grid_FastFourierTransform.hpp:58
Tag for full scaling of FFT.
Definition Cabana_Grid_FastFourierTransform.hpp:41
Tag for no scaling of FFT.
Definition Cabana_Grid_FastFourierTransform.hpp:45
Tag for symmetric scaling of FFT.
Definition Cabana_Grid_FastFourierTransform.hpp:49
Matching Array static type checker.
Definition Cabana_Grid_FastFourierTransform.hpp:75
Local index tag.
Definition Cabana_Grid_Types.hpp:208
Owned decomposition tag.
Definition Cabana_Grid_Types.hpp:190
Definition Cabana_Grid_Array.hpp:324