KokkosFFT::execute

template<typename PlanType, typename InViewType, typename OutViewType>
void KokkosFFT::execute(const PlanType &plan, const InViewType &in, const OutViewType &out, KokkosFFT::Normalization norm = KokkosFFT::Normalization::backward)

Execute FFT given by the Plan on input and output Views with normalization.

Template Parameters:
  • PlanType – KokkosFFT Plan type

  • InViewType – Input View type for the fft

  • OutViewType – Output View type for the fft

Parameters:
  • plan – [in] KokkosFFT Plan to be executed

  • in – [in] Input data

  • out – [out] Output data

  • norm – [in] How the normalization is applied (default, backward)

Examples

In this example, we use the 2D View with LayoutRight to avoid the internal transpose. This allows execute to perform 1D FFT on the outermost dimension without transpose.

 1#include <iostream>
 2#include <Kokkos_Core.hpp>
 3#include <Kokkos_Complex.hpp>
 4#include <KokkosFFT.hpp>
 5
 6/// \brief Example of Plan usage in documentation
 7/// This corresponds to 1D batched rfft on 2D Views
 8/// x = [[1, 2, 3, 4],
 9///      [5, 6, 7, 8],
10///      [9, 10, 11, 12]]
11/// x_hat = [[10.+0.j, -2.+2.j, -2.+0.j],
12///          [26.+0.j, -2.+2.j, -2.+0.j],
13///          [42.+0.j, -2.+2.j, -2.+0.j]]
14int main(int argc, char* argv[]) {
15  Kokkos::ScopeGuard guard(argc, argv);
16  using ExecutionSpace = Kokkos::DefaultExecutionSpace;
17  using View2D = Kokkos::View<double**, Kokkos::LayoutRight, ExecutionSpace>;
18  using ComplexView2D = Kokkos::View<Kokkos::complex<double>**,
19                                     Kokkos::LayoutRight, ExecutionSpace>;
20
21  const int n0 = 3, n1 = 4;
22
23  View2D x("x", n0, n1);
24  ComplexView2D x_hat("x_hat", n0, n1 / 2 + 1),
25      x_hat2("x_hat2", n0, n1 / 2 + 1);
26  auto h_x = Kokkos::create_mirror_view(x);
27  for (int i = 0; i < n0; ++i) {
28    for (int j = 0; j < n1; ++j) {
29      h_x(i, j) = i * n1 + j + 1;
30    }
31  }
32  Kokkos::deep_copy(x, h_x);
33
34  ExecutionSpace exec;
35
36  int axis = -1;
37  KokkosFFT::Plan plan(exec, x, x_hat, KokkosFFT::Direction::forward, axis);
38  KokkosFFT::execute(plan, x, x_hat2);
39
40  auto h_x_hat2 =
41      Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x_hat2);
42
43  for (int i = 0; i < h_x_hat2.extent_int(0); ++i) {
44    for (int j = 0; j < h_x_hat2.extent_int(1); ++j) {
45      std::cout << " " << h_x_hat2(i, j);
46    }
47    std::cout << std::endl;
48  }
49  std::cout << std::endl;
50
51  return 0;
52}

Expected output:

(10,0) (-2,2) (-2,0)
(26,0) (-2,2) (-2,0)
(42,0) (-2,2) (-2,0)