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
183 using memory_space = MemorySpace;
184 static_assert( Kokkos::is_memory_space<MemorySpace>() );
185
187 using execution_space = typename memory_space::execution_space;
188
190 static constexpr std::size_t num_space_dim = mesh_type::num_space_dim;
191
193 std::array<int, num_space_dim> global_high;
195 std::array<int, num_space_dim> global_low;
196
202 {
203 checkArrayDofs( layout.dofsPerEntity() );
204
205 // Get the local dimensions of the problem.
206 auto entity_space =
207 layout.localGrid()->indexSpace( Own(), EntityType(), Local() );
208 // Get the global grid.
209 const auto& global_grid = layout.localGrid()->globalGrid();
210
211 for ( std::size_t d = 0; d < num_space_dim; ++d )
212 {
213 // Get the low corner of the global index space on this rank.
214 global_low[d] =
215 (int)global_grid.globalOffset( num_space_dim - d - 1 );
216
217 // Get the high corner of the global index space on this rank.
218 int local_num_entity =
219 (int)entity_space.extent( num_space_dim - d - 1 );
220 global_high[d] = global_low[d] + local_num_entity - 1;
221 }
222 }
223
228 inline void checkArrayDofs( const int dof )
229 {
230 if ( 2 != dof )
231 throw std::logic_error(
232 "Cabana::Grid::Experimental::FastFourierTransform::"
233 "checkArrayDofs: Only 1 complex value per entity allowed in "
234 "FFT" );
235 }
236
242 template <class Array_t, class ScaleType>
244 const Array_t& x, const ScaleType scaling,
245 typename std::enable_if<
248 typename Array_t::entity_type, typename Array_t::mesh_type,
249 typename Array_t::memory_space, typename Array_t::value_type,
251 int>::type* = 0 )
252 {
253 Kokkos::Profiling::ScopedRegion region( "Cabana::FFT::forward" );
254
255 checkArrayDofs( x.layout()->dofsPerEntity() );
256 static_cast<Derived*>( this )->forwardImpl( x, scaling );
257 }
258
264 template <class Array_t, class ScaleType>
266 const Array_t& x, const ScaleType scaling,
267 typename std::enable_if<
270 typename Array_t::entity_type, typename Array_t::mesh_type,
271 typename Array_t::memory_space, typename Array_t::value_type,
273 int>::type* = 0 )
274 {
275 Kokkos::Profiling::ScopedRegion region( "Cabana::FFT::reverse" );
276
277 checkArrayDofs( x.layout()->dofsPerEntity() );
278 static_cast<Derived*>( this )->reverseImpl( x, scaling );
279 }
280
284 template <class ExecutionSpace, class IndexSpaceType, class LViewType,
285 class LGViewType, std::size_t NSD = num_space_dim>
286 std::enable_if_t<3 == NSD, void>
287 copyToLocal( ExecutionSpace exec_space, const IndexSpaceType own_space,
288 LViewType& l_view, const LGViewType lg_view )
289 {
290 Kokkos::parallel_for(
291 "Cabana::Grid::FastFourierTransform::copyTo",
292 createExecutionPolicy( own_space, exec_space ),
293 KOKKOS_LAMBDA( const int i, const int j, const int k ) {
294 auto iw = i - own_space.min( Dim::I );
295 auto jw = j - own_space.min( Dim::J );
296 auto kw = k - own_space.min( Dim::K );
297 l_view( iw, jw, kw, 0 ) = lg_view( i, j, k, 0 );
298 l_view( iw, jw, kw, 1 ) = lg_view( i, j, k, 1 );
299 } );
300 }
301
305 template <class ExecutionSpace, class IndexSpaceType, class LViewType,
306 class LGViewType, std::size_t NSD = num_space_dim>
307 std::enable_if_t<2 == NSD, void>
308 copyToLocal( ExecutionSpace space, const IndexSpaceType own_space,
309 LViewType& l_view, const LGViewType lg_view )
310 {
311 Kokkos::parallel_for(
312 "Cabana::Grid::FastFourierTransform::copyTo",
313 createExecutionPolicy( own_space, space ),
314 KOKKOS_LAMBDA( const int i, const int j ) {
315 auto iw = i - own_space.min( Dim::I );
316 auto jw = j - own_space.min( Dim::J );
317 l_view( iw, jw, 0 ) = lg_view( i, j, 0 );
318 l_view( iw, jw, 1 ) = lg_view( i, j, 1 );
319 } );
320 }
321
325 template <class ExecutionSpace, class IndexSpaceType, class LViewType,
326 class LGViewType, std::size_t NSD = num_space_dim>
327 std::enable_if_t<3 == NSD, void>
328 copyFromLocal( ExecutionSpace space, const IndexSpaceType own_space,
329 const LViewType l_view, LGViewType& lg_view )
330 {
331 Kokkos::parallel_for(
332 "Cabana::Grid::FastFourierTransform::copyFrom",
333 createExecutionPolicy( own_space, space ),
334 KOKKOS_LAMBDA( const int i, const int j, const int k ) {
335 auto iw = i - own_space.min( Dim::I );
336 auto jw = j - own_space.min( Dim::J );
337 auto kw = k - own_space.min( Dim::K );
338 lg_view( i, j, k, 0 ) = l_view( iw, jw, kw, 0 );
339 lg_view( i, j, k, 1 ) = l_view( iw, jw, kw, 1 );
340 } );
341 }
342
346 template <class ExecutionSpace, class IndexSpaceType, class LViewType,
347 class LGViewType, std::size_t NSD = num_space_dim>
348 std::enable_if_t<2 == NSD, void>
349 copyFromLocal( ExecutionSpace space, const IndexSpaceType own_space,
350 const LViewType l_view, LGViewType& lg_view )
351 {
352 Kokkos::parallel_for(
353 "Cabana::Grid::FastFourierTransform::copyFrom",
354 createExecutionPolicy( own_space, space ),
355 KOKKOS_LAMBDA( const int i, const int j ) {
356 auto iw = i - own_space.min( Dim::I );
357 auto jw = j - own_space.min( Dim::J );
358 lg_view( i, j, 0 ) = l_view( iw, jw, 0 );
359 lg_view( i, j, 1 ) = l_view( iw, jw, 1 );
360 } );
361 }
362};
363
364//---------------------------------------------------------------------------//
365// heFFTe
366//---------------------------------------------------------------------------//
367namespace Impl
368{
370template <class ExecutionSpace, class BackendType>
371struct HeffteBackendTraits
372{
373};
374#ifdef Heffte_ENABLE_MKL
375template <class ExecutionSpace>
376struct HeffteBackendTraits<ExecutionSpace, FFTBackendMKL>
377{
378 using backend_type = heffte::backend::mkl;
379};
380#endif
381#ifdef Heffte_ENABLE_FFTW
382template <class ExecutionSpace>
383struct HeffteBackendTraits<ExecutionSpace, FFTBackendFFTW>
384{
385 using backend_type = heffte::backend::fftw;
386};
387#endif
388#ifdef Heffte_ENABLE_FFTW
389template <class ExecutionSpace>
390struct HeffteBackendTraits<ExecutionSpace, Impl::FFTBackendDefault>
391{
392 using backend_type = heffte::backend::fftw;
393};
394#else
395#ifdef Heffte_ENABLE_MKL
396template <class ExecutionSpace>
397struct HeffteBackendTraits<ExecutionSpace, Impl::FFTBackendDefault>
398{
399 using backend_type = heffte::backend::mkl;
400};
401#else
402throw std::runtime_error( "Cabana::Grid::FastFourierTransform: Must enable at "
403 "least one heFFTe host backend." );
404#endif
405#endif
406#ifdef Heffte_ENABLE_CUDA
407#ifdef KOKKOS_ENABLE_CUDA
408template <>
409struct HeffteBackendTraits<Kokkos::Cuda, Impl::FFTBackendDefault>
410{
411 using backend_type = heffte::backend::cufft;
412};
413#endif
414#endif
415#ifdef Heffte_ENABLE_ROCM
416#ifdef KOKKOS_ENABLE_HIP
417template <>
418struct HeffteBackendTraits<Kokkos::Experimental::HIP, Impl::FFTBackendDefault>
419{
420 using backend_type = heffte::backend::rocfft;
421};
422#endif
423#endif
424#ifdef Heffte_ENABLE_ONEAPI
425#ifdef KOKKOS_ENABLE_SYCL
426template <>
427struct HeffteBackendTraits<Kokkos::Experimental::SYCL, Impl::FFTBackendDefault>
428{
429 using backend_type = heffte::backend::onemkl;
430};
431#endif
432#endif
433
434template <class ScaleType>
435struct HeffteScalingTraits
436{
437};
438template <>
439struct HeffteScalingTraits<FFTScaleNone>
440{
441 static const auto scaling_type = heffte::scale::none;
442};
443template <>
444struct HeffteScalingTraits<FFTScaleFull>
445{
446 static const auto scaling_type = heffte::scale::full;
447};
448template <>
449struct HeffteScalingTraits<FFTScaleSymmetric>
450{
451 static const auto scaling_type = heffte::scale::symmetric;
452};
453
454#ifdef KOKKOS_ENABLE_SYCL
455// Overload for SYCL.
456template <class ExecSpace, class HeffteBackendType>
457auto createHeffteFft3d(
458 ExecSpace exec_space, HeffteBackendType, heffte::box3d<> inbox,
459 heffte::box3d<> outbox, MPI_Comm comm, heffte::plan_options params,
460 typename std::enable_if<
461 std::is_same<HeffteBackendType, heffte::backend::onemkl>::value,
462 int>::type* = 0 )
463{
464 // Set FFT options from given parameters
465 // heFFTe correctly handles 2D or 3D FFTs within "fft3d"
466 sycl::queue& q = exec_space.sycl_queue();
467 return std::make_shared<heffte::fft3d<HeffteBackendType>>( q, inbox, outbox,
468 comm, params );
469}
470#endif
471
472template <class ExecSpace, class HeffteBackendType>
473auto createHeffteFft3d(
474 ExecSpace, HeffteBackendType, heffte::box3d<> inbox, heffte::box3d<> outbox,
475 MPI_Comm comm, heffte::plan_options params,
476 typename std::enable_if<
477 std::is_same<HeffteBackendType, heffte::backend::fftw>::value ||
478 std::is_same<HeffteBackendType, heffte::backend::mkl>::value ||
479 std::is_same<HeffteBackendType, heffte::backend::cufft>::value ||
480 std::is_same<HeffteBackendType, heffte::backend::rocfft>::value,
481 int>::type* = 0 )
482{
483 // Set FFT options from given parameters
484 // heFFTe correctly handles 2D or 3D FFTs within "fft3d"
485 return std::make_shared<heffte::fft3d<HeffteBackendType>>( inbox, outbox,
486 comm, params );
487}
488
490} // namespace Impl
491
492//---------------------------------------------------------------------------//
496template <class EntityType, class MeshType, class Scalar, class MemorySpace,
497 class ExecSpace, class BackendType>
499 : public FastFourierTransform<
500 EntityType, MeshType, Scalar, MemorySpace,
501 HeffteFastFourierTransform<EntityType, MeshType, Scalar, MemorySpace,
502 ExecSpace, BackendType>>
503{
504 public:
506 using value_type = Scalar;
507
509 using memory_space = MemorySpace;
510 static_assert( Kokkos::is_memory_space<MemorySpace>() );
511
513 using execution_space = ExecSpace;
515 using backend_type = BackendType;
517 using mesh_type = MeshType;
518
520 static constexpr std::size_t num_space_dim = mesh_type::num_space_dim;
521
524 typename Impl::HeffteBackendTraits<execution_space,
526
529
538 const FastFourierTransformParams& params )
540 EntityType, MeshType, Scalar, MemorySpace,
541 HeffteFastFourierTransform<EntityType, MeshType, Scalar,
542 MemorySpace, ExecSpace, BackendType>>(
543 layout )
544 , heffte_execution_space( exec_space )
545 {
546 // heFFTe correctly handles 2D or 3D domains within "box3d"
547 heffte::box3d<> inbox = { this->global_low, this->global_high };
548 heffte::box3d<> outbox = { this->global_low, this->global_high };
549
550 heffte::plan_options heffte_params =
551 heffte::default_options<heffte_backend_type>();
552 auto FFTcomm = params.getAlltoAll();
553 switch ( FFTcomm )
554 {
555 case Cabana::Grid::Experimental::FFTCommPattern::p2p:
556 heffte_params.algorithm = heffte::reshape_algorithm::p2p;
557 break;
558 case Cabana::Grid::Experimental::FFTCommPattern::alltoallv:
559 heffte_params.algorithm = heffte::reshape_algorithm::alltoallv;
560 break;
561 case Cabana::Grid::Experimental::FFTCommPattern::alltoall:
562 heffte_params.algorithm = heffte::reshape_algorithm::alltoall;
563 break;
564 case Cabana::Grid::Experimental::FFTCommPattern::p2p_plined:
565 heffte_params.algorithm = heffte::reshape_algorithm::p2p_plined;
566 break;
567 default:
568 heffte_params.algorithm = heffte::reshape_algorithm::alltoallv;
569 break;
570 }
571
572 heffte_params.use_pencils = params.getPencils();
573 heffte_params.use_reorder = params.getReorder();
574
575 // Create the heFFTe main class (separated to handle SYCL queue
576 // correctly).
577 _fft = Impl::createHeffteFft3d(
579 layout.localGrid()->globalGrid().comm(), heffte_params );
580 long long fftsize = std::max( _fft->size_outbox(), _fft->size_inbox() );
581
582 // Check the size.
583 auto entity_space =
584 layout.localGrid()->indexSpace( Own(), EntityType(), Local() );
585 if ( fftsize < (int)entity_space.size() )
586 throw std::logic_error(
587 "Cabana::Grid::Experimental::HeffteFastFourierTransform: "
588 "Expected FFT allocation size smaller "
589 "than local grid size" );
590
591 _fft_work = Kokkos::View<Scalar*, memory_space>(
592 Kokkos::ViewAllocateWithoutInitializing( "fft_work" ),
593 2 * fftsize );
594 _workspace = Kokkos::View<Scalar* [2], memory_space>(
595 Kokkos::ViewAllocateWithoutInitializing( "workspace" ),
596 _fft->size_workspace() );
597 }
598
604 template <class Array_t, class ScaleType>
605 void forwardImpl( const Array_t& x, const ScaleType )
606 {
607 compute( x, 1, Impl::HeffteScalingTraits<ScaleType>().scaling_type );
608 }
609
615 template <class Array_t, class ScaleType>
616 void reverseImpl( const Array_t& x, const ScaleType )
617 {
618 compute( x, -1, Impl::HeffteScalingTraits<ScaleType>().scaling_type );
619 }
620
627 template <class Array_t>
628 void compute( const Array_t& x, const int flag, const heffte::scale scale )
629 {
630 // Create a subview of the work array to write the local data into.
631 auto own_space =
632 x.layout()->localGrid()->indexSpace( Own(), EntityType(), Local() );
633 auto local_view_space = appendDimension( own_space, 2 );
635 local_view_space, _fft_work.data() );
636
637 // TODO: pull this out to template function
638 // Copy to the work array. The work array only contains owned data.
639 auto localghost_view = x.view();
640
641 this->copyToLocal( heffte_execution_space, own_space, local_view,
642 localghost_view );
643
644 if ( flag == 1 )
645 {
646 _fft->forward(
647 reinterpret_cast<std::complex<Scalar>*>( _fft_work.data() ),
648 reinterpret_cast<std::complex<Scalar>*>( _fft_work.data() ),
649 reinterpret_cast<std::complex<Scalar>*>( _workspace.data() ),
650 scale );
651 }
652 else if ( flag == -1 )
653 {
654 _fft->backward(
655 reinterpret_cast<std::complex<Scalar>*>( _fft_work.data() ),
656 reinterpret_cast<std::complex<Scalar>*>( _fft_work.data() ),
657 reinterpret_cast<std::complex<Scalar>*>( _workspace.data() ),
658 scale );
659 }
660 else
661 {
662 throw std::logic_error(
663 "Cabana::Grid::Experimental::HeffteFastFourierTransform::"
664 "compute: Only 1:forward and -1:backward are allowed as "
665 "compute flag" );
666 }
667
668 // Copy back to output array.
669 this->copyFromLocal( heffte_execution_space, own_space, local_view,
670 localghost_view );
671 }
672
673 private:
674 // heFFTe correctly handles 2D or 3D FFTs within "fft3d"
675 std::shared_ptr<heffte::fft3d<heffte_backend_type>> _fft;
676 Kokkos::View<Scalar*, memory_space> _fft_work;
677 Kokkos::View<Scalar* [2], memory_space> _workspace;
678};
679
680//---------------------------------------------------------------------------//
681// heFFTe creation
682//---------------------------------------------------------------------------//
687template <class Scalar, class MemorySpace, class BackendType, class EntityType,
688 class MeshType, class ExecSpace>
690 ExecSpace exec_space, const ArrayLayout<EntityType, MeshType>& layout,
691 const FastFourierTransformParams& params )
692{
693 return std::make_shared<HeffteFastFourierTransform<
694 EntityType, MeshType, Scalar, MemorySpace, ExecSpace, BackendType>>(
695 exec_space, layout, params );
696}
697
702template <class Scalar, class MemorySpace, class EntityType, class MeshType,
703 class ExecSpace>
705 ExecSpace exec_space, const ArrayLayout<EntityType, MeshType>& layout,
706 const FastFourierTransformParams& params )
707{
708 return createHeffteFastFourierTransform<Scalar, MemorySpace,
709 Impl::FFTBackendDefault>(
710 exec_space, layout, params );
711}
712
717template <class Scalar, class MemorySpace, class BackendType, class EntityType,
718 class MeshType, class ExecSpace>
720 ExecSpace exec_space, const ArrayLayout<EntityType, MeshType>& layout )
721{
722 using heffte_backend_type =
723 typename Impl::HeffteBackendTraits<ExecSpace,
724 BackendType>::backend_type;
725
726 // use default heFFTe params for this backend
727 const heffte::plan_options heffte_params =
728 heffte::default_options<heffte_backend_type>();
730 params.setAlltoAll( FFTCommPattern::alltoallv );
731 params.setPencils( heffte_params.use_pencils );
732 params.setReorder( heffte_params.use_reorder );
733
734 return std::make_shared<HeffteFastFourierTransform<
735 EntityType, MeshType, Scalar, MemorySpace, ExecSpace, BackendType>>(
736 exec_space, layout, params );
737}
738
743template <class Scalar, class MemorySpace, class EntityType, class MeshType,
744 class ExecSpace>
746 ExecSpace exec_space, const ArrayLayout<EntityType, MeshType>& layout )
747{
749 Scalar, MemorySpace, Impl::FFTBackendDefault, EntityType, MeshType>(
750 exec_space, layout );
751}
752
756template <class Scalar, class MemorySpace, class BackendType, class EntityType,
757 class MeshType>
760 const FastFourierTransformParams& params )
761{
762 using exec_space = typename MemorySpace::execution_space;
763 return createHeffteFastFourierTransform<Scalar, MemorySpace, BackendType,
764 EntityType, MeshType>(
765 exec_space{}, layout, params );
766}
767
771template <class Scalar, class MemorySpace, class EntityType, class MeshType>
774 const FastFourierTransformParams& params )
775{
776 using exec_space = typename MemorySpace::execution_space;
778 Scalar, MemorySpace, Impl::FFTBackendDefault, EntityType, MeshType>(
779 exec_space{}, layout, params );
780}
781
785template <class Scalar, class MemorySpace, class BackendType, class EntityType,
786 class MeshType>
789{
790 using exec_space = typename MemorySpace::execution_space;
791 return createHeffteFastFourierTransform<Scalar, MemorySpace, BackendType,
792 EntityType, MeshType>( exec_space{},
793 layout );
794}
795
799template <class Scalar, class MemorySpace, class EntityType, class MeshType>
802{
803 using exec_space = typename MemorySpace::execution_space;
805 Scalar, MemorySpace, Impl::FFTBackendDefault, EntityType, MeshType>(
806 exec_space{}, layout );
807}
808
809//---------------------------------------------------------------------------//
810
811} // end namespace Experimental
812} // namespace Grid
813} // namespace Cabana
814
815#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:689
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:237
Kokkos::RangePolicy< ExecutionSpace > createExecutionPolicy(const IndexSpace< 1 > &index_space, const ExecutionSpace &exec_space)
Create a multi-dimensional execution policy over an index space.
Definition Cabana_Grid_IndexSpace.hpp:175
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:444
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:187
FastFourierTransform(const ArrayLayout< EntityType, MeshType > &layout)
Constructor.
Definition Cabana_Grid_FastFourierTransform.hpp:201
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:287
MemorySpace memory_space
Kokkos memory space.
Definition Cabana_Grid_FastFourierTransform.hpp:183
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:190
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:243
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:328
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:265
void checkArrayDofs(const int dof)
Ensure the FFT compute array has the correct DoFs.
Definition Cabana_Grid_FastFourierTransform.hpp:228
std::array< int, num_space_dim > global_low
Global low box corner.
Definition Cabana_Grid_FastFourierTransform.hpp:195
std::array< int, num_space_dim > global_high
Global high box corner.
Definition Cabana_Grid_FastFourierTransform.hpp:193
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:308
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:349
Interface to heFFTe fast Fourier transform library.
Definition Cabana_Grid_FastFourierTransform.hpp:503
execution_space heffte_execution_space
Stored execution space used by heFFTe.
Definition Cabana_Grid_FastFourierTransform.hpp:528
ExecSpace execution_space
Kokkos execution space.
Definition Cabana_Grid_FastFourierTransform.hpp:513
void forwardImpl(const Array_t &x, const ScaleType)
Do a forward FFT.
Definition Cabana_Grid_FastFourierTransform.hpp:605
static constexpr std::size_t num_space_dim
Spatial dimension.
Definition Cabana_Grid_FastFourierTransform.hpp:520
HeffteFastFourierTransform(execution_space exec_space, const ArrayLayout< EntityType, MeshType > &layout, const FastFourierTransformParams &params)
Constructor.
Definition Cabana_Grid_FastFourierTransform.hpp:536
void reverseImpl(const Array_t &x, const ScaleType)
Do a reverse FFT.
Definition Cabana_Grid_FastFourierTransform.hpp:616
typename Impl::HeffteBackendTraits< execution_space, backend_type >::backend_type heffte_backend_type
heFFTe backend type.
Definition Cabana_Grid_FastFourierTransform.hpp:523
MemorySpace memory_space
Kokkos memory space.
Definition Cabana_Grid_FastFourierTransform.hpp:509
Scalar value_type
Scalar value type.
Definition Cabana_Grid_FastFourierTransform.hpp:506
BackendType backend_type
FFT backend type.
Definition Cabana_Grid_FastFourierTransform.hpp:515
void compute(const Array_t &x, const int flag, const heffte::scale scale)
Do the FFT.
Definition Cabana_Grid_FastFourierTransform.hpp:628
MeshType mesh_type
Mesh type.
Definition Cabana_Grid_FastFourierTransform.hpp:517
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