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 mush match FFT entity type." );
78 static_assert( std::is_same<ArrayMesh, Mesh>::value,
79 "Array mesh type mush 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 "Only 1 complex value per entity allowed in FFT" );
241 }
242
248 template <class Array_t, class ScaleType>
250 const Array_t& x, const ScaleType scaling,
251 typename std::enable_if<
254 typename Array_t::entity_type, typename Array_t::mesh_type,
255 typename Array_t::memory_space, typename Array_t::value_type,
257 int>::type* = 0 )
258 {
259 Kokkos::Profiling::ScopedRegion region( "Cabana::FFT::forward" );
260
261 checkArrayDofs( x.layout()->dofsPerEntity() );
262 static_cast<Derived*>( this )->forwardImpl( x, scaling );
263 }
264
270 template <class Array_t, class ScaleType>
272 const Array_t& x, const ScaleType scaling,
273 typename std::enable_if<
276 typename Array_t::entity_type, typename Array_t::mesh_type,
277 typename Array_t::memory_space, typename Array_t::value_type,
279 int>::type* = 0 )
280 {
281 Kokkos::Profiling::ScopedRegion region( "Cabana::FFT::reverse" );
282
283 checkArrayDofs( x.layout()->dofsPerEntity() );
284 static_cast<Derived*>( this )->reverseImpl( x, scaling );
285 }
286
290 template <class ExecutionSpace, class IndexSpaceType, class LViewType,
291 class LGViewType, std::size_t NSD = num_space_dim>
292 std::enable_if_t<3 == NSD, void>
293 copyToLocal( ExecutionSpace exec_space, const IndexSpaceType own_space,
294 LViewType& l_view, const LGViewType lg_view )
295 {
296 Kokkos::parallel_for(
297 "fft_copy_to_work", createExecutionPolicy( own_space, exec_space ),
298 KOKKOS_LAMBDA( const int i, const int j, const int k ) {
299 auto iw = i - own_space.min( Dim::I );
300 auto jw = j - own_space.min( Dim::J );
301 auto kw = k - own_space.min( Dim::K );
302 l_view( iw, jw, kw, 0 ) = lg_view( i, j, k, 0 );
303 l_view( iw, jw, kw, 1 ) = lg_view( i, j, k, 1 );
304 } );
305 }
306
310 template <class ExecutionSpace, class IndexSpaceType, class LViewType,
311 class LGViewType, std::size_t NSD = num_space_dim>
312 std::enable_if_t<2 == NSD, void>
313 copyToLocal( ExecutionSpace space, const IndexSpaceType own_space,
314 LViewType& l_view, const LGViewType lg_view )
315 {
316 Kokkos::parallel_for(
317 "fft_copy_to_work", createExecutionPolicy( own_space, space ),
318 KOKKOS_LAMBDA( const int i, const int j ) {
319 auto iw = i - own_space.min( Dim::I );
320 auto jw = j - own_space.min( Dim::J );
321 l_view( iw, jw, 0 ) = lg_view( i, j, 0 );
322 l_view( iw, jw, 1 ) = lg_view( i, j, 1 );
323 } );
324 }
325
329 template <class ExecutionSpace, class IndexSpaceType, class LViewType,
330 class LGViewType, std::size_t NSD = num_space_dim>
331 std::enable_if_t<3 == NSD, void>
332 copyFromLocal( ExecutionSpace space, const IndexSpaceType own_space,
333 const LViewType l_view, LGViewType& lg_view )
334 {
335 Kokkos::parallel_for(
336 "fft_copy_from_work", createExecutionPolicy( own_space, space ),
337 KOKKOS_LAMBDA( const int i, const int j, const int k ) {
338 auto iw = i - own_space.min( Dim::I );
339 auto jw = j - own_space.min( Dim::J );
340 auto kw = k - own_space.min( Dim::K );
341 lg_view( i, j, k, 0 ) = l_view( iw, jw, kw, 0 );
342 lg_view( i, j, k, 1 ) = l_view( iw, jw, kw, 1 );
343 } );
344 }
345
349 template <class ExecutionSpace, class IndexSpaceType, class LViewType,
350 class LGViewType, std::size_t NSD = num_space_dim>
351 std::enable_if_t<2 == NSD, void>
352 copyFromLocal( ExecutionSpace space, const IndexSpaceType own_space,
353 const LViewType l_view, LGViewType& lg_view )
354 {
355 Kokkos::parallel_for(
356 "fft_copy_from_work", createExecutionPolicy( own_space, space ),
357 KOKKOS_LAMBDA( const int i, const int j ) {
358 auto iw = i - own_space.min( Dim::I );
359 auto jw = j - own_space.min( Dim::J );
360 lg_view( i, j, 0 ) = l_view( iw, jw, 0 );
361 lg_view( i, j, 1 ) = l_view( iw, jw, 1 );
362 } );
363 }
364};
365
366//---------------------------------------------------------------------------//
367// heFFTe
368//---------------------------------------------------------------------------//
369namespace Impl
370{
372template <class ExecutionSpace, class BackendType>
373struct HeffteBackendTraits
374{
375};
376#ifdef Heffte_ENABLE_MKL
377template <class ExecutionSpace>
378struct HeffteBackendTraits<ExecutionSpace, FFTBackendMKL>
379{
380 using backend_type = heffte::backend::mkl;
381};
382#endif
383#ifdef Heffte_ENABLE_FFTW
384template <class ExecutionSpace>
385struct HeffteBackendTraits<ExecutionSpace, FFTBackendFFTW>
386{
387 using backend_type = heffte::backend::fftw;
388};
389#endif
390#ifdef Heffte_ENABLE_FFTW
391template <class ExecutionSpace>
392struct HeffteBackendTraits<ExecutionSpace, Impl::FFTBackendDefault>
393{
394 using backend_type = heffte::backend::fftw;
395};
396#else
397#ifdef Heffte_ENABLE_MKL
398template <class ExecutionSpace>
399struct HeffteBackendTraits<ExecutionSpace, Impl::FFTBackendDefault>
400{
401 using backend_type = heffte::backend::mkl;
402};
403#else
404throw std::runtime_error( "Must enable at least one heFFTe host backend." );
405#endif
406#endif
407#ifdef Heffte_ENABLE_CUDA
408#ifdef KOKKOS_ENABLE_CUDA
409template <>
410struct HeffteBackendTraits<Kokkos::Cuda, Impl::FFTBackendDefault>
411{
412 using backend_type = heffte::backend::cufft;
413};
414#endif
415#endif
416#ifdef Heffte_ENABLE_ROCM
417#ifdef KOKKOS_ENABLE_HIP
418template <>
419struct HeffteBackendTraits<Kokkos::Experimental::HIP, Impl::FFTBackendDefault>
420{
421 using backend_type = heffte::backend::rocfft;
422};
423#endif
424#endif
425#ifdef Heffte_ENABLE_ONEAPI
426#ifdef KOKKOS_ENABLE_SYCL
427template <>
428struct HeffteBackendTraits<Kokkos::Experimental::SYCL, Impl::FFTBackendDefault>
429{
430 using backend_type = heffte::backend::onemkl;
431};
432#endif
433#endif
434
435template <class ScaleType>
436struct HeffteScalingTraits
437{
438};
439template <>
440struct HeffteScalingTraits<FFTScaleNone>
441{
442 static const auto scaling_type = heffte::scale::none;
443};
444template <>
445struct HeffteScalingTraits<FFTScaleFull>
446{
447 static const auto scaling_type = heffte::scale::full;
448};
449template <>
450struct HeffteScalingTraits<FFTScaleSymmetric>
451{
452 static const auto scaling_type = heffte::scale::symmetric;
453};
454
455#ifdef KOKKOS_ENABLE_SYCL
456// Overload for SYCL.
457template <class ExecSpace, class HeffteBackendType>
458auto createHeffteFft3d(
459 ExecSpace exec_space, HeffteBackendType, heffte::box3d<> inbox,
460 heffte::box3d<> outbox, MPI_Comm comm, heffte::plan_options params,
461 typename std::enable_if<
462 std::is_same<HeffteBackendType, heffte::backend::onemkl>::value,
463 int>::type* = 0 )
464{
465 // Set FFT options from given parameters
466 // heFFTe correctly handles 2D or 3D FFTs within "fft3d"
467 sycl::queue& q = exec_space.sycl_queue();
468 return std::make_shared<heffte::fft3d<HeffteBackendType>>( q, inbox, outbox,
469 comm, params );
470}
471#endif
472
473template <class ExecSpace, class HeffteBackendType>
474auto createHeffteFft3d(
475 ExecSpace, HeffteBackendType, heffte::box3d<> inbox, heffte::box3d<> outbox,
476 MPI_Comm comm, heffte::plan_options params,
477 typename std::enable_if<
478 std::is_same<HeffteBackendType, heffte::backend::fftw>::value ||
479 std::is_same<HeffteBackendType, heffte::backend::mkl>::value ||
480 std::is_same<HeffteBackendType, heffte::backend::cufft>::value ||
481 std::is_same<HeffteBackendType, heffte::backend::rocfft>::value,
482 int>::type* = 0 )
483{
484 // Set FFT options from given parameters
485 // heFFTe correctly handles 2D or 3D FFTs within "fft3d"
486 return std::make_shared<heffte::fft3d<HeffteBackendType>>( inbox, outbox,
487 comm, params );
488}
489
491} // namespace Impl
492
493//---------------------------------------------------------------------------//
497template <class EntityType, class MeshType, class Scalar, class MemorySpace,
498 class ExecSpace, class BackendType>
500 : public FastFourierTransform<
501 EntityType, MeshType, Scalar, MemorySpace,
502 HeffteFastFourierTransform<EntityType, MeshType, Scalar, MemorySpace,
503 ExecSpace, BackendType>>
504{
505 public:
507 using value_type = Scalar;
508
509 // FIXME: extracting the self type for backwards compatibility with previous
510 // template on DeviceType. Should simply be MemorySpace after next release.
512 using memory_space = typename MemorySpace::memory_space;
513 // FIXME: replace warning with memory space assert after next release.
514 static_assert(
515 Cabana::Impl::deprecated( Kokkos::is_device<MemorySpace>() ) );
516
518 using execution_space = ExecSpace;
520 using exec_space [[deprecated]] = execution_space;
522 using device_type [[deprecated]] = typename memory_space::device_type;
524 using backend_type = BackendType;
526 using mesh_type = MeshType;
527
529 static constexpr std::size_t num_space_dim = mesh_type::num_space_dim;
530
533 typename Impl::HeffteBackendTraits<execution_space,
535
538
547 const FastFourierTransformParams& params )
549 EntityType, MeshType, Scalar, MemorySpace,
550 HeffteFastFourierTransform<EntityType, MeshType, Scalar,
551 MemorySpace, ExecSpace, BackendType>>(
552 layout )
553 , heffte_execution_space( exec_space )
554 {
555 // heFFTe correctly handles 2D or 3D domains within "box3d"
556 heffte::box3d<> inbox = { this->global_low, this->global_high };
557 heffte::box3d<> outbox = { this->global_low, this->global_high };
558
559 heffte::plan_options heffte_params =
560 heffte::default_options<heffte_backend_type>();
561 auto FFTcomm = params.getAlltoAll();
562 switch ( FFTcomm )
563 {
564 case Cabana::Grid::Experimental::FFTCommPattern::p2p:
565 heffte_params.algorithm = heffte::reshape_algorithm::p2p;
566 break;
567 case Cabana::Grid::Experimental::FFTCommPattern::alltoallv:
568 heffte_params.algorithm = heffte::reshape_algorithm::alltoallv;
569 break;
570 case Cabana::Grid::Experimental::FFTCommPattern::alltoall:
571 heffte_params.algorithm = heffte::reshape_algorithm::alltoall;
572 break;
573 case Cabana::Grid::Experimental::FFTCommPattern::p2p_plined:
574 heffte_params.algorithm = heffte::reshape_algorithm::p2p_plined;
575 break;
576 default:
577 heffte_params.algorithm = heffte::reshape_algorithm::alltoallv;
578 break;
579 }
580
581 heffte_params.use_pencils = params.getPencils();
582 heffte_params.use_reorder = params.getReorder();
583
584 // Create the heFFTe main class (separated to handle SYCL queue
585 // correctly).
586 _fft = Impl::createHeffteFft3d(
588 layout.localGrid()->globalGrid().comm(), heffte_params );
589 long long fftsize = std::max( _fft->size_outbox(), _fft->size_inbox() );
590
591 // Check the size.
592 auto entity_space =
593 layout.localGrid()->indexSpace( Own(), EntityType(), Local() );
594 if ( fftsize < (int)entity_space.size() )
595 throw std::logic_error( "Expected FFT allocation size smaller "
596 "than local grid size" );
597
598 _fft_work = Kokkos::View<Scalar*, memory_space>(
599 Kokkos::ViewAllocateWithoutInitializing( "fft_work" ),
600 2 * fftsize );
601 _workspace = Kokkos::View<Scalar* [2], memory_space>(
602 Kokkos::ViewAllocateWithoutInitializing( "workspace" ),
603 _fft->size_workspace() );
604 }
605
611 template <class Array_t, class ScaleType>
612 void forwardImpl( const Array_t& x, const ScaleType )
613 {
614 compute( x, 1, Impl::HeffteScalingTraits<ScaleType>().scaling_type );
615 }
616
622 template <class Array_t, class ScaleType>
623 void reverseImpl( const Array_t& x, const ScaleType )
624 {
625 compute( x, -1, Impl::HeffteScalingTraits<ScaleType>().scaling_type );
626 }
627
634 template <class Array_t>
635 void compute( const Array_t& x, const int flag, const heffte::scale scale )
636 {
637 // Create a subview of the work array to write the local data into.
638 auto own_space =
639 x.layout()->localGrid()->indexSpace( Own(), EntityType(), Local() );
640 auto local_view_space = appendDimension( own_space, 2 );
642 local_view_space, _fft_work.data() );
643
644 // TODO: pull this out to template function
645 // Copy to the work array. The work array only contains owned data.
646 auto localghost_view = x.view();
647
648 this->copyToLocal( heffte_execution_space, own_space, local_view,
649 localghost_view );
650
651 if ( flag == 1 )
652 {
653 _fft->forward(
654 reinterpret_cast<std::complex<Scalar>*>( _fft_work.data() ),
655 reinterpret_cast<std::complex<Scalar>*>( _fft_work.data() ),
656 reinterpret_cast<std::complex<Scalar>*>( _workspace.data() ),
657 scale );
658 }
659 else if ( flag == -1 )
660 {
661 _fft->backward(
662 reinterpret_cast<std::complex<Scalar>*>( _fft_work.data() ),
663 reinterpret_cast<std::complex<Scalar>*>( _fft_work.data() ),
664 reinterpret_cast<std::complex<Scalar>*>( _workspace.data() ),
665 scale );
666 }
667 else
668 {
669 throw std::logic_error(
670 "Only 1:forward and -1:backward are allowed as compute flag" );
671 }
672
673 // Copy back to output array.
674 this->copyFromLocal( heffte_execution_space, own_space, local_view,
675 localghost_view );
676 }
677
678 private:
679 // heFFTe correctly handles 2D or 3D FFTs within "fft3d"
680 std::shared_ptr<heffte::fft3d<heffte_backend_type>> _fft;
681 Kokkos::View<Scalar*, memory_space> _fft_work;
682 Kokkos::View<Scalar* [2], memory_space> _workspace;
683};
684
685//---------------------------------------------------------------------------//
686// heFFTe creation
687//---------------------------------------------------------------------------//
692template <class Scalar, class MemorySpace, class BackendType, class EntityType,
693 class MeshType, class ExecSpace>
695 ExecSpace exec_space, const ArrayLayout<EntityType, MeshType>& layout,
696 const FastFourierTransformParams& params )
697{
698 return std::make_shared<HeffteFastFourierTransform<
699 EntityType, MeshType, Scalar, MemorySpace, ExecSpace, BackendType>>(
700 exec_space, layout, params );
701}
702
707template <class Scalar, class MemorySpace, class EntityType, class MeshType,
708 class ExecSpace>
710 ExecSpace exec_space, const ArrayLayout<EntityType, MeshType>& layout,
711 const FastFourierTransformParams& params )
712{
713 return createHeffteFastFourierTransform<Scalar, MemorySpace,
714 Impl::FFTBackendDefault>(
715 exec_space, layout, params );
716}
717
722template <class Scalar, class MemorySpace, class BackendType, class EntityType,
723 class MeshType, class ExecSpace>
725 ExecSpace exec_space, const ArrayLayout<EntityType, MeshType>& layout )
726{
727 using heffte_backend_type =
728 typename Impl::HeffteBackendTraits<ExecSpace,
729 BackendType>::backend_type;
730
731 // use default heFFTe params for this backend
732 const heffte::plan_options heffte_params =
733 heffte::default_options<heffte_backend_type>();
735 params.setAlltoAll( FFTCommPattern::alltoallv );
736 params.setPencils( heffte_params.use_pencils );
737 params.setReorder( heffte_params.use_reorder );
738
739 return std::make_shared<HeffteFastFourierTransform<
740 EntityType, MeshType, Scalar, MemorySpace, ExecSpace, BackendType>>(
741 exec_space, layout, params );
742}
743
748template <class Scalar, class MemorySpace, class EntityType, class MeshType,
749 class ExecSpace>
751 ExecSpace exec_space, const ArrayLayout<EntityType, MeshType>& layout )
752{
754 Scalar, MemorySpace, Impl::FFTBackendDefault, EntityType, MeshType>(
755 exec_space, layout );
756}
757
761template <class Scalar, class MemorySpace, class BackendType, class EntityType,
762 class MeshType>
765 const FastFourierTransformParams& params )
766{
767 using exec_space = typename MemorySpace::execution_space;
768 return createHeffteFastFourierTransform<Scalar, MemorySpace, BackendType,
769 EntityType, MeshType>(
770 exec_space{}, layout, params );
771}
772
776template <class Scalar, class MemorySpace, class EntityType, class MeshType>
779 const FastFourierTransformParams& params )
780{
781 using exec_space = typename MemorySpace::execution_space;
783 Scalar, MemorySpace, Impl::FFTBackendDefault, EntityType, MeshType>(
784 exec_space{}, layout, params );
785}
786
790template <class Scalar, class MemorySpace, class BackendType, class EntityType,
791 class MeshType>
794{
795 using exec_space = typename MemorySpace::execution_space;
796 return createHeffteFastFourierTransform<Scalar, MemorySpace, BackendType,
797 EntityType, MeshType>( exec_space{},
798 layout );
799}
800
804template <class Scalar, class MemorySpace, class EntityType, class MeshType>
807{
808 using exec_space = typename MemorySpace::execution_space;
810 Scalar, MemorySpace, Impl::FFTBackendDefault, EntityType, MeshType>(
811 exec_space{}, layout );
812}
813
814//---------------------------------------------------------------------------//
815
816} // end namespace Experimental
817} // namespace Grid
818} // namespace Cabana
819
820#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:694
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:293
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:249
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:332
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:271
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:313
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:352
Interface to heFFTe fast Fourier transform library.
Definition Cabana_Grid_FastFourierTransform.hpp:504
execution_space heffte_execution_space
Stored execution space used by heFFTe.
Definition Cabana_Grid_FastFourierTransform.hpp:537
ExecSpace execution_space
Kokkos execution space.
Definition Cabana_Grid_FastFourierTransform.hpp:518
void forwardImpl(const Array_t &x, const ScaleType)
Do a forward FFT.
Definition Cabana_Grid_FastFourierTransform.hpp:612
typename MemorySpace::memory_space memory_space
Kokkos memory space.
Definition Cabana_Grid_FastFourierTransform.hpp:512
static constexpr std::size_t num_space_dim
Spatial dimension.
Definition Cabana_Grid_FastFourierTransform.hpp:529
HeffteFastFourierTransform(execution_space exec_space, const ArrayLayout< EntityType, MeshType > &layout, const FastFourierTransformParams &params)
Constructor.
Definition Cabana_Grid_FastFourierTransform.hpp:545
void reverseImpl(const Array_t &x, const ScaleType)
Do a reverse FFT.
Definition Cabana_Grid_FastFourierTransform.hpp:623
typename Impl::HeffteBackendTraits< execution_space, backend_type >::backend_type heffte_backend_type
heFFTe backend type.
Definition Cabana_Grid_FastFourierTransform.hpp:532
Scalar value_type
Scalar value type.
Definition Cabana_Grid_FastFourierTransform.hpp:507
BackendType backend_type
FFT backend type.
Definition Cabana_Grid_FastFourierTransform.hpp:524
void compute(const Array_t &x, const int flag, const heffte::scale scale)
Do the FFT.
Definition Cabana_Grid_FastFourierTransform.hpp:635
MeshType mesh_type
Mesh type.
Definition Cabana_Grid_FastFourierTransform.hpp:526
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:322