From fc8b3a776ec8a864f5003d3fa0413429240b11d9 Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Mon, 11 Dec 2023 22:16:36 +0900 Subject: [PATCH 1/9] Avoid calling normalization function if unnecessary --- common/src/KokkosFFT_normalization.hpp | 28 +++++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/common/src/KokkosFFT_normalization.hpp b/common/src/KokkosFFT_normalization.hpp index 44de5e8c..1ba9920f 100644 --- a/common/src/KokkosFFT_normalization.hpp +++ b/common/src/KokkosFFT_normalization.hpp @@ -1,6 +1,7 @@ #ifndef __KOKKOSFFT_NORMALIZATION_HPP__ #define __KOKKOSFFT_NORMALIZATION_HPP__ +#include #include "KokkosFFT_default_types.hpp" #include "KokkosFFT_utils.hpp" @@ -24,31 +25,38 @@ namespace KokkosFFT { template auto _coefficients(const ViewType& inout, FFTDirectionType direction, FFT_Normalization normalization, std::size_t fft_size) { - using value_type = real_type_t; + using value_type = real_type_t; value_type coef = 1; + bool to_normalize = false; switch (normalization) { case FFT_Normalization::FORWARD: - coef = direction == KOKKOS_FFT_FORWARD - ? static_cast(1) / static_cast(fft_size) - : 1; + if(direction == KOKKOS_FFT_FORWARD) { + coef = static_cast(1) / static_cast(fft_size); + to_normalize = true; + } + break; case FFT_Normalization::BACKWARD: - coef = direction == KOKKOS_FFT_BACKWARD - ? static_cast(1) / static_cast(fft_size) - : 1; + if(direction == KOKKOS_FFT_BACKWARD) { + coef = static_cast(1) / static_cast(fft_size); + to_normalize = true; + } + break; case FFT_Normalization::ORTHO: coef = static_cast(1) / Kokkos::sqrt(static_cast(fft_size)); + to_normalize = true; + break; }; - return coef; + return std::tuple ({coef, to_normalize}); } template void normalize(ViewType& inout, FFTDirectionType direction, FFT_Normalization normalization, std::size_t fft_size) { - auto coef = _coefficients(inout, direction, normalization, fft_size); - _normalize(inout, coef); + auto [coef, to_normalize] = _coefficients(inout, direction, normalization, fft_size); + if(to_normalize) _normalize(inout, coef); } }; From e05adf5e0039438287bbea90fc6a65821b2a5bcd Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Mon, 11 Dec 2023 22:22:39 +0900 Subject: [PATCH 2/9] Use templates to reduce lines from Tests in common/unit_test --- common/unit_test/Test_Layouts.cpp | 1134 ++++++++++----------------- common/unit_test/Test_Transpose.cpp | 868 ++++++++++---------- common/unit_test/Test_Utils.cpp | 121 +-- 3 files changed, 911 insertions(+), 1212 deletions(-) diff --git a/common/unit_test/Test_Layouts.cpp b/common/unit_test/Test_Layouts.cpp index 10d32458..6ba1256b 100644 --- a/common/unit_test/Test_Layouts.cpp +++ b/common/unit_test/Test_Layouts.cpp @@ -5,742 +5,444 @@ #include "Test_Types.hpp" #include "Test_Utils.hpp" -TEST(Layouts, 1D) { - const int n0 = 6; - View1D xr("xr", n0); - View1D> xc("xc", n0/2+1); - View1D> xcin("xcin", n0), xcout("xcout", n0); - - // R2C - std::vector ref_in_extents_r2c(1), ref_out_extents_r2c(1), ref_fft_extents_r2c(1); - ref_in_extents_r2c.at(0) = n0; - ref_out_extents_r2c.at(0) = n0/2+1; - ref_fft_extents_r2c.at(0) = n0; - - auto [in_extents_r2c, out_extents_r2c, fft_extents_r2c] = KokkosFFT::get_extents(xr, xc, 0); - EXPECT_TRUE( in_extents_r2c == ref_in_extents_r2c ); - EXPECT_TRUE( out_extents_r2c == ref_out_extents_r2c ); - EXPECT_TRUE( fft_extents_r2c == ref_fft_extents_r2c ); - - // C2R - std::vector ref_in_extents_c2r(1), ref_out_extents_c2r(1), ref_fft_extents_c2r(1); - ref_in_extents_c2r.at(0) = n0/2+1; - ref_out_extents_c2r.at(0) = n0; - ref_fft_extents_c2r.at(0) = n0; - - auto [in_extents_c2r, out_extents_c2r, fft_extents_c2r] = KokkosFFT::get_extents(xc, xr, 0); - EXPECT_TRUE( in_extents_c2r == ref_in_extents_c2r ); - EXPECT_TRUE( out_extents_c2r == ref_out_extents_c2r ); - EXPECT_TRUE( fft_extents_c2r == ref_fft_extents_c2r ); - - // C2C - std::vector ref_in_extents_c2c(1), ref_out_extents_c2c(1), ref_fft_extents_c2c(1); - ref_in_extents_c2c.at(0) = n0; - ref_out_extents_c2c.at(0) = n0; - ref_fft_extents_c2c.at(0) = n0; - auto [in_extents_c2c, out_extents_c2c, fft_extents_c2c] = KokkosFFT::get_extents(xcin, xcout, 0); - EXPECT_TRUE( in_extents_c2c == ref_in_extents_c2c ); - EXPECT_TRUE( out_extents_c2c == ref_out_extents_c2c ); - EXPECT_TRUE( fft_extents_c2c == ref_fft_extents_c2c ); +template +void test_layouts_1d() { + const int n0 = 6; + using RealView1Dtype = Kokkos::View; + using ComplexView1Dtype = Kokkos::View*, LayoutType, execution_space>; + + RealView1Dtype xr("xr", n0); + ComplexView1Dtype xc("xc", n0/2+1); + ComplexView1Dtype xcin("xcin", n0), xcout("xcout", n0); + + // R2C + std::vector ref_in_extents_r2c(1), ref_out_extents_r2c(1), ref_fft_extents_r2c(1); + ref_in_extents_r2c.at(0) = n0; + ref_out_extents_r2c.at(0) = n0/2+1; + ref_fft_extents_r2c.at(0) = n0; + + auto [in_extents_r2c, out_extents_r2c, fft_extents_r2c] = KokkosFFT::get_extents(xr, xc, 0); + EXPECT_TRUE( in_extents_r2c == ref_in_extents_r2c ); + EXPECT_TRUE( out_extents_r2c == ref_out_extents_r2c ); + EXPECT_TRUE( fft_extents_r2c == ref_fft_extents_r2c ); + + // C2R + std::vector ref_in_extents_c2r(1), ref_out_extents_c2r(1), ref_fft_extents_c2r(1); + ref_in_extents_c2r.at(0) = n0/2+1; + ref_out_extents_c2r.at(0) = n0; + ref_fft_extents_c2r.at(0) = n0; + + auto [in_extents_c2r, out_extents_c2r, fft_extents_c2r] = KokkosFFT::get_extents(xc, xr, 0); + EXPECT_TRUE( in_extents_c2r == ref_in_extents_c2r ); + EXPECT_TRUE( out_extents_c2r == ref_out_extents_c2r ); + EXPECT_TRUE( fft_extents_c2r == ref_fft_extents_c2r ); + + // C2C + std::vector ref_in_extents_c2c(1), ref_out_extents_c2c(1), ref_fft_extents_c2c(1); + ref_in_extents_c2c.at(0) = n0; + ref_out_extents_c2c.at(0) = n0; + ref_fft_extents_c2c.at(0) = n0; + + auto [in_extents_c2c, out_extents_c2c, fft_extents_c2c] = KokkosFFT::get_extents(xcin, xcout, 0); + EXPECT_TRUE( in_extents_c2c == ref_in_extents_c2c ); + EXPECT_TRUE( out_extents_c2c == ref_out_extents_c2c ); + EXPECT_TRUE( fft_extents_c2c == ref_fft_extents_c2c ); } -TEST(Layouts, 2DLeft) { - const int n0 = 6, n1 = 10; - - LeftView2D xr2("l_xr2", n0, n1); - LeftView2D> xc2_axis0("xc2_axis0", n0/2+1, n1); - LeftView2D> xc2_axis1("xc2_axis1", n0, n1/2+1); - LeftView2D> xcin2("xcin2", n0, n1), xcout2("xcout2", n0, n1); - - // R2C - std::size_t rank = 2; - std::vector ref_in_extents_r2c_axis0{n0, n1}; - std::vector ref_in_extents_r2c_axis1{n1, n0}; - std::vector ref_fft_extents_r2c_axis0{n0, n1}; - std::vector ref_fft_extents_r2c_axis1{n1, n0}; - std::vector ref_out_extents_r2c_axis0{n0/2+1, n1}; - std::vector ref_out_extents_r2c_axis1{n1/2+1, n0}; - - std::reverse( ref_in_extents_r2c_axis0.begin(), ref_in_extents_r2c_axis0.end() ); - std::reverse( ref_in_extents_r2c_axis1.begin(), ref_in_extents_r2c_axis1.end() ); - std::reverse( ref_fft_extents_r2c_axis0.begin(), ref_fft_extents_r2c_axis0.end() ); - std::reverse( ref_fft_extents_r2c_axis1.begin(), ref_fft_extents_r2c_axis1.end() ); - std::reverse( ref_out_extents_r2c_axis0.begin(), ref_out_extents_r2c_axis0.end() ); - std::reverse( ref_out_extents_r2c_axis1.begin(), ref_out_extents_r2c_axis1.end() ); - - auto [in_extents_r2c_axis0, out_extents_r2c_axis0, fft_extents_r2c_axis0] = KokkosFFT::get_extents(xr2, xc2_axis0, 0); - auto [in_extents_r2c_axis1, out_extents_r2c_axis1, fft_extents_r2c_axis1] = KokkosFFT::get_extents(xr2, xc2_axis1, 1); - EXPECT_TRUE( in_extents_r2c_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_TRUE( in_extents_r2c_axis1 == ref_in_extents_r2c_axis1 ); - - EXPECT_TRUE( fft_extents_r2c_axis0 == ref_fft_extents_r2c_axis0 ); - EXPECT_TRUE( fft_extents_r2c_axis1 == ref_fft_extents_r2c_axis1 ); - - EXPECT_TRUE( out_extents_r2c_axis0 == ref_out_extents_r2c_axis0 ); - EXPECT_TRUE( out_extents_r2c_axis1 == ref_out_extents_r2c_axis1 ); - - // C2R - auto [in_extents_c2r_axis0, out_extents_c2r_axis0, fft_extents_c2r_axis0] = KokkosFFT::get_extents(xc2_axis0, xr2, 0); - auto [in_extents_c2r_axis1, out_extents_c2r_axis1, fft_extents_c2r_axis1] = KokkosFFT::get_extents(xc2_axis1, xr2, 1); - EXPECT_TRUE( in_extents_c2r_axis0 == ref_out_extents_r2c_axis0 ); - EXPECT_TRUE( in_extents_c2r_axis1 == ref_out_extents_r2c_axis1 ); - - EXPECT_TRUE( fft_extents_c2r_axis0 == ref_fft_extents_r2c_axis0 ); - EXPECT_TRUE( fft_extents_c2r_axis1 == ref_fft_extents_r2c_axis1 ); - - EXPECT_TRUE( out_extents_c2r_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_TRUE( out_extents_c2r_axis1 == ref_in_extents_r2c_axis1 ); - - // C2C - auto [in_extents_c2c_axis0, out_extents_c2c_axis0, fft_extents_c2c_axis0] = KokkosFFT::get_extents(xcin2, xcout2, 0); - auto [in_extents_c2c_axis1, out_extents_c2c_axis1, fft_extents_c2c_axis1] = KokkosFFT::get_extents(xcin2, xcout2, 1); - EXPECT_TRUE( in_extents_c2c_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_TRUE( in_extents_c2c_axis1 == ref_in_extents_r2c_axis1 ); - - EXPECT_TRUE( fft_extents_c2c_axis0 == ref_fft_extents_r2c_axis0 ); - EXPECT_TRUE( fft_extents_c2c_axis1 == ref_fft_extents_r2c_axis1 ); - - EXPECT_TRUE( out_extents_c2c_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_TRUE( out_extents_c2c_axis1 == ref_in_extents_r2c_axis1 ); +TEST(Layouts, 1DLeftView) { + test_layouts_1d(); } -TEST(Layouts, 2DRight) { - const int n0 = 6, n1 = 10; - - RightView2D xr2("r_xr2", n0, n1); - RightView2D> xc2_axis0("xc2_axis0", n0/2+1, n1); - RightView2D> xc2_axis1("xc2_axis1", n0, n1/2+1); - RightView2D> xcin2("xcin2", n0, n1), xcout2("xcout2", n0, n1); - - // R2C - std::size_t rank = 2; - std::vector ref_in_extents_r2c_axis0{n1, n0}; - std::vector ref_in_extents_r2c_axis1{n0, n1}; - std::vector ref_fft_extents_r2c_axis0{n1, n0}; - std::vector ref_fft_extents_r2c_axis1{n0, n1}; - std::vector ref_out_extents_r2c_axis0{n1, n0/2+1}; - std::vector ref_out_extents_r2c_axis1{n0, n1/2+1}; - - auto [in_extents_r2c_axis0, out_extents_r2c_axis0, fft_extents_r2c_axis0] = KokkosFFT::get_extents(xr2, xc2_axis0, 0); - auto [in_extents_r2c_axis1, out_extents_r2c_axis1, fft_extents_r2c_axis1] = KokkosFFT::get_extents(xr2, xc2_axis1, 1); - EXPECT_TRUE( in_extents_r2c_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_TRUE( in_extents_r2c_axis1 == ref_in_extents_r2c_axis1 ); - - EXPECT_TRUE( fft_extents_r2c_axis0 == ref_fft_extents_r2c_axis0 ); - EXPECT_TRUE( fft_extents_r2c_axis1 == ref_fft_extents_r2c_axis1 ); - - EXPECT_TRUE( out_extents_r2c_axis0 == ref_out_extents_r2c_axis0 ); - EXPECT_TRUE( out_extents_r2c_axis1 == ref_out_extents_r2c_axis1 ); - - // C2R - auto [in_extents_c2r_axis0, out_extents_c2r_axis0, fft_extents_c2r_axis0] = KokkosFFT::get_extents(xc2_axis0, xr2, 0); - auto [in_extents_c2r_axis1, out_extents_c2r_axis1, fft_extents_c2r_axis1] = KokkosFFT::get_extents(xc2_axis1, xr2, 1); - EXPECT_TRUE( in_extents_c2r_axis0 == ref_out_extents_r2c_axis0 ); - EXPECT_TRUE( in_extents_c2r_axis1 == ref_out_extents_r2c_axis1 ); - - EXPECT_TRUE( fft_extents_c2r_axis0 == ref_fft_extents_r2c_axis0 ); - EXPECT_TRUE( fft_extents_c2r_axis1 == ref_fft_extents_r2c_axis1 ); - - EXPECT_TRUE( out_extents_c2r_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_TRUE( out_extents_c2r_axis1 == ref_in_extents_r2c_axis1 ); - - // C2C - auto [in_extents_c2c_axis0, out_extents_c2c_axis0, fft_extents_c2c_axis0] = KokkosFFT::get_extents(xcin2, xcout2, 0); - auto [in_extents_c2c_axis1, out_extents_c2c_axis1, fft_extents_c2c_axis1] = KokkosFFT::get_extents(xcin2, xcout2, 1); - EXPECT_TRUE( in_extents_c2c_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_TRUE( in_extents_c2c_axis1 == ref_in_extents_r2c_axis1 ); - - EXPECT_TRUE( fft_extents_c2c_axis0 == ref_fft_extents_r2c_axis0 ); - EXPECT_TRUE( fft_extents_c2c_axis1 == ref_fft_extents_r2c_axis1 ); - - EXPECT_TRUE( out_extents_c2c_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_TRUE( out_extents_c2c_axis1 == ref_in_extents_r2c_axis1 ); +TEST(Layouts, 1DRightView) { + test_layouts_1d(); +} + +template +void test_layouts_2d() { + const int n0 = 6, n1 = 10; + using RealView2Dtype = Kokkos::View; + using ComplexView2Dtype = Kokkos::View**, LayoutType, execution_space>; + + RealView2Dtype xr2("xr2", n0, n1); + ComplexView2Dtype xc2_axis0("xc2_axis0", n0/2+1, n1); + ComplexView2Dtype xc2_axis1("xc2_axis1", n0, n1/2+1); + ComplexView2Dtype xcin2("xcin2", n0, n1), xcout2("xcout2", n0, n1); + + std::vector ref_in_extents_r2c_axis0{n1, n0}; + std::vector ref_in_extents_r2c_axis1{n0, n1}; + std::vector ref_fft_extents_r2c_axis0{n1, n0}; + std::vector ref_fft_extents_r2c_axis1{n0, n1}; + std::vector ref_out_extents_r2c_axis0{n1, n0/2+1}; + std::vector ref_out_extents_r2c_axis1{n0, n1/2+1}; + + // R2C + auto [in_extents_r2c_axis0, out_extents_r2c_axis0, fft_extents_r2c_axis0] = KokkosFFT::get_extents(xr2, xc2_axis0, 0); + auto [in_extents_r2c_axis1, out_extents_r2c_axis1, fft_extents_r2c_axis1] = KokkosFFT::get_extents(xr2, xc2_axis1, 1); + EXPECT_TRUE( in_extents_r2c_axis0 == ref_in_extents_r2c_axis0 ); + EXPECT_TRUE( in_extents_r2c_axis1 == ref_in_extents_r2c_axis1 ); + + EXPECT_TRUE( fft_extents_r2c_axis0 == ref_fft_extents_r2c_axis0 ); + EXPECT_TRUE( fft_extents_r2c_axis1 == ref_fft_extents_r2c_axis1 ); + + EXPECT_TRUE( out_extents_r2c_axis0 == ref_out_extents_r2c_axis0 ); + EXPECT_TRUE( out_extents_r2c_axis1 == ref_out_extents_r2c_axis1 ); + + // C2R + auto [in_extents_c2r_axis0, out_extents_c2r_axis0, fft_extents_c2r_axis0] = KokkosFFT::get_extents(xc2_axis0, xr2, 0); + auto [in_extents_c2r_axis1, out_extents_c2r_axis1, fft_extents_c2r_axis1] = KokkosFFT::get_extents(xc2_axis1, xr2, 1); + EXPECT_TRUE( in_extents_c2r_axis0 == ref_out_extents_r2c_axis0 ); + EXPECT_TRUE( in_extents_c2r_axis1 == ref_out_extents_r2c_axis1 ); + + EXPECT_TRUE( fft_extents_c2r_axis0 == ref_fft_extents_r2c_axis0 ); + EXPECT_TRUE( fft_extents_c2r_axis1 == ref_fft_extents_r2c_axis1 ); + + EXPECT_TRUE( out_extents_c2r_axis0 == ref_in_extents_r2c_axis0 ); + EXPECT_TRUE( out_extents_c2r_axis1 == ref_in_extents_r2c_axis1 ); + + // C2C + auto [in_extents_c2c_axis0, out_extents_c2c_axis0, fft_extents_c2c_axis0] = KokkosFFT::get_extents(xcin2, xcout2, 0); + auto [in_extents_c2c_axis1, out_extents_c2c_axis1, fft_extents_c2c_axis1] = KokkosFFT::get_extents(xcin2, xcout2, 1); + EXPECT_TRUE( in_extents_c2c_axis0 == ref_in_extents_r2c_axis0 ); + EXPECT_TRUE( in_extents_c2c_axis1 == ref_in_extents_r2c_axis1 ); + + EXPECT_TRUE( fft_extents_c2c_axis0 == ref_fft_extents_r2c_axis0 ); + EXPECT_TRUE( fft_extents_c2c_axis1 == ref_fft_extents_r2c_axis1 ); + + EXPECT_TRUE( out_extents_c2c_axis0 == ref_in_extents_r2c_axis0 ); + EXPECT_TRUE( out_extents_c2c_axis1 == ref_in_extents_r2c_axis1 ); +} + +TEST(Layouts, 2DLeftView) { + test_layouts_2d(); +} + +TEST(Layouts, 2DRightView) { + test_layouts_2d(); +} + +template +void test_layouts_1d_batched_FFT_2d() { + const int n0 = 6, n1 = 10; + using RealView2Dtype = Kokkos::View; + using ComplexView2Dtype = Kokkos::View**, LayoutType, execution_space>; + + RealView2Dtype xr2("xr2", n0, n1); + ComplexView2Dtype xc2_axis0("xc2_axis0", n0/2+1, n1); + ComplexView2Dtype xc2_axis1("xc2_axis1", n0, n1/2+1); + ComplexView2Dtype xcin2("xcin2", n0, n1), xcout2("xcout2", n0, n1); + + // Reference shapes + std::vector ref_in_extents_r2c_axis1{n1}, ref_in_extents_r2c_axis0{n0}; + std::vector ref_fft_extents_r2c_axis1{n1}, ref_fft_extents_r2c_axis0{n0}; + std::vector ref_out_extents_r2c_axis1{n1/2+1}, ref_out_extents_r2c_axis0{n0/2+1}; + int ref_howmany_r2c_axis0 = n1; + int ref_howmany_r2c_axis1 = n0; + + // R2C + auto [in_extents_r2c_axis0, out_extents_r2c_axis0, fft_extents_r2c_axis0, howmany_r2c_axis0] = KokkosFFT::get_extents_batched(xr2, xc2_axis0, 0); + EXPECT_TRUE( in_extents_r2c_axis0 == ref_in_extents_r2c_axis0 ); + EXPECT_TRUE( fft_extents_r2c_axis0 == ref_fft_extents_r2c_axis0 ); + EXPECT_TRUE( out_extents_r2c_axis0 == ref_out_extents_r2c_axis0 ); + EXPECT_EQ( howmany_r2c_axis0, ref_howmany_r2c_axis0 ); + + auto [in_extents_r2c_axis1, out_extents_r2c_axis1, fft_extents_r2c_axis1, howmany_r2c_axis1] = KokkosFFT::get_extents_batched(xr2, xc2_axis1, 1); + EXPECT_TRUE( in_extents_r2c_axis1 == ref_in_extents_r2c_axis1 ); + EXPECT_TRUE( fft_extents_r2c_axis1 == ref_fft_extents_r2c_axis1 ); + EXPECT_TRUE( out_extents_r2c_axis1 == ref_out_extents_r2c_axis1 ); + EXPECT_EQ( howmany_r2c_axis1, ref_howmany_r2c_axis1 ); + + // C2R + auto [in_extents_c2r_axis0, out_extents_c2r_axis0, fft_extents_c2r_axis0, howmany_c2r_axis0] = KokkosFFT::get_extents_batched(xc2_axis0, xr2, 0); + EXPECT_TRUE( in_extents_c2r_axis0 == ref_out_extents_r2c_axis0 ); + EXPECT_TRUE( fft_extents_c2r_axis0 == ref_fft_extents_r2c_axis0 ); + EXPECT_TRUE( out_extents_c2r_axis0 == ref_in_extents_r2c_axis0 ); + EXPECT_EQ( howmany_c2r_axis0, ref_howmany_r2c_axis0 ); + + auto [in_extents_c2r_axis1, out_extents_c2r_axis1, fft_extents_c2r_axis1, howmany_c2r_axis1] = KokkosFFT::get_extents_batched(xc2_axis1, xr2, 1); + EXPECT_TRUE( in_extents_c2r_axis1 == ref_out_extents_r2c_axis1 ); + EXPECT_TRUE( fft_extents_c2r_axis1 == ref_fft_extents_r2c_axis1 ); + EXPECT_TRUE( out_extents_c2r_axis1 == ref_in_extents_r2c_axis1 ); + EXPECT_EQ( howmany_c2r_axis1, ref_howmany_r2c_axis1 ); + + // C2C + auto [in_extents_c2c_axis0, out_extents_c2c_axis0, fft_extents_c2c_axis0, howmany_c2c_axis0] = KokkosFFT::get_extents_batched(xcin2, xcout2, 0); + EXPECT_TRUE( in_extents_c2c_axis0 == ref_in_extents_r2c_axis0 ); + EXPECT_TRUE( fft_extents_c2c_axis0 == ref_fft_extents_r2c_axis0 ); + EXPECT_TRUE( out_extents_c2c_axis0 == ref_in_extents_r2c_axis0 ); + EXPECT_EQ( howmany_c2c_axis0, ref_howmany_r2c_axis0 ); + + auto [in_extents_c2c_axis1, out_extents_c2c_axis1, fft_extents_c2c_axis1, howmany_c2c_axis1] = KokkosFFT::get_extents_batched(xcin2, xcout2, 1); + EXPECT_TRUE( in_extents_c2c_axis1 == ref_in_extents_r2c_axis1 ); + EXPECT_TRUE( fft_extents_c2c_axis1 == ref_fft_extents_r2c_axis1 ); + EXPECT_TRUE( out_extents_c2c_axis1 == ref_in_extents_r2c_axis1 ); + EXPECT_EQ( howmany_c2c_axis1, ref_howmany_r2c_axis1 ); } TEST(Layouts, 1DBatchedFFT_2DLeftView) { - const int n0 = 6, n1 = 10; - - LeftView2D xr2("l_xr2", n0, n1); - LeftView2D> xc2_axis0("xc2_axis0", n0/2+1, n1); - LeftView2D> xc2_axis1("xc2_axis1", n0, n1/2+1); - LeftView2D> xcin2("xcin2", n0, n1), xcout2("xcout2", n0, n1); - - // Reference shapes - std::vector ref_in_extents_r2c_axis1{n1}, ref_in_extents_r2c_axis0{n0}; - std::vector ref_fft_extents_r2c_axis1{n1}, ref_fft_extents_r2c_axis0{n0}; - std::vector ref_out_extents_r2c_axis1{n1/2+1}, ref_out_extents_r2c_axis0{n0/2+1}; - int ref_howmany_r2c_axis0 = n1; - int ref_howmany_r2c_axis1 = n0; - - // R2C - auto [in_extents_r2c_axis0, out_extents_r2c_axis0, fft_extents_r2c_axis0, howmany_r2c_axis0] = KokkosFFT::get_extents_batched(xr2, xc2_axis0, 0); - EXPECT_TRUE( in_extents_r2c_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_TRUE( fft_extents_r2c_axis0 == ref_fft_extents_r2c_axis0 ); - EXPECT_TRUE( out_extents_r2c_axis0 == ref_out_extents_r2c_axis0 ); - EXPECT_EQ( howmany_r2c_axis0, ref_howmany_r2c_axis0 ); - - auto [in_extents_r2c_axis1, out_extents_r2c_axis1, fft_extents_r2c_axis1, howmany_r2c_axis1] = KokkosFFT::get_extents_batched(xr2, xc2_axis1, 1); - EXPECT_TRUE( in_extents_r2c_axis1 == ref_in_extents_r2c_axis1 ); - EXPECT_TRUE( fft_extents_r2c_axis1 == ref_fft_extents_r2c_axis1 ); - EXPECT_TRUE( out_extents_r2c_axis1 == ref_out_extents_r2c_axis1 ); - EXPECT_EQ( howmany_r2c_axis1, ref_howmany_r2c_axis1 ); - - // C2R - auto [in_extents_c2r_axis0, out_extents_c2r_axis0, fft_extents_c2r_axis0, howmany_c2r_axis0] = KokkosFFT::get_extents_batched(xc2_axis0, xr2, 0); - EXPECT_TRUE( in_extents_c2r_axis0 == ref_out_extents_r2c_axis0 ); - EXPECT_TRUE( fft_extents_c2r_axis0 == ref_fft_extents_r2c_axis0 ); - EXPECT_TRUE( out_extents_c2r_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_EQ( howmany_c2r_axis0, ref_howmany_r2c_axis0 ); - - auto [in_extents_c2r_axis1, out_extents_c2r_axis1, fft_extents_c2r_axis1, howmany_c2r_axis1] = KokkosFFT::get_extents_batched(xc2_axis1, xr2, 1); - EXPECT_TRUE( in_extents_c2r_axis1 == ref_out_extents_r2c_axis1 ); - EXPECT_TRUE( fft_extents_c2r_axis1 == ref_fft_extents_r2c_axis1 ); - EXPECT_TRUE( out_extents_c2r_axis1 == ref_in_extents_r2c_axis1 ); - EXPECT_EQ( howmany_c2r_axis1, ref_howmany_r2c_axis1 ); - - // C2C - auto [in_extents_c2c_axis0, out_extents_c2c_axis0, fft_extents_c2c_axis0, howmany_c2c_axis0] = KokkosFFT::get_extents_batched(xcin2, xcout2, 0); - EXPECT_TRUE( in_extents_c2c_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_TRUE( fft_extents_c2c_axis0 == ref_fft_extents_r2c_axis0 ); - EXPECT_TRUE( out_extents_c2c_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_EQ( howmany_c2c_axis0, ref_howmany_r2c_axis0 ); - - auto [in_extents_c2c_axis1, out_extents_c2c_axis1, fft_extents_c2c_axis1, howmany_c2c_axis1] = KokkosFFT::get_extents_batched(xcin2, xcout2, 1); - EXPECT_TRUE( in_extents_c2c_axis1 == ref_in_extents_r2c_axis1 ); - EXPECT_TRUE( fft_extents_c2c_axis1 == ref_fft_extents_r2c_axis1 ); - EXPECT_TRUE( out_extents_c2c_axis1 == ref_in_extents_r2c_axis1 ); - EXPECT_EQ( howmany_c2c_axis1, ref_howmany_r2c_axis1 ); + test_layouts_1d_batched_FFT_2d(); } TEST(Layouts, 1DBatchedFFT_2DRightView) { - const int n0 = 6, n1 = 10; - - RightView2D xr2("r_xr2", n0, n1); - RightView2D> xc2_axis0("xc2_axis0", n0/2+1, n1); - RightView2D> xc2_axis1("xc2_axis1", n0, n1/2+1); - RightView2D> xcin2("xcin2", n0, n1), xcout2("xcout2", n0, n1); - - // Reference shapes - std::vector ref_in_extents_r2c_axis1{n1}, ref_in_extents_r2c_axis0{n0}; - std::vector ref_fft_extents_r2c_axis1{n1}, ref_fft_extents_r2c_axis0{n0}; - std::vector ref_out_extents_r2c_axis1{n1/2+1}, ref_out_extents_r2c_axis0{n0/2+1}; - int ref_howmany_r2c_axis0 = n1; - int ref_howmany_r2c_axis1 = n0; - - // R2C - auto [in_extents_r2c_axis0, out_extents_r2c_axis0, fft_extents_r2c_axis0, howmany_r2c_axis0] = KokkosFFT::get_extents_batched(xr2, xc2_axis0, 0); - EXPECT_TRUE( in_extents_r2c_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_TRUE( fft_extents_r2c_axis0 == ref_fft_extents_r2c_axis0 ); - EXPECT_TRUE( out_extents_r2c_axis0 == ref_out_extents_r2c_axis0 ); - EXPECT_EQ( howmany_r2c_axis0, ref_howmany_r2c_axis0 ); - - auto [in_extents_r2c_axis1, out_extents_r2c_axis1, fft_extents_r2c_axis1, howmany_r2c_axis1] = KokkosFFT::get_extents_batched(xr2, xc2_axis1, 1); - EXPECT_TRUE( in_extents_r2c_axis1 == ref_in_extents_r2c_axis1 ); - EXPECT_TRUE( fft_extents_r2c_axis1 == ref_fft_extents_r2c_axis1 ); - EXPECT_TRUE( out_extents_r2c_axis1 == ref_out_extents_r2c_axis1 ); - EXPECT_EQ( howmany_r2c_axis1, ref_howmany_r2c_axis1 ); - - // C2R - auto [in_extents_c2r_axis0, out_extents_c2r_axis0, fft_extents_c2r_axis0, howmany_c2r_axis0] = KokkosFFT::get_extents_batched(xc2_axis0, xr2, 0); - EXPECT_TRUE( in_extents_c2r_axis0 == ref_out_extents_r2c_axis0 ); - EXPECT_TRUE( fft_extents_c2r_axis0 == ref_fft_extents_r2c_axis0 ); - EXPECT_TRUE( out_extents_c2r_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_EQ( howmany_c2r_axis0, ref_howmany_r2c_axis0 ); - - auto [in_extents_c2r_axis1, out_extents_c2r_axis1, fft_extents_c2r_axis1, howmany_c2r_axis1] = KokkosFFT::get_extents_batched(xc2_axis1, xr2, 1); - EXPECT_TRUE( in_extents_c2r_axis1 == ref_out_extents_r2c_axis1 ); - EXPECT_TRUE( fft_extents_c2r_axis1 == ref_fft_extents_r2c_axis1 ); - EXPECT_TRUE( out_extents_c2r_axis1 == ref_in_extents_r2c_axis1 ); - EXPECT_EQ( howmany_c2r_axis1, ref_howmany_r2c_axis1 ); - - // C2C - auto [in_extents_c2c_axis0, out_extents_c2c_axis0, fft_extents_c2c_axis0, howmany_c2c_axis0] = KokkosFFT::get_extents_batched(xcin2, xcout2, 0); - EXPECT_TRUE( in_extents_c2c_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_TRUE( fft_extents_c2c_axis0 == ref_fft_extents_r2c_axis0 ); - EXPECT_TRUE( out_extents_c2c_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_EQ( howmany_c2c_axis0, ref_howmany_r2c_axis0 ); - - auto [in_extents_c2c_axis1, out_extents_c2c_axis1, fft_extents_c2c_axis1, howmany_c2c_axis1] = KokkosFFT::get_extents_batched(xcin2, xcout2, 1); - EXPECT_TRUE( in_extents_c2c_axis1 == ref_in_extents_r2c_axis1 ); - EXPECT_TRUE( fft_extents_c2c_axis1 == ref_fft_extents_r2c_axis1 ); - EXPECT_TRUE( out_extents_c2c_axis1 == ref_in_extents_r2c_axis1 ); - EXPECT_EQ( howmany_c2c_axis1, ref_howmany_r2c_axis1 ); + test_layouts_1d_batched_FFT_2d(); +} + +template +void test_layouts_1d_batched_FFT_3d() { + const int n0 = 6, n1 = 10, n2 = 8; + using RealView3Dtype = Kokkos::View; + using ComplexView3Dtype = Kokkos::View***, LayoutType, execution_space>; + + RealView3Dtype xr3("xr3", n0, n1, n2); + ComplexView3Dtype xc3_axis0("xc3_axis0", n0/2+1, n1, n2); + ComplexView3Dtype xc3_axis1("xc3_axis1", n0, n1/2+1, n2); + ComplexView3Dtype xc3_axis2("xc3_axis2", n0, n1, n2/2+1); + ComplexView3Dtype xcin3("xcin3", n0, n1, n2), xcout3("xcout3", n0, n1, n2); + + // Reference shapes + std::vector ref_in_extents_r2c_axis0{n0}; + std::vector ref_fft_extents_r2c_axis0{n0}; + std::vector ref_out_extents_r2c_axis0{n0/2+1}; + int ref_howmany_r2c_axis0 = n1 * n2; + + std::vector ref_in_extents_r2c_axis1{n1}; + std::vector ref_fft_extents_r2c_axis1{n1}; + std::vector ref_out_extents_r2c_axis1{n1/2+1}; + int ref_howmany_r2c_axis1 = n0 * n2; + + std::vector ref_in_extents_r2c_axis2{n2}; + std::vector ref_fft_extents_r2c_axis2{n2}; + std::vector ref_out_extents_r2c_axis2{n2/2+1}; + int ref_howmany_r2c_axis2 = n0 * n1; + + // R2C + auto [in_extents_r2c_axis0, out_extents_r2c_axis0, fft_extents_r2c_axis0, howmany_r2c_axis0] = KokkosFFT::get_extents_batched(xr3, xc3_axis0, 0); + EXPECT_TRUE( in_extents_r2c_axis0 == ref_in_extents_r2c_axis0 ); + EXPECT_TRUE( fft_extents_r2c_axis0 == ref_fft_extents_r2c_axis0 ); + EXPECT_TRUE( out_extents_r2c_axis0 == ref_out_extents_r2c_axis0 ); + EXPECT_EQ( howmany_r2c_axis0, ref_howmany_r2c_axis0 ); + + auto [in_extents_r2c_axis1, out_extents_r2c_axis1, fft_extents_r2c_axis1, howmany_r2c_axis1] = KokkosFFT::get_extents_batched(xr3, xc3_axis1, 1); + EXPECT_TRUE( in_extents_r2c_axis1 == ref_in_extents_r2c_axis1 ); + EXPECT_TRUE( fft_extents_r2c_axis1 == ref_fft_extents_r2c_axis1 ); + EXPECT_TRUE( out_extents_r2c_axis1 == ref_out_extents_r2c_axis1 ); + EXPECT_EQ( howmany_r2c_axis1, ref_howmany_r2c_axis1 ); + + auto [in_extents_r2c_axis2, out_extents_r2c_axis2, fft_extents_r2c_axis2, howmany_r2c_axis2] = KokkosFFT::get_extents_batched(xr3, xc3_axis2, 2); + EXPECT_TRUE( in_extents_r2c_axis2 == ref_in_extents_r2c_axis2 ); + EXPECT_TRUE( fft_extents_r2c_axis2 == ref_fft_extents_r2c_axis2 ); + EXPECT_TRUE( out_extents_r2c_axis2 == ref_out_extents_r2c_axis2 ); + EXPECT_EQ( howmany_r2c_axis2, ref_howmany_r2c_axis2 ); + + // C2R + auto [in_extents_c2r_axis0, out_extents_c2r_axis0, fft_extents_c2r_axis0, howmany_c2r_axis0] = KokkosFFT::get_extents_batched(xc3_axis0, xr3, 0); + EXPECT_TRUE( in_extents_c2r_axis0 == ref_out_extents_r2c_axis0 ); + EXPECT_TRUE( fft_extents_c2r_axis0 == ref_fft_extents_r2c_axis0 ); + EXPECT_TRUE( out_extents_c2r_axis0 == ref_in_extents_r2c_axis0 ); + EXPECT_EQ( howmany_c2r_axis0, ref_howmany_r2c_axis0 ); + + auto [in_extents_c2r_axis1, out_extents_c2r_axis1, fft_extents_c2r_axis1, howmany_c2r_axis1] = KokkosFFT::get_extents_batched(xc3_axis1, xr3, 1); + EXPECT_TRUE( in_extents_c2r_axis1 == ref_out_extents_r2c_axis1 ); + EXPECT_TRUE( fft_extents_c2r_axis1 == ref_fft_extents_r2c_axis1 ); + EXPECT_TRUE( out_extents_c2r_axis1 == ref_in_extents_r2c_axis1 ); + EXPECT_EQ( howmany_c2r_axis1, ref_howmany_r2c_axis1 ); + + auto [in_extents_c2r_axis2, out_extents_c2r_axis2, fft_extents_c2r_axis2, howmany_c2r_axis2] = KokkosFFT::get_extents_batched(xc3_axis2, xr3, 2); + EXPECT_TRUE( in_extents_c2r_axis2 == ref_out_extents_r2c_axis2 ); + EXPECT_TRUE( fft_extents_c2r_axis2 == ref_fft_extents_r2c_axis2 ); + EXPECT_TRUE( out_extents_c2r_axis2 == ref_in_extents_r2c_axis2 ); + EXPECT_EQ( howmany_c2r_axis2, ref_howmany_r2c_axis2 ); + + // C2C + auto [in_extents_c2c_axis0, out_extents_c2c_axis0, fft_extents_c2c_axis0, howmany_c2c_axis0] = KokkosFFT::get_extents_batched(xcin3, xcout3, 0); + EXPECT_TRUE( in_extents_c2c_axis0 == ref_in_extents_r2c_axis0 ); + EXPECT_TRUE( fft_extents_c2c_axis0 == ref_fft_extents_r2c_axis0 ); + EXPECT_TRUE( out_extents_c2c_axis0 == ref_in_extents_r2c_axis0 ); + EXPECT_EQ( howmany_c2c_axis0, ref_howmany_r2c_axis0 ); + + auto [in_extents_c2c_axis1, out_extents_c2c_axis1, fft_extents_c2c_axis1, howmany_c2c_axis1] = KokkosFFT::get_extents_batched(xcin3, xcout3, 1); + EXPECT_TRUE( in_extents_c2c_axis1 == ref_in_extents_r2c_axis1 ); + EXPECT_TRUE( fft_extents_c2c_axis1 == ref_fft_extents_r2c_axis1 ); + EXPECT_TRUE( out_extents_c2c_axis1 == ref_in_extents_r2c_axis1 ); + EXPECT_EQ( howmany_c2c_axis1, ref_howmany_r2c_axis1 ); + + auto [in_extents_c2c_axis2, out_extents_c2c_axis2, fft_extents_c2c_axis2, howmany_c2c_axis2] = KokkosFFT::get_extents_batched(xcin3, xcout3, 2); + EXPECT_TRUE( in_extents_c2c_axis2 == ref_in_extents_r2c_axis2 ); + EXPECT_TRUE( fft_extents_c2c_axis2 == ref_fft_extents_r2c_axis2 ); + EXPECT_TRUE( out_extents_c2c_axis2 == ref_in_extents_r2c_axis2 ); + EXPECT_EQ( howmany_c2c_axis2, ref_howmany_r2c_axis2 ); } TEST(Layouts, 1DBatchedFFT_3DLeftView) { - const int n0 = 6, n1 = 10, n2 = 8; - - LeftView3D xr3("r_xr3", n0, n1, n2); - LeftView3D> xc3_axis0("xc3_axis0", n0/2+1, n1, n2); - LeftView3D> xc3_axis1("xc3_axis1", n0, n1/2+1, n2); - LeftView3D> xc3_axis2("xc3_axis2", n0, n1, n2/2+1); - LeftView3D> xcin3("xcin3", n0, n1, n2), xcout3("xcout3", n0, n1, n2); - - // Reference shapes - std::vector ref_in_extents_r2c_axis0{n0}; - std::vector ref_fft_extents_r2c_axis0{n0}; - std::vector ref_out_extents_r2c_axis0{n0/2+1}; - int ref_howmany_r2c_axis0 = n1 * n2; - - std::vector ref_in_extents_r2c_axis1{n1}; - std::vector ref_fft_extents_r2c_axis1{n1}; - std::vector ref_out_extents_r2c_axis1{n1/2+1}; - int ref_howmany_r2c_axis1 = n0 * n2; - - std::vector ref_in_extents_r2c_axis2{n2}; - std::vector ref_fft_extents_r2c_axis2{n2}; - std::vector ref_out_extents_r2c_axis2{n2/2+1}; - int ref_howmany_r2c_axis2 = n0 * n1; - - // R2C - auto [in_extents_r2c_axis0, out_extents_r2c_axis0, fft_extents_r2c_axis0, howmany_r2c_axis0] = KokkosFFT::get_extents_batched(xr3, xc3_axis0, 0); - EXPECT_TRUE( in_extents_r2c_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_TRUE( fft_extents_r2c_axis0 == ref_fft_extents_r2c_axis0 ); - EXPECT_TRUE( out_extents_r2c_axis0 == ref_out_extents_r2c_axis0 ); - EXPECT_EQ( howmany_r2c_axis0, ref_howmany_r2c_axis0 ); - - auto [in_extents_r2c_axis1, out_extents_r2c_axis1, fft_extents_r2c_axis1, howmany_r2c_axis1] = KokkosFFT::get_extents_batched(xr3, xc3_axis1, 1); - EXPECT_TRUE( in_extents_r2c_axis1 == ref_in_extents_r2c_axis1 ); - EXPECT_TRUE( fft_extents_r2c_axis1 == ref_fft_extents_r2c_axis1 ); - EXPECT_TRUE( out_extents_r2c_axis1 == ref_out_extents_r2c_axis1 ); - EXPECT_EQ( howmany_r2c_axis1, ref_howmany_r2c_axis1 ); - - auto [in_extents_r2c_axis2, out_extents_r2c_axis2, fft_extents_r2c_axis2, howmany_r2c_axis2] = KokkosFFT::get_extents_batched(xr3, xc3_axis2, 2); - EXPECT_TRUE( in_extents_r2c_axis2 == ref_in_extents_r2c_axis2 ); - EXPECT_TRUE( fft_extents_r2c_axis2 == ref_fft_extents_r2c_axis2 ); - EXPECT_TRUE( out_extents_r2c_axis2 == ref_out_extents_r2c_axis2 ); - EXPECT_EQ( howmany_r2c_axis2, ref_howmany_r2c_axis2 ); - - // C2R - auto [in_extents_c2r_axis0, out_extents_c2r_axis0, fft_extents_c2r_axis0, howmany_c2r_axis0] = KokkosFFT::get_extents_batched(xc3_axis0, xr3, 0); - EXPECT_TRUE( in_extents_c2r_axis0 == ref_out_extents_r2c_axis0 ); - EXPECT_TRUE( fft_extents_c2r_axis0 == ref_fft_extents_r2c_axis0 ); - EXPECT_TRUE( out_extents_c2r_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_EQ( howmany_c2r_axis0, ref_howmany_r2c_axis0 ); - - auto [in_extents_c2r_axis1, out_extents_c2r_axis1, fft_extents_c2r_axis1, howmany_c2r_axis1] = KokkosFFT::get_extents_batched(xc3_axis1, xr3, 1); - EXPECT_TRUE( in_extents_c2r_axis1 == ref_out_extents_r2c_axis1 ); - EXPECT_TRUE( fft_extents_c2r_axis1 == ref_fft_extents_r2c_axis1 ); - EXPECT_TRUE( out_extents_c2r_axis1 == ref_in_extents_r2c_axis1 ); - EXPECT_EQ( howmany_c2r_axis1, ref_howmany_r2c_axis1 ); - - auto [in_extents_c2r_axis2, out_extents_c2r_axis2, fft_extents_c2r_axis2, howmany_c2r_axis2] = KokkosFFT::get_extents_batched(xc3_axis2, xr3, 2); - EXPECT_TRUE( in_extents_c2r_axis2 == ref_out_extents_r2c_axis2 ); - EXPECT_TRUE( fft_extents_c2r_axis2 == ref_fft_extents_r2c_axis2 ); - EXPECT_TRUE( out_extents_c2r_axis2 == ref_in_extents_r2c_axis2 ); - EXPECT_EQ( howmany_c2r_axis2, ref_howmany_r2c_axis2 ); - - // C2C - auto [in_extents_c2c_axis0, out_extents_c2c_axis0, fft_extents_c2c_axis0, howmany_c2c_axis0] = KokkosFFT::get_extents_batched(xcin3, xcout3, 0); - EXPECT_TRUE( in_extents_c2c_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_TRUE( fft_extents_c2c_axis0 == ref_fft_extents_r2c_axis0 ); - EXPECT_TRUE( out_extents_c2c_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_EQ( howmany_c2c_axis0, ref_howmany_r2c_axis0 ); - - auto [in_extents_c2c_axis1, out_extents_c2c_axis1, fft_extents_c2c_axis1, howmany_c2c_axis1] = KokkosFFT::get_extents_batched(xcin3, xcout3, 1); - EXPECT_TRUE( in_extents_c2c_axis1 == ref_in_extents_r2c_axis1 ); - EXPECT_TRUE( fft_extents_c2c_axis1 == ref_fft_extents_r2c_axis1 ); - EXPECT_TRUE( out_extents_c2c_axis1 == ref_in_extents_r2c_axis1 ); - EXPECT_EQ( howmany_c2c_axis1, ref_howmany_r2c_axis1 ); - - auto [in_extents_c2c_axis2, out_extents_c2c_axis2, fft_extents_c2c_axis2, howmany_c2c_axis2] = KokkosFFT::get_extents_batched(xcin3, xcout3, 2); - EXPECT_TRUE( in_extents_c2c_axis2 == ref_in_extents_r2c_axis2 ); - EXPECT_TRUE( fft_extents_c2c_axis2 == ref_fft_extents_r2c_axis2 ); - EXPECT_TRUE( out_extents_c2c_axis2 == ref_in_extents_r2c_axis2 ); - EXPECT_EQ( howmany_c2c_axis2, ref_howmany_r2c_axis2 ); + test_layouts_1d_batched_FFT_3d(); } TEST(Layouts, 1DBatchedFFT_3DRightView) { - const int n0 = 6, n1 = 10, n2 = 8; - - RightView3D xr3("r_xr3", n0, n1, n2); - RightView3D> xc3_axis0("xc3_axis0", n0/2+1, n1, n2); - RightView3D> xc3_axis1("xc3_axis1", n0, n1/2+1, n2); - RightView3D> xc3_axis2("xc3_axis2", n0, n1, n2/2+1); - RightView3D> xcin3("xcin3", n0, n1, n2), xcout3("xcout3", n0, n1, n2); - - // Reference shapes - std::vector ref_in_extents_r2c_axis0{n0}; - std::vector ref_fft_extents_r2c_axis0{n0}; - std::vector ref_out_extents_r2c_axis0{n0/2+1}; - int ref_howmany_r2c_axis0 = n1 * n2; - - std::vector ref_in_extents_r2c_axis1{n1}; - std::vector ref_fft_extents_r2c_axis1{n1}; - std::vector ref_out_extents_r2c_axis1{n1/2+1}; - int ref_howmany_r2c_axis1 = n0 * n2; - - std::vector ref_in_extents_r2c_axis2{n2}; - std::vector ref_fft_extents_r2c_axis2{n2}; - std::vector ref_out_extents_r2c_axis2{n2/2+1}; - int ref_howmany_r2c_axis2 = n0 * n1; - - // R2C - auto [in_extents_r2c_axis0, out_extents_r2c_axis0, fft_extents_r2c_axis0, howmany_r2c_axis0] = KokkosFFT::get_extents_batched(xr3, xc3_axis0, 0); - EXPECT_TRUE( in_extents_r2c_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_TRUE( fft_extents_r2c_axis0 == ref_fft_extents_r2c_axis0 ); - EXPECT_TRUE( out_extents_r2c_axis0 == ref_out_extents_r2c_axis0 ); - EXPECT_EQ( howmany_r2c_axis0, ref_howmany_r2c_axis0 ); - - auto [in_extents_r2c_axis1, out_extents_r2c_axis1, fft_extents_r2c_axis1, howmany_r2c_axis1] = KokkosFFT::get_extents_batched(xr3, xc3_axis1, 1); - EXPECT_TRUE( in_extents_r2c_axis1 == ref_in_extents_r2c_axis1 ); - EXPECT_TRUE( fft_extents_r2c_axis1 == ref_fft_extents_r2c_axis1 ); - EXPECT_TRUE( out_extents_r2c_axis1 == ref_out_extents_r2c_axis1 ); - EXPECT_EQ( howmany_r2c_axis1, ref_howmany_r2c_axis1 ); - - auto [in_extents_r2c_axis2, out_extents_r2c_axis2, fft_extents_r2c_axis2, howmany_r2c_axis2] = KokkosFFT::get_extents_batched(xr3, xc3_axis2, 2); - EXPECT_TRUE( in_extents_r2c_axis2 == ref_in_extents_r2c_axis2 ); - EXPECT_TRUE( fft_extents_r2c_axis2 == ref_fft_extents_r2c_axis2 ); - EXPECT_TRUE( out_extents_r2c_axis2 == ref_out_extents_r2c_axis2 ); - EXPECT_EQ( howmany_r2c_axis2, ref_howmany_r2c_axis2 ); - - // C2R - auto [in_extents_c2r_axis0, out_extents_c2r_axis0, fft_extents_c2r_axis0, howmany_c2r_axis0] = KokkosFFT::get_extents_batched(xc3_axis0, xr3, 0); - EXPECT_TRUE( in_extents_c2r_axis0 == ref_out_extents_r2c_axis0 ); - EXPECT_TRUE( fft_extents_c2r_axis0 == ref_fft_extents_r2c_axis0 ); - EXPECT_TRUE( out_extents_c2r_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_EQ( howmany_c2r_axis0, ref_howmany_r2c_axis0 ); - - auto [in_extents_c2r_axis1, out_extents_c2r_axis1, fft_extents_c2r_axis1, howmany_c2r_axis1] = KokkosFFT::get_extents_batched(xc3_axis1, xr3, 1); - EXPECT_TRUE( in_extents_c2r_axis1 == ref_out_extents_r2c_axis1 ); - EXPECT_TRUE( fft_extents_c2r_axis1 == ref_fft_extents_r2c_axis1 ); - EXPECT_TRUE( out_extents_c2r_axis1 == ref_in_extents_r2c_axis1 ); - EXPECT_EQ( howmany_c2r_axis1, ref_howmany_r2c_axis1 ); - - auto [in_extents_c2r_axis2, out_extents_c2r_axis2, fft_extents_c2r_axis2, howmany_c2r_axis2] = KokkosFFT::get_extents_batched(xc3_axis2, xr3, 2); - EXPECT_TRUE( in_extents_c2r_axis2 == ref_out_extents_r2c_axis2 ); - EXPECT_TRUE( fft_extents_c2r_axis2 == ref_fft_extents_r2c_axis2 ); - EXPECT_TRUE( out_extents_c2r_axis2 == ref_in_extents_r2c_axis2 ); - EXPECT_EQ( howmany_c2r_axis2, ref_howmany_r2c_axis2 ); - - // C2C - auto [in_extents_c2c_axis0, out_extents_c2c_axis0, fft_extents_c2c_axis0, howmany_c2c_axis0] = KokkosFFT::get_extents_batched(xcin3, xcout3, 0); - EXPECT_TRUE( in_extents_c2c_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_TRUE( fft_extents_c2c_axis0 == ref_fft_extents_r2c_axis0 ); - EXPECT_TRUE( out_extents_c2c_axis0 == ref_in_extents_r2c_axis0 ); - EXPECT_EQ( howmany_c2c_axis0, ref_howmany_r2c_axis0 ); - - auto [in_extents_c2c_axis1, out_extents_c2c_axis1, fft_extents_c2c_axis1, howmany_c2c_axis1] = KokkosFFT::get_extents_batched(xcin3, xcout3, 1); - EXPECT_TRUE( in_extents_c2c_axis1 == ref_in_extents_r2c_axis1 ); - EXPECT_TRUE( fft_extents_c2c_axis1 == ref_fft_extents_r2c_axis1 ); - EXPECT_TRUE( out_extents_c2c_axis1 == ref_in_extents_r2c_axis1 ); - EXPECT_EQ( howmany_c2c_axis1, ref_howmany_r2c_axis1 ); - - auto [in_extents_c2c_axis2, out_extents_c2c_axis2, fft_extents_c2c_axis2, howmany_c2c_axis2] = KokkosFFT::get_extents_batched(xcin3, xcout3, 2); - EXPECT_TRUE( in_extents_c2c_axis2 == ref_in_extents_r2c_axis2 ); - EXPECT_TRUE( fft_extents_c2c_axis2 == ref_fft_extents_r2c_axis2 ); - EXPECT_TRUE( out_extents_c2c_axis2 == ref_in_extents_r2c_axis2 ); - EXPECT_EQ( howmany_c2c_axis2, ref_howmany_r2c_axis2 ); + test_layouts_1d_batched_FFT_3d(); +} + +template +void test_layouts_2d_batched_FFT_3d() { + const int n0 = 6, n1 = 10, n2 = 8; + using axes_type = KokkosFFT::axis_type<2>; + using RealView3Dtype = Kokkos::View; + using ComplexView3Dtype = Kokkos::View***, LayoutType, execution_space>; + + RealView3Dtype xr3("xr3", n0, n1, n2); + ComplexView3Dtype xc3_axis_01("xc3_axis_01", n0, n1/2+1, n2); + ComplexView3Dtype xc3_axis_02("xc3_axis_02", n0, n1, n2/2+1); + ComplexView3Dtype xc3_axis_10("xc3_axis_10", n0/2+1, n1, n2); + ComplexView3Dtype xc3_axis_12("xc3_axis_12", n0, n1, n2/2+1); + ComplexView3Dtype xc3_axis_20("xc3_axis_20", n0/2+1, n1, n2); + ComplexView3Dtype xc3_axis_21("xc3_axis_21", n0, n1/2+1, n2); + ComplexView3Dtype xcin3("xcin3", n0, n1, n2), xcout3("xcout3", n0, n1, n2); + + // Reference shapes + std::vector ref_in_extents_r2c_axis_01{n0, n1}; + std::vector ref_fft_extents_r2c_axis_01{n0, n1}; + std::vector ref_out_extents_r2c_axis_01{n0, n1/2+1}; + int ref_howmany_r2c_axis_01 = n2; + + std::vector ref_in_extents_r2c_axis_02{n0, n2}; + std::vector ref_fft_extents_r2c_axis_02{n0, n2}; + std::vector ref_out_extents_r2c_axis_02{n0, n2/2+1}; + int ref_howmany_r2c_axis_02 = n1; + + std::vector ref_in_extents_r2c_axis_10{n1, n0}; + std::vector ref_fft_extents_r2c_axis_10{n1, n0}; + std::vector ref_out_extents_r2c_axis_10{n1, n0/2+1}; + int ref_howmany_r2c_axis_10 = n2; + + std::vector ref_in_extents_r2c_axis_12{n1, n2}; + std::vector ref_fft_extents_r2c_axis_12{n1, n2}; + std::vector ref_out_extents_r2c_axis_12{n1, n2/2+1}; + int ref_howmany_r2c_axis_12 = n0; + + std::vector ref_in_extents_r2c_axis_20{n2, n0}; + std::vector ref_fft_extents_r2c_axis_20{n2, n0}; + std::vector ref_out_extents_r2c_axis_20{n2, n0/2+1}; + int ref_howmany_r2c_axis_20 = n1; + + std::vector ref_in_extents_r2c_axis_21{n2, n1}; + std::vector ref_fft_extents_r2c_axis_21{n2, n1}; + std::vector ref_out_extents_r2c_axis_21{n2, n1/2+1}; + int ref_howmany_r2c_axis_21 = n0; + + // R2C + auto [in_extents_r2c_axis_01, out_extents_r2c_axis_01, fft_extents_r2c_axis_01, howmany_r2c_axis_01] = KokkosFFT::get_extents_batched(xr3, xc3_axis_01, axes_type({0, 1})); + EXPECT_TRUE( in_extents_r2c_axis_01 == ref_in_extents_r2c_axis_01 ); + EXPECT_TRUE( fft_extents_r2c_axis_01 == ref_fft_extents_r2c_axis_01 ); + EXPECT_TRUE( out_extents_r2c_axis_01 == ref_out_extents_r2c_axis_01 ); + EXPECT_EQ( howmany_r2c_axis_01, ref_howmany_r2c_axis_01 ); + + auto [in_extents_r2c_axis_02, out_extents_r2c_axis_02, fft_extents_r2c_axis_02, howmany_r2c_axis_02] = KokkosFFT::get_extents_batched(xr3, xc3_axis_02, axes_type({0, 2})); + EXPECT_TRUE( in_extents_r2c_axis_02 == ref_in_extents_r2c_axis_02 ); + EXPECT_TRUE( fft_extents_r2c_axis_02 == ref_fft_extents_r2c_axis_02 ); + EXPECT_TRUE( out_extents_r2c_axis_02 == ref_out_extents_r2c_axis_02 ); + EXPECT_EQ( howmany_r2c_axis_02, ref_howmany_r2c_axis_02 ); + + auto [in_extents_r2c_axis_10, out_extents_r2c_axis_10, fft_extents_r2c_axis_10, howmany_r2c_axis_10] = KokkosFFT::get_extents_batched(xr3, xc3_axis_10, axes_type({1, 0})); + EXPECT_TRUE( in_extents_r2c_axis_10 == ref_in_extents_r2c_axis_10 ); + EXPECT_TRUE( fft_extents_r2c_axis_10 == ref_fft_extents_r2c_axis_10 ); + EXPECT_TRUE( out_extents_r2c_axis_10 == ref_out_extents_r2c_axis_10 ); + EXPECT_EQ( howmany_r2c_axis_10, ref_howmany_r2c_axis_10 ); + + auto [in_extents_r2c_axis_12, out_extents_r2c_axis_12, fft_extents_r2c_axis_12, howmany_r2c_axis_12] = KokkosFFT::get_extents_batched(xr3, xc3_axis_12, axes_type({1, 2})); + EXPECT_TRUE( in_extents_r2c_axis_12 == ref_in_extents_r2c_axis_12 ); + EXPECT_TRUE( fft_extents_r2c_axis_12 == ref_fft_extents_r2c_axis_12 ); + EXPECT_TRUE( out_extents_r2c_axis_12 == ref_out_extents_r2c_axis_12 ); + EXPECT_EQ( howmany_r2c_axis_12, ref_howmany_r2c_axis_12 ); + + auto [in_extents_r2c_axis_20, out_extents_r2c_axis_20, fft_extents_r2c_axis_20, howmany_r2c_axis_20] = KokkosFFT::get_extents_batched(xr3, xc3_axis_20, axes_type({2, 0})); + EXPECT_TRUE( in_extents_r2c_axis_20 == ref_in_extents_r2c_axis_20 ); + EXPECT_TRUE( fft_extents_r2c_axis_20 == ref_fft_extents_r2c_axis_20 ); + EXPECT_TRUE( out_extents_r2c_axis_20 == ref_out_extents_r2c_axis_20 ); + EXPECT_EQ( howmany_r2c_axis_20, ref_howmany_r2c_axis_20 ); + + auto [in_extents_r2c_axis_21, out_extents_r2c_axis_21, fft_extents_r2c_axis_21, howmany_r2c_axis_21] = KokkosFFT::get_extents_batched(xr3, xc3_axis_21, axes_type({2, 1})); + EXPECT_TRUE( in_extents_r2c_axis_21 == ref_in_extents_r2c_axis_21 ); + EXPECT_TRUE( fft_extents_r2c_axis_21 == ref_fft_extents_r2c_axis_21 ); + EXPECT_TRUE( out_extents_r2c_axis_21 == ref_out_extents_r2c_axis_21 ); + EXPECT_EQ( howmany_r2c_axis_21, ref_howmany_r2c_axis_21 ); + + // C2R + auto [in_extents_c2r_axis_01, out_extents_c2r_axis_01, fft_extents_c2r_axis_01, howmany_c2r_axis_01] = KokkosFFT::get_extents_batched(xc3_axis_01, xr3, axes_type({0, 1})); + EXPECT_TRUE( in_extents_c2r_axis_01 == ref_out_extents_r2c_axis_01 ); + EXPECT_TRUE( fft_extents_c2r_axis_01 == ref_fft_extents_r2c_axis_01 ); + EXPECT_TRUE( out_extents_c2r_axis_01 == ref_in_extents_r2c_axis_01 ); + EXPECT_EQ( howmany_c2r_axis_01, ref_howmany_r2c_axis_01 ); + + auto [in_extents_c2r_axis_02, out_extents_c2r_axis_02, fft_extents_c2r_axis_02, howmany_c2r_axis_02] = KokkosFFT::get_extents_batched(xc3_axis_02, xr3, axes_type({0, 2})); + EXPECT_TRUE( in_extents_c2r_axis_02 == ref_out_extents_r2c_axis_02 ); + EXPECT_TRUE( fft_extents_c2r_axis_02 == ref_fft_extents_r2c_axis_02 ); + EXPECT_TRUE( out_extents_c2r_axis_02 == ref_in_extents_r2c_axis_02 ); + EXPECT_EQ( howmany_c2r_axis_02, ref_howmany_r2c_axis_02 ); + + auto [in_extents_c2r_axis_10, out_extents_c2r_axis_10, fft_extents_c2r_axis_10, howmany_c2r_axis_10] = KokkosFFT::get_extents_batched(xc3_axis_10, xr3, axes_type({1, 0})); + EXPECT_TRUE( in_extents_c2r_axis_10 == ref_out_extents_r2c_axis_10 ); + EXPECT_TRUE( fft_extents_c2r_axis_10 == ref_fft_extents_r2c_axis_10 ); + EXPECT_TRUE( out_extents_c2r_axis_10 == ref_in_extents_r2c_axis_10 ); + EXPECT_EQ( howmany_c2r_axis_10, ref_howmany_r2c_axis_10 ); + + auto [in_extents_c2r_axis_12, out_extents_c2r_axis_12, fft_extents_c2r_axis_12, howmany_c2r_axis_12] = KokkosFFT::get_extents_batched(xc3_axis_12, xr3, axes_type({1, 2})); + EXPECT_TRUE( in_extents_c2r_axis_12 == ref_out_extents_r2c_axis_12 ); + EXPECT_TRUE( fft_extents_c2r_axis_12 == ref_fft_extents_r2c_axis_12 ); + EXPECT_TRUE( out_extents_c2r_axis_12 == ref_in_extents_r2c_axis_12 ); + EXPECT_EQ( howmany_c2r_axis_12, ref_howmany_r2c_axis_12 ); + + auto [in_extents_c2r_axis_20, out_extents_c2r_axis_20, fft_extents_c2r_axis_20, howmany_c2r_axis_20] = KokkosFFT::get_extents_batched(xc3_axis_20, xr3, axes_type({2, 0})); + EXPECT_TRUE( in_extents_c2r_axis_20 == ref_out_extents_r2c_axis_20 ); + EXPECT_TRUE( fft_extents_c2r_axis_20 == ref_fft_extents_r2c_axis_20 ); + EXPECT_TRUE( out_extents_c2r_axis_20 == ref_in_extents_r2c_axis_20 ); + EXPECT_EQ( howmany_c2r_axis_20, ref_howmany_r2c_axis_20 ); + + auto [in_extents_c2r_axis_21, out_extents_c2r_axis_21, fft_extents_c2r_axis_21, howmany_c2r_axis_21] = KokkosFFT::get_extents_batched(xc3_axis_21, xr3, axes_type({2, 1})); + EXPECT_TRUE( in_extents_c2r_axis_21 == ref_out_extents_r2c_axis_21 ); + EXPECT_TRUE( fft_extents_c2r_axis_21 == ref_fft_extents_r2c_axis_21 ); + EXPECT_TRUE( out_extents_c2r_axis_21 == ref_in_extents_r2c_axis_21 ); + EXPECT_EQ( howmany_c2r_axis_21, ref_howmany_r2c_axis_21 ); + + // C2C + auto [in_extents_c2c_axis_01, out_extents_c2c_axis_01, fft_extents_c2c_axis_01, howmany_c2c_axis_01] = KokkosFFT::get_extents_batched(xcin3, xcout3, axes_type({0, 1})); + EXPECT_TRUE( in_extents_c2c_axis_01 == ref_in_extents_r2c_axis_01 ); + EXPECT_TRUE( fft_extents_c2c_axis_01 == ref_fft_extents_r2c_axis_01 ); + EXPECT_TRUE( out_extents_c2c_axis_01 == ref_in_extents_r2c_axis_01 ); + EXPECT_EQ( howmany_c2c_axis_01, ref_howmany_r2c_axis_01 ); + + auto [in_extents_c2c_axis_02, out_extents_c2c_axis_02, fft_extents_c2c_axis_02, howmany_c2c_axis_02] = KokkosFFT::get_extents_batched(xcin3, xcout3, axes_type({0, 2})); + EXPECT_TRUE( in_extents_c2c_axis_02 == ref_in_extents_r2c_axis_02 ); + EXPECT_TRUE( fft_extents_c2c_axis_02 == ref_fft_extents_r2c_axis_02 ); + EXPECT_TRUE( out_extents_c2c_axis_02 == ref_in_extents_r2c_axis_02 ); + EXPECT_EQ( howmany_c2c_axis_02, ref_howmany_r2c_axis_02 ); + + auto [in_extents_c2c_axis_10, out_extents_c2c_axis_10, fft_extents_c2c_axis_10, howmany_c2c_axis_10] = KokkosFFT::get_extents_batched(xcin3, xcout3, axes_type({1, 0})); + EXPECT_TRUE( in_extents_c2c_axis_10 == ref_in_extents_r2c_axis_10 ); + EXPECT_TRUE( fft_extents_c2c_axis_10 == ref_fft_extents_r2c_axis_10 ); + EXPECT_TRUE( out_extents_c2c_axis_10 == ref_in_extents_r2c_axis_10 ); + EXPECT_EQ( howmany_c2c_axis_10, ref_howmany_r2c_axis_10 ); + + auto [in_extents_c2c_axis_12, out_extents_c2c_axis_12, fft_extents_c2c_axis_12, howmany_c2c_axis_12] = KokkosFFT::get_extents_batched(xcin3, xcout3, axes_type({1, 2})); + EXPECT_TRUE( in_extents_c2c_axis_12 == ref_in_extents_r2c_axis_12 ); + EXPECT_TRUE( fft_extents_c2c_axis_12 == ref_fft_extents_r2c_axis_12 ); + EXPECT_TRUE( out_extents_c2c_axis_12 == ref_in_extents_r2c_axis_12 ); + EXPECT_EQ( howmany_c2c_axis_12, ref_howmany_r2c_axis_12 ); + + auto [in_extents_c2c_axis_20, out_extents_c2c_axis_20, fft_extents_c2c_axis_20, howmany_c2c_axis_20] = KokkosFFT::get_extents_batched(xcin3, xcout3, axes_type({2, 0})); + EXPECT_TRUE( in_extents_c2c_axis_20 == ref_in_extents_r2c_axis_20 ); + EXPECT_TRUE( fft_extents_c2c_axis_20 == ref_fft_extents_r2c_axis_20 ); + EXPECT_TRUE( out_extents_c2c_axis_20 == ref_in_extents_r2c_axis_20 ); + EXPECT_EQ( howmany_c2c_axis_20, ref_howmany_r2c_axis_20 ); + + auto [in_extents_c2c_axis_21, out_extents_c2c_axis_21, fft_extents_c2c_axis_21, howmany_c2c_axis_21] = KokkosFFT::get_extents_batched(xcin3, xcout3, axes_type({2, 1})); + EXPECT_TRUE( in_extents_c2c_axis_21 == ref_in_extents_r2c_axis_21 ); + EXPECT_TRUE( fft_extents_c2c_axis_21 == ref_fft_extents_r2c_axis_21 ); + EXPECT_TRUE( out_extents_c2c_axis_21 == ref_in_extents_r2c_axis_21 ); + EXPECT_EQ( howmany_c2c_axis_21, ref_howmany_r2c_axis_21 ); } TEST(Layouts, 2DBatchedFFT_3DLeftView) { - using axes_type = KokkosFFT::axis_type<2>; - const int n0 = 6, n1 = 10, n2 = 8; - - LeftView3D xr3("r_xr3", n0, n1, n2); - LeftView3D> xc3_axis_01("xc3_axis_01", n0, n1/2+1, n2); - LeftView3D> xc3_axis_02("xc3_axis_02", n0, n1, n2/2+1); - LeftView3D> xc3_axis_10("xc3_axis_10", n0/2+1, n1, n2); - LeftView3D> xc3_axis_12("xc3_axis_12", n0, n1, n2/2+1); - LeftView3D> xc3_axis_20("xc3_axis_20", n0/2+1, n1, n2); - LeftView3D> xc3_axis_21("xc3_axis_21", n0, n1/2+1, n2); - LeftView3D> xcin3("xcin3", n0, n1, n2), xcout3("xcout3", n0, n1, n2); - - // Reference shapes - std::vector ref_in_extents_r2c_axis_01{n0, n1}; - std::vector ref_fft_extents_r2c_axis_01{n0, n1}; - std::vector ref_out_extents_r2c_axis_01{n0, n1/2+1}; - int ref_howmany_r2c_axis_01 = n2; - - std::vector ref_in_extents_r2c_axis_02{n0, n2}; - std::vector ref_fft_extents_r2c_axis_02{n0, n2}; - std::vector ref_out_extents_r2c_axis_02{n0, n2/2+1}; - int ref_howmany_r2c_axis_02 = n1; - - std::vector ref_in_extents_r2c_axis_10{n1, n0}; - std::vector ref_fft_extents_r2c_axis_10{n1, n0}; - std::vector ref_out_extents_r2c_axis_10{n1, n0/2+1}; - int ref_howmany_r2c_axis_10 = n2; - - std::vector ref_in_extents_r2c_axis_12{n1, n2}; - std::vector ref_fft_extents_r2c_axis_12{n1, n2}; - std::vector ref_out_extents_r2c_axis_12{n1, n2/2+1}; - int ref_howmany_r2c_axis_12 = n0; - - std::vector ref_in_extents_r2c_axis_20{n2, n0}; - std::vector ref_fft_extents_r2c_axis_20{n2, n0}; - std::vector ref_out_extents_r2c_axis_20{n2, n0/2+1}; - int ref_howmany_r2c_axis_20 = n1; - - std::vector ref_in_extents_r2c_axis_21{n2, n1}; - std::vector ref_fft_extents_r2c_axis_21{n2, n1}; - std::vector ref_out_extents_r2c_axis_21{n2, n1/2+1}; - int ref_howmany_r2c_axis_21 = n0; - - // R2C - auto [in_extents_r2c_axis_01, out_extents_r2c_axis_01, fft_extents_r2c_axis_01, howmany_r2c_axis_01] = KokkosFFT::get_extents_batched(xr3, xc3_axis_01, axes_type({0, 1})); - EXPECT_TRUE( in_extents_r2c_axis_01 == ref_in_extents_r2c_axis_01 ); - EXPECT_TRUE( fft_extents_r2c_axis_01 == ref_fft_extents_r2c_axis_01 ); - EXPECT_TRUE( out_extents_r2c_axis_01 == ref_out_extents_r2c_axis_01 ); - EXPECT_EQ( howmany_r2c_axis_01, ref_howmany_r2c_axis_01 ); - - auto [in_extents_r2c_axis_02, out_extents_r2c_axis_02, fft_extents_r2c_axis_02, howmany_r2c_axis_02] = KokkosFFT::get_extents_batched(xr3, xc3_axis_02, axes_type({0, 2})); - EXPECT_TRUE( in_extents_r2c_axis_02 == ref_in_extents_r2c_axis_02 ); - EXPECT_TRUE( fft_extents_r2c_axis_02 == ref_fft_extents_r2c_axis_02 ); - EXPECT_TRUE( out_extents_r2c_axis_02 == ref_out_extents_r2c_axis_02 ); - EXPECT_EQ( howmany_r2c_axis_02, ref_howmany_r2c_axis_02 ); - - auto [in_extents_r2c_axis_10, out_extents_r2c_axis_10, fft_extents_r2c_axis_10, howmany_r2c_axis_10] = KokkosFFT::get_extents_batched(xr3, xc3_axis_10, axes_type({1, 0})); - EXPECT_TRUE( in_extents_r2c_axis_10 == ref_in_extents_r2c_axis_10 ); - EXPECT_TRUE( fft_extents_r2c_axis_10 == ref_fft_extents_r2c_axis_10 ); - EXPECT_TRUE( out_extents_r2c_axis_10 == ref_out_extents_r2c_axis_10 ); - EXPECT_EQ( howmany_r2c_axis_10, ref_howmany_r2c_axis_10 ); - - auto [in_extents_r2c_axis_12, out_extents_r2c_axis_12, fft_extents_r2c_axis_12, howmany_r2c_axis_12] = KokkosFFT::get_extents_batched(xr3, xc3_axis_12, axes_type({1, 2})); - EXPECT_TRUE( in_extents_r2c_axis_12 == ref_in_extents_r2c_axis_12 ); - EXPECT_TRUE( fft_extents_r2c_axis_12 == ref_fft_extents_r2c_axis_12 ); - EXPECT_TRUE( out_extents_r2c_axis_12 == ref_out_extents_r2c_axis_12 ); - EXPECT_EQ( howmany_r2c_axis_12, ref_howmany_r2c_axis_12 ); - - auto [in_extents_r2c_axis_20, out_extents_r2c_axis_20, fft_extents_r2c_axis_20, howmany_r2c_axis_20] = KokkosFFT::get_extents_batched(xr3, xc3_axis_20, axes_type({2, 0})); - EXPECT_TRUE( in_extents_r2c_axis_20 == ref_in_extents_r2c_axis_20 ); - EXPECT_TRUE( fft_extents_r2c_axis_20 == ref_fft_extents_r2c_axis_20 ); - EXPECT_TRUE( out_extents_r2c_axis_20 == ref_out_extents_r2c_axis_20 ); - EXPECT_EQ( howmany_r2c_axis_20, ref_howmany_r2c_axis_20 ); - - auto [in_extents_r2c_axis_21, out_extents_r2c_axis_21, fft_extents_r2c_axis_21, howmany_r2c_axis_21] = KokkosFFT::get_extents_batched(xr3, xc3_axis_21, axes_type({2, 1})); - EXPECT_TRUE( in_extents_r2c_axis_21 == ref_in_extents_r2c_axis_21 ); - EXPECT_TRUE( fft_extents_r2c_axis_21 == ref_fft_extents_r2c_axis_21 ); - EXPECT_TRUE( out_extents_r2c_axis_21 == ref_out_extents_r2c_axis_21 ); - EXPECT_EQ( howmany_r2c_axis_21, ref_howmany_r2c_axis_21 ); - - // C2R - auto [in_extents_c2r_axis_01, out_extents_c2r_axis_01, fft_extents_c2r_axis_01, howmany_c2r_axis_01] = KokkosFFT::get_extents_batched(xc3_axis_01, xr3, axes_type({0, 1})); - EXPECT_TRUE( in_extents_c2r_axis_01 == ref_out_extents_r2c_axis_01 ); - EXPECT_TRUE( fft_extents_c2r_axis_01 == ref_fft_extents_r2c_axis_01 ); - EXPECT_TRUE( out_extents_c2r_axis_01 == ref_in_extents_r2c_axis_01 ); - EXPECT_EQ( howmany_c2r_axis_01, ref_howmany_r2c_axis_01 ); - - auto [in_extents_c2r_axis_02, out_extents_c2r_axis_02, fft_extents_c2r_axis_02, howmany_c2r_axis_02] = KokkosFFT::get_extents_batched(xc3_axis_02, xr3, axes_type({0, 2})); - EXPECT_TRUE( in_extents_c2r_axis_02 == ref_out_extents_r2c_axis_02 ); - EXPECT_TRUE( fft_extents_c2r_axis_02 == ref_fft_extents_r2c_axis_02 ); - EXPECT_TRUE( out_extents_c2r_axis_02 == ref_in_extents_r2c_axis_02 ); - EXPECT_EQ( howmany_c2r_axis_02, ref_howmany_r2c_axis_02 ); - - auto [in_extents_c2r_axis_10, out_extents_c2r_axis_10, fft_extents_c2r_axis_10, howmany_c2r_axis_10] = KokkosFFT::get_extents_batched(xc3_axis_10, xr3, axes_type({1, 0})); - EXPECT_TRUE( in_extents_c2r_axis_10 == ref_out_extents_r2c_axis_10 ); - EXPECT_TRUE( fft_extents_c2r_axis_10 == ref_fft_extents_r2c_axis_10 ); - EXPECT_TRUE( out_extents_c2r_axis_10 == ref_in_extents_r2c_axis_10 ); - EXPECT_EQ( howmany_c2r_axis_10, ref_howmany_r2c_axis_10 ); - - auto [in_extents_c2r_axis_12, out_extents_c2r_axis_12, fft_extents_c2r_axis_12, howmany_c2r_axis_12] = KokkosFFT::get_extents_batched(xc3_axis_12, xr3, axes_type({1, 2})); - EXPECT_TRUE( in_extents_c2r_axis_12 == ref_out_extents_r2c_axis_12 ); - EXPECT_TRUE( fft_extents_c2r_axis_12 == ref_fft_extents_r2c_axis_12 ); - EXPECT_TRUE( out_extents_c2r_axis_12 == ref_in_extents_r2c_axis_12 ); - EXPECT_EQ( howmany_c2r_axis_12, ref_howmany_r2c_axis_12 ); - - auto [in_extents_c2r_axis_20, out_extents_c2r_axis_20, fft_extents_c2r_axis_20, howmany_c2r_axis_20] = KokkosFFT::get_extents_batched(xc3_axis_20, xr3, axes_type({2, 0})); - EXPECT_TRUE( in_extents_c2r_axis_20 == ref_out_extents_r2c_axis_20 ); - EXPECT_TRUE( fft_extents_c2r_axis_20 == ref_fft_extents_r2c_axis_20 ); - EXPECT_TRUE( out_extents_c2r_axis_20 == ref_in_extents_r2c_axis_20 ); - EXPECT_EQ( howmany_c2r_axis_20, ref_howmany_r2c_axis_20 ); - - auto [in_extents_c2r_axis_21, out_extents_c2r_axis_21, fft_extents_c2r_axis_21, howmany_c2r_axis_21] = KokkosFFT::get_extents_batched(xc3_axis_21, xr3, axes_type({2, 1})); - EXPECT_TRUE( in_extents_c2r_axis_21 == ref_out_extents_r2c_axis_21 ); - EXPECT_TRUE( fft_extents_c2r_axis_21 == ref_fft_extents_r2c_axis_21 ); - EXPECT_TRUE( out_extents_c2r_axis_21 == ref_in_extents_r2c_axis_21 ); - EXPECT_EQ( howmany_c2r_axis_21, ref_howmany_r2c_axis_21 ); - - // C2C - auto [in_extents_c2c_axis_01, out_extents_c2c_axis_01, fft_extents_c2c_axis_01, howmany_c2c_axis_01] = KokkosFFT::get_extents_batched(xcin3, xcout3, axes_type({0, 1})); - EXPECT_TRUE( in_extents_c2c_axis_01 == ref_in_extents_r2c_axis_01 ); - EXPECT_TRUE( fft_extents_c2c_axis_01 == ref_fft_extents_r2c_axis_01 ); - EXPECT_TRUE( out_extents_c2c_axis_01 == ref_in_extents_r2c_axis_01 ); - EXPECT_EQ( howmany_c2c_axis_01, ref_howmany_r2c_axis_01 ); - - auto [in_extents_c2c_axis_02, out_extents_c2c_axis_02, fft_extents_c2c_axis_02, howmany_c2c_axis_02] = KokkosFFT::get_extents_batched(xcin3, xcout3, axes_type({0, 2})); - EXPECT_TRUE( in_extents_c2c_axis_02 == ref_in_extents_r2c_axis_02 ); - EXPECT_TRUE( fft_extents_c2c_axis_02 == ref_fft_extents_r2c_axis_02 ); - EXPECT_TRUE( out_extents_c2c_axis_02 == ref_in_extents_r2c_axis_02 ); - EXPECT_EQ( howmany_c2c_axis_02, ref_howmany_r2c_axis_02 ); - - auto [in_extents_c2c_axis_10, out_extents_c2c_axis_10, fft_extents_c2c_axis_10, howmany_c2c_axis_10] = KokkosFFT::get_extents_batched(xcin3, xcout3, axes_type({1, 0})); - EXPECT_TRUE( in_extents_c2c_axis_10 == ref_in_extents_r2c_axis_10 ); - EXPECT_TRUE( fft_extents_c2c_axis_10 == ref_fft_extents_r2c_axis_10 ); - EXPECT_TRUE( out_extents_c2c_axis_10 == ref_in_extents_r2c_axis_10 ); - EXPECT_EQ( howmany_c2c_axis_10, ref_howmany_r2c_axis_10 ); - - auto [in_extents_c2c_axis_12, out_extents_c2c_axis_12, fft_extents_c2c_axis_12, howmany_c2c_axis_12] = KokkosFFT::get_extents_batched(xcin3, xcout3, axes_type({1, 2})); - EXPECT_TRUE( in_extents_c2c_axis_12 == ref_in_extents_r2c_axis_12 ); - EXPECT_TRUE( fft_extents_c2c_axis_12 == ref_fft_extents_r2c_axis_12 ); - EXPECT_TRUE( out_extents_c2c_axis_12 == ref_in_extents_r2c_axis_12 ); - EXPECT_EQ( howmany_c2c_axis_12, ref_howmany_r2c_axis_12 ); - - auto [in_extents_c2c_axis_20, out_extents_c2c_axis_20, fft_extents_c2c_axis_20, howmany_c2c_axis_20] = KokkosFFT::get_extents_batched(xcin3, xcout3, axes_type({2, 0})); - EXPECT_TRUE( in_extents_c2c_axis_20 == ref_in_extents_r2c_axis_20 ); - EXPECT_TRUE( fft_extents_c2c_axis_20 == ref_fft_extents_r2c_axis_20 ); - EXPECT_TRUE( out_extents_c2c_axis_20 == ref_in_extents_r2c_axis_20 ); - EXPECT_EQ( howmany_c2c_axis_20, ref_howmany_r2c_axis_20 ); - - auto [in_extents_c2c_axis_21, out_extents_c2c_axis_21, fft_extents_c2c_axis_21, howmany_c2c_axis_21] = KokkosFFT::get_extents_batched(xcin3, xcout3, axes_type({2, 1})); - EXPECT_TRUE( in_extents_c2c_axis_21 == ref_in_extents_r2c_axis_21 ); - EXPECT_TRUE( fft_extents_c2c_axis_21 == ref_fft_extents_r2c_axis_21 ); - EXPECT_TRUE( out_extents_c2c_axis_21 == ref_in_extents_r2c_axis_21 ); - EXPECT_EQ( howmany_c2c_axis_21, ref_howmany_r2c_axis_21 ); + test_layouts_2d_batched_FFT_3d(); } TEST(Layouts, 2DBatchedFFT_3DRightView) { - using axes_type = KokkosFFT::axis_type<2>; - const int n0 = 6, n1 = 10, n2 = 8; - - RightView3D xr3("r_xr3", n0, n1, n2); - RightView3D> xc3_axis_01("xc3_axis_01", n0, n1/2+1, n2); - RightView3D> xc3_axis_02("xc3_axis_02", n0, n1, n2/2+1); - RightView3D> xc3_axis_10("xc3_axis_10", n0/2+1, n1, n2); - RightView3D> xc3_axis_12("xc3_axis_12", n0, n1, n2/2+1); - RightView3D> xc3_axis_20("xc3_axis_20", n0/2+1, n1, n2); - RightView3D> xc3_axis_21("xc3_axis_21", n0, n1/2+1, n2); - RightView3D> xcin3("xcin3", n0, n1, n2), xcout3("xcout3", n0, n1, n2); - - // Reference shapes - std::vector ref_in_extents_r2c_axis_01{n0, n1}; - std::vector ref_fft_extents_r2c_axis_01{n0, n1}; - std::vector ref_out_extents_r2c_axis_01{n0, n1/2+1}; - int ref_howmany_r2c_axis_01 = n2; - - std::vector ref_in_extents_r2c_axis_02{n0, n2}; - std::vector ref_fft_extents_r2c_axis_02{n0, n2}; - std::vector ref_out_extents_r2c_axis_02{n0, n2/2+1}; - int ref_howmany_r2c_axis_02 = n1; - - std::vector ref_in_extents_r2c_axis_10{n1, n0}; - std::vector ref_fft_extents_r2c_axis_10{n1, n0}; - std::vector ref_out_extents_r2c_axis_10{n1, n0/2+1}; - int ref_howmany_r2c_axis_10 = n2; - - std::vector ref_in_extents_r2c_axis_12{n1, n2}; - std::vector ref_fft_extents_r2c_axis_12{n1, n2}; - std::vector ref_out_extents_r2c_axis_12{n1, n2/2+1}; - int ref_howmany_r2c_axis_12 = n0; - - std::vector ref_in_extents_r2c_axis_20{n2, n0}; - std::vector ref_fft_extents_r2c_axis_20{n2, n0}; - std::vector ref_out_extents_r2c_axis_20{n2, n0/2+1}; - int ref_howmany_r2c_axis_20 = n1; - - std::vector ref_in_extents_r2c_axis_21{n2, n1}; - std::vector ref_fft_extents_r2c_axis_21{n2, n1}; - std::vector ref_out_extents_r2c_axis_21{n2, n1/2+1}; - int ref_howmany_r2c_axis_21 = n0; - - // R2C - auto [in_extents_r2c_axis_01, out_extents_r2c_axis_01, fft_extents_r2c_axis_01, howmany_r2c_axis_01] = KokkosFFT::get_extents_batched(xr3, xc3_axis_01, axes_type({0, 1})); - EXPECT_TRUE( in_extents_r2c_axis_01 == ref_in_extents_r2c_axis_01 ); - EXPECT_TRUE( fft_extents_r2c_axis_01 == ref_fft_extents_r2c_axis_01 ); - EXPECT_TRUE( out_extents_r2c_axis_01 == ref_out_extents_r2c_axis_01 ); - EXPECT_EQ( howmany_r2c_axis_01, ref_howmany_r2c_axis_01 ); - - auto [in_extents_r2c_axis_02, out_extents_r2c_axis_02, fft_extents_r2c_axis_02, howmany_r2c_axis_02] = KokkosFFT::get_extents_batched(xr3, xc3_axis_02, axes_type({0, 2})); - EXPECT_TRUE( in_extents_r2c_axis_02 == ref_in_extents_r2c_axis_02 ); - EXPECT_TRUE( fft_extents_r2c_axis_02 == ref_fft_extents_r2c_axis_02 ); - EXPECT_TRUE( out_extents_r2c_axis_02 == ref_out_extents_r2c_axis_02 ); - EXPECT_EQ( howmany_r2c_axis_02, ref_howmany_r2c_axis_02 ); - - auto [in_extents_r2c_axis_10, out_extents_r2c_axis_10, fft_extents_r2c_axis_10, howmany_r2c_axis_10] = KokkosFFT::get_extents_batched(xr3, xc3_axis_10, axes_type({1, 0})); - EXPECT_TRUE( in_extents_r2c_axis_10 == ref_in_extents_r2c_axis_10 ); - EXPECT_TRUE( fft_extents_r2c_axis_10 == ref_fft_extents_r2c_axis_10 ); - EXPECT_TRUE( out_extents_r2c_axis_10 == ref_out_extents_r2c_axis_10 ); - EXPECT_EQ( howmany_r2c_axis_10, ref_howmany_r2c_axis_10 ); - - auto [in_extents_r2c_axis_12, out_extents_r2c_axis_12, fft_extents_r2c_axis_12, howmany_r2c_axis_12] = KokkosFFT::get_extents_batched(xr3, xc3_axis_12, axes_type({1, 2})); - EXPECT_TRUE( in_extents_r2c_axis_12 == ref_in_extents_r2c_axis_12 ); - EXPECT_TRUE( fft_extents_r2c_axis_12 == ref_fft_extents_r2c_axis_12 ); - EXPECT_TRUE( out_extents_r2c_axis_12 == ref_out_extents_r2c_axis_12 ); - EXPECT_EQ( howmany_r2c_axis_12, ref_howmany_r2c_axis_12 ); - - auto [in_extents_r2c_axis_20, out_extents_r2c_axis_20, fft_extents_r2c_axis_20, howmany_r2c_axis_20] = KokkosFFT::get_extents_batched(xr3, xc3_axis_20, axes_type({2, 0})); - EXPECT_TRUE( in_extents_r2c_axis_20 == ref_in_extents_r2c_axis_20 ); - EXPECT_TRUE( fft_extents_r2c_axis_20 == ref_fft_extents_r2c_axis_20 ); - EXPECT_TRUE( out_extents_r2c_axis_20 == ref_out_extents_r2c_axis_20 ); - EXPECT_EQ( howmany_r2c_axis_20, ref_howmany_r2c_axis_20 ); - - auto [in_extents_r2c_axis_21, out_extents_r2c_axis_21, fft_extents_r2c_axis_21, howmany_r2c_axis_21] = KokkosFFT::get_extents_batched(xr3, xc3_axis_21, axes_type({2, 1})); - EXPECT_TRUE( in_extents_r2c_axis_21 == ref_in_extents_r2c_axis_21 ); - EXPECT_TRUE( fft_extents_r2c_axis_21 == ref_fft_extents_r2c_axis_21 ); - EXPECT_TRUE( out_extents_r2c_axis_21 == ref_out_extents_r2c_axis_21 ); - EXPECT_EQ( howmany_r2c_axis_21, ref_howmany_r2c_axis_21 ); - - // C2R - auto [in_extents_c2r_axis_01, out_extents_c2r_axis_01, fft_extents_c2r_axis_01, howmany_c2r_axis_01] = KokkosFFT::get_extents_batched(xc3_axis_01, xr3, axes_type({0, 1})); - EXPECT_TRUE( in_extents_c2r_axis_01 == ref_out_extents_r2c_axis_01 ); - EXPECT_TRUE( fft_extents_c2r_axis_01 == ref_fft_extents_r2c_axis_01 ); - EXPECT_TRUE( out_extents_c2r_axis_01 == ref_in_extents_r2c_axis_01 ); - EXPECT_EQ( howmany_c2r_axis_01, ref_howmany_r2c_axis_01 ); - - auto [in_extents_c2r_axis_02, out_extents_c2r_axis_02, fft_extents_c2r_axis_02, howmany_c2r_axis_02] = KokkosFFT::get_extents_batched(xc3_axis_02, xr3, axes_type({0, 2})); - EXPECT_TRUE( in_extents_c2r_axis_02 == ref_out_extents_r2c_axis_02 ); - EXPECT_TRUE( fft_extents_c2r_axis_02 == ref_fft_extents_r2c_axis_02 ); - EXPECT_TRUE( out_extents_c2r_axis_02 == ref_in_extents_r2c_axis_02 ); - EXPECT_EQ( howmany_c2r_axis_02, ref_howmany_r2c_axis_02 ); - - auto [in_extents_c2r_axis_10, out_extents_c2r_axis_10, fft_extents_c2r_axis_10, howmany_c2r_axis_10] = KokkosFFT::get_extents_batched(xc3_axis_10, xr3, axes_type({1, 0})); - EXPECT_TRUE( in_extents_c2r_axis_10 == ref_out_extents_r2c_axis_10 ); - EXPECT_TRUE( fft_extents_c2r_axis_10 == ref_fft_extents_r2c_axis_10 ); - EXPECT_TRUE( out_extents_c2r_axis_10 == ref_in_extents_r2c_axis_10 ); - EXPECT_EQ( howmany_c2r_axis_10, ref_howmany_r2c_axis_10 ); - - auto [in_extents_c2r_axis_12, out_extents_c2r_axis_12, fft_extents_c2r_axis_12, howmany_c2r_axis_12] = KokkosFFT::get_extents_batched(xc3_axis_12, xr3, axes_type({1, 2})); - EXPECT_TRUE( in_extents_c2r_axis_12 == ref_out_extents_r2c_axis_12 ); - EXPECT_TRUE( fft_extents_c2r_axis_12 == ref_fft_extents_r2c_axis_12 ); - EXPECT_TRUE( out_extents_c2r_axis_12 == ref_in_extents_r2c_axis_12 ); - EXPECT_EQ( howmany_c2r_axis_12, ref_howmany_r2c_axis_12 ); - - auto [in_extents_c2r_axis_20, out_extents_c2r_axis_20, fft_extents_c2r_axis_20, howmany_c2r_axis_20] = KokkosFFT::get_extents_batched(xc3_axis_20, xr3, axes_type({2, 0})); - EXPECT_TRUE( in_extents_c2r_axis_20 == ref_out_extents_r2c_axis_20 ); - EXPECT_TRUE( fft_extents_c2r_axis_20 == ref_fft_extents_r2c_axis_20 ); - EXPECT_TRUE( out_extents_c2r_axis_20 == ref_in_extents_r2c_axis_20 ); - EXPECT_EQ( howmany_c2r_axis_20, ref_howmany_r2c_axis_20 ); - - auto [in_extents_c2r_axis_21, out_extents_c2r_axis_21, fft_extents_c2r_axis_21, howmany_c2r_axis_21] = KokkosFFT::get_extents_batched(xc3_axis_21, xr3, axes_type({2, 1})); - EXPECT_TRUE( in_extents_c2r_axis_21 == ref_out_extents_r2c_axis_21 ); - EXPECT_TRUE( fft_extents_c2r_axis_21 == ref_fft_extents_r2c_axis_21 ); - EXPECT_TRUE( out_extents_c2r_axis_21 == ref_in_extents_r2c_axis_21 ); - EXPECT_EQ( howmany_c2r_axis_21, ref_howmany_r2c_axis_21 ); - - // C2C - auto [in_extents_c2c_axis_01, out_extents_c2c_axis_01, fft_extents_c2c_axis_01, howmany_c2c_axis_01] = KokkosFFT::get_extents_batched(xcin3, xcout3, axes_type({0, 1})); - EXPECT_TRUE( in_extents_c2c_axis_01 == ref_in_extents_r2c_axis_01 ); - EXPECT_TRUE( fft_extents_c2c_axis_01 == ref_fft_extents_r2c_axis_01 ); - EXPECT_TRUE( out_extents_c2c_axis_01 == ref_in_extents_r2c_axis_01 ); - EXPECT_EQ( howmany_c2c_axis_01, ref_howmany_r2c_axis_01 ); - - auto [in_extents_c2c_axis_02, out_extents_c2c_axis_02, fft_extents_c2c_axis_02, howmany_c2c_axis_02] = KokkosFFT::get_extents_batched(xcin3, xcout3, axes_type({0, 2})); - EXPECT_TRUE( in_extents_c2c_axis_02 == ref_in_extents_r2c_axis_02 ); - EXPECT_TRUE( fft_extents_c2c_axis_02 == ref_fft_extents_r2c_axis_02 ); - EXPECT_TRUE( out_extents_c2c_axis_02 == ref_in_extents_r2c_axis_02 ); - EXPECT_EQ( howmany_c2c_axis_02, ref_howmany_r2c_axis_02 ); - - auto [in_extents_c2c_axis_10, out_extents_c2c_axis_10, fft_extents_c2c_axis_10, howmany_c2c_axis_10] = KokkosFFT::get_extents_batched(xcin3, xcout3, axes_type({1, 0})); - EXPECT_TRUE( in_extents_c2c_axis_10 == ref_in_extents_r2c_axis_10 ); - EXPECT_TRUE( fft_extents_c2c_axis_10 == ref_fft_extents_r2c_axis_10 ); - EXPECT_TRUE( out_extents_c2c_axis_10 == ref_in_extents_r2c_axis_10 ); - EXPECT_EQ( howmany_c2c_axis_10, ref_howmany_r2c_axis_10 ); - - auto [in_extents_c2c_axis_12, out_extents_c2c_axis_12, fft_extents_c2c_axis_12, howmany_c2c_axis_12] = KokkosFFT::get_extents_batched(xcin3, xcout3, axes_type({1, 2})); - EXPECT_TRUE( in_extents_c2c_axis_12 == ref_in_extents_r2c_axis_12 ); - EXPECT_TRUE( fft_extents_c2c_axis_12 == ref_fft_extents_r2c_axis_12 ); - EXPECT_TRUE( out_extents_c2c_axis_12 == ref_in_extents_r2c_axis_12 ); - EXPECT_EQ( howmany_c2c_axis_12, ref_howmany_r2c_axis_12 ); - - auto [in_extents_c2c_axis_20, out_extents_c2c_axis_20, fft_extents_c2c_axis_20, howmany_c2c_axis_20] = KokkosFFT::get_extents_batched(xcin3, xcout3, axes_type({2, 0})); - EXPECT_TRUE( in_extents_c2c_axis_20 == ref_in_extents_r2c_axis_20 ); - EXPECT_TRUE( fft_extents_c2c_axis_20 == ref_fft_extents_r2c_axis_20 ); - EXPECT_TRUE( out_extents_c2c_axis_20 == ref_in_extents_r2c_axis_20 ); - EXPECT_EQ( howmany_c2c_axis_20, ref_howmany_r2c_axis_20 ); - - auto [in_extents_c2c_axis_21, out_extents_c2c_axis_21, fft_extents_c2c_axis_21, howmany_c2c_axis_21] = KokkosFFT::get_extents_batched(xcin3, xcout3, axes_type({2, 1})); - EXPECT_TRUE( in_extents_c2c_axis_21 == ref_in_extents_r2c_axis_21 ); - EXPECT_TRUE( fft_extents_c2c_axis_21 == ref_fft_extents_r2c_axis_21 ); - EXPECT_TRUE( out_extents_c2c_axis_21 == ref_in_extents_r2c_axis_21 ); - EXPECT_EQ( howmany_c2c_axis_21, ref_howmany_r2c_axis_21 ); + test_layouts_2d_batched_FFT_3d(); } \ No newline at end of file diff --git a/common/unit_test/Test_Transpose.cpp b/common/unit_test/Test_Transpose.cpp index a155b55e..af0a6a1f 100644 --- a/common/unit_test/Test_Transpose.cpp +++ b/common/unit_test/Test_Transpose.cpp @@ -7,512 +7,480 @@ template using axes_type = std::array; -TEST(MapAxes, 1D) { - const int len = 30; - View1D x("x", len); +template +void test_map_axes1d() { + const int len = 30; + using RealView1Dtype = Kokkos::View; + RealView1Dtype x("x", len); + + auto [map_axis, map_inv_axis] = KokkosFFT::get_map_axes(x, /*axis=*/0); + auto [map_axes, map_inv_axes] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<1>({0})); + + axes_type<1> ref_map_axis = {0}; + axes_type<1> ref_map_axes = {0}; + + EXPECT_TRUE( map_axis == ref_map_axis ); + EXPECT_TRUE( map_axes == ref_map_axes ); + EXPECT_TRUE( map_inv_axis == ref_map_axis ); + EXPECT_TRUE( map_inv_axes == ref_map_axes ); +} + +TEST(MapAxes, 1DLeftView) { + test_map_axes1d(); +} - auto [map_axis, map_inv_axis] = KokkosFFT::get_map_axes(x, /*axis=*/0); - auto [map_axes, map_inv_axes] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<1>({0})); +TEST(MapAxes, 1DRightView) { + test_map_axes1d(); +} - axes_type<1> ref_map_axis = {0}; - axes_type<1> ref_map_axes = {0}; +template +void test_map_axes2d() { + const int n0 = 3, n1 = 5; + using RealView2Dtype = Kokkos::View; + RealView2Dtype x("x", n0, n1); + + auto [map_axis_0, map_inv_axis_0] = KokkosFFT::get_map_axes(x, /*axis=*/0); + auto [map_axis_1, map_inv_axis_1] = KokkosFFT::get_map_axes(x, /*axis=*/1); + auto [map_axis_minus1, map_inv_axis_minus1] = KokkosFFT::get_map_axes(x, /*axis=*/-1); + auto [map_axes_0, map_inv_axes_0] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<1>({0})); + auto [map_axes_1, map_inv_axes_1] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<1>({1})); + auto [map_axes_minus1, map_inv_axes_minus1] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<1>({-1})); + auto [map_axes_0_minus1, map_inv_axes_0_minus1] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<2>({0, -1})); + auto [map_axes_minus1_0, map_inv_axes_minus1_0] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<2>({-1, 0})); + auto [map_axes_0_1, map_inv_axes_0_1] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<2>({0, 1})); + auto [map_axes_1_0, map_inv_axes_1_0] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<2>({1, 0})); + + axes_type<2> ref_map_axis_0, ref_map_inv_axis_0; + axes_type<2> ref_map_axis_1, ref_map_inv_axis_1; + axes_type<2> ref_map_axis_minus1, ref_map_inv_axis_minus1; + axes_type<2> ref_map_axes_0, ref_map_inv_axes_0; + axes_type<2> ref_map_axes_1, ref_map_inv_axes_1; + axes_type<2> ref_map_axes_minus1, ref_map_inv_axes_minus1; + + axes_type<2> ref_map_axes_0_minus1, ref_map_inv_axes_0_minus1; + axes_type<2> ref_map_axes_minus1_0, ref_map_inv_axes_minus1_0; + axes_type<2> ref_map_axes_0_1, ref_map_inv_axes_0_1; + axes_type<2> ref_map_axes_1_0, ref_map_inv_axes_1_0; + + if(std::is_same_v) { + // Layout Left + ref_map_axis_0 = {0, 1}, ref_map_inv_axis_0 = {0, 1}; + ref_map_axis_1 = {1, 0}, ref_map_inv_axis_1 = {1, 0}; + ref_map_axis_minus1 = {1, 0}, ref_map_inv_axis_minus1 = {1, 0}; + ref_map_axes_0 = {0, 1}, ref_map_inv_axes_0 = {0, 1}; + ref_map_axes_1 = {1, 0}, ref_map_inv_axes_1 = {1, 0}; + ref_map_axes_minus1 = {1, 0}, ref_map_inv_axes_minus1 = {1, 0}; + + ref_map_axes_0_minus1 = {1, 0}, ref_map_inv_axes_0_minus1 = {1, 0}; + ref_map_axes_minus1_0 = {0, 1}, ref_map_inv_axes_minus1_0 = {0, 1}; + ref_map_axes_0_1 = {1, 0}, ref_map_inv_axes_0_1 = {1, 0}; + ref_map_axes_1_0 = {0, 1}, ref_map_inv_axes_1_0 = {0, 1}; + } else { + // Layout Right + ref_map_axis_0 = {1, 0}, ref_map_inv_axis_0 = {1, 0}; + ref_map_axis_1 = {0, 1}, ref_map_inv_axis_1 = {0, 1}; + ref_map_axis_minus1 = {0, 1}, ref_map_inv_axis_minus1 = {0, 1}; + ref_map_axes_0 = {1, 0}, ref_map_inv_axes_0 = {1, 0}; + ref_map_axes_1 = {0, 1}, ref_map_inv_axes_1 = {0, 1}; + ref_map_axes_minus1 = {0, 1}, ref_map_inv_axes_minus1 = {0, 1}; + + ref_map_axes_0_minus1 = {0, 1}, ref_map_inv_axes_0_minus1 = {0, 1}; + ref_map_axes_minus1_0 = {1, 0}, ref_map_inv_axes_minus1_0 = {1, 0}; + ref_map_axes_0_1 = {0, 1}, ref_map_inv_axes_0_1 = {0, 1}; + ref_map_axes_1_0 = {1, 0}, ref_map_inv_axes_1_0 = {1, 0}; + } + + // Forward mapping + EXPECT_TRUE( map_axis_0 == ref_map_axis_0 ); + EXPECT_TRUE( map_axis_1 == ref_map_axis_1 ); + EXPECT_TRUE( map_axis_minus1 == ref_map_axis_minus1 ); + EXPECT_TRUE( map_axes_0 == ref_map_axes_0 ); + EXPECT_TRUE( map_axes_1 == ref_map_axes_1 ); + EXPECT_TRUE( map_axes_minus1 == ref_map_axes_minus1 ); + EXPECT_TRUE( map_axes_0_minus1 == ref_map_axes_0_minus1 ); + EXPECT_TRUE( map_axes_minus1_0 == ref_map_axes_minus1_0 ); + EXPECT_TRUE( map_axes_0_1 == ref_map_axes_0_1 ); + EXPECT_TRUE( map_axes_1_0 == ref_map_axes_1_0 ); + + // Inverse mapping + EXPECT_TRUE( map_inv_axis_0 == ref_map_inv_axis_0 ); + EXPECT_TRUE( map_inv_axis_1 == ref_map_inv_axis_1 ); + EXPECT_TRUE( map_inv_axis_minus1 == ref_map_inv_axis_minus1 ); + EXPECT_TRUE( map_inv_axes_0 == ref_map_inv_axes_0 ); + EXPECT_TRUE( map_inv_axes_1 == ref_map_inv_axes_1 ); + EXPECT_TRUE( map_inv_axes_minus1 == ref_map_inv_axes_minus1 ); + EXPECT_TRUE( map_inv_axes_0_minus1 == ref_map_inv_axes_0_minus1 ); + EXPECT_TRUE( map_inv_axes_minus1_0 == ref_map_inv_axes_minus1_0 ); + EXPECT_TRUE( map_inv_axes_0_1 == ref_map_inv_axes_0_1 ); + EXPECT_TRUE( map_inv_axes_1_0 == ref_map_inv_axes_1_0 ); +} - EXPECT_TRUE( map_axis == ref_map_axis ); - EXPECT_TRUE( map_axes == ref_map_axes ); - EXPECT_TRUE( map_inv_axis == ref_map_axis ); - EXPECT_TRUE( map_inv_axes == ref_map_axes ); +TEST(MapAxes, 2DLeftView) { + test_map_axes2d(); } -TEST(MapAxes, 2DLeft) { - const int n0 = 3, n1 = 5; - LeftView2D x("x", n0, n1); - - auto [map_axis_0, map_inv_axis_0] = KokkosFFT::get_map_axes(x, /*axis=*/0); - auto [map_axis_1, map_inv_axis_1] = KokkosFFT::get_map_axes(x, /*axis=*/1); - auto [map_axis_minus1, map_inv_axis_minus1] = KokkosFFT::get_map_axes(x, /*axis=*/-1); - auto [map_axes_0, map_inv_axes_0] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<1>({0})); - auto [map_axes_1, map_inv_axes_1] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<1>({1})); - auto [map_axes_minus1, map_inv_axes_minus1] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<1>({-1})); - auto [map_axes_0_minus1, map_inv_axes_0_minus1] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<2>({0, -1})); - auto [map_axes_minus1_0, map_inv_axes_minus1_0] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<2>({-1, 0})); - auto [map_axes_0_1, map_inv_axes_0_1] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<2>({0, 1})); - auto [map_axes_1_0, map_inv_axes_1_0] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<2>({1, 0})); - - axes_type<2> ref_map_axis_0 = {0, 1}, ref_map_inv_axis_0 = {0, 1}; - axes_type<2> ref_map_axis_1 = {1, 0}, ref_map_inv_axis_1 = {1, 0}; - axes_type<2> ref_map_axis_minus1 = {1, 0}, ref_map_inv_axis_minus1 = {1, 0}; - axes_type<2> ref_map_axes_0 = {0, 1}, ref_map_inv_axes_0 = {0, 1}; - axes_type<2> ref_map_axes_1 = {1, 0}, ref_map_inv_axes_1 = {1, 0}; - axes_type<2> ref_map_axes_minus1 = {1, 0}, ref_map_inv_axes_minus1 = {1, 0}; - - axes_type<2> ref_map_axes_0_minus1 = {1, 0}, ref_map_inv_axes_0_minus1 = {1, 0}; - axes_type<2> ref_map_axes_minus1_0 = {0, 1}, ref_map_inv_axes_minus1_0 = {0, 1}; - axes_type<2> ref_map_axes_0_1 = {1, 0}, ref_map_inv_axes_0_1 = {1, 0}; - axes_type<2> ref_map_axes_1_0 = {0, 1}, ref_map_inv_axes_1_0 = {0, 1}; - - // Forward mapping - EXPECT_TRUE( map_axis_0 == ref_map_axis_0 ); - EXPECT_TRUE( map_axis_1 == ref_map_axis_1 ); - EXPECT_TRUE( map_axis_minus1 == ref_map_axis_minus1 ); - EXPECT_TRUE( map_axes_0 == ref_map_axes_0 ); - EXPECT_TRUE( map_axes_1 == ref_map_axes_1 ); - EXPECT_TRUE( map_axes_minus1 == ref_map_axes_minus1 ); - EXPECT_TRUE( map_axes_0_minus1 == ref_map_axes_0_minus1 ); - EXPECT_TRUE( map_axes_minus1_0 == ref_map_axes_minus1_0 ); - EXPECT_TRUE( map_axes_0_1 == ref_map_axes_0_1 ); - EXPECT_TRUE( map_axes_1_0 == ref_map_axes_1_0 ); - - // Inverse mapping - EXPECT_TRUE( map_inv_axis_0 == ref_map_inv_axis_0 ); - EXPECT_TRUE( map_inv_axis_1 == ref_map_inv_axis_1 ); - EXPECT_TRUE( map_inv_axis_minus1 == ref_map_inv_axis_minus1 ); - EXPECT_TRUE( map_inv_axes_0 == ref_map_inv_axes_0 ); - EXPECT_TRUE( map_inv_axes_1 == ref_map_inv_axes_1 ); - EXPECT_TRUE( map_inv_axes_minus1 == ref_map_inv_axes_minus1 ); - EXPECT_TRUE( map_inv_axes_0_minus1 == ref_map_inv_axes_0_minus1 ); - EXPECT_TRUE( map_inv_axes_minus1_0 == ref_map_inv_axes_minus1_0 ); - EXPECT_TRUE( map_inv_axes_0_1 == ref_map_inv_axes_0_1 ); - EXPECT_TRUE( map_inv_axes_1_0 == ref_map_inv_axes_1_0 ); +TEST(MapAxes, 2DRightView) { + test_map_axes2d(); } -TEST(MapAxes, 2DRight) { - const int n0 = 3, n1 = 5; - RightView2D x("x", n0, n1); - - auto [map_axis_0, map_inv_axis_0] = KokkosFFT::get_map_axes(x, /*axis=*/0); - auto [map_axis_1, map_inv_axis_1] = KokkosFFT::get_map_axes(x, /*axis=*/1); - auto [map_axis_minus1, map_inv_axis_minus1] = KokkosFFT::get_map_axes(x, /*axis=*/-1); - auto [map_axes_0, map_inv_axes_0] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<1>({0})); - auto [map_axes_1, map_inv_axes_1] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<1>({1})); - auto [map_axes_minus1, map_inv_axes_minus1] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<1>({-1})); - auto [map_axes_0_minus1, map_inv_axes_0_minus1] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<2>({0, -1})); - auto [map_axes_minus1_0, map_inv_axes_minus1_0] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<2>({-1, 0})); - auto [map_axes_0_1, map_inv_axes_0_1] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<2>({0, 1})); - auto [map_axes_1_0, map_inv_axes_1_0] = KokkosFFT::get_map_axes(x, /*axes=*/ axes_type<2>({1, 0})); - - axes_type<2> ref_map_axis_0 = {1, 0}, ref_map_inv_axis_0 = {1, 0}; - axes_type<2> ref_map_axis_1 = {0, 1}, ref_map_inv_axis_1 = {0, 1}; - axes_type<2> ref_map_axis_minus1 = {0, 1}, ref_map_inv_axis_minus1 = {0, 1}; - axes_type<2> ref_map_axes_0 = {1, 0}, ref_map_inv_axes_0 = {1, 0}; - axes_type<2> ref_map_axes_1 = {0, 1}, ref_map_inv_axes_1 = {0, 1}; - axes_type<2> ref_map_axes_minus1 = {0, 1}, ref_map_inv_axes_minus1 = {0, 1}; - - axes_type<2> ref_map_axes_0_minus1 = {0, 1}, ref_map_inv_axes_0_minus1 = {0, 1}; - axes_type<2> ref_map_axes_minus1_0 = {1, 0}, ref_map_inv_axes_minus1_0 = {1, 0}; - axes_type<2> ref_map_axes_0_1 = {0, 1}, ref_map_inv_axes_0_1 = {0, 1}; - axes_type<2> ref_map_axes_1_0 = {1, 0}, ref_map_inv_axes_1_0 = {1, 0}; - - // Forward mapping - EXPECT_TRUE( map_axis_0 == ref_map_axis_0 ); - EXPECT_TRUE( map_axis_1 == ref_map_axis_1 ); - EXPECT_TRUE( map_axis_minus1 == ref_map_axis_minus1 ); - EXPECT_TRUE( map_axes_0 == ref_map_axes_0 ); - EXPECT_TRUE( map_axes_1 == ref_map_axes_1 ); - EXPECT_TRUE( map_axes_minus1 == ref_map_axes_minus1 ); - EXPECT_TRUE( map_axes_0_minus1 == ref_map_axes_0_minus1 ); - EXPECT_TRUE( map_axes_minus1_0 == ref_map_axes_minus1_0 ); - EXPECT_TRUE( map_axes_0_1 == ref_map_axes_0_1 ); - EXPECT_TRUE( map_axes_1_0 == ref_map_axes_1_0 ); - - // Inverse mapping - EXPECT_TRUE( map_inv_axis_0 == ref_map_inv_axis_0 ); - EXPECT_TRUE( map_inv_axis_1 == ref_map_inv_axis_1 ); - EXPECT_TRUE( map_inv_axis_minus1 == ref_map_inv_axis_minus1 ); - EXPECT_TRUE( map_inv_axes_0 == ref_map_inv_axes_0 ); - EXPECT_TRUE( map_inv_axes_1 == ref_map_inv_axes_1 ); - EXPECT_TRUE( map_inv_axes_minus1 == ref_map_inv_axes_minus1 ); - EXPECT_TRUE( map_inv_axes_0_minus1 == ref_map_inv_axes_0_minus1 ); - EXPECT_TRUE( map_inv_axes_minus1_0 == ref_map_inv_axes_minus1_0 ); - EXPECT_TRUE( map_inv_axes_0_1 == ref_map_inv_axes_0_1 ); - EXPECT_TRUE( map_inv_axes_1_0 == ref_map_inv_axes_1_0 ); +template +void test_map_axes3d() { + const int n0 = 3, n1 = 5, n2 = 8; + using RealView3Dtype = Kokkos::View; + RealView3Dtype x("x", n0, n1, n2); + + auto [map_axis_0, map_inv_axis_0] = KokkosFFT::get_map_axes(x, 0); + auto [map_axis_1, map_inv_axis_1] = KokkosFFT::get_map_axes(x, 1); + auto [map_axis_2, map_inv_axis_2] = KokkosFFT::get_map_axes(x, 2); + auto [map_axes_0, map_inv_axes_0] = KokkosFFT::get_map_axes(x, axes_type<1>({0})); + auto [map_axes_1, map_inv_axes_1] = KokkosFFT::get_map_axes(x, axes_type<1>({1})); + auto [map_axes_2, map_inv_axes_2] = KokkosFFT::get_map_axes(x, axes_type<1>({2})); + + auto [map_axes_0_1, map_inv_axes_0_1] = KokkosFFT::get_map_axes(x, axes_type<2>({0, 1})); + auto [map_axes_0_2, map_inv_axes_0_2] = KokkosFFT::get_map_axes(x, axes_type<2>({0, 2})); + auto [map_axes_1_0, map_inv_axes_1_0] = KokkosFFT::get_map_axes(x, axes_type<2>({1, 0})); + auto [map_axes_1_2, map_inv_axes_1_2] = KokkosFFT::get_map_axes(x, axes_type<2>({1, 2})); + auto [map_axes_2_0, map_inv_axes_2_0] = KokkosFFT::get_map_axes(x, axes_type<2>({2, 0})); + auto [map_axes_2_1, map_inv_axes_2_1] = KokkosFFT::get_map_axes(x, axes_type<2>({2, 1})); + + auto [map_axes_0_1_2, map_inv_axes_0_1_2] = KokkosFFT::get_map_axes(x, axes_type<3>({0, 1, 2})); + auto [map_axes_0_2_1, map_inv_axes_0_2_1] = KokkosFFT::get_map_axes(x, axes_type<3>({0, 2, 1})); + + auto [map_axes_1_0_2, map_inv_axes_1_0_2] = KokkosFFT::get_map_axes(x, axes_type<3>({1, 0, 2})); + auto [map_axes_1_2_0, map_inv_axes_1_2_0] = KokkosFFT::get_map_axes(x, axes_type<3>({1, 2, 0})); + auto [map_axes_2_0_1, map_inv_axes_2_0_1] = KokkosFFT::get_map_axes(x, axes_type<3>({2, 0, 1})); + auto [map_axes_2_1_0, map_inv_axes_2_1_0] = KokkosFFT::get_map_axes(x, axes_type<3>({2, 1, 0})); + + axes_type<3> ref_map_axis_0, ref_map_inv_axis_0; + axes_type<3> ref_map_axis_1, ref_map_inv_axis_1; + axes_type<3> ref_map_axis_2, ref_map_inv_axis_2; + + axes_type<3> ref_map_axes_0, ref_map_inv_axes_0; + axes_type<3> ref_map_axes_1, ref_map_inv_axes_1; + axes_type<3> ref_map_axes_2, ref_map_inv_axes_2; + + axes_type<3> ref_map_axes_0_1, ref_map_inv_axes_0_1; + axes_type<3> ref_map_axes_0_2, ref_map_inv_axes_0_2; + axes_type<3> ref_map_axes_1_0, ref_map_inv_axes_1_0; + axes_type<3> ref_map_axes_1_2, ref_map_inv_axes_1_2; + axes_type<3> ref_map_axes_2_0, ref_map_inv_axes_2_0; + axes_type<3> ref_map_axes_2_1, ref_map_inv_axes_2_1; + + axes_type<3> ref_map_axes_0_1_2, ref_map_inv_axes_0_1_2; + axes_type<3> ref_map_axes_0_2_1, ref_map_inv_axes_0_2_1; + axes_type<3> ref_map_axes_1_0_2, ref_map_inv_axes_1_0_2; + axes_type<3> ref_map_axes_1_2_0, ref_map_inv_axes_1_2_0; + axes_type<3> ref_map_axes_2_0_1, ref_map_inv_axes_2_0_1; + axes_type<3> ref_map_axes_2_1_0, ref_map_inv_axes_2_1_0; + + if(std::is_same_v) { + // Layout Left + ref_map_axis_0 = {0, 1, 2}, ref_map_inv_axis_0 = {0, 1, 2}; + ref_map_axis_1 = {1, 0, 2}, ref_map_inv_axis_1 = {1, 0, 2}; + ref_map_axis_2 = {2, 0, 1}, ref_map_inv_axis_2 = {1, 2, 0}; + + ref_map_axes_0 = {0, 1, 2}, ref_map_inv_axes_0 = {0, 1, 2}; + ref_map_axes_1 = {1, 0, 2}, ref_map_inv_axes_1 = {1, 0, 2}; + ref_map_axes_2 = {2, 0, 1}, ref_map_inv_axes_2 = {1, 2, 0}; + + ref_map_axes_0_1 = {1, 0, 2}, ref_map_inv_axes_0_1 = {1, 0, 2}; + ref_map_axes_0_2 = {2, 0, 1}, ref_map_inv_axes_0_2 = {1, 2, 0}; + ref_map_axes_1_0 = {0, 1, 2}, ref_map_inv_axes_1_0 = {0, 1, 2}; + ref_map_axes_1_2 = {2, 1, 0}, ref_map_inv_axes_1_2 = {2, 1, 0}; + ref_map_axes_2_0 = {0, 2, 1}, ref_map_inv_axes_2_0 = {0, 2, 1}; + ref_map_axes_2_1 = {1, 2, 0}, ref_map_inv_axes_2_1 = {2, 0, 1}; + + ref_map_axes_0_1_2 = {2, 1, 0}, ref_map_inv_axes_0_1_2 = {2, 1, 0}; + ref_map_axes_0_2_1 = {1, 2, 0}, ref_map_inv_axes_0_2_1 = {2, 0, 1}; + ref_map_axes_1_0_2 = {2, 0, 1}, ref_map_inv_axes_1_0_2 = {1, 2, 0}; + ref_map_axes_1_2_0 = {0, 2, 1}, ref_map_inv_axes_1_2_0 = {0, 2, 1}; + ref_map_axes_2_0_1 = {1, 0, 2}, ref_map_inv_axes_2_0_1 = {1, 0, 2}; + ref_map_axes_2_1_0 = {0, 1, 2}, ref_map_inv_axes_2_1_0 = {0, 1, 2}; + } else { + // Layout Right + ref_map_axis_0 = {1, 2, 0}, ref_map_inv_axis_0 = {2, 0, 1}; + ref_map_axis_1 = {0, 2, 1}, ref_map_inv_axis_1 = {0, 2, 1}; + ref_map_axis_2 = {0, 1, 2}, ref_map_inv_axis_2 = {0, 1, 2}; + + ref_map_axes_0 = {1, 2, 0}, ref_map_inv_axes_0 = {2, 0, 1}; + ref_map_axes_1 = {0, 2, 1}, ref_map_inv_axes_1 = {0, 2, 1}; + ref_map_axes_2 = {0, 1, 2}, ref_map_inv_axes_2 = {0, 1, 2}; + + ref_map_axes_0_1 = {2, 0, 1}, ref_map_inv_axes_0_1 = {1, 2, 0}; + ref_map_axes_0_2 = {1, 0, 2}, ref_map_inv_axes_0_2 = {1, 0, 2}; + ref_map_axes_1_0 = {2, 1, 0}, ref_map_inv_axes_1_0 = {2, 1, 0}; + ref_map_axes_1_2 = {0, 1, 2}, ref_map_inv_axes_1_2 = {0, 1, 2}; + ref_map_axes_2_0 = {1, 2, 0}, ref_map_inv_axes_2_0 = {2, 0, 1}; + ref_map_axes_2_1 = {0, 2, 1}, ref_map_inv_axes_2_1 = {0, 2, 1}; + + ref_map_axes_0_1_2 = {0, 1, 2}, ref_map_inv_axes_0_1_2 = {0, 1, 2}; + ref_map_axes_0_2_1 = {0, 2, 1}, ref_map_inv_axes_0_2_1 = {0, 2, 1}; + ref_map_axes_1_0_2 = {1, 0, 2}, ref_map_inv_axes_1_0_2 = {1, 0, 2}; + ref_map_axes_1_2_0 = {1, 2, 0}, ref_map_inv_axes_1_2_0 = {2, 0, 1}; + ref_map_axes_2_0_1 = {2, 0, 1}, ref_map_inv_axes_2_0_1 = {1, 2, 0}; + ref_map_axes_2_1_0 = {2, 1, 0}, ref_map_inv_axes_2_1_0 = {2, 1, 0}; + } + + // Forward mapping + EXPECT_TRUE( map_axis_0 == ref_map_axis_0 ); + EXPECT_TRUE( map_axis_1 == ref_map_axis_1 ); + EXPECT_TRUE( map_axis_2 == ref_map_axis_2 ); + EXPECT_TRUE( map_axes_0 == ref_map_axes_0 ); + EXPECT_TRUE( map_axes_1 == ref_map_axes_1 ); + EXPECT_TRUE( map_axes_2 == ref_map_axes_2 ); + + EXPECT_TRUE( map_axes_0_1 == ref_map_axes_0_1 ); + EXPECT_TRUE( map_axes_0_2 == ref_map_axes_0_2 ); + EXPECT_TRUE( map_axes_1_0 == ref_map_axes_1_0 ); + EXPECT_TRUE( map_axes_1_2 == ref_map_axes_1_2 ); + EXPECT_TRUE( map_axes_2_0 == ref_map_axes_2_0 ); + EXPECT_TRUE( map_axes_2_1 == ref_map_axes_2_1 ); + + EXPECT_TRUE( map_axes_0_1_2 == ref_map_axes_0_1_2 ); + EXPECT_TRUE( map_axes_0_2_1 == ref_map_axes_0_2_1 ); + EXPECT_TRUE( map_axes_1_0_2 == ref_map_axes_1_0_2 ); + EXPECT_TRUE( map_axes_1_2_0 == ref_map_axes_1_2_0 ); + EXPECT_TRUE( map_axes_2_0_1 == ref_map_axes_2_0_1 ); + EXPECT_TRUE( map_axes_2_1_0 == ref_map_axes_2_1_0 ); + + // Inverse mapping + EXPECT_TRUE( map_inv_axis_0 == ref_map_inv_axis_0 ); + EXPECT_TRUE( map_inv_axis_1 == ref_map_inv_axis_1 ); + EXPECT_TRUE( map_inv_axis_2 == ref_map_inv_axis_2 ); + EXPECT_TRUE( map_inv_axes_0 == ref_map_inv_axes_0 ); + EXPECT_TRUE( map_inv_axes_1 == ref_map_inv_axes_1 ); + EXPECT_TRUE( map_inv_axes_2 == ref_map_inv_axes_2 ); + + EXPECT_TRUE( map_inv_axes_0_1 == ref_map_inv_axes_0_1 ); + EXPECT_TRUE( map_inv_axes_0_2 == ref_map_inv_axes_0_2 ); + EXPECT_TRUE( map_inv_axes_1_0 == ref_map_inv_axes_1_0 ); + EXPECT_TRUE( map_inv_axes_1_2 == ref_map_inv_axes_1_2 ); + EXPECT_TRUE( map_inv_axes_2_0 == ref_map_inv_axes_2_0 ); + EXPECT_TRUE( map_inv_axes_2_1 == ref_map_inv_axes_2_1 ); + + EXPECT_TRUE( map_inv_axes_0_1_2 == ref_map_inv_axes_0_1_2 ); + EXPECT_TRUE( map_inv_axes_0_2_1 == ref_map_inv_axes_0_2_1 ); + EXPECT_TRUE( map_inv_axes_1_0_2 == ref_map_inv_axes_1_0_2 ); + EXPECT_TRUE( map_inv_axes_1_2_0 == ref_map_inv_axes_1_2_0 ); + EXPECT_TRUE( map_inv_axes_2_0_1 == ref_map_inv_axes_2_0_1 ); + EXPECT_TRUE( map_inv_axes_2_1_0 == ref_map_inv_axes_2_1_0 ); } -TEST(MapAxes, 3DLeft) { - const int n0 = 3, n1 = 5, n2 = 8; - LeftView3D x("x", n0, n1, n2); - - auto [map_axis_0, map_inv_axis_0] = KokkosFFT::get_map_axes(x, 0); - auto [map_axis_1, map_inv_axis_1] = KokkosFFT::get_map_axes(x, 1); - auto [map_axis_2, map_inv_axis_2] = KokkosFFT::get_map_axes(x, 2); - auto [map_axes_0, map_inv_axes_0] = KokkosFFT::get_map_axes(x, axes_type<1>({0})); - auto [map_axes_1, map_inv_axes_1] = KokkosFFT::get_map_axes(x, axes_type<1>({1})); - auto [map_axes_2, map_inv_axes_2] = KokkosFFT::get_map_axes(x, axes_type<1>({2})); - - auto [map_axes_0_1, map_inv_axes_0_1] = KokkosFFT::get_map_axes(x, axes_type<2>({0, 1})); - auto [map_axes_0_2, map_inv_axes_0_2] = KokkosFFT::get_map_axes(x, axes_type<2>({0, 2})); - auto [map_axes_1_0, map_inv_axes_1_0] = KokkosFFT::get_map_axes(x, axes_type<2>({1, 0})); - auto [map_axes_1_2, map_inv_axes_1_2] = KokkosFFT::get_map_axes(x, axes_type<2>({1, 2})); - auto [map_axes_2_0, map_inv_axes_2_0] = KokkosFFT::get_map_axes(x, axes_type<2>({2, 0})); - auto [map_axes_2_1, map_inv_axes_2_1] = KokkosFFT::get_map_axes(x, axes_type<2>({2, 1})); - - auto [map_axes_0_1_2, map_inv_axes_0_1_2] = KokkosFFT::get_map_axes(x, axes_type<3>({0, 1, 2})); - auto [map_axes_0_2_1, map_inv_axes_0_2_1] = KokkosFFT::get_map_axes(x, axes_type<3>({0, 2, 1})); - - auto [map_axes_1_0_2, map_inv_axes_1_0_2] = KokkosFFT::get_map_axes(x, axes_type<3>({1, 0, 2})); - auto [map_axes_1_2_0, map_inv_axes_1_2_0] = KokkosFFT::get_map_axes(x, axes_type<3>({1, 2, 0})); - auto [map_axes_2_0_1, map_inv_axes_2_0_1] = KokkosFFT::get_map_axes(x, axes_type<3>({2, 0, 1})); - auto [map_axes_2_1_0, map_inv_axes_2_1_0] = KokkosFFT::get_map_axes(x, axes_type<3>({2, 1, 0})); - - axes_type<3> ref_map_axis_0({0, 1, 2}), ref_map_inv_axis_0({0, 1, 2}); - axes_type<3> ref_map_axis_1({1, 0, 2}), ref_map_inv_axis_1({1, 0, 2}); - axes_type<3> ref_map_axis_2({2, 0, 1}), ref_map_inv_axis_2({1, 2, 0}); - - axes_type<3> ref_map_axes_0({0, 1, 2}), ref_map_inv_axes_0({0, 1, 2}); - axes_type<3> ref_map_axes_1({1, 0, 2}), ref_map_inv_axes_1({1, 0, 2}); - axes_type<3> ref_map_axes_2({2, 0, 1}), ref_map_inv_axes_2({1, 2, 0}); - - axes_type<3> ref_map_axes_0_1({1, 0, 2}), ref_map_inv_axes_0_1({1, 0, 2}); - axes_type<3> ref_map_axes_0_2({2, 0, 1}), ref_map_inv_axes_0_2({1, 2, 0}); - axes_type<3> ref_map_axes_1_0({0, 1, 2}), ref_map_inv_axes_1_0({0, 1, 2}); - axes_type<3> ref_map_axes_1_2({2, 1, 0}), ref_map_inv_axes_1_2({2, 1, 0}); - axes_type<3> ref_map_axes_2_0({0, 2, 1}), ref_map_inv_axes_2_0({0, 2, 1}); - axes_type<3> ref_map_axes_2_1({1, 2, 0}), ref_map_inv_axes_2_1({2, 0, 1}); - - axes_type<3> ref_map_axes_0_1_2({2, 1, 0}), ref_map_inv_axes_0_1_2({2, 1, 0}); - axes_type<3> ref_map_axes_0_2_1({1, 2, 0}), ref_map_inv_axes_0_2_1({2, 0, 1}); - axes_type<3> ref_map_axes_1_0_2({2, 0, 1}), ref_map_inv_axes_1_0_2({1, 2, 0}); - axes_type<3> ref_map_axes_1_2_0({0, 2, 1}), ref_map_inv_axes_1_2_0({0, 2, 1}); - axes_type<3> ref_map_axes_2_0_1({1, 0, 2}), ref_map_inv_axes_2_0_1({1, 0, 2}); - axes_type<3> ref_map_axes_2_1_0({0, 1, 2}), ref_map_inv_axes_2_1_0({0, 1, 2}); - - // Forward mapping - EXPECT_TRUE( map_axis_0 == ref_map_axis_0 ); - EXPECT_TRUE( map_axis_1 == ref_map_axis_1 ); - EXPECT_TRUE( map_axis_2 == ref_map_axis_2 ); - EXPECT_TRUE( map_axes_0 == ref_map_axes_0 ); - EXPECT_TRUE( map_axes_1 == ref_map_axes_1 ); - EXPECT_TRUE( map_axes_2 == ref_map_axes_2 ); - - EXPECT_TRUE( map_axes_0_1 == ref_map_axes_0_1 ); - EXPECT_TRUE( map_axes_0_2 == ref_map_axes_0_2 ); - EXPECT_TRUE( map_axes_1_0 == ref_map_axes_1_0 ); - EXPECT_TRUE( map_axes_1_2 == ref_map_axes_1_2 ); - EXPECT_TRUE( map_axes_2_0 == ref_map_axes_2_0 ); - EXPECT_TRUE( map_axes_2_1 == ref_map_axes_2_1 ); - - EXPECT_TRUE( map_axes_0_1_2 == ref_map_axes_0_1_2 ); - EXPECT_TRUE( map_axes_0_2_1 == ref_map_axes_0_2_1 ); - EXPECT_TRUE( map_axes_1_0_2 == ref_map_axes_1_0_2 ); - EXPECT_TRUE( map_axes_1_2_0 == ref_map_axes_1_2_0 ); - EXPECT_TRUE( map_axes_2_1_0 == ref_map_axes_2_1_0 ); - - // Inverse mapping - EXPECT_TRUE( map_inv_axis_0 == ref_map_inv_axis_0 ); - EXPECT_TRUE( map_inv_axis_1 == ref_map_inv_axis_1 ); - EXPECT_TRUE( map_inv_axis_2 == ref_map_inv_axis_2 ); - EXPECT_TRUE( map_inv_axes_0 == ref_map_inv_axes_0 ); - EXPECT_TRUE( map_inv_axes_1 == ref_map_inv_axes_1 ); - EXPECT_TRUE( map_inv_axes_2 == ref_map_inv_axes_2 ); - - EXPECT_TRUE( map_inv_axes_0_1 == ref_map_inv_axes_0_1 ); - EXPECT_TRUE( map_inv_axes_0_2 == ref_map_inv_axes_0_2 ); - EXPECT_TRUE( map_inv_axes_1_0 == ref_map_inv_axes_1_0 ); - EXPECT_TRUE( map_inv_axes_1_2 == ref_map_inv_axes_1_2 ); - EXPECT_TRUE( map_inv_axes_2_0 == ref_map_inv_axes_2_0 ); - EXPECT_TRUE( map_inv_axes_2_1 == ref_map_inv_axes_2_1 ); - - EXPECT_TRUE( map_inv_axes_0_1_2 == ref_map_inv_axes_0_1_2 ); - EXPECT_TRUE( map_inv_axes_0_2_1 == ref_map_inv_axes_0_2_1 ); - EXPECT_TRUE( map_inv_axes_1_0_2 == ref_map_inv_axes_1_0_2 ); - EXPECT_TRUE( map_inv_axes_1_2_0 == ref_map_inv_axes_1_2_0 ); - EXPECT_TRUE( map_inv_axes_2_1_0 == ref_map_inv_axes_2_1_0 ); +TEST(MapAxes, 3DLeftView) { + test_map_axes3d(); } -TEST(MapAxes, 3DRight) { - const int n0 = 3, n1 = 5, n2 = 8; - RightView3D x("x", n0, n1, n2); - - auto [map_axis_0, map_inv_axis_0] = KokkosFFT::get_map_axes(x, 0); - auto [map_axis_1, map_inv_axis_1] = KokkosFFT::get_map_axes(x, 1); - auto [map_axis_2, map_inv_axis_2] = KokkosFFT::get_map_axes(x, 2); - auto [map_axes_0, map_inv_axes_0] = KokkosFFT::get_map_axes(x, axes_type<1>({0})); - auto [map_axes_1, map_inv_axes_1] = KokkosFFT::get_map_axes(x, axes_type<1>({1})); - auto [map_axes_2, map_inv_axes_2] = KokkosFFT::get_map_axes(x, axes_type<1>({2})); - - auto [map_axes_0_1, map_inv_axes_0_1] = KokkosFFT::get_map_axes(x, axes_type<2>({0, 1})); - auto [map_axes_0_2, map_inv_axes_0_2] = KokkosFFT::get_map_axes(x, axes_type<2>({0, 2})); - auto [map_axes_1_0, map_inv_axes_1_0] = KokkosFFT::get_map_axes(x, axes_type<2>({1, 0})); - auto [map_axes_1_2, map_inv_axes_1_2] = KokkosFFT::get_map_axes(x, axes_type<2>({1, 2})); - auto [map_axes_2_0, map_inv_axes_2_0] = KokkosFFT::get_map_axes(x, axes_type<2>({2, 0})); - auto [map_axes_2_1, map_inv_axes_2_1] = KokkosFFT::get_map_axes(x, axes_type<2>({2, 1})); - - auto [map_axes_0_1_2, map_inv_axes_0_1_2] = KokkosFFT::get_map_axes(x, axes_type<3>({0, 1, 2})); - auto [map_axes_0_2_1, map_inv_axes_0_2_1] = KokkosFFT::get_map_axes(x, axes_type<3>({0, 2, 1})); - - auto [map_axes_1_0_2, map_inv_axes_1_0_2] = KokkosFFT::get_map_axes(x, axes_type<3>({1, 0, 2})); - auto [map_axes_1_2_0, map_inv_axes_1_2_0] = KokkosFFT::get_map_axes(x, axes_type<3>({1, 2, 0})); - auto [map_axes_2_0_1, map_inv_axes_2_0_1] = KokkosFFT::get_map_axes(x, axes_type<3>({2, 0, 1})); - auto [map_axes_2_1_0, map_inv_axes_2_1_0] = KokkosFFT::get_map_axes(x, axes_type<3>({2, 1, 0})); - - axes_type<3> ref_map_axis_0({1, 2, 0}), ref_map_inv_axis_0({2, 0, 1}); - axes_type<3> ref_map_axis_1({0, 2, 1}), ref_map_inv_axis_1({0, 2, 1}); - axes_type<3> ref_map_axis_2({0, 1, 2}), ref_map_inv_axis_2({0, 1, 2}); - - axes_type<3> ref_map_axes_0({1, 2, 0}), ref_map_inv_axes_0({2, 0, 1}); - axes_type<3> ref_map_axes_1({0, 2, 1}), ref_map_inv_axes_1({0, 2, 1}); - axes_type<3> ref_map_axes_2({0, 1, 2}), ref_map_inv_axes_2({0, 1, 2}); - - axes_type<3> ref_map_axes_0_1({2, 0, 1}), ref_map_inv_axes_0_1({1, 2, 0}); - axes_type<3> ref_map_axes_0_2({1, 0, 2}), ref_map_inv_axes_0_2({1, 0, 2}); - axes_type<3> ref_map_axes_1_0({2, 1, 0}), ref_map_inv_axes_1_0({2, 1, 0}); - axes_type<3> ref_map_axes_1_2({0, 1, 2}), ref_map_inv_axes_1_2({0, 1, 2}); - axes_type<3> ref_map_axes_2_0({1, 2, 0}), ref_map_inv_axes_2_0({2, 0, 1}); - axes_type<3> ref_map_axes_2_1({0, 2, 1}), ref_map_inv_axes_2_1({0, 2, 1}); - - axes_type<3> ref_map_axes_0_1_2({0, 1, 2}), ref_map_inv_axes_0_1_2({0, 1, 2}); - axes_type<3> ref_map_axes_0_2_1({0, 2, 1}), ref_map_inv_axes_0_2_1({0, 2, 1}); - axes_type<3> ref_map_axes_1_0_2({1, 0, 2}), ref_map_inv_axes_1_0_2({1, 0, 2}); - axes_type<3> ref_map_axes_1_2_0({1, 2, 0}), ref_map_inv_axes_1_2_0({2, 0, 1}); - axes_type<3> ref_map_axes_2_0_1({2, 0, 1}), ref_map_inv_axes_2_0_1({1, 2, 0}); - axes_type<3> ref_map_axes_2_1_0({2, 1, 0}), ref_map_inv_axes_2_1_0({2, 1, 0}); - - // Forward mapping - EXPECT_TRUE( map_axis_0 == ref_map_axis_0 ); - EXPECT_TRUE( map_axis_1 == ref_map_axis_1 ); - EXPECT_TRUE( map_axis_2 == ref_map_axis_2 ); - EXPECT_TRUE( map_axes_0 == ref_map_axes_0 ); - EXPECT_TRUE( map_axes_1 == ref_map_axes_1 ); - EXPECT_TRUE( map_axes_2 == ref_map_axes_2 ); - - EXPECT_TRUE( map_axes_0_1 == ref_map_axes_0_1 ); - EXPECT_TRUE( map_axes_0_2 == ref_map_axes_0_2 ); - EXPECT_TRUE( map_axes_1_0 == ref_map_axes_1_0 ); - EXPECT_TRUE( map_axes_1_2 == ref_map_axes_1_2 ); - EXPECT_TRUE( map_axes_2_0 == ref_map_axes_2_0 ); - EXPECT_TRUE( map_axes_2_1 == ref_map_axes_2_1 ); - - EXPECT_TRUE( map_axes_0_1_2 == ref_map_axes_0_1_2 ); - EXPECT_TRUE( map_axes_0_2_1 == ref_map_axes_0_2_1 ); - EXPECT_TRUE( map_axes_1_0_2 == ref_map_axes_1_0_2 ); - EXPECT_TRUE( map_axes_1_2_0 == ref_map_axes_1_2_0 ); - EXPECT_TRUE( map_axes_2_1_0 == ref_map_axes_2_1_0 ); - - // Inverse mapping - EXPECT_TRUE( map_inv_axis_0 == ref_map_inv_axis_0 ); - EXPECT_TRUE( map_inv_axis_1 == ref_map_inv_axis_1 ); - EXPECT_TRUE( map_inv_axis_2 == ref_map_inv_axis_2 ); - EXPECT_TRUE( map_inv_axes_0 == ref_map_inv_axes_0 ); - EXPECT_TRUE( map_inv_axes_1 == ref_map_inv_axes_1 ); - EXPECT_TRUE( map_inv_axes_2 == ref_map_inv_axes_2 ); - - EXPECT_TRUE( map_inv_axes_0_1 == ref_map_inv_axes_0_1 ); - EXPECT_TRUE( map_inv_axes_0_2 == ref_map_inv_axes_0_2 ); - EXPECT_TRUE( map_inv_axes_1_0 == ref_map_inv_axes_1_0 ); - EXPECT_TRUE( map_inv_axes_1_2 == ref_map_inv_axes_1_2 ); - EXPECT_TRUE( map_inv_axes_2_0 == ref_map_inv_axes_2_0 ); - EXPECT_TRUE( map_inv_axes_2_1 == ref_map_inv_axes_2_1 ); - - EXPECT_TRUE( map_inv_axes_0_1_2 == ref_map_inv_axes_0_1_2 ); - EXPECT_TRUE( map_inv_axes_0_2_1 == ref_map_inv_axes_0_2_1 ); - EXPECT_TRUE( map_inv_axes_1_0_2 == ref_map_inv_axes_1_0_2 ); - EXPECT_TRUE( map_inv_axes_1_2_0 == ref_map_inv_axes_1_2_0 ); - EXPECT_TRUE( map_inv_axes_2_1_0 == ref_map_inv_axes_2_1_0 ); +TEST(MapAxes, 3DRightView) { + test_map_axes3d(); } -TEST(Transpose, 1D) { +template +void test_transpose_1d() { // When transpose is not necessary, we should not call transpose method - const int len = 30; - View1D x("x", len), ref("ref", len); - View1D xt; + const int len = 30; + View1D x("x", len), ref("ref", len); + View1D xt; + + Kokkos::Random_XorShift64_Pool<> random_pool(12345); + Kokkos::fill_random(x, random_pool, 1.0); - Kokkos::Random_XorShift64_Pool<> random_pool(12345); - Kokkos::fill_random(x, random_pool, 1.0); + Kokkos::deep_copy(ref, x); - Kokkos::deep_copy(ref, x); + Kokkos::fence(); - Kokkos::fence(); + EXPECT_THROW( + KokkosFFT::transpose(x, xt, axes_type<1>({0})), + std::runtime_error + ); +} - EXPECT_THROW( - KokkosFFT::transpose(x, xt, axes_type<1>({0})), - std::runtime_error - ); +TEST(Transpose, 1DLeftView) { + test_transpose_1d(); } -TEST(Transpose, 2DLeft) { - const int n0 = 3, n1 = 5; - LeftView2D x("x", n0, n1), ref_axis0("ref_axis0", n0, n1); - LeftView2D xt_axis0, xt_axis1; // views are allocated internally - LeftView2D ref_axis1("ref_axis1", n1, n0); +TEST(Transpose, 1DRightView) { + test_transpose_1d(); +} - Kokkos::Random_XorShift64_Pool<> random_pool(12345); - Kokkos::fill_random(x, random_pool, 1.0); +TEST(Transpose, 2DLeftView) { + const int n0 = 3, n1 = 5; + LeftView2D x("x", n0, n1); + LeftView2D xt_axis0, xt_axis1; // views are allocated internally + LeftView2D ref_axis1("ref_axis1", n1, n0); - Kokkos::deep_copy(ref_axis0, x); + Kokkos::Random_XorShift64_Pool<> random_pool(12345); + Kokkos::fill_random(x, random_pool, 1.0); - // Transposed views - auto h_x = Kokkos::create_mirror_view(x); - auto h_ref_axis1 = Kokkos::create_mirror_view(ref_axis1); - Kokkos::deep_copy(h_x, x); + // Transposed views + auto h_x = Kokkos::create_mirror_view(x); + auto h_ref_axis1 = Kokkos::create_mirror_view(ref_axis1); + Kokkos::deep_copy(h_x, x); - for(int i0=0; i0({0, 1})), // xt is identical to x - std::runtime_error - ); + EXPECT_THROW( + KokkosFFT::transpose(x, xt_axis0, axes_type<2>({0, 1})), // xt is identical to x + std::runtime_error + ); - KokkosFFT::transpose(x, xt_axis1, axes_type<2>({1, 0})); // xt is the transpose of x - EXPECT_TRUE( allclose(xt_axis1, ref_axis1, 1.e-5, 1.e-12) ); + KokkosFFT::transpose(x, xt_axis1, axes_type<2>({1, 0})); // xt is the transpose of x + EXPECT_TRUE( allclose(xt_axis1, ref_axis1, 1.e-5, 1.e-12) ); } -TEST(Transpose, 2DRight) { - const int n0 = 3, n1 = 5; - RightView2D x("x", n0, n1), ref_axis0("ref_axis0", n1, n0); - RightView2D xt_axis0, xt_axis1; // views are allocated internally - RightView2D ref_axis1("ref_axis1", n0, n1); +TEST(Transpose, 2DRightView) { + const int n0 = 3, n1 = 5; + RightView2D x("x", n0, n1), ref_axis0("ref_axis0", n1, n0); + RightView2D xt_axis0, xt_axis1; // views are allocated internally - Kokkos::Random_XorShift64_Pool<> random_pool(12345); - Kokkos::fill_random(x, random_pool, 1.0); + Kokkos::Random_XorShift64_Pool<> random_pool(12345); + Kokkos::fill_random(x, random_pool, 1.0); - // Identical to x - Kokkos::deep_copy(ref_axis1, x); + // Transposed views + auto h_x = Kokkos::create_mirror_view(x); + auto h_ref_axis0 = Kokkos::create_mirror_view(ref_axis0); + Kokkos::deep_copy(h_x, x); - // Transposed views - auto h_x = Kokkos::create_mirror_view(x); - auto h_ref_axis0 = Kokkos::create_mirror_view(ref_axis0); - Kokkos::deep_copy(h_x, x); - - for(int i0=0; i0({1, 0})); // xt is the transpose of x - EXPECT_TRUE( allclose(xt_axis0, ref_axis0, 1.e-5, 1.e-12) ); + KokkosFFT::transpose(x, xt_axis0, axes_type<2>({1, 0})); // xt is the transpose of x + EXPECT_TRUE( allclose(xt_axis0, ref_axis0, 1.e-5, 1.e-12) ); - EXPECT_THROW( - KokkosFFT::transpose(x, xt_axis1, axes_type<2>({0, 1})), // xt is identical to x - std::runtime_error - ); + EXPECT_THROW( + KokkosFFT::transpose(x, xt_axis1, axes_type<2>({0, 1})), // xt is identical to x + std::runtime_error + ); } -TEST(Transpose, 3DLeft) { - const int n0 = 3, n1 = 5, n2 = 8; - LeftView3D x("x", n0, n1, n2); - LeftView3D xt_axis012, xt_axis021, xt_axis102, xt_axis120, xt_axis201, xt_axis210; // views are allocated internally - LeftView3D ref_axis012("ref_axis012", n0, n1, n2), ref_axis021("ref_axis021", n0, n2, n1), ref_axis102("ref_axis102", n1, n0, n2); - LeftView3D ref_axis120("ref_axis120", n1, n2, n0), ref_axis201("ref_axis201", n2, n0, n1), ref_axis210("ref_axis210", n2, n1, n0); - - Kokkos::Random_XorShift64_Pool<> random_pool(12345); - Kokkos::fill_random(x, random_pool, 1.0); - - // Transposed views - auto h_x = Kokkos::create_mirror_view(x); - auto h_ref_axis021 = Kokkos::create_mirror_view(ref_axis021); - auto h_ref_axis102 = Kokkos::create_mirror_view(ref_axis102); - auto h_ref_axis120 = Kokkos::create_mirror_view(ref_axis120); - auto h_ref_axis201 = Kokkos::create_mirror_view(ref_axis201); - auto h_ref_axis210 = Kokkos::create_mirror_view(ref_axis210); - - Kokkos::deep_copy(h_x, x); - - for(int i0=0; i0 x("x", n0, n1, n2); + LeftView3D xt_axis012, xt_axis021, xt_axis102, xt_axis120, xt_axis201, xt_axis210; // views are allocated internally + LeftView3D ref_axis021("ref_axis021", n0, n2, n1), ref_axis102("ref_axis102", n1, n0, n2); + LeftView3D ref_axis120("ref_axis120", n1, n2, n0), ref_axis201("ref_axis201", n2, n0, n1), ref_axis210("ref_axis210", n2, n1, n0); + + Kokkos::Random_XorShift64_Pool<> random_pool(12345); + Kokkos::fill_random(x, random_pool, 1.0); + + // Transposed views + auto h_x = Kokkos::create_mirror_view(x); + auto h_ref_axis021 = Kokkos::create_mirror_view(ref_axis021); + auto h_ref_axis102 = Kokkos::create_mirror_view(ref_axis102); + auto h_ref_axis120 = Kokkos::create_mirror_view(ref_axis120); + auto h_ref_axis201 = Kokkos::create_mirror_view(ref_axis201); + auto h_ref_axis210 = Kokkos::create_mirror_view(ref_axis210); + + Kokkos::deep_copy(h_x, x); + + for(int i0=0; i0({0, 1, 2})), // xt is identical to x - std::runtime_error - ); + EXPECT_THROW( + KokkosFFT::transpose(x, xt_axis012, axes_type<3>({0, 1, 2})), // xt is identical to x + std::runtime_error + ); - KokkosFFT::transpose(x, xt_axis021, axes_type<3>({0, 2, 1})); // xt is the transpose of x - EXPECT_TRUE( allclose(xt_axis021, ref_axis021, 1.e-5, 1.e-12) ); + KokkosFFT::transpose(x, xt_axis021, axes_type<3>({0, 2, 1})); // xt is the transpose of x + EXPECT_TRUE( allclose(xt_axis021, ref_axis021, 1.e-5, 1.e-12) ); - KokkosFFT::transpose(x, xt_axis102, axes_type<3>({1, 0, 2})); // xt is the transpose of x - EXPECT_TRUE( allclose(xt_axis102, ref_axis102, 1.e-5, 1.e-12) ); + KokkosFFT::transpose(x, xt_axis102, axes_type<3>({1, 0, 2})); // xt is the transpose of x + EXPECT_TRUE( allclose(xt_axis102, ref_axis102, 1.e-5, 1.e-12) ); - KokkosFFT::transpose(x, xt_axis120, axes_type<3>({1, 2, 0})); // xt is the transpose of x - EXPECT_TRUE( allclose(xt_axis120, ref_axis120, 1.e-5, 1.e-12) ); + KokkosFFT::transpose(x, xt_axis120, axes_type<3>({1, 2, 0})); // xt is the transpose of x + EXPECT_TRUE( allclose(xt_axis120, ref_axis120, 1.e-5, 1.e-12) ); - KokkosFFT::transpose(x, xt_axis201, axes_type<3>({2, 0, 1})); // xt is the transpose of x - EXPECT_TRUE( allclose(xt_axis201, ref_axis201, 1.e-5, 1.e-12) ); + KokkosFFT::transpose(x, xt_axis201, axes_type<3>({2, 0, 1})); // xt is the transpose of x + EXPECT_TRUE( allclose(xt_axis201, ref_axis201, 1.e-5, 1.e-12) ); - KokkosFFT::transpose(x, xt_axis210, axes_type<3>({2, 1, 0})); // xt is the transpose of x - EXPECT_TRUE( allclose(xt_axis210, ref_axis210, 1.e-5, 1.e-12) ); + KokkosFFT::transpose(x, xt_axis210, axes_type<3>({2, 1, 0})); // xt is the transpose of x + EXPECT_TRUE( allclose(xt_axis210, ref_axis210, 1.e-5, 1.e-12) ); } -TEST(Transpose, 3DRight) { - const int n0 = 3, n1 = 5, n2 = 8; - RightView3D x("x", n0, n1, n2); - RightView3D xt_axis012, xt_axis021, xt_axis102, xt_axis120, xt_axis201, xt_axis210; // views are allocated internally - RightView3D ref_axis012("ref_axis012", n0, n1, n2), ref_axis021("ref_axis021", n0, n2, n1), ref_axis102("ref_axis102", n1, n0, n2); - RightView3D ref_axis120("ref_axis120", n1, n2, n0), ref_axis201("ref_axis201", n2, n0, n1), ref_axis210("ref_axis210", n2, n1, n0); - - Kokkos::Random_XorShift64_Pool<> random_pool(12345); - Kokkos::fill_random(x, random_pool, 1.0); - - // Transposed views - auto h_x = Kokkos::create_mirror_view(x); - auto h_ref_axis021 = Kokkos::create_mirror_view(ref_axis021); - auto h_ref_axis102 = Kokkos::create_mirror_view(ref_axis102); - auto h_ref_axis120 = Kokkos::create_mirror_view(ref_axis120); - auto h_ref_axis201 = Kokkos::create_mirror_view(ref_axis201); - auto h_ref_axis210 = Kokkos::create_mirror_view(ref_axis210); - - Kokkos::deep_copy(h_x, x); - - for(int i0=0; i0 x("x", n0, n1, n2); + RightView3D xt_axis012, xt_axis021, xt_axis102, xt_axis120, xt_axis201, xt_axis210; // views are allocated internally + RightView3D ref_axis021("ref_axis021", n0, n2, n1), ref_axis102("ref_axis102", n1, n0, n2); + RightView3D ref_axis120("ref_axis120", n1, n2, n0), ref_axis201("ref_axis201", n2, n0, n1), ref_axis210("ref_axis210", n2, n1, n0); + + Kokkos::Random_XorShift64_Pool<> random_pool(12345); + Kokkos::fill_random(x, random_pool, 1.0); + + // Transposed views + auto h_x = Kokkos::create_mirror_view(x); + auto h_ref_axis021 = Kokkos::create_mirror_view(ref_axis021); + auto h_ref_axis102 = Kokkos::create_mirror_view(ref_axis102); + auto h_ref_axis120 = Kokkos::create_mirror_view(ref_axis120); + auto h_ref_axis201 = Kokkos::create_mirror_view(ref_axis201); + auto h_ref_axis210 = Kokkos::create_mirror_view(ref_axis210); + + Kokkos::deep_copy(h_x, x); + + for(int i0=0; i0({0, 1, 2})), // xt is identical to x - std::runtime_error - ); + EXPECT_THROW( + KokkosFFT::transpose(x, xt_axis012, axes_type<3>({0, 1, 2})), // xt is identical to x + std::runtime_error + ); - KokkosFFT::transpose(x, xt_axis021, axes_type<3>({0, 2, 1})); // xt is the transpose of x - EXPECT_TRUE( allclose(xt_axis021, ref_axis021, 1.e-5, 1.e-12) ); + KokkosFFT::transpose(x, xt_axis021, axes_type<3>({0, 2, 1})); // xt is the transpose of x + EXPECT_TRUE( allclose(xt_axis021, ref_axis021, 1.e-5, 1.e-12) ); - KokkosFFT::transpose(x, xt_axis102, axes_type<3>({1, 0, 2})); // xt is the transpose of x - EXPECT_TRUE( allclose(xt_axis102, ref_axis102, 1.e-5, 1.e-12) ); + KokkosFFT::transpose(x, xt_axis102, axes_type<3>({1, 0, 2})); // xt is the transpose of x + EXPECT_TRUE( allclose(xt_axis102, ref_axis102, 1.e-5, 1.e-12) ); - KokkosFFT::transpose(x, xt_axis120, axes_type<3>({1, 2, 0})); // xt is the transpose of x - EXPECT_TRUE( allclose(xt_axis120, ref_axis120, 1.e-5, 1.e-12) ); + KokkosFFT::transpose(x, xt_axis120, axes_type<3>({1, 2, 0})); // xt is the transpose of x + EXPECT_TRUE( allclose(xt_axis120, ref_axis120, 1.e-5, 1.e-12) ); - KokkosFFT::transpose(x, xt_axis201, axes_type<3>({2, 0, 1})); // xt is the transpose of x - EXPECT_TRUE( allclose(xt_axis201, ref_axis201, 1.e-5, 1.e-12) ); + KokkosFFT::transpose(x, xt_axis201, axes_type<3>({2, 0, 1})); // xt is the transpose of x + EXPECT_TRUE( allclose(xt_axis201, ref_axis201, 1.e-5, 1.e-12) ); - KokkosFFT::transpose(x, xt_axis210, axes_type<3>({2, 1, 0})); // xt is the transpose of x - EXPECT_TRUE( allclose(xt_axis210, ref_axis210, 1.e-5, 1.e-12) ); -} + KokkosFFT::transpose(x, xt_axis210, axes_type<3>({2, 1, 0})); // xt is the transpose of x + EXPECT_TRUE( allclose(xt_axis210, ref_axis210, 1.e-5, 1.e-12) ); +} \ No newline at end of file diff --git a/common/unit_test/Test_Utils.cpp b/common/unit_test/Test_Utils.cpp index 5de89689..38dce978 100644 --- a/common/unit_test/Test_Utils.cpp +++ b/common/unit_test/Test_Utils.cpp @@ -2,9 +2,11 @@ #include "KokkosFFT_utils.hpp" #include "Test_Types.hpp" -TEST(ConvertNegativeAxis, 1D) { +template +void test_convert_negative_axes_1d() { const int len = 30; - View1D x("x", len); + using RealView1Dtype = Kokkos::View; + RealView1Dtype x("x", len); int converted_axis_0 = KokkosFFT::convert_negative_axis(x, /*axis=*/0); int converted_axis_minus1 = KokkosFFT::convert_negative_axis(x, /*axis=*/-1); @@ -16,33 +18,26 @@ TEST(ConvertNegativeAxis, 1D) { EXPECT_EQ( converted_axis_minus1, ref_converted_axis_minus1 ); } -TEST(ConvertNegativeAxis, 2DLeft) { - const int n0 = 3, n1 = 5; - LeftView2D x("x", n0, n1); - - int converted_axis_0 = KokkosFFT::convert_negative_axis(x, /*axis=*/0); - int converted_axis_1 = KokkosFFT::convert_negative_axis(x, /*axis=*/1); - int converted_axis_minus1 = KokkosFFT::convert_negative_axis(x, /*axis=*/-1); - - int ref_converted_axis_0 = 0; - int ref_converted_axis_1 = 1; - int ref_converted_axis_minus1 = 1; +TEST(ConvertNegativeAxis, 1DLeftView) { + test_convert_negative_axes_1d(); +} - EXPECT_EQ( converted_axis_0, ref_converted_axis_0 ); - EXPECT_EQ( converted_axis_1, ref_converted_axis_1 ); - EXPECT_EQ( converted_axis_minus1, ref_converted_axis_minus1 ); +TEST(ConvertNegativeAxis, 1DRightView) { + test_convert_negative_axes_1d(); } -TEST(ConvertNegativeAxis, 2DRight) { +template +void test_convert_negative_axes_2d() { const int n0 = 3, n1 = 5; - RightView2D x("x", n0, n1); + using RealView2Dtype = Kokkos::View; + RealView2Dtype x("x", n0, n1); - int converted_axis_0 = KokkosFFT::convert_negative_axis(x, /*axis=*/0); - int converted_axis_1 = KokkosFFT::convert_negative_axis(x, /*axis=*/1); + int converted_axis_0 = KokkosFFT::convert_negative_axis(x, /*axis=*/0); + int converted_axis_1 = KokkosFFT::convert_negative_axis(x, /*axis=*/1); int converted_axis_minus1 = KokkosFFT::convert_negative_axis(x, /*axis=*/-1); - int ref_converted_axis_0 = 0; - int ref_converted_axis_1 = 1; + int ref_converted_axis_0 = 0; + int ref_converted_axis_1 = 1; int ref_converted_axis_minus1 = 1; EXPECT_EQ( converted_axis_0, ref_converted_axis_0 ); @@ -50,19 +45,29 @@ TEST(ConvertNegativeAxis, 2DRight) { EXPECT_EQ( converted_axis_minus1, ref_converted_axis_minus1 ); } -TEST(ConvertNegativeAxis, 3DLeft) { +TEST(ConvertNegativeAxis, 2DLeftView) { + test_convert_negative_axes_2d(); +} + +TEST(ConvertNegativeAxis, 2DRightView) { + test_convert_negative_axes_2d(); +} + +template +void test_convert_negative_axes_3d() { const int n0 = 3, n1 = 5, n2 = 8; - LeftView3D x("x", n0, n1, n2); + using RealView3Dtype = Kokkos::View; + RealView3Dtype x("x", n0, n1, n2); - int converted_axis_0 = KokkosFFT::convert_negative_axis(x, /*axis=*/0); - int converted_axis_1 = KokkosFFT::convert_negative_axis(x, /*axis=*/1); - int converted_axis_2 = KokkosFFT::convert_negative_axis(x, /*axis=*/2); + int converted_axis_0 = KokkosFFT::convert_negative_axis(x, /*axis=*/0); + int converted_axis_1 = KokkosFFT::convert_negative_axis(x, /*axis=*/1); + int converted_axis_2 = KokkosFFT::convert_negative_axis(x, /*axis=*/2); int converted_axis_minus1 = KokkosFFT::convert_negative_axis(x, /*axis=*/-1); int converted_axis_minus2 = KokkosFFT::convert_negative_axis(x, /*axis=*/-2); - int ref_converted_axis_0 = 0; - int ref_converted_axis_1 = 1; - int ref_converted_axis_2 = 2; + int ref_converted_axis_0 = 0; + int ref_converted_axis_1 = 1; + int ref_converted_axis_2 = 2; int ref_converted_axis_minus1 = 2; int ref_converted_axis_minus2 = 1; @@ -73,27 +78,51 @@ TEST(ConvertNegativeAxis, 3DLeft) { EXPECT_EQ( converted_axis_minus2, ref_converted_axis_minus2 ); } -TEST(ConvertNegativeAxis, 3DRight) { - const int n0 = 3, n1 = 5, n2 = 8; - RightView3D x("x", n0, n1, n2); +TEST(ConvertNegativeAxis, 3DLeftView) { + test_convert_negative_axes_3d(); +} - int converted_axis_0 = KokkosFFT::convert_negative_axis(x, /*axis=*/0); - int converted_axis_1 = KokkosFFT::convert_negative_axis(x, /*axis=*/1); - int converted_axis_2 = KokkosFFT::convert_negative_axis(x, /*axis=*/2); +TEST(ConvertNegativeAxis, 3DRightView) { + test_convert_negative_axes_3d(); +} + +template +void test_convert_negative_axes_4d() { + const int n0 = 3, n1 = 5, n2 = 8, n3 = 13; + using RealView4Dtype = Kokkos::View; + RealView4Dtype x("x", n0, n1, n2, n3); + + int converted_axis_0 = KokkosFFT::convert_negative_axis(x, /*axis=*/0); + int converted_axis_1 = KokkosFFT::convert_negative_axis(x, /*axis=*/1); + int converted_axis_2 = KokkosFFT::convert_negative_axis(x, /*axis=*/2); + int converted_axis_3 = KokkosFFT::convert_negative_axis(x, /*axis=*/3); int converted_axis_minus1 = KokkosFFT::convert_negative_axis(x, /*axis=*/-1); int converted_axis_minus2 = KokkosFFT::convert_negative_axis(x, /*axis=*/-2); + int converted_axis_minus3 = KokkosFFT::convert_negative_axis(x, /*axis=*/-3); - int ref_converted_axis_0 = 0; - int ref_converted_axis_1 = 1; - int ref_converted_axis_2 = 2; - int ref_converted_axis_minus1 = 2; - int ref_converted_axis_minus2 = 1; + int ref_converted_axis_0 = 0; + int ref_converted_axis_1 = 1; + int ref_converted_axis_2 = 2; + int ref_converted_axis_3 = 3; + int ref_converted_axis_minus1 = 3; + int ref_converted_axis_minus2 = 2; + int ref_converted_axis_minus3 = 1; EXPECT_EQ( converted_axis_0, ref_converted_axis_0 ); EXPECT_EQ( converted_axis_1, ref_converted_axis_1 ); EXPECT_EQ( converted_axis_2, ref_converted_axis_2 ); + EXPECT_EQ( converted_axis_3, ref_converted_axis_3 ); EXPECT_EQ( converted_axis_minus1, ref_converted_axis_minus1 ); EXPECT_EQ( converted_axis_minus2, ref_converted_axis_minus2 ); + EXPECT_EQ( converted_axis_minus3, ref_converted_axis_minus3 ); +} + +TEST(ConvertNegativeAxis, 4DLeftView) { + test_convert_negative_axes_4d(); +} + +TEST(ConvertNegativeAxis, 4DRightView) { + test_convert_negative_axes_4d(); } TEST(IsTransposeNeeded, 1Dto3D) { @@ -122,11 +151,11 @@ TEST(IsTransposeNeeded, 1Dto3D) { TEST(GetIndex, Vectors) { std::vector v = {0, 1, 4, 2, 3}; - EXPECT_EQ( KokkosFFT::get_index(v, 0), 0); - EXPECT_EQ( KokkosFFT::get_index(v, 1), 1); - EXPECT_EQ( KokkosFFT::get_index(v, 2), 3); - EXPECT_EQ( KokkosFFT::get_index(v, 3), 4); - EXPECT_EQ( KokkosFFT::get_index(v, 4), 2); + EXPECT_EQ( KokkosFFT::get_index(v, 0), 0 ); + EXPECT_EQ( KokkosFFT::get_index(v, 1), 1 ); + EXPECT_EQ( KokkosFFT::get_index(v, 2), 3 ); + EXPECT_EQ( KokkosFFT::get_index(v, 3), 4 ); + EXPECT_EQ( KokkosFFT::get_index(v, 4), 2 ); EXPECT_THROW( KokkosFFT::get_index(v, -1), From f6f66acccdb504ede62a003a47373cee28d4f699 Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Mon, 11 Dec 2023 22:24:04 +0900 Subject: [PATCH 3/9] out_extents missing for R2C fftw plan --- fft/src/KokkosFFT_OpenMP_plans.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/fft/src/KokkosFFT_OpenMP_plans.hpp b/fft/src/KokkosFFT_OpenMP_plans.hpp index b31572cb..f3ebe088 100644 --- a/fft/src/KokkosFFT_OpenMP_plans.hpp +++ b/fft/src/KokkosFFT_OpenMP_plans.hpp @@ -57,6 +57,7 @@ namespace KokkosFFT { istride, idist, odata, + out_extents.data(), ostride, odist, FFTW_ESTIMATE From 2f9ebe92442014c5994a5c7a0d5b01090a93b331 Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Mon, 11 Dec 2023 22:24:50 +0900 Subject: [PATCH 4/9] Fix static assertions in KokkosFF_T_Plans.hpp --- fft/src/KokkosFFT_Plans.hpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/fft/src/KokkosFFT_Plans.hpp b/fft/src/KokkosFFT_Plans.hpp index 0b6f6f0b..32b3f0c0 100644 --- a/fft/src/KokkosFFT_Plans.hpp +++ b/fft/src/KokkosFFT_Plans.hpp @@ -20,7 +20,7 @@ #include "KokkosFFT_OpenMP_plans.hpp" #else using default_device = Kokkos::Serial; - #include "KokkosFFT_Serial_plans.hpp" + #include "KokkosFFT_OpenMP_plans.hpp" #endif namespace KokkosFFT { @@ -49,9 +49,9 @@ namespace KokkosFFT { // Available only for R2C or C2R // For C2C, direction should be given by an user static_assert(Kokkos::is_view::value, - "KokkosFFT::_create: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::_create: OutViewType is not a Kokkos::View."); + "KokkosFFT::Plan: InViewType is not a Kokkos::View."); + static_assert(Kokkos::is_view::value, + "KokkosFFT::Plan: OutViewType is not a Kokkos::View."); using in_value_type = typename InViewType::non_const_value_type; using out_value_type = typename OutViewType::non_const_value_type; @@ -72,9 +72,9 @@ namespace KokkosFFT { // Available only for R2C or C2R // For C2C, direction should be given by an user static_assert(Kokkos::is_view::value, - "KokkosFFT::_create: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::_create: OutViewType is not a Kokkos::View."); + "KokkosFFT::Plan: InViewType is not a Kokkos::View."); + static_assert(Kokkos::is_view::value, + "KokkosFFT::Plan: OutViewType is not a Kokkos::View."); using in_value_type = typename InViewType::non_const_value_type; using out_value_type = typename OutViewType::non_const_value_type; @@ -92,17 +92,32 @@ namespace KokkosFFT { } explicit Plan(InViewType& in, OutViewType& out, FFTDirectionType direction) : m_fft_size(1), m_is_transpose_needed(false) { + static_assert(Kokkos::is_view::value, + "KokkosFFT::Plan: InViewType is not a Kokkos::View."); + static_assert(Kokkos::is_view::value, + "KokkosFFT::Plan: OutViewType is not a Kokkos::View."); + /* Apply FFT over entire axes or along inner most directions */ m_fft_size = _create(m_plan, in, out, direction); } explicit Plan(InViewType& in, OutViewType& out, FFTDirectionType direction, int axis) : m_fft_size(1), m_is_transpose_needed(false) { + static_assert(Kokkos::is_view::value, + "KokkosFFT::Plan: InViewType is not a Kokkos::View."); + static_assert(Kokkos::is_view::value, + "KokkosFFT::Plan: OutViewType is not a Kokkos::View."); + std::tie(m_map, m_map_inv) = KokkosFFT::get_map_axes(in, axis); m_is_transpose_needed = KokkosFFT::is_transpose_needed(m_map); m_fft_size = _create(m_plan, in, out, direction, axis_type<1>{axis}); } explicit Plan(InViewType& in, OutViewType& out, FFTDirectionType direction, axis_type axes) : m_fft_size(1), m_is_transpose_needed(false) { + static_assert(Kokkos::is_view::value, + "KokkosFFT::Plan: InViewType is not a Kokkos::View."); + static_assert(Kokkos::is_view::value, + "KokkosFFT::Plan: OutViewType is not a Kokkos::View."); + std::tie(m_map, m_map_inv) = KokkosFFT::get_map_axes(in, axes); m_is_transpose_needed = KokkosFFT::is_transpose_needed(m_map); m_fft_size = _create(m_plan, in, out, direction, axes); From ba2bbd26ccf959cb7de6e6c6a426c066d1914c86 Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Mon, 11 Dec 2023 22:25:56 +0900 Subject: [PATCH 5/9] Suppress the interface to reuse the plans in KokkosFFT_Transform.hpp --- fft/src/KokkosFFT_Transform.hpp | 370 ++++---------------------------- 1 file changed, 38 insertions(+), 332 deletions(-) diff --git a/fft/src/KokkosFFT_Transform.hpp b/fft/src/KokkosFFT_Transform.hpp index 4b785cbb..73e7acf0 100644 --- a/fft/src/KokkosFFT_Transform.hpp +++ b/fft/src/KokkosFFT_Transform.hpp @@ -28,11 +28,11 @@ // 1D Transform namespace KokkosFFT { template - void _fft(PlanType& plan, const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, int axis=-1) { + void _fft(PlanType& plan, const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD) { static_assert(Kokkos::is_view::value, - "KokkosFFT::fft: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::fft: OutViewType is not a Kokkos::View."); + "KokkosFFT::_fft: InViewType is not a Kokkos::View."); + static_assert(Kokkos::is_view::value, + "KokkosFFT::_fft: OutViewType is not a Kokkos::View."); using in_value_type = typename InViewType::non_const_value_type; using out_value_type = typename OutViewType::non_const_value_type; @@ -45,11 +45,11 @@ namespace KokkosFFT { } template - void _ifft(PlanType& plan, const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, int axis=-1) { + void _ifft(PlanType& plan, const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD) { static_assert(Kokkos::is_view::value, - "KokkosFFT::ifft: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::ifft: OutViewType is not a Kokkos::View."); + "KokkosFFT::_ifft: InViewType is not a Kokkos::View."); + static_assert(Kokkos::is_view::value, + "KokkosFFT::_ifft: OutViewType is not a Kokkos::View."); using in_value_type = typename InViewType::non_const_value_type; using out_value_type = typename OutViewType::non_const_value_type; @@ -61,42 +61,6 @@ namespace KokkosFFT { normalize(out, KOKKOS_FFT_BACKWARD, norm, plan.fft_size()); } - template - void _rfft(PlanType& plan, const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, int axis=-1) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::rfft: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::rfft: OutViewType is not a Kokkos::View."); - - using in_value_type = typename InViewType::non_const_value_type; - using out_value_type = typename OutViewType::non_const_value_type; - - static_assert(std::is_floating_point::value, - "KokkosFFT::rfft: InViewType must be real"); - static_assert(is_complex::value, - "KokkosFFT::rfft: OutViewType must be complex"); - - _fft(plan, in, out, norm, axis); - } - - template - void _irfft(PlanType& plan, const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, int axis=-1) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::irfft: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::irfft: OutViewType is not a Kokkos::View."); - - using in_value_type = typename InViewType::non_const_value_type; - using out_value_type = typename OutViewType::non_const_value_type; - - static_assert(is_complex::value, - "KokkosFFT::irfft: InViewType must be complex"); - static_assert(std::is_floating_point::value, - "KokkosFFT::irfft: OutViewType must be real"); - - _ifft(plan, in, out, norm, axis); - } - template void fft(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, int axis=-1) { static_assert(Kokkos::is_view::value, @@ -112,12 +76,12 @@ namespace KokkosFFT { KokkosFFT::transpose(in, in_T, plan.map()); KokkosFFT::transpose(out, out_T, plan.map()); - _fft(plan, in_T, out_T, norm, axis); + _fft(plan, in_T, out_T, norm); KokkosFFT::transpose(out_T, out, plan.map_inv()); } else { - _fft(plan, in, out, norm, axis); + _fft(plan, in, out, norm); } } @@ -136,12 +100,12 @@ namespace KokkosFFT { KokkosFFT::transpose(in, in_T, plan.map()); KokkosFFT::transpose(out, out_T, plan.map()); - _ifft(plan, in_T, out_T, norm, axis); + _ifft(plan, in_T, out_T, norm); KokkosFFT::transpose(out_T, out, plan.map_inv()); } else { - _ifft(plan, in, out, norm, axis); + _ifft(plan, in, out, norm); } } @@ -149,7 +113,7 @@ namespace KokkosFFT { void rfft(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, int axis=-1) { static_assert(Kokkos::is_view::value, "KokkosFFT::rfft: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, + static_assert(Kokkos::is_view::value, "KokkosFFT::rfft: OutViewType is not a Kokkos::View."); using in_value_type = typename InViewType::non_const_value_type; @@ -160,28 +124,14 @@ namespace KokkosFFT { static_assert(is_complex::value, "KokkosFFT::rfft: OutViewType must be complex"); - Plan plan(in, out, KOKKOS_FFT_FORWARD, axis); - if(plan.is_transpose_needed()) { - InViewType in_T; - OutViewType out_T; - - KokkosFFT::transpose(in, in_T, plan.map()); - KokkosFFT::transpose(out, out_T, plan.map()); - - _rfft(plan, in_T, out_T, norm, axis); - - KokkosFFT::transpose(out_T, out, plan.map_inv()); - - } else { - _rfft(plan, in, out, norm, axis); - } + fft(in, out, norm, axis); } template void irfft(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, int axis=-1) { static_assert(Kokkos::is_view::value, "KokkosFFT::irfft: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, + static_assert(Kokkos::is_view::value, "KokkosFFT::irfft: OutViewType is not a Kokkos::View."); using in_value_type = typename InViewType::non_const_value_type; @@ -192,99 +142,13 @@ namespace KokkosFFT { static_assert(std::is_floating_point::value, "KokkosFFT::irfft: OutViewType must be real"); - Plan plan(in, out, KOKKOS_FFT_BACKWARD, axis); - if(plan.is_transpose_needed()) { - InViewType in_T; - OutViewType out_T; - - KokkosFFT::transpose(in, in_T, plan.map()); - KokkosFFT::transpose(out, out_T, plan.map()); - - _irfft(plan, in_T, out_T, norm, axis); - - KokkosFFT::transpose(out_T, out, plan.map_inv()); - - } else { - _irfft(plan, in, out, norm, axis); - } + ifft(in, out, norm, axis); } }; namespace KokkosFFT { - using axis2D_type = axis_type<2>; - - template - void _fft2(PlanType& plan, const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, axis2D_type axes={-2, -1}) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::fft2: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::fft2: OutViewType is not a Kokkos::View."); - - using in_value_type = typename InViewType::non_const_value_type; - using out_value_type = typename OutViewType::non_const_value_type; - - auto* idata = reinterpret_cast::type*>(in.data()); - auto* odata = reinterpret_cast::type*>(out.data()); - - _exec(plan.plan(), idata, odata, KOKKOS_FFT_FORWARD); - normalize(out, KOKKOS_FFT_FORWARD, norm, plan.fft_size()); - } - - template - void _ifft2(PlanType& plan, const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, axis2D_type axes={-2, -1}) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::ifft2: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::ifft2: OutViewType is not a Kokkos::View."); - - using in_value_type = typename InViewType::non_const_value_type; - using out_value_type = typename OutViewType::non_const_value_type; - - auto* idata = reinterpret_cast::type*>(in.data()); - auto* odata = reinterpret_cast::type*>(out.data()); - - _exec(plan.plan(), idata, odata, KOKKOS_FFT_BACKWARD); - normalize(out, KOKKOS_FFT_BACKWARD, norm, plan.fft_size()); - } - - template - void _rfft2(PlanType& plan, const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, axis2D_type axes={-2, -1}) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::rfft2: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::rfft2: OutViewType is not a Kokkos::View."); - - using in_value_type = typename InViewType::non_const_value_type; - using out_value_type = typename OutViewType::non_const_value_type; - - static_assert(std::is_floating_point::value, - "KokkosFFT::rfft2: InViewType must be real"); - static_assert(is_complex::value, - "KokkosFFT::rfft2: OutViewType must be complex"); - - _fft2(plan, in, out, norm, axes); - } - - template - void _irfft2(PlanType& plan, const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, axis2D_type axes={-2, -1}) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::irfft: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::irfft: OutViewType is not a Kokkos::View."); - - using in_value_type = typename InViewType::non_const_value_type; - using out_value_type = typename OutViewType::non_const_value_type; - - static_assert(is_complex::value, - "KokkosFFT::irfft: InViewType must be complex"); - static_assert(std::is_floating_point::value, - "KokkosFFT::irfft: OutViewType must be real"); - - _ifft2(plan, in, out, norm, axes); - } - template - void fft2(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, axis2D_type axes={-2, -1}) { + void fft2(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, axis_type<2> axes={-2, -1}) { static_assert(Kokkos::is_view::value, "KokkosFFT::fft2: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -298,16 +162,16 @@ namespace KokkosFFT { KokkosFFT::transpose(in, in_T, plan.map()); KokkosFFT::transpose(out, out_T, plan.map()); - _fft2(plan, in_T, out_T, norm, axes); + _fft(plan, in_T, out_T, norm); KokkosFFT::transpose(out_T, out, plan.map_inv()); } else { - _fft2(plan, in, out, norm, axes); + _fft(plan, in, out, norm); } } template - void ifft2(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, axis2D_type axes={-2, -1}) { + void ifft2(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, axis_type<2> axes={-2, -1}) { static_assert(Kokkos::is_view::value, "KokkosFFT::ifft2: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -321,16 +185,16 @@ namespace KokkosFFT { KokkosFFT::transpose(in, in_T, plan.map()); KokkosFFT::transpose(out, out_T, plan.map()); - _ifft2(plan, in_T, out_T, norm, axes); + _ifft(plan, in_T, out_T, norm); KokkosFFT::transpose(out_T, out, plan.map_inv()); } else { - _ifft2(plan, in, out, norm, axes); + _ifft(plan, in, out, norm); } } template - void rfft2(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, axis2D_type axes={-2, -1}) { + void rfft2(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, axis_type<2> axes={-2, -1}) { static_assert(Kokkos::is_view::value, "KokkosFFT::rfft2: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -344,24 +208,11 @@ namespace KokkosFFT { static_assert(is_complex::value, "KokkosFFT::rfft2: OutViewType must be complex"); - Plan plan(in, out, KOKKOS_FFT_FORWARD, axes); - if(plan.is_transpose_needed()) { - InViewType in_T; - OutViewType out_T; - - KokkosFFT::transpose(in, in_T, plan.map()); - KokkosFFT::transpose(out, out_T, plan.map()); - - _rfft2(plan, in_T, out_T, norm, axes); - - KokkosFFT::transpose(out_T, out, plan.map_inv()); - } else { - _rfft2(plan, in, out, norm, axes); - } + fft2(in, out, norm, axes); } template - void irfft2(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, axis2D_type axes={-2, -1}) { + void irfft2(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, axis_type<2> axes={-2, -1}) { static_assert(Kokkos::is_view::value, "KokkosFFT::irfft2: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -375,94 +226,11 @@ namespace KokkosFFT { static_assert(std::is_floating_point::value, "KokkosFFT::irfft2: OutViewType must be real"); - Plan plan(in, out, KOKKOS_FFT_BACKWARD, axes); - if(plan.is_transpose_needed()) { - InViewType in_T; - OutViewType out_T; - - KokkosFFT::transpose(in, in_T, plan.map()); - KokkosFFT::transpose(out, out_T, plan.map()); - - _irfft2(plan, in_T, out_T, norm, axes); - - KokkosFFT::transpose(out_T, out, plan.map_inv()); - } else { - _irfft2(plan, in, out, norm, axes); - } + ifft2(in, out, norm, axes); } } namespace KokkosFFT { - template - void _fftn(PlanType& plan, const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::fftn: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::fftn: OutViewType is not a Kokkos::View."); - - using in_value_type = typename InViewType::non_const_value_type; - using out_value_type = typename OutViewType::non_const_value_type; - - auto* idata = reinterpret_cast::type*>(in.data()); - auto* odata = reinterpret_cast::type*>(out.data()); - - _exec(plan.plan(), idata, odata, KOKKOS_FFT_FORWARD); - normalize(out, KOKKOS_FFT_FORWARD, norm, plan.fft_size()); - } - - template - void _ifftn(PlanType& plan, const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::ifftn: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::ifftn: OutViewType is not a Kokkos::View."); - - using in_value_type = typename InViewType::non_const_value_type; - using out_value_type = typename OutViewType::non_const_value_type; - - auto* idata = reinterpret_cast::type*>(in.data()); - auto* odata = reinterpret_cast::type*>(out.data()); - - _exec(plan.plan(), idata, odata, KOKKOS_FFT_BACKWARD); - normalize(out, KOKKOS_FFT_BACKWARD, norm, plan.fft_size()); - } - - template - void _rfftn(PlanType& plan, const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::rfftn: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::rfftn: OutViewType is not a Kokkos::View."); - - using in_value_type = typename InViewType::non_const_value_type; - using out_value_type = typename OutViewType::non_const_value_type; - - static_assert(std::is_floating_point::value, - "KokkosFFT::rfftn: InViewType must be real"); - static_assert(is_complex::value, - "KokkosFFT::rfftn: OutViewType must be complex"); - - _fftn(plan, in, out, norm); - } - - template - void _irfftn(PlanType& plan, const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::irfftn: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::irfftn: OutViewType is not a Kokkos::View."); - - using in_value_type = typename InViewType::non_const_value_type; - using out_value_type = typename OutViewType::non_const_value_type; - - static_assert(is_complex::value, - "KokkosFFT::irfftn: InViewType must be complex"); - static_assert(std::is_floating_point::value, - "KokkosFFT::irfftn: OutViewType must be real"); - - _ifftn(plan, in, out, norm); - } - template void fftn(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD) { static_assert(Kokkos::is_view::value, @@ -483,11 +251,11 @@ namespace KokkosFFT { KokkosFFT::transpose(in, in_T, plan.map()); KokkosFFT::transpose(out, out_T, plan.map()); - _fftn(plan, in_T, out_T, norm); + _fft(plan, in_T, out_T, norm); KokkosFFT::transpose(out_T, out, plan.map_inv()); } else { - _fftn(plan, in, out, norm); + _fft(plan, in, out, norm); } } @@ -506,11 +274,11 @@ namespace KokkosFFT { KokkosFFT::transpose(in, in_T, plan.map()); KokkosFFT::transpose(out, out_T, plan.map()); - _fftn(plan, in_T, out_T, norm); + _fft(plan, in_T, out_T, norm); KokkosFFT::transpose(out_T, out, plan.map_inv()); } else { - _fftn(plan, in, out, norm); + _fft(plan, in, out, norm); } } @@ -534,11 +302,11 @@ namespace KokkosFFT { KokkosFFT::transpose(in, in_T, plan.map()); KokkosFFT::transpose(out, out_T, plan.map()); - _ifftn(plan, in_T, out_T, norm); + _ifft(plan, in_T, out_T, norm); KokkosFFT::transpose(out_T, out, plan.map_inv()); } else { - _ifftn(plan, in, out, norm); + _ifft(plan, in, out, norm); } } @@ -557,11 +325,11 @@ namespace KokkosFFT { KokkosFFT::transpose(in, in_T, plan.map()); KokkosFFT::transpose(out, out_T, plan.map()); - _ifftn(plan, in_T, out_T, norm); + _ifft(plan, in_T, out_T, norm); KokkosFFT::transpose(out_T, out, plan.map_inv()); } else { - _ifftn(plan, in, out, norm); + _ifft(plan, in, out, norm); } } @@ -580,25 +348,7 @@ namespace KokkosFFT { static_assert(is_complex::value, "KokkosFFT::rfftn: OutViewType must be complex"); - // Create a default sequence of axes {-rank, -(rank-1), ..., -1} - constexpr std::size_t rank = InViewType::rank(); - constexpr int start = -static_cast(rank); - axis_type axes = index_sequence(start); - - Plan plan(in, out, KOKKOS_FFT_FORWARD, axes); - if(plan.is_transpose_needed()) { - InViewType in_T; - OutViewType out_T; - - KokkosFFT::transpose(in, in_T, plan.map()); - KokkosFFT::transpose(out, out_T, plan.map()); - - _rfftn(plan, in_T, out_T, norm); - - KokkosFFT::transpose(out_T, out, plan.map_inv()); - } else { - _rfftn(plan, in, out, norm); - } + fftn(in, out, norm); } template @@ -616,20 +366,7 @@ namespace KokkosFFT { static_assert(is_complex::value, "KokkosFFT::rfftn: OutViewType must be complex"); - Plan plan(in, out, KOKKOS_FFT_FORWARD, axes); - if(plan.is_transpose_needed()) { - InViewType in_T; - OutViewType out_T; - - KokkosFFT::transpose(in, in_T, plan.map()); - KokkosFFT::transpose(out, out_T, plan.map()); - - _rfftn(plan, in_T, out_T, norm); - - KokkosFFT::transpose(out_T, out, plan.map_inv()); - } else { - _rfftn(plan, in, out, norm); - } + fftn(in, out, axes, norm); } template @@ -647,25 +384,7 @@ namespace KokkosFFT { static_assert(std::is_floating_point::value, "KokkosFFT::irfftn: OutViewType must be real"); - // Create a default sequence of axes {-rank, -(rank-1), ..., -1} - constexpr std::size_t rank = InViewType::rank(); - constexpr int start = -static_cast(rank); - axis_type axes = index_sequence(start); - - Plan plan(in, out, KOKKOS_FFT_BACKWARD, axes); - if(plan.is_transpose_needed()) { - InViewType in_T; - OutViewType out_T; - - KokkosFFT::transpose(in, in_T, plan.map()); - KokkosFFT::transpose(out, out_T, plan.map()); - - _irfftn(plan, in_T, out_T, norm); - - KokkosFFT::transpose(out_T, out, plan.map_inv()); - } else { - _irfftn(plan, in, out, norm); - } + ifftn(in, out, norm); } template @@ -683,20 +402,7 @@ namespace KokkosFFT { static_assert(std::is_floating_point::value, "KokkosFFT::irfftn: OutViewType must be real"); - Plan plan(in, out, KOKKOS_FFT_BACKWARD, axes); - if(plan.is_transpose_needed()) { - InViewType in_T; - OutViewType out_T; - - KokkosFFT::transpose(in, in_T, plan.map()); - KokkosFFT::transpose(out, out_T, plan.map()); - - _irfftn(plan, in_T, out_T, norm); - - KokkosFFT::transpose(out_T, out, plan.map_inv()); - } else { - _irfftn(plan, in, out, norm); - } + ifftn(in, out, axes, norm); } }; From 3b263b8b93956700b516f395b87658f597fa8bdd Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Mon, 11 Dec 2023 22:27:43 +0900 Subject: [PATCH 6/9] Increment atol for test_fftn_3dfft_3dview with fp32 since it fails on A100 --- fft/unit_test/Test_Transform.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/fft/unit_test/Test_Transform.cpp b/fft/unit_test/Test_Transform.cpp index f1249d0a..0cd368ba 100644 --- a/fft/unit_test/Test_Transform.cpp +++ b/fft/unit_test/Test_Transform.cpp @@ -698,7 +698,7 @@ void test_fftn_2dfft_2dview() { } template -void test_fftn_3dfft_3dview() { +void test_fftn_3dfft_3dview(T atol=1.0e-6) { const int n0 = 4, n1 = 6, n2 = 8; using ComplexView3DType = Kokkos::View***, LayoutType, execution_space>; @@ -725,10 +725,10 @@ void test_fftn_3dfft_3dview() { multiply(out_o, sqrt(static_cast(n0 * n1 * n2))); multiply(out_f, static_cast(n0 * n1 * n2)); - EXPECT_TRUE( allclose(out, out3, 1.e-5, 1.e-6) ); - EXPECT_TRUE( allclose(out_b, out3, 1.e-5, 1.e-6) ); - EXPECT_TRUE( allclose(out_o, out3, 1.e-5, 1.e-6) ); - EXPECT_TRUE( allclose(out_f, out3, 1.e-5, 1.e-6) ); + EXPECT_TRUE( allclose(out, out3, 1.e-5, atol) ); + EXPECT_TRUE( allclose(out_b, out3, 1.e-5, atol) ); + EXPECT_TRUE( allclose(out_o, out3, 1.e-5, atol) ); + EXPECT_TRUE( allclose(out_f, out3, 1.e-5, atol) ); // Same tests with specifying axes // np.fftn for 3D array is identical to np.fft(np.fft(np.fft(x, axis=2), axis=1), axis=0) @@ -742,10 +742,10 @@ void test_fftn_3dfft_3dview() { multiply(out_o, sqrt(static_cast(n0 * n1 * n2))); multiply(out_f, static_cast(n0 * n1 * n2)); - EXPECT_TRUE( allclose(out, out3, 1.e-5, 1.e-6) ); - EXPECT_TRUE( allclose(out_b, out3, 1.e-5, 1.e-6) ); - EXPECT_TRUE( allclose(out_o, out3, 1.e-5, 1.e-6) ); - EXPECT_TRUE( allclose(out_f, out3, 1.e-5, 1.e-6) ); + EXPECT_TRUE( allclose(out, out3, 1.e-5, atol) ); + EXPECT_TRUE( allclose(out_b, out3, 1.e-5, atol) ); + EXPECT_TRUE( allclose(out_o, out3, 1.e-5, atol) ); + EXPECT_TRUE( allclose(out_f, out3, 1.e-5, atol) ); } template @@ -1128,19 +1128,19 @@ TEST(FFTN, 2DFFT_2DRightViewDouble) { // fftn on 3D Views TEST(FFTN, 3DFFT_3DLeftViewFloat) { - test_fftn_3dfft_3dview(); + test_fftn_3dfft_3dview(5.0e-5); } TEST(FFTN, 3DFFT_3DLeftViewDouble) { - test_fftn_3dfft_3dview(); + test_fftn_3dfft_3dview(1.0e-6); } TEST(FFTN, 3DFFT_3DRightViewFloat) { - test_fftn_3dfft_3dview(); + test_fftn_3dfft_3dview(5.0e-5); } TEST(FFTN, 3DFFT_3DRightViewDouble) { - test_fftn_3dfft_3dview(); + test_fftn_3dfft_3dview(1.0e-6); } // ifftn on 2D Views From 5c7b2ee65aba07d3cd99547c184b44c1fdaee674 Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Mon, 11 Dec 2023 22:28:09 +0900 Subject: [PATCH 7/9] Add more tests for Test_Plans.cpp --- fft/unit_test/Test_Plans.cpp | 366 ++++++++++++++++++++++++++++------- 1 file changed, 291 insertions(+), 75 deletions(-) diff --git a/fft/unit_test/Test_Plans.cpp b/fft/unit_test/Test_Plans.cpp index 0fa7cb32..ce759f45 100644 --- a/fft/unit_test/Test_Plans.cpp +++ b/fft/unit_test/Test_Plans.cpp @@ -2,149 +2,365 @@ #include "KokkosFFT_Plans.hpp" #include "Test_Types.hpp" -TEST(Plans, 1DDefaultAxis) { +template +using axes_type = std::array; + +template +void test_plan_1dfft_1dview() { const int n = 30; - View1D x("x", n); - View1D> x_c("x_c", n/2+1); - View1D> x_cin("x_cin", n), x_cout("x_cout", n); + using RealView1DType = Kokkos::View; + using ComplexView1DType = Kokkos::View*, LayoutType, execution_space>; + + RealView1DType x("x", n); + ComplexView1DType x_c("x_c", n/2+1); + ComplexView1DType x_cin("x_cin", n), x_cout("x_cout", n); // R2C plan KokkosFFT::Plan plan_r2c(x, x_c); + KokkosFFT::Plan plan_r2c_axis_0(x, x_c, /*axis=*/0); + KokkosFFT::Plan plan_r2c_axes_0(x, x_c, /*axes=*/axes_type<1>({0})); // C2R plan KokkosFFT::Plan plan_c2r(x_c, x); + KokkosFFT::Plan plan_c2r_axis0(x_c, x, /*axis=*/0); + KokkosFFT::Plan plan_c2r_axes0(x_c, x, /*axes=*/axes_type<1>({0})); // C2C plan KokkosFFT::Plan plan_c2c_f(x_cin, x_cout, KOKKOS_FFT_FORWARD); KokkosFFT::Plan plan_c2c_b(x_cin, x_cout, KOKKOS_FFT_BACKWARD); + KokkosFFT::Plan plan_c2c_f_axis0(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axis=*/0); + KokkosFFT::Plan plan_c2c_f_axes0(x_cin, x_cout, KOKKOS_FFT_BACKWARD, /*axes=*/axes_type<1>({0})); + + EXPECT_THROW( + { + KokkosFFT::Plan plan_c2c(x_cin, x_cout); + }, + std::runtime_error + ); } -TEST(Plans, 2DLeftDefaultAxis) { - const int n0 = 10, n1 = 6; - LeftView2D x("x", n0, n1); - LeftView2D> x_c("x_c", n0/2+1, n1); - LeftView2D> x_cin("x_cin", n0, n1), x_cout("x_cout", n0, n1); +TEST(Plans, 1DFFT_1DLeftViewFloat) { + test_plan_1dfft_1dview(); +} - // R2C plan - KokkosFFT::Plan plan_r2c(x, x_c); +TEST(Plans, 1DFFT_1DLeftViewDouble) { + test_plan_1dfft_1dview(); +} - // C2R plan - KokkosFFT::Plan plan_c2r(x_c, x); +TEST(Plans, 1DFFT_1DRightViewFloat) { + test_plan_1dfft_1dview(); +} - // C2C plan - KokkosFFT::Plan plan_c2c_f(x_cin, x_cout, KOKKOS_FFT_FORWARD); - KokkosFFT::Plan plan_c2c_b(x_cin, x_cout, KOKKOS_FFT_BACKWARD); +TEST(Plans, 1DFFT_1DRightViewDouble) { + test_plan_1dfft_1dview(); } -TEST(Plans, 2DRightDefaultAxis) { +template +void test_plan_2dfft_2dview() { const int n0 = 10, n1 = 6; - RightView2D x("x", n0, n1); - RightView2D> x_c("x_c", n0/2+1, n1); - RightView2D> x_cin("x_cin", n0, n1), x_cout("x_cout", n0, n1); + using RealView2DType = Kokkos::View; + using ComplexView2DType = Kokkos::View**, LayoutType, execution_space>; + RealView2DType x("x", n0, n1); + ComplexView2DType x_c_axis_0("x_c_axis_0", n0/2+1, n1), x_c_axis_1("x_c_axis_1", n0, n1/2+1); + ComplexView2DType x_cin("x_cin", n0, n1), x_cout("x_cout", n0, n1); // R2C plan - KokkosFFT::Plan plan_r2c(x, x_c); + KokkosFFT::Plan plan_r2c(x, x_c_axis_1); + KokkosFFT::Plan plan_r2c_axes_0_1(x, x_c_axis_1, /*axes=*/axes_type<2>({0, 1})); + KokkosFFT::Plan plan_r2c_axes_1_0(x, x_c_axis_0, /*axes=*/axes_type<2>({1, 0})); // C2R plan - KokkosFFT::Plan plan_c2r(x_c, x); + KokkosFFT::Plan plan_c2r(x_c_axis_1, x); + KokkosFFT::Plan plan_c2r_axes_0_1(x_c_axis_1, x, /*axes=*/axes_type<2>({0, 1})); + KokkosFFT::Plan plan_c2r_axes_1_0(x_c_axis_0, x, /*axes=*/axes_type<2>({1, 0})); // C2C plan KokkosFFT::Plan plan_c2c_f(x_cin, x_cout, KOKKOS_FFT_FORWARD); KokkosFFT::Plan plan_c2c_b(x_cin, x_cout, KOKKOS_FFT_BACKWARD); + KokkosFFT::Plan plan_c2c_f_axes_0_1(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axes=*/axes_type<2>({0, 1})); + KokkosFFT::Plan plan_c2c_f_axes_1_0(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axes=*/axes_type<2>({1, 0})); + + EXPECT_THROW( + { + KokkosFFT::Plan plan_c2c(x_cin, x_cout); + }, + std::runtime_error + ); + + EXPECT_THROW( + { + KokkosFFT::Plan plan_c2c_axes_0_1(x_cin, x_cout, /*axes=*/axes_type<2>({0, 1})); + }, + std::runtime_error + ); + + EXPECT_THROW( + { + KokkosFFT::Plan plan_c2c_axes_1_0(x_cin, x_cout, /*axes=*/axes_type<2>({1, 0})); + }, + std::runtime_error + ); } -TEST(Plans, 3DLeftDefaultAxis) { - const int n0 = 10, n1 = 6, n2 = 8; - LeftView3D x("x", n0, n1, n2); - LeftView3D> x_c("x_c", n0/2+1, n1, n2); - LeftView3D> x_cin("x_cin", n0, n1, n2), x_cout("x_cout", n0, n1, n2); +TEST(Plans, 2DFFT_2DLeftViewFloat) { + test_plan_2dfft_2dview(); +} - // R2C plan - KokkosFFT::Plan plan_r2c(x, x_c); +TEST(Plans, 2DFFT_2DLeftViewDouble) { + test_plan_2dfft_2dview(); +} - // C2R plan - KokkosFFT::Plan plan_c2r(x_c, x); +TEST(Plans, 2DFFT_2DRightViewFloat) { + test_plan_2dfft_2dview(); +} - // C2C plan - KokkosFFT::Plan plan_c2c_f(x_cin, x_cout, KOKKOS_FFT_FORWARD); - KokkosFFT::Plan plan_c2c_b(x_cin, x_cout, KOKKOS_FFT_BACKWARD); +TEST(Plans, 2DFFT_2DRightViewDouble) { + test_plan_2dfft_2dview(); } -TEST(Plans, 3DRightDefaultAxis) { +template +void test_plan_3dfft_3dview() { const int n0 = 10, n1 = 6, n2 = 8; - RightView3D x("x", n0, n1, n2); - RightView3D> x_c("x_c", n0/2+1, n1, n2); - RightView3D> x_cin("x_cin", n0, n1, n2), x_cout("x_cout", n0, n1, n2); + using RealView3DType = Kokkos::View; + using ComplexView3DType = Kokkos::View***, LayoutType, execution_space>; + + RealView3DType x("x", n0, n1, n2); + ComplexView3DType x_c_axis_0("x_c_axis_0", n0/2+1, n1, n2), x_c_axis_1("x_c_axis_1", n0, n1/2+1, n2), x_c_axis_2("x_c_axis_2", n0, n1, n2/2+1); + ComplexView3DType x_cin("x_cin", n0, n1, n2), x_cout("x_cout", n0, n1, n2); // R2C plan - KokkosFFT::Plan plan_r2c(x, x_c); + KokkosFFT::Plan plan_r2c_axes_0_1_2(x, x_c_axis_2, /*axes=*/axes_type<3>({0, 1, 2})); + KokkosFFT::Plan plan_r2c_axes_0_2_1(x, x_c_axis_1, /*axes=*/axes_type<3>({0, 2, 1})); + KokkosFFT::Plan plan_r2c_axes_1_0_2(x, x_c_axis_2, /*axes=*/axes_type<3>({1, 0, 2})); + KokkosFFT::Plan plan_r2c_axes_1_2_0(x, x_c_axis_0, /*axes=*/axes_type<3>({1, 2, 0})); + KokkosFFT::Plan plan_r2c_axes_2_0_1(x, x_c_axis_1, /*axes=*/axes_type<3>({2, 0, 1})); + KokkosFFT::Plan plan_r2c_axes_2_1_0(x, x_c_axis_0, /*axes=*/axes_type<3>({2, 1, 0})); // C2R plan - KokkosFFT::Plan plan_c2r(x_c, x); + KokkosFFT::Plan plan_c2r_axes_0_1_2(x_c_axis_2, x, /*axes=*/axes_type<3>({0, 1, 2})); + KokkosFFT::Plan plan_c2r_axes_0_2_1(x_c_axis_1, x, /*axes=*/axes_type<3>({0, 2, 1})); + KokkosFFT::Plan plan_c2r_axes_1_0_2(x_c_axis_2, x, /*axes=*/axes_type<3>({1, 0, 2})); + KokkosFFT::Plan plan_c2r_axes_1_2_0(x_c_axis_0, x, /*axes=*/axes_type<3>({1, 2, 0})); + KokkosFFT::Plan plan_c2r_axes_2_0_1(x_c_axis_1, x, /*axes=*/axes_type<3>({2, 0, 1})); + KokkosFFT::Plan plan_c2r_axes_2_1_0(x_c_axis_0, x, /*axes=*/axes_type<3>({2, 1, 0})); // C2C plan - KokkosFFT::Plan plan_c2c_f(x_cin, x_cout, KOKKOS_FFT_FORWARD); - KokkosFFT::Plan plan_c2c_b(x_cin, x_cout, KOKKOS_FFT_BACKWARD); + KokkosFFT::Plan plan_c2c_f_axes_0_1_2(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axes=*/axes_type<3>({0, 1, 2})); + KokkosFFT::Plan plan_c2c_f_axes_0_2_1(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axes=*/axes_type<3>({0, 2, 1})); + KokkosFFT::Plan plan_c2c_f_axes_1_0_2(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axes=*/axes_type<3>({1, 0, 2})); + KokkosFFT::Plan plan_c2c_f_axes_1_2_0(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axes=*/axes_type<3>({1, 2, 0})); + KokkosFFT::Plan plan_c2c_f_axes_2_0_1(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axes=*/axes_type<3>({2, 0, 1})); + KokkosFFT::Plan plan_c2c_f_axes_2_1_0(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axes=*/axes_type<3>({2, 1, 0})); + + EXPECT_THROW( + { + KokkosFFT::Plan plan_c2c(x_cin, x_cout); + }, + std::runtime_error + ); + + EXPECT_THROW( + { + KokkosFFT::Plan plan_c2c_axes_0_1_2(x_cin, x_cout, /*axes=*/axes_type<3>({0, 1, 2})); + }, + std::runtime_error + ); } -TEST(Plans, 1DFFT_2DRightDefaultAxis) { +TEST(Plans, 3DFFT_3DLeftViewFloat) { + test_plan_3dfft_3dview(); +} + +TEST(Plans, 3DFFT_3DLeftViewDouble) { + test_plan_3dfft_3dview(); +} + +TEST(Plans, 3DFFT_3DRightViewFloat) { + test_plan_3dfft_3dview(); +} + +TEST(Plans, 3DFFT_3DRightViewDouble) { + test_plan_3dfft_3dview(); +} + +template +void test_plan_1dfft_2dview() { const int n0 = 10, n1 = 6; - LeftView2D x("x", n0, n1); - LeftView2D> x_c("x_c", n0, n1/2+1); - LeftView2D> x_cin("x_cin", n0, n1), x_cout("x_cout", n0, n1); + using RealView2DType = Kokkos::View; + using ComplexView2DType = Kokkos::View**, LayoutType, execution_space>; + RealView2DType x("x", n0, n1); + ComplexView2DType x_c_axis_0("x_c_axis_0", n0/2+1, n1), x_c_axis_1("x_c_axis_1", n0, n1/2+1); + ComplexView2DType x_cin("x_cin", n0, n1), x_cout("x_cout", n0, n1); // R2C plan - KokkosFFT::Plan plan_r2c_axis_0(x, x_c, 0); - KokkosFFT::Plan plan_r2c_axis_1(x, x_c, 1); - KokkosFFT::Plan plan_r2c_axis_minus1(x, x_c, -1); + KokkosFFT::Plan plan_r2c_axis_0(x, x_c_axis_0, /*axis=*/0); + KokkosFFT::Plan plan_r2c_axis_1(x, x_c_axis_1, /*axis=*/1); + KokkosFFT::Plan plan_r2c_axis_minus1(x, x_c_axis_1, /*axis=*/-1); // C2R plan - KokkosFFT::Plan plan_c2r_axis_0(x_c, x, 0); - KokkosFFT::Plan plan_c2r_axis_1(x_c, x, 1); - KokkosFFT::Plan plan_c2r_axis_minus1(x_c, x, -1); + KokkosFFT::Plan plan_c2r_axis_0(x_c_axis_0, x, /*axis=*/0); + KokkosFFT::Plan plan_c2r_axis_1(x_c_axis_1, x, /*axis=*/1); + KokkosFFT::Plan plan_c2r_axis_minus1(x_c_axis_1, x, /*axis=*/-1); // C2C plan - KokkosFFT::Plan plan_c2c_f_axis_0(x_cin, x_cout, KOKKOS_FFT_FORWARD, 0); - KokkosFFT::Plan plan_c2c_f_axis_1(x_cin, x_cout, KOKKOS_FFT_FORWARD, 1); - KokkosFFT::Plan plan_c2c_f_axis_minus1(x_cin, x_cout, KOKKOS_FFT_FORWARD, -1); + KokkosFFT::Plan plan_c2c_f_axis_0(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axis=*/0); + KokkosFFT::Plan plan_c2c_f_axis_1(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axis=*/1); + + // [TO DO] Fix this, this can be instanized with explicit Plan(InViewType& in, OutViewType& out, FFTDirectionType direction) + // Because FFTDirectionType is int for most libraries + //EXPECT_THROW( + // { + // KokkosFFT::Plan plan_c2c_axis_0(x_cin, x_cout, /*axis=*/0); + // }, + // std::runtime_error + //); + + //EXPECT_THROW( + // { + // KokkosFFT::Plan plan_c2c_axis_1(x_cin, x_cout, /*axis=*/1); + // }, + // std::runtime_error + //); +} - KokkosFFT::Plan plan_c2c_b_axis_0(x_cin, x_cout, KOKKOS_FFT_BACKWARD, 0); - KokkosFFT::Plan plan_c2c_b_axis_1(x_cin, x_cout, KOKKOS_FFT_BACKWARD, 1); - KokkosFFT::Plan plan_c2c_b_axis_minus1(x_cin, x_cout, KOKKOS_FFT_BACKWARD, -1); +TEST(Plans, 1DBatchedFFT_2DLeftViewFloat) { + test_plan_1dfft_2dview(); } -TEST(Plans, 1DFFT_3DRightDefaultAxis) { +TEST(Plans, 1DBatchedFFT_2DLeftViewDouble) { + test_plan_1dfft_2dview(); +} + +TEST(Plans, 1DBatchedFFT_2DRightViewFloat) { + test_plan_1dfft_2dview(); +} + +TEST(Plans, 1DBatchedFFT_2DRightViewDouble) { + test_plan_1dfft_2dview(); +} + +template +void test_plan_1dfft_3dview() { const int n0 = 10, n1 = 6, n2 = 8; - LeftView3D x("x", n0, n1, n2); - LeftView3D> x_c("x_c", n0, n1, n2/2+1); - LeftView3D> x_cin("x_cin", n0, n1, n2), x_cout("x_cout", n0, n1, n2); + using RealView3DType = Kokkos::View; + using ComplexView3DType = Kokkos::View***, LayoutType, execution_space>; + + RealView3DType x("x", n0, n1, n2); + ComplexView3DType x_c_axis_0("x_c_axis_0", n0/2+1, n1, n2), x_c_axis_1("x_c_axis_1", n0, n1/2+1, n2), x_c_axis_2("x_c_axis_2", n0, n1, n2/2+1); + ComplexView3DType x_cin("x_cin", n0, n1, n2), x_cout("x_cout", n0, n1, n2); // R2C plan - KokkosFFT::Plan plan_r2c(x, x_c, -1); + KokkosFFT::Plan plan_r2c_axis_0(x, x_c_axis_0, /*axis=*/0); + KokkosFFT::Plan plan_r2c_axis_1(x, x_c_axis_1, /*axis=*/1); + KokkosFFT::Plan plan_r2c_axis_2(x, x_c_axis_2, /*axis=*/2); // C2R plan - KokkosFFT::Plan plan_c2r(x_c, x, -1); + KokkosFFT::Plan plan_c2r_axis_0(x_c_axis_0, x, /*axis=*/0); + KokkosFFT::Plan plan_c2r_axis_1(x_c_axis_1, x, /*axis=*/1); + KokkosFFT::Plan plan_c2r_axis_2(x_c_axis_2, x, /*axis=*/2); // C2C plan - KokkosFFT::Plan plan_c2c_f(x_cin, x_cout, KOKKOS_FFT_FORWARD, -1); - KokkosFFT::Plan plan_c2c_b(x_cin, x_cout, KOKKOS_FFT_BACKWARD, -1); + KokkosFFT::Plan plan_c2c_f_axis_0(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axis=*/0); + KokkosFFT::Plan plan_c2c_f_axis_1(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axis=*/1); + KokkosFFT::Plan plan_c2c_f_axis_2(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axis=*/2); + KokkosFFT::Plan plan_c2c_b_axis_0(x_cin, x_cout, KOKKOS_FFT_BACKWARD, /*axis=*/0); + KokkosFFT::Plan plan_c2c_b_axis_1(x_cin, x_cout, KOKKOS_FFT_BACKWARD, /*axis=*/1); + KokkosFFT::Plan plan_c2c_b_axis_2(x_cin, x_cout, KOKKOS_FFT_BACKWARD, /*axis=*/2); + + // [TO DO] Fix this, this can be instanized with explicit Plan(InViewType& in, OutViewType& out, FFTDirectionType direction) + // Because FFTDirectionType is int for most libraries + //EXPECT_THROW( + // { + // KokkosFFT::Plan plan_c2c_axis_0(x_cin, x_cout, /*axis=*/0); + // }, + // std::runtime_error + //); + + //EXPECT_THROW( + // { + // KokkosFFT::Plan plan_c2c_axis_1(x_cin, x_cout, /*axis=*/1); + // }, + // std::runtime_error + //); + + //EXPECT_THROW( + // { + // KokkosFFT::Plan plan_c2c_axis_1(x_cin, x_cout, /*axis=*/2); + // }, + // std::runtime_error + //); } -TEST(Plans, 2DFFT_3DRightDefaultAxis) { - using axes_type = KokkosFFT::axis_type<2>; +TEST(Plans, 1DBatchedFFT_3DLeftViewFloat) { + test_plan_1dfft_3dview(); +} +TEST(Plans, 1DBatchedFFT_3DLeftViewDouble) { + test_plan_1dfft_3dview(); +} + +TEST(Plans, 1DBatchedFFT_3DRightViewFloat) { + test_plan_1dfft_3dview(); +} + +TEST(Plans, 1DBatchedFFT_3DRightViewDouble) { + test_plan_1dfft_3dview(); +} + +template +void test_plan_2dfft_3dview() { const int n0 = 10, n1 = 6, n2 = 8; - LeftView3D x("x", n0, n1, n2); - LeftView3D> x_c("x_c", n0, n1, n2/2+1); - LeftView3D> x_cin("x_cin", n0, n1, n2), x_cout("x_cout", n0, n1, n2); + using RealView3DType = Kokkos::View; + using ComplexView3DType = Kokkos::View***, LayoutType, execution_space>; + + RealView3DType x("x", n0, n1, n2); + ComplexView3DType x_c_axis_0("x_c_axis_0", n0/2+1, n1, n2), x_c_axis_1("x_c_axis_1", n0, n1/2+1, n2), x_c_axis_2("x_c_axis_2", n0, n1, n2/2+1); + ComplexView3DType x_cin("x_cin", n0, n1, n2), x_cout("x_cout", n0, n1, n2); // R2C plan - KokkosFFT::Plan plan_r2c(x, x_c, axes_type({-2, -1})); + KokkosFFT::Plan plan_r2c_axes_0_1(x, x_c_axis_1, /*axes=*/axes_type<2>({0, 1})); + KokkosFFT::Plan plan_r2c_axes_0_2(x, x_c_axis_2, /*axes=*/axes_type<2>({0, 2})); + KokkosFFT::Plan plan_r2c_axes_1_0(x, x_c_axis_0, /*axes=*/axes_type<2>({1, 0})); + KokkosFFT::Plan plan_r2c_axes_1_2(x, x_c_axis_2, /*axes=*/axes_type<2>({1, 2})); + KokkosFFT::Plan plan_r2c_axes_2_0(x, x_c_axis_0, /*axes=*/axes_type<2>({2, 0})); + KokkosFFT::Plan plan_r2c_axes_2_1(x, x_c_axis_1, /*axes=*/axes_type<2>({2, 1})); // C2R plan - KokkosFFT::Plan plan_c2r(x_c, x, axes_type({-2, -1})); + KokkosFFT::Plan plan_c2r_axes_0_1(x_c_axis_1, x, /*axes=*/axes_type<2>({0, 1})); + KokkosFFT::Plan plan_c2r_axes_0_2(x_c_axis_2, x, /*axes=*/axes_type<2>({0, 2})); + KokkosFFT::Plan plan_c2r_axes_1_0(x_c_axis_0, x, /*axes=*/axes_type<2>({1, 0})); + KokkosFFT::Plan plan_c2r_axes_1_2(x_c_axis_2, x, /*axes=*/axes_type<2>({1, 2})); + KokkosFFT::Plan plan_c2r_axes_2_0(x_c_axis_0, x, /*axes=*/axes_type<2>({2, 0})); + KokkosFFT::Plan plan_c2r_axes_2_1(x_c_axis_1, x, /*axes=*/axes_type<2>({2, 1})); // C2C plan - KokkosFFT::Plan plan_c2c_f(x_cin, x_cout, KOKKOS_FFT_FORWARD, axes_type({-2, -1})); - KokkosFFT::Plan plan_c2c_b(x_cin, x_cout, KOKKOS_FFT_BACKWARD, axes_type({-2, -1})); + KokkosFFT::Plan plan_c2c_f_axes_0_1(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axes=*/axes_type<2>({0, 1})); + KokkosFFT::Plan plan_c2c_f_axes_0_2(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axes=*/axes_type<2>({0, 2})); + KokkosFFT::Plan plan_c2c_f_axes_1_0(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axes=*/axes_type<2>({1, 0})); + KokkosFFT::Plan plan_c2c_f_axes_1_2(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axes=*/axes_type<2>({1, 2})); + KokkosFFT::Plan plan_c2c_f_axes_2_0(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axes=*/axes_type<2>({2, 0})); + KokkosFFT::Plan plan_c2c_f_axes_2_1(x_cin, x_cout, KOKKOS_FFT_FORWARD, /*axes=*/axes_type<2>({2, 1})); + + EXPECT_THROW( + { + KokkosFFT::Plan plan_c2c_axes_0_1(x_cin, x_cout, /*axes=*/axes_type<2>({0, 1})); + }, + std::runtime_error + ); +} + +TEST(Plans, 2DBatchedFFT_3DLeftViewFloat) { + test_plan_2dfft_3dview(); +} + +TEST(Plans, 2DBatchedFFT_3DLeftViewDouble) { + test_plan_2dfft_3dview(); +} + +TEST(Plans, 2DBatchedFFT_3DRightViewFloat) { + test_plan_2dfft_3dview(); +} + +TEST(Plans, 2DBatchedFFT_3DRightViewDouble) { + test_plan_2dfft_3dview(); } \ No newline at end of file From 0ffcc271b1bf44966c2ce121a1b7aa1029cd1e7c Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Wed, 13 Dec 2023 23:11:40 +0900 Subject: [PATCH 8/9] Unuse double underscore indentifiers in header files --- common/src/KokkosFFT_Cuda_types.hpp | 4 ++-- common/src/KokkosFFT_HIP_types.hpp | 4 ++-- common/src/KokkosFFT_OpenMP_types.hpp | 4 ++-- common/src/KokkosFFT_default_types.hpp | 4 ++-- common/src/KokkosFFT_layouts.hpp | 4 ++-- common/src/KokkosFFT_normalization.hpp | 4 ++-- common/src/KokkosFFT_transpose.hpp | 4 ++-- common/src/KokkosFFT_utils.hpp | 4 ++-- fft/src/KokkosFFT.hpp | 4 ++-- fft/src/KokkosFFT_Cuda_plans.hpp | 4 ++-- fft/src/KokkosFFT_Cuda_transform.hpp | 4 ++-- fft/src/KokkosFFT_HIP_plans.hpp | 4 ++-- fft/src/KokkosFFT_HIP_transform.hpp | 4 ++-- fft/src/KokkosFFT_OpenMP_plans.hpp | 4 ++-- fft/src/KokkosFFT_OpenMP_transform.hpp | 4 ++-- fft/src/KokkosFFT_Plans.hpp | 4 ++-- fft/src/KokkosFFT_Transform.hpp | 4 ++-- 17 files changed, 34 insertions(+), 34 deletions(-) diff --git a/common/src/KokkosFFT_Cuda_types.hpp b/common/src/KokkosFFT_Cuda_types.hpp index 30535e62..80a69524 100644 --- a/common/src/KokkosFFT_Cuda_types.hpp +++ b/common/src/KokkosFFT_Cuda_types.hpp @@ -1,5 +1,5 @@ -#ifndef __KOKKOSFFT_CUDA_TYPES_HPP__ -#define __KOKKOSFFT_CUDA_TYPES_HPP__ +#ifndef KOKKOSFFT_CUDA_TYPES_HPP +#define KOKKOSFFT_CUDA_TYPES_HPP #include diff --git a/common/src/KokkosFFT_HIP_types.hpp b/common/src/KokkosFFT_HIP_types.hpp index 72b97380..9ab97f79 100644 --- a/common/src/KokkosFFT_HIP_types.hpp +++ b/common/src/KokkosFFT_HIP_types.hpp @@ -1,5 +1,5 @@ -#ifndef __KOKKOSFFT_HIP_TYPES_HPP__ -#define __KOKKOSFFT_HIP_TYPES_HPP__ +#ifndef KOKKOSFFT_HIP_TYPES_HPP +#define KOKKOSFFT_HIP_TYPES_HPP #include diff --git a/common/src/KokkosFFT_OpenMP_types.hpp b/common/src/KokkosFFT_OpenMP_types.hpp index 433025fd..1de4af14 100644 --- a/common/src/KokkosFFT_OpenMP_types.hpp +++ b/common/src/KokkosFFT_OpenMP_types.hpp @@ -1,5 +1,5 @@ -#ifndef __KOKKOSFFT_OPENMP_TYPES_HPP__ -#define __KOKKOSFFT_OPENMP_TYPES_HPP__ +#ifndef KOKKOSFFT_OPENMP_TYPES_HPP +#define KOKKOSFFT_OPENMP_TYPES_HPP #include #include "KokkosFFT_utils.hpp" diff --git a/common/src/KokkosFFT_default_types.hpp b/common/src/KokkosFFT_default_types.hpp index 86fa44dc..02467122 100644 --- a/common/src/KokkosFFT_default_types.hpp +++ b/common/src/KokkosFFT_default_types.hpp @@ -1,5 +1,5 @@ -#ifndef __KOKKOSFFT_DEFAULT_TYPES_HPP__ -#define __KOKKOSFFT_DEFAULT_TYPES_HPP__ +#ifndef KOKKOSFFT_DEFAULT_TYPES_HPP +#define KOKKOSFFT_DEFAULT_TYPES_HPP #include diff --git a/common/src/KokkosFFT_layouts.hpp b/common/src/KokkosFFT_layouts.hpp index 83d6d734..a972092c 100644 --- a/common/src/KokkosFFT_layouts.hpp +++ b/common/src/KokkosFFT_layouts.hpp @@ -1,5 +1,5 @@ -#ifndef __KOKKOSFFT_LAYOUTS_HPP__ -#define __KOKKOSFFT_LAYOUTS_HPP__ +#ifndef KOKKOSFFT_LAYOUTS_HPP +#define KOKKOSFFT_LAYOUTS_HPP #include diff --git a/common/src/KokkosFFT_normalization.hpp b/common/src/KokkosFFT_normalization.hpp index 1ba9920f..ad5a4992 100644 --- a/common/src/KokkosFFT_normalization.hpp +++ b/common/src/KokkosFFT_normalization.hpp @@ -1,5 +1,5 @@ -#ifndef __KOKKOSFFT_NORMALIZATION_HPP__ -#define __KOKKOSFFT_NORMALIZATION_HPP__ +#ifndef KOKKOSFFT_NORMALIZATION_HPP +#define KOKKOSFFT_NORMALIZATION_HPP #include #include "KokkosFFT_default_types.hpp" diff --git a/common/src/KokkosFFT_transpose.hpp b/common/src/KokkosFFT_transpose.hpp index 065a6f90..e735d6f9 100644 --- a/common/src/KokkosFFT_transpose.hpp +++ b/common/src/KokkosFFT_transpose.hpp @@ -1,5 +1,5 @@ -#ifndef __KOKKOSFFT_TRANSPOSE_HPP__ -#define __KOKKOSFFT_TRANSPOSE_HPP__ +#ifndef KOKKOSFFT_TRANSPOSE_HPP +#define KOKKOSFFT_TRANSPOSE_HPP #include #include diff --git a/common/src/KokkosFFT_utils.hpp b/common/src/KokkosFFT_utils.hpp index 2c1d0010..3c29420f 100644 --- a/common/src/KokkosFFT_utils.hpp +++ b/common/src/KokkosFFT_utils.hpp @@ -1,5 +1,5 @@ -#ifndef __KOKKOSFFT_UTILS_HPP__ -#define __KOKKOSFFT_UTILS_HPP__ +#ifndef KOKKOSFFT_UTILS_HPP +#define KOKKOSFFT_UTILS_HPP #include #include diff --git a/fft/src/KokkosFFT.hpp b/fft/src/KokkosFFT.hpp index e3471d7e..1c9c137a 100644 --- a/fft/src/KokkosFFT.hpp +++ b/fft/src/KokkosFFT.hpp @@ -1,5 +1,5 @@ -#ifndef __KOKKOS_FFT_HPP__ -#define __KOKKOS_FFT_HPP__ +#ifndef KOKKOS_FFT_HPP +#define KOKKOS_FFT_HPP #include "KokkosFFT_default_types.hpp" #include "KokkosFFT_utils.hpp" diff --git a/fft/src/KokkosFFT_Cuda_plans.hpp b/fft/src/KokkosFFT_Cuda_plans.hpp index d6a31403..dfc23896 100644 --- a/fft/src/KokkosFFT_Cuda_plans.hpp +++ b/fft/src/KokkosFFT_Cuda_plans.hpp @@ -1,5 +1,5 @@ -#ifndef __KOKKOSFFT_CUDA_PLANS_HPP__ -#define __KOKKOSFFT_CUDA_PLANS_HPP__ +#ifndef KOKKOSFFT_CUDA_PLANS_HPP +#define KOKKOSFFT_CUDA_PLANS_HPP #include #include "KokkosFFT_Cuda_types.hpp" diff --git a/fft/src/KokkosFFT_Cuda_transform.hpp b/fft/src/KokkosFFT_Cuda_transform.hpp index b4b00d37..e7643d9e 100644 --- a/fft/src/KokkosFFT_Cuda_transform.hpp +++ b/fft/src/KokkosFFT_Cuda_transform.hpp @@ -1,5 +1,5 @@ -#ifndef __KOKKOSFFT_CUDA_TRANSFORM_HPP__ -#define __KOKKOSFFT_CUDA_TRANSFORM_HPP__ +#ifndef KOKKOSFFT_CUDA_TRANSFORM_HPP +#define KOKKOSFFT_CUDA_TRANSFORM_HPP #include diff --git a/fft/src/KokkosFFT_HIP_plans.hpp b/fft/src/KokkosFFT_HIP_plans.hpp index c6c573a4..bd2822b2 100644 --- a/fft/src/KokkosFFT_HIP_plans.hpp +++ b/fft/src/KokkosFFT_HIP_plans.hpp @@ -1,5 +1,5 @@ -#ifndef __KOKKOSFFT_HIP_PLANS_HPP__ -#define __KOKKOSFFT_HIP_PLANS_HPP__ +#ifndef KOKKOSFFT_HIP_PLANS_HPP +#define KOKKOSFFT_HIP_PLANS_HPP #include #include "KokkosFFT_HIP_types.hpp" diff --git a/fft/src/KokkosFFT_HIP_transform.hpp b/fft/src/KokkosFFT_HIP_transform.hpp index ad276781..08bca6a4 100644 --- a/fft/src/KokkosFFT_HIP_transform.hpp +++ b/fft/src/KokkosFFT_HIP_transform.hpp @@ -1,5 +1,5 @@ -#ifndef __KOKKOSFFT_HIP_TRANSFORM_HPP__ -#define __KOKKOSFFT_HIP_TRANSFORM_HPP__ +#ifndef KOKKOSFFT_HIP_TRANSFORM_HPP +#define KOKKOSFFT_HIP_TRANSFORM_HPP #include diff --git a/fft/src/KokkosFFT_OpenMP_plans.hpp b/fft/src/KokkosFFT_OpenMP_plans.hpp index f3ebe088..35323cc3 100644 --- a/fft/src/KokkosFFT_OpenMP_plans.hpp +++ b/fft/src/KokkosFFT_OpenMP_plans.hpp @@ -1,5 +1,5 @@ -#ifndef __KOKKOSFFT_OPENMP_PLANS_HPP__ -#define __KOKKOSFFT_OPENMP_PLANS_HPP__ +#ifndef KOKKOSFFT_OPENMP_PLANS_HPP +#define KOKKOSFFT_OPENMP_PLANS_HPP #include #include "KokkosFFT_OpenMP_types.hpp" diff --git a/fft/src/KokkosFFT_OpenMP_transform.hpp b/fft/src/KokkosFFT_OpenMP_transform.hpp index 52e7d50b..18152d34 100644 --- a/fft/src/KokkosFFT_OpenMP_transform.hpp +++ b/fft/src/KokkosFFT_OpenMP_transform.hpp @@ -1,5 +1,5 @@ -#ifndef __KOKKOSFFT_OPENMP_TRANSFORM_HPP__ -#define __KOKKOSFFT_OPENMP_TRANSFORM_HPP__ +#ifndef KOKKOSFFT_OPENMP_TRANSFORM_HPP +#define KOKKOSFFT_OPENMP_TRANSFORM_HPP #include diff --git a/fft/src/KokkosFFT_Plans.hpp b/fft/src/KokkosFFT_Plans.hpp index 32b3f0c0..1f4d56fb 100644 --- a/fft/src/KokkosFFT_Plans.hpp +++ b/fft/src/KokkosFFT_Plans.hpp @@ -1,5 +1,5 @@ -#ifndef __KOKKOSFFT_PLANS_HPP__ -#define __KOKKOSFFT_PLANS_HPP__ +#ifndef KOKKOSFFT_PLANS_HPP +#define KOKKOSFFT_PLANS_HPP #include #include "KokkosFFT_default_types.hpp" diff --git a/fft/src/KokkosFFT_Transform.hpp b/fft/src/KokkosFFT_Transform.hpp index 73e7acf0..68d3bcaa 100644 --- a/fft/src/KokkosFFT_Transform.hpp +++ b/fft/src/KokkosFFT_Transform.hpp @@ -1,5 +1,5 @@ -#ifndef __KOKKOSFFT_TRANSFORM_HPP__ -#define __KOKKOSFFT_TRANSFORM_HPP__ +#ifndef KOKKOSFFT_TRANSFORM_HPP +#define KOKKOSFFT_TRANSFORM_HPP #include #include "KokkosFFT_default_types.hpp" From 45d029476aa92f033cd185346a19848f661f3264 Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Thu, 14 Dec 2023 23:18:01 +0900 Subject: [PATCH 9/9] Rename KokkosFFT::FFT_Normalization into KokkosFFT::Normalization --- common/src/KokkosFFT_normalization.hpp | 12 +- common/unit_test/Test_Normalization.cpp | 12 +- examples/04_batchedFFT/04_batchedFFT.cpp | 8 +- fft/src/KokkosFFT_Transform.hpp | 36 +-- fft/unit_test/Test_Transform.cpp | 272 +++++++++++------------ 5 files changed, 170 insertions(+), 170 deletions(-) diff --git a/common/src/KokkosFFT_normalization.hpp b/common/src/KokkosFFT_normalization.hpp index ad5a4992..f3d3ace9 100644 --- a/common/src/KokkosFFT_normalization.hpp +++ b/common/src/KokkosFFT_normalization.hpp @@ -6,7 +6,7 @@ #include "KokkosFFT_utils.hpp" namespace KokkosFFT { - enum class FFT_Normalization { + enum class Normalization { FORWARD, BACKWARD, ORTHO @@ -24,27 +24,27 @@ namespace KokkosFFT { } template - auto _coefficients(const ViewType& inout, FFTDirectionType direction, FFT_Normalization normalization, std::size_t fft_size) { + auto _coefficients(const ViewType& inout, FFTDirectionType direction, Normalization normalization, std::size_t fft_size) { using value_type = real_type_t; value_type coef = 1; bool to_normalize = false; switch (normalization) { - case FFT_Normalization::FORWARD: + case Normalization::FORWARD: if(direction == KOKKOS_FFT_FORWARD) { coef = static_cast(1) / static_cast(fft_size); to_normalize = true; } break; - case FFT_Normalization::BACKWARD: + case Normalization::BACKWARD: if(direction == KOKKOS_FFT_BACKWARD) { coef = static_cast(1) / static_cast(fft_size); to_normalize = true; } break; - case FFT_Normalization::ORTHO: + case Normalization::ORTHO: coef = static_cast(1) / Kokkos::sqrt(static_cast(fft_size)); to_normalize = true; @@ -54,7 +54,7 @@ namespace KokkosFFT { } template - void normalize(ViewType& inout, FFTDirectionType direction, FFT_Normalization normalization, std::size_t fft_size) { + void normalize(ViewType& inout, FFTDirectionType direction, Normalization normalization, std::size_t fft_size) { auto [coef, to_normalize] = _coefficients(inout, direction, normalization, fft_size); if(to_normalize) _normalize(inout, coef); } diff --git a/common/unit_test/Test_Normalization.cpp b/common/unit_test/Test_Normalization.cpp index 3610e153..a479642c 100644 --- a/common/unit_test/Test_Normalization.cpp +++ b/common/unit_test/Test_Normalization.cpp @@ -21,11 +21,11 @@ TEST(Normalization, Forward) { Kokkos::fence(); // Backward FFT with Forward Normalization -> Do nothing - KokkosFFT::normalize(x, KOKKOS_FFT_BACKWARD, KokkosFFT::FFT_Normalization::FORWARD, len); + KokkosFFT::normalize(x, KOKKOS_FFT_BACKWARD, KokkosFFT::Normalization::FORWARD, len); EXPECT_TRUE( allclose(x, ref_b, 1.e-5, 1.e-12) ); // Forward FFT with Forward Normalization -> 1/N normalization - KokkosFFT::normalize(x, KOKKOS_FFT_FORWARD, KokkosFFT::FFT_Normalization::FORWARD, len); + KokkosFFT::normalize(x, KOKKOS_FFT_FORWARD, KokkosFFT::Normalization::FORWARD, len); EXPECT_TRUE( allclose(x, ref_f, 1.e-5, 1.e-12) ); } @@ -45,11 +45,11 @@ TEST(Normalization, Backward) { Kokkos::fence(); // Forward FFT with Backward Normalization -> Do nothing - KokkosFFT::normalize(x, KOKKOS_FFT_FORWARD, KokkosFFT::FFT_Normalization::BACKWARD, len); + KokkosFFT::normalize(x, KOKKOS_FFT_FORWARD, KokkosFFT::Normalization::BACKWARD, len); EXPECT_TRUE( allclose(x, ref_f, 1.e-5, 1.e-12) ); // Backward FFT with Backward Normalization -> 1/N normalization - KokkosFFT::normalize(x, KOKKOS_FFT_BACKWARD, KokkosFFT::FFT_Normalization::BACKWARD, len); + KokkosFFT::normalize(x, KOKKOS_FFT_BACKWARD, KokkosFFT::Normalization::BACKWARD, len); EXPECT_TRUE( allclose(x, ref_b, 1.e-5, 1.e-12) ); } @@ -72,10 +72,10 @@ TEST(Normalization, Ortho) { Kokkos::fence(); // Forward FFT with Ortho Normalization -> 1 / sqrt(N) normalization - KokkosFFT::normalize(x_f, KOKKOS_FFT_FORWARD, KokkosFFT::FFT_Normalization::ORTHO, len); + KokkosFFT::normalize(x_f, KOKKOS_FFT_FORWARD, KokkosFFT::Normalization::ORTHO, len); EXPECT_TRUE( allclose(x_f, ref_f, 1.e-5, 1.e-12) ); // Backward FFT with Ortho Normalization -> 1 / sqrt(N) normalization - KokkosFFT::normalize(x_b, KOKKOS_FFT_BACKWARD, KokkosFFT::FFT_Normalization::ORTHO, len); + KokkosFFT::normalize(x_b, KOKKOS_FFT_BACKWARD, KokkosFFT::Normalization::ORTHO, len); EXPECT_TRUE( allclose(x_b, ref_b, 1.e-5, 1.e-12) ); } \ No newline at end of file diff --git a/examples/04_batchedFFT/04_batchedFFT.cpp b/examples/04_batchedFFT/04_batchedFFT.cpp index 3554ab96..9263d377 100644 --- a/examples/04_batchedFFT/04_batchedFFT.cpp +++ b/examples/04_batchedFFT/04_batchedFFT.cpp @@ -20,22 +20,22 @@ int main( int argc, char* argv[] ) { Kokkos::Random_XorShift64_Pool<> random_pool(12345); Kokkos::fill_random(xc2c, random_pool, I); - KokkosFFT::fft(xc2c, xc2c_hat, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/-1); - KokkosFFT::ifft(xc2c_hat, xc2c_inv, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/-1); + KokkosFFT::fft(xc2c, xc2c_hat, KokkosFFT::Normalization::BACKWARD, /*axis=*/-1); + KokkosFFT::ifft(xc2c_hat, xc2c_inv, KokkosFFT::Normalization::BACKWARD, /*axis=*/-1); // 1D batched R2C FFT View3D xr2c("xr2c", n0, n1, n2); View3D > xr2c_hat("xr2c_hat", n0, n1, n2/2+1); Kokkos::fill_random(xr2c, random_pool, 1); - KokkosFFT::rfft(xr2c, xr2c_hat, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/-1); + KokkosFFT::rfft(xr2c, xr2c_hat, KokkosFFT::Normalization::BACKWARD, /*axis=*/-1); // 1D batched C2R FFT View3D > xc2r("xr2c_hat", n0, n1, n2/2+1); View3D xc2r_hat("xc2r", n0, n1, n2); Kokkos::fill_random(xc2r, random_pool, I); - KokkosFFT::irfft(xc2r, xc2r_hat, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/-1); + KokkosFFT::irfft(xc2r, xc2r_hat, KokkosFFT::Normalization::BACKWARD, /*axis=*/-1); } Kokkos::finalize(); diff --git a/fft/src/KokkosFFT_Transform.hpp b/fft/src/KokkosFFT_Transform.hpp index 68d3bcaa..7a059801 100644 --- a/fft/src/KokkosFFT_Transform.hpp +++ b/fft/src/KokkosFFT_Transform.hpp @@ -28,7 +28,7 @@ // 1D Transform namespace KokkosFFT { template - void _fft(PlanType& plan, const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD) { + void _fft(PlanType& plan, const InViewType& in, OutViewType& out, KokkosFFT::Normalization norm=KokkosFFT::Normalization::BACKWARD) { static_assert(Kokkos::is_view::value, "KokkosFFT::_fft: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -45,7 +45,7 @@ namespace KokkosFFT { } template - void _ifft(PlanType& plan, const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD) { + void _ifft(PlanType& plan, const InViewType& in, OutViewType& out, KokkosFFT::Normalization norm=KokkosFFT::Normalization::BACKWARD) { static_assert(Kokkos::is_view::value, "KokkosFFT::_ifft: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -62,7 +62,7 @@ namespace KokkosFFT { } template - void fft(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, int axis=-1) { + void fft(const InViewType& in, OutViewType& out, KokkosFFT::Normalization norm=KokkosFFT::Normalization::BACKWARD, int axis=-1) { static_assert(Kokkos::is_view::value, "KokkosFFT::fft: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -86,7 +86,7 @@ namespace KokkosFFT { } template - void ifft(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, int axis=-1) { + void ifft(const InViewType& in, OutViewType& out, KokkosFFT::Normalization norm=KokkosFFT::Normalization::BACKWARD, int axis=-1) { static_assert(Kokkos::is_view::value, "KokkosFFT::ifft: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -110,7 +110,7 @@ namespace KokkosFFT { } template - void rfft(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, int axis=-1) { + void rfft(const InViewType& in, OutViewType& out, KokkosFFT::Normalization norm=KokkosFFT::Normalization::BACKWARD, int axis=-1) { static_assert(Kokkos::is_view::value, "KokkosFFT::rfft: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -128,7 +128,7 @@ namespace KokkosFFT { } template - void irfft(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, int axis=-1) { + void irfft(const InViewType& in, OutViewType& out, KokkosFFT::Normalization norm=KokkosFFT::Normalization::BACKWARD, int axis=-1) { static_assert(Kokkos::is_view::value, "KokkosFFT::irfft: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -148,7 +148,7 @@ namespace KokkosFFT { namespace KokkosFFT { template - void fft2(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, axis_type<2> axes={-2, -1}) { + void fft2(const InViewType& in, OutViewType& out, KokkosFFT::Normalization norm=KokkosFFT::Normalization::BACKWARD, axis_type<2> axes={-2, -1}) { static_assert(Kokkos::is_view::value, "KokkosFFT::fft2: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -171,7 +171,7 @@ namespace KokkosFFT { } template - void ifft2(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, axis_type<2> axes={-2, -1}) { + void ifft2(const InViewType& in, OutViewType& out, KokkosFFT::Normalization norm=KokkosFFT::Normalization::BACKWARD, axis_type<2> axes={-2, -1}) { static_assert(Kokkos::is_view::value, "KokkosFFT::ifft2: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -194,7 +194,7 @@ namespace KokkosFFT { } template - void rfft2(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, axis_type<2> axes={-2, -1}) { + void rfft2(const InViewType& in, OutViewType& out, KokkosFFT::Normalization norm=KokkosFFT::Normalization::BACKWARD, axis_type<2> axes={-2, -1}) { static_assert(Kokkos::is_view::value, "KokkosFFT::rfft2: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -212,7 +212,7 @@ namespace KokkosFFT { } template - void irfft2(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD, axis_type<2> axes={-2, -1}) { + void irfft2(const InViewType& in, OutViewType& out, KokkosFFT::Normalization norm=KokkosFFT::Normalization::BACKWARD, axis_type<2> axes={-2, -1}) { static_assert(Kokkos::is_view::value, "KokkosFFT::irfft2: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -232,7 +232,7 @@ namespace KokkosFFT { namespace KokkosFFT { template - void fftn(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD) { + void fftn(const InViewType& in, OutViewType& out, KokkosFFT::Normalization norm=KokkosFFT::Normalization::BACKWARD) { static_assert(Kokkos::is_view::value, "KokkosFFT::fftn: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -260,7 +260,7 @@ namespace KokkosFFT { } template - void fftn(const InViewType& in, OutViewType& out, axis_type axes, FFT_Normalization norm=FFT_Normalization::BACKWARD) { + void fftn(const InViewType& in, OutViewType& out, axis_type axes, KokkosFFT::Normalization norm=KokkosFFT::Normalization::BACKWARD) { static_assert(Kokkos::is_view::value, "KokkosFFT::fftn: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -283,7 +283,7 @@ namespace KokkosFFT { } template - void ifftn(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD) { + void ifftn(const InViewType& in, OutViewType& out, KokkosFFT::Normalization norm=KokkosFFT::Normalization::BACKWARD) { static_assert(Kokkos::is_view::value, "KokkosFFT::ifftn: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -311,7 +311,7 @@ namespace KokkosFFT { } template - void ifftn(const InViewType& in, OutViewType& out, axis_type axes, FFT_Normalization norm=FFT_Normalization::BACKWARD) { + void ifftn(const InViewType& in, OutViewType& out, axis_type axes, KokkosFFT::Normalization norm=KokkosFFT::Normalization::BACKWARD) { static_assert(Kokkos::is_view::value, "KokkosFFT::ifftn: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -334,7 +334,7 @@ namespace KokkosFFT { } template - void rfftn(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD) { + void rfftn(const InViewType& in, OutViewType& out, KokkosFFT::Normalization norm=KokkosFFT::Normalization::BACKWARD) { static_assert(Kokkos::is_view::value, "KokkosFFT::rfftn: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -352,7 +352,7 @@ namespace KokkosFFT { } template - void rfftn(const InViewType& in, OutViewType& out, axis_type axes, FFT_Normalization norm=FFT_Normalization::BACKWARD) { + void rfftn(const InViewType& in, OutViewType& out, axis_type axes, KokkosFFT::Normalization norm=KokkosFFT::Normalization::BACKWARD) { static_assert(Kokkos::is_view::value, "KokkosFFT::rfftn: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -370,7 +370,7 @@ namespace KokkosFFT { } template - void irfftn(const InViewType& in, OutViewType& out, FFT_Normalization norm=FFT_Normalization::BACKWARD) { + void irfftn(const InViewType& in, OutViewType& out, KokkosFFT::Normalization norm=KokkosFFT::Normalization::BACKWARD) { static_assert(Kokkos::is_view::value, "KokkosFFT::irfftn: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, @@ -388,7 +388,7 @@ namespace KokkosFFT { } template - void irfftn(const InViewType& in, OutViewType& out, axis_type axes, FFT_Normalization norm=FFT_Normalization::BACKWARD) { + void irfftn(const InViewType& in, OutViewType& out, axis_type axes, KokkosFFT::Normalization norm=KokkosFFT::Normalization::BACKWARD) { static_assert(Kokkos::is_view::value, "KokkosFFT::irfftn: InViewType is not a Kokkos::View."); static_assert(Kokkos::is_view::value, diff --git a/fft/unit_test/Test_Transform.cpp b/fft/unit_test/Test_Transform.cpp index 0cd368ba..a52f90ea 100644 --- a/fft/unit_test/Test_Transform.cpp +++ b/fft/unit_test/Test_Transform.cpp @@ -127,10 +127,10 @@ void test_fft1_1dfft_1dview() { Kokkos::fence(); - KokkosFFT::fft(x, out); // default: KokkosFFT::FFT_Normalization::BACKWARD - KokkosFFT::fft(x, out_b, KokkosFFT::FFT_Normalization::BACKWARD); - KokkosFFT::fft(x, out_o, KokkosFFT::FFT_Normalization::ORTHO); - KokkosFFT::fft(x, out_f, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::fft(x, out); // default: KokkosFFT::Normalization::BACKWARD + KokkosFFT::fft(x, out_b, KokkosFFT::Normalization::BACKWARD); + KokkosFFT::fft(x, out_o, KokkosFFT::Normalization::ORTHO); + KokkosFFT::fft(x, out_f, KokkosFFT::Normalization::FORWARD); fft1(x, ref); multiply(out_o, sqrt(static_cast(len))); @@ -156,10 +156,10 @@ void test_fft1_1difft_1dview() { Kokkos::fence(); - KokkosFFT::ifft(x, out); // default: KokkosFFT::FFT_Normalization::BACKWARD - KokkosFFT::ifft(x, out_b, KokkosFFT::FFT_Normalization::BACKWARD); - KokkosFFT::ifft(x, out_o, KokkosFFT::FFT_Normalization::ORTHO); - KokkosFFT::ifft(x, out_f, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::ifft(x, out); // default: KokkosFFT::Normalization::BACKWARD + KokkosFFT::ifft(x, out_b, KokkosFFT::Normalization::BACKWARD); + KokkosFFT::ifft(x, out_o, KokkosFFT::Normalization::ORTHO); + KokkosFFT::ifft(x, out_f, KokkosFFT::Normalization::FORWARD); ifft1(x, ref); multiply(out_o, sqrt(static_cast(len))); @@ -206,15 +206,15 @@ void test_fft1_1dfft_2dview(T atol=1.e-12) { fft1(sub_x, sub_ref); } - KokkosFFT::fft(x, out_axis0, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/0); + KokkosFFT::fft(x, out_axis0, KokkosFFT::Normalization::BACKWARD, /*axis=*/0); EXPECT_TRUE( allclose(out_axis0, ref_out_axis0, 1.e-5, atol) ); - KokkosFFT::ifft(out_axis0, x_axis0, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/0); + KokkosFFT::ifft(out_axis0, x_axis0, KokkosFFT::Normalization::BACKWARD, /*axis=*/0); EXPECT_TRUE( allclose(x_axis0, ref_x, 1.e-5, atol) ); // Simple identity tests for r2c and c2r transforms - KokkosFFT::rfft(xr, outr_axis0, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/0); - KokkosFFT::irfft(outr_axis0, xr_axis0, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/0); + KokkosFFT::rfft(xr, outr_axis0, KokkosFFT::Normalization::BACKWARD, /*axis=*/0); + KokkosFFT::irfft(outr_axis0, xr_axis0, KokkosFFT::Normalization::BACKWARD, /*axis=*/0); EXPECT_TRUE( allclose(xr_axis0, ref_xr, 1.e-5, atol) ); @@ -230,15 +230,15 @@ void test_fft1_1dfft_2dview(T atol=1.e-12) { fft1(sub_x, sub_ref); } - KokkosFFT::fft(x, out_axis1, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/1); + KokkosFFT::fft(x, out_axis1, KokkosFFT::Normalization::BACKWARD, /*axis=*/1); EXPECT_TRUE( allclose(out_axis1, ref_out_axis1, 1.e-5, atol) ); - KokkosFFT::ifft(out_axis1, x_axis1, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/1); + KokkosFFT::ifft(out_axis1, x_axis1, KokkosFFT::Normalization::BACKWARD, /*axis=*/1); EXPECT_TRUE( allclose(x_axis1, ref_x, 1.e-5, atol) ); // Simple identity tests for r2c and c2r transforms - KokkosFFT::rfft(xr, outr_axis1, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/1); - KokkosFFT::irfft(outr_axis1, xr_axis1, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/1); + KokkosFFT::rfft(xr, outr_axis1, KokkosFFT::Normalization::BACKWARD, /*axis=*/1); + KokkosFFT::irfft(outr_axis1, xr_axis1, KokkosFFT::Normalization::BACKWARD, /*axis=*/1); EXPECT_TRUE( allclose(xr_axis1, ref_xr, 1.e-5, atol) ); } @@ -280,15 +280,15 @@ void test_fft1_1dfft_3dview(T atol=1.e-12) { } } - KokkosFFT::fft(x, out_axis0, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/0); + KokkosFFT::fft(x, out_axis0, KokkosFFT::Normalization::BACKWARD, /*axis=*/0); EXPECT_TRUE( allclose(out_axis0, ref_out_axis0, 1.e-5, atol) ); - KokkosFFT::ifft(out_axis0, x_axis0, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/0); + KokkosFFT::ifft(out_axis0, x_axis0, KokkosFFT::Normalization::BACKWARD, /*axis=*/0); EXPECT_TRUE( allclose(x_axis0, ref_x, 1.e-5, atol) ); // Simple identity tests for r2c and c2r transforms - KokkosFFT::rfft(xr, outr_axis0, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/0); - KokkosFFT::irfft(outr_axis0, xr_axis0, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/0); + KokkosFFT::rfft(xr, outr_axis0, KokkosFFT::Normalization::BACKWARD, /*axis=*/0); + KokkosFFT::irfft(outr_axis0, xr_axis0, KokkosFFT::Normalization::BACKWARD, /*axis=*/0); EXPECT_TRUE( allclose(xr_axis0, ref_xr, 1.e-5, atol) ); @@ -306,15 +306,15 @@ void test_fft1_1dfft_3dview(T atol=1.e-12) { } } - KokkosFFT::fft(x, out_axis1, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/1); + KokkosFFT::fft(x, out_axis1, KokkosFFT::Normalization::BACKWARD, /*axis=*/1); EXPECT_TRUE( allclose(out_axis1, ref_out_axis1, 1.e-5, atol) ); - KokkosFFT::ifft(out_axis1, x_axis1, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/1); + KokkosFFT::ifft(out_axis1, x_axis1, KokkosFFT::Normalization::BACKWARD, /*axis=*/1); EXPECT_TRUE( allclose(x_axis1, ref_x, 1.e-5, atol) ); // Simple identity tests for r2c and c2r transforms - KokkosFFT::rfft(xr, outr_axis1, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/1); - KokkosFFT::irfft(outr_axis1, xr_axis1, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/1); + KokkosFFT::rfft(xr, outr_axis1, KokkosFFT::Normalization::BACKWARD, /*axis=*/1); + KokkosFFT::irfft(outr_axis1, xr_axis1, KokkosFFT::Normalization::BACKWARD, /*axis=*/1); EXPECT_TRUE( allclose(xr_axis1, ref_xr, 1.e-5, atol) ); @@ -332,15 +332,15 @@ void test_fft1_1dfft_3dview(T atol=1.e-12) { } } - KokkosFFT::fft(x, out_axis2, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/2); + KokkosFFT::fft(x, out_axis2, KokkosFFT::Normalization::BACKWARD, /*axis=*/2); EXPECT_TRUE( allclose(out_axis2, ref_out_axis2, 1.e-5, atol) ); - KokkosFFT::ifft(out_axis2, x_axis2, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/2); + KokkosFFT::ifft(out_axis2, x_axis2, KokkosFFT::Normalization::BACKWARD, /*axis=*/2); EXPECT_TRUE( allclose(x_axis2, ref_x, 1.e-5, atol) ); // Simple identity tests for r2c and c2r transforms - KokkosFFT::rfft(xr, outr_axis2, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/2); - KokkosFFT::irfft(outr_axis2, xr_axis2, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/2); + KokkosFFT::rfft(xr, outr_axis2, KokkosFFT::Normalization::BACKWARD, /*axis=*/2); + KokkosFFT::irfft(outr_axis2, xr_axis2, KokkosFFT::Normalization::BACKWARD, /*axis=*/2); EXPECT_TRUE( allclose(xr_axis2, ref_xr, 1.e-5, atol) ); } @@ -447,13 +447,13 @@ void test_fft2_2dfft_2dview() { Kokkos::fence(); // np.fft2 is identical to np.fft(np.fft(x, axis=1), axis=0) - KokkosFFT::fft(x, out1, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/1); - KokkosFFT::fft(out1, out2, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/0); + KokkosFFT::fft(x, out1, KokkosFFT::Normalization::BACKWARD, /*axis=*/1); + KokkosFFT::fft(out1, out2, KokkosFFT::Normalization::BACKWARD, /*axis=*/0); - KokkosFFT::fft2(x, out); // default: KokkosFFT::FFT_Normalization::BACKWARD - KokkosFFT::fft2(x, out_b, KokkosFFT::FFT_Normalization::BACKWARD); - KokkosFFT::fft2(x, out_o, KokkosFFT::FFT_Normalization::ORTHO); - KokkosFFT::fft2(x, out_f, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::fft2(x, out); // default: KokkosFFT::Normalization::BACKWARD + KokkosFFT::fft2(x, out_b, KokkosFFT::Normalization::BACKWARD); + KokkosFFT::fft2(x, out_o, KokkosFFT::Normalization::ORTHO); + KokkosFFT::fft2(x, out_f, KokkosFFT::Normalization::FORWARD); multiply(out_o, sqrt(static_cast(n0 * n1))); multiply(out_f, static_cast(n0 * n1)); @@ -480,13 +480,13 @@ void test_fft2_2difft_2dview() { Kokkos::fence(); // np.ifft2 is identical to np.ifft(np.ifft(x, axis=1), axis=0) - KokkosFFT::ifft(x, out1, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/1); - KokkosFFT::ifft(out1, out2, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/0); + KokkosFFT::ifft(x, out1, KokkosFFT::Normalization::BACKWARD, /*axis=*/1); + KokkosFFT::ifft(out1, out2, KokkosFFT::Normalization::BACKWARD, /*axis=*/0); - KokkosFFT::ifft2(x, out); // default: KokkosFFT::FFT_Normalization::BACKWARD - KokkosFFT::ifft2(x, out_b, KokkosFFT::FFT_Normalization::BACKWARD); - KokkosFFT::ifft2(x, out_o, KokkosFFT::FFT_Normalization::ORTHO); - KokkosFFT::ifft2(x, out_f, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::ifft2(x, out); // default: KokkosFFT::Normalization::BACKWARD + KokkosFFT::ifft2(x, out_b, KokkosFFT::Normalization::BACKWARD); + KokkosFFT::ifft2(x, out_o, KokkosFFT::Normalization::ORTHO); + KokkosFFT::ifft2(x, out_f, KokkosFFT::Normalization::FORWARD); multiply(out_o, 1.0/sqrt(static_cast(n0 * n1))); multiply(out_f, 1.0/static_cast(n0 * n1)); @@ -513,20 +513,20 @@ void test_fft2_2drfft_2dview() { Kokkos::fence(); // np.rfft2 is identical to np.fft(np.rfft(x, axis=1), axis=0) - KokkosFFT::rfft(x, out1, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/1); - KokkosFFT::fft(out1, out2, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/0); + KokkosFFT::rfft(x, out1, KokkosFFT::Normalization::BACKWARD, /*axis=*/1); + KokkosFFT::fft(out1, out2, KokkosFFT::Normalization::BACKWARD, /*axis=*/0); Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfft2(x, out); // default: KokkosFFT::FFT_Normalization::BACKWARD + KokkosFFT::rfft2(x, out); // default: KokkosFFT::Normalization::BACKWARD Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfft2(x, out_b, KokkosFFT::FFT_Normalization::BACKWARD); + KokkosFFT::rfft2(x, out_b, KokkosFFT::Normalization::BACKWARD); Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfft2(x, out_o, KokkosFFT::FFT_Normalization::ORTHO); + KokkosFFT::rfft2(x, out_o, KokkosFFT::Normalization::ORTHO); Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfft2(x, out_f, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::rfft2(x, out_f, KokkosFFT::Normalization::FORWARD); multiply(out_o, sqrt(static_cast(n0 * n1))); multiply(out_f, static_cast(n0 * n1)); @@ -554,20 +554,20 @@ void test_fft2_2dirfft_2dview() { Kokkos::deep_copy(x_ref, x); // np.irfft2 is identical to np.irfft(np.ifft(x, axis=0), axis=1) - KokkosFFT::ifft(x, out1, KokkosFFT::FFT_Normalization::BACKWARD, 0); - KokkosFFT::irfft(out1, out2, KokkosFFT::FFT_Normalization::BACKWARD, 1); + KokkosFFT::ifft(x, out1, KokkosFFT::Normalization::BACKWARD, 0); + KokkosFFT::irfft(out1, out2, KokkosFFT::Normalization::BACKWARD, 1); Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfft2(x, out); // default: KokkosFFT::FFT_Normalization::BACKWARD + KokkosFFT::irfft2(x, out); // default: KokkosFFT::Normalization::BACKWARD Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfft2(x, out_b, KokkosFFT::FFT_Normalization::BACKWARD); + KokkosFFT::irfft2(x, out_b, KokkosFFT::Normalization::BACKWARD); Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfft2(x, out_o, KokkosFFT::FFT_Normalization::ORTHO); + KokkosFFT::irfft2(x, out_o, KokkosFFT::Normalization::ORTHO); Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfft2(x, out_f, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::irfft2(x, out_f, KokkosFFT::Normalization::FORWARD); multiply(out_o, 1.0/sqrt(static_cast(n0 * n1))); multiply(out_f, 1.0/static_cast(n0 * n1)); @@ -663,13 +663,13 @@ void test_fftn_2dfft_2dview() { Kokkos::fence(); // np.fftn for 2D array is identical to np.fft(np.fft(x, axis=1), axis=0) - KokkosFFT::fft(x, out1, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/1); - KokkosFFT::fft(out1, out2, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/0); + KokkosFFT::fft(x, out1, KokkosFFT::Normalization::BACKWARD, /*axis=*/1); + KokkosFFT::fft(out1, out2, KokkosFFT::Normalization::BACKWARD, /*axis=*/0); - KokkosFFT::fftn(x, out); // default: KokkosFFT::FFT_Normalization::BACKWARD - KokkosFFT::fftn(x, out_b, KokkosFFT::FFT_Normalization::BACKWARD); - KokkosFFT::fftn(x, out_o, KokkosFFT::FFT_Normalization::ORTHO); - KokkosFFT::fftn(x, out_f, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::fftn(x, out); // default: KokkosFFT::Normalization::BACKWARD + KokkosFFT::fftn(x, out_b, KokkosFFT::Normalization::BACKWARD); + KokkosFFT::fftn(x, out_o, KokkosFFT::Normalization::ORTHO); + KokkosFFT::fftn(x, out_f, KokkosFFT::Normalization::FORWARD); multiply(out_o, sqrt(static_cast(n0 * n1))); multiply(out_f, static_cast(n0 * n1)); @@ -683,10 +683,10 @@ void test_fftn_2dfft_2dview() { // np.fftn for 2D array is identical to np.fft(np.fft(x, axis=1), axis=0) using axes_type = KokkosFFT::axis_type<2>; - KokkosFFT::fftn(x, out, axes_type{-2, -1}); // default: KokkosFFT::FFT_Normalization::BACKWARD - KokkosFFT::fftn(x, out_b, axes_type{-2, -1}, KokkosFFT::FFT_Normalization::BACKWARD); - KokkosFFT::fftn(x, out_o, axes_type{-2, -1}, KokkosFFT::FFT_Normalization::ORTHO); - KokkosFFT::fftn(x, out_f, axes_type{-2, -1}, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::fftn(x, out, axes_type{-2, -1}); // default: KokkosFFT::Normalization::BACKWARD + KokkosFFT::fftn(x, out_b, axes_type{-2, -1}, KokkosFFT::Normalization::BACKWARD); + KokkosFFT::fftn(x, out_o, axes_type{-2, -1}, KokkosFFT::Normalization::ORTHO); + KokkosFFT::fftn(x, out_f, axes_type{-2, -1}, KokkosFFT::Normalization::FORWARD); multiply(out_o, sqrt(static_cast(n0 * n1))); multiply(out_f, static_cast(n0 * n1)); @@ -713,14 +713,14 @@ void test_fftn_3dfft_3dview(T atol=1.0e-6) { Kokkos::fence(); // np.fftn for 3D array is identical to np.fft(np.fft(np.fft(x, axis=2), axis=1), axis=0) - KokkosFFT::fft(x, out1, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/2); - KokkosFFT::fft(out1, out2, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/1); - KokkosFFT::fft(out2, out3, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/0); + KokkosFFT::fft(x, out1, KokkosFFT::Normalization::BACKWARD, /*axis=*/2); + KokkosFFT::fft(out1, out2, KokkosFFT::Normalization::BACKWARD, /*axis=*/1); + KokkosFFT::fft(out2, out3, KokkosFFT::Normalization::BACKWARD, /*axis=*/0); - KokkosFFT::fftn(x, out); // default: KokkosFFT::FFT_Normalization::BACKWARD - KokkosFFT::fftn(x, out_b, KokkosFFT::FFT_Normalization::BACKWARD); - KokkosFFT::fftn(x, out_o, KokkosFFT::FFT_Normalization::ORTHO); - KokkosFFT::fftn(x, out_f, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::fftn(x, out); // default: KokkosFFT::Normalization::BACKWARD + KokkosFFT::fftn(x, out_b, KokkosFFT::Normalization::BACKWARD); + KokkosFFT::fftn(x, out_o, KokkosFFT::Normalization::ORTHO); + KokkosFFT::fftn(x, out_f, KokkosFFT::Normalization::FORWARD); multiply(out_o, sqrt(static_cast(n0 * n1 * n2))); multiply(out_f, static_cast(n0 * n1 * n2)); @@ -734,10 +734,10 @@ void test_fftn_3dfft_3dview(T atol=1.0e-6) { // np.fftn for 3D array is identical to np.fft(np.fft(np.fft(x, axis=2), axis=1), axis=0) using axes_type = KokkosFFT::axis_type<3>; - KokkosFFT::fftn(x, out, axes_type{-3, -2, -1}); // default: KokkosFFT::FFT_Normalization::BACKWARD - KokkosFFT::fftn(x, out_b, axes_type{-3, -2, -1}, KokkosFFT::FFT_Normalization::BACKWARD); - KokkosFFT::fftn(x, out_o, axes_type{-3, -2, -1}, KokkosFFT::FFT_Normalization::ORTHO); - KokkosFFT::fftn(x, out_f, axes_type{-3, -2, -1}, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::fftn(x, out, axes_type{-3, -2, -1}); // default: KokkosFFT::Normalization::BACKWARD + KokkosFFT::fftn(x, out_b, axes_type{-3, -2, -1}, KokkosFFT::Normalization::BACKWARD); + KokkosFFT::fftn(x, out_o, axes_type{-3, -2, -1}, KokkosFFT::Normalization::ORTHO); + KokkosFFT::fftn(x, out_f, axes_type{-3, -2, -1}, KokkosFFT::Normalization::FORWARD); multiply(out_o, sqrt(static_cast(n0 * n1 * n2))); multiply(out_f, static_cast(n0 * n1 * n2)); @@ -764,13 +764,13 @@ void test_ifftn_2dfft_2dview() { Kokkos::fence(); // np.ifftn for 2D array is identical to np.ifft(np.ifft(x, axis=1), axis=0) - KokkosFFT::ifft(x, out1, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/1); - KokkosFFT::ifft(out1, out2, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/0); + KokkosFFT::ifft(x, out1, KokkosFFT::Normalization::BACKWARD, /*axis=*/1); + KokkosFFT::ifft(out1, out2, KokkosFFT::Normalization::BACKWARD, /*axis=*/0); - KokkosFFT::ifftn(x, out); // default: KokkosFFT::FFT_Normalization::BACKWARD - KokkosFFT::ifftn(x, out_b, KokkosFFT::FFT_Normalization::BACKWARD); - KokkosFFT::ifftn(x, out_o, KokkosFFT::FFT_Normalization::ORTHO); - KokkosFFT::ifftn(x, out_f, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::ifftn(x, out); // default: KokkosFFT::Normalization::BACKWARD + KokkosFFT::ifftn(x, out_b, KokkosFFT::Normalization::BACKWARD); + KokkosFFT::ifftn(x, out_o, KokkosFFT::Normalization::ORTHO); + KokkosFFT::ifftn(x, out_f, KokkosFFT::Normalization::FORWARD); multiply(out_o, 1.0/sqrt(static_cast(n0 * n1))); multiply(out_f, 1.0/static_cast(n0 * n1)); @@ -784,10 +784,10 @@ void test_ifftn_2dfft_2dview() { // np.fftn for 2D array is identical to np.fft(np.fft(x, axis=1), axis=0) using axes_type = KokkosFFT::axis_type<2>; - KokkosFFT::ifftn(x, out, axes_type{-2, -1}); // default: KokkosFFT::FFT_Normalization::BACKWARD - KokkosFFT::ifftn(x, out_b, axes_type{-2, -1}, KokkosFFT::FFT_Normalization::BACKWARD); - KokkosFFT::ifftn(x, out_o, axes_type{-2, -1}, KokkosFFT::FFT_Normalization::ORTHO); - KokkosFFT::ifftn(x, out_f, axes_type{-2, -1}, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::ifftn(x, out, axes_type{-2, -1}); // default: KokkosFFT::Normalization::BACKWARD + KokkosFFT::ifftn(x, out_b, axes_type{-2, -1}, KokkosFFT::Normalization::BACKWARD); + KokkosFFT::ifftn(x, out_o, axes_type{-2, -1}, KokkosFFT::Normalization::ORTHO); + KokkosFFT::ifftn(x, out_f, axes_type{-2, -1}, KokkosFFT::Normalization::FORWARD); multiply(out_o, 1.0/sqrt(static_cast(n0 * n1))); multiply(out_f, 1.0/static_cast(n0 * n1)); @@ -814,14 +814,14 @@ void test_ifftn_3dfft_3dview() { Kokkos::fence(); // np.ifftn for 3D array is identical to np.ifft(np.ifft(np.ifft(x, axis=2), axis=1), axis=0) - KokkosFFT::ifft(x, out1, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/2); - KokkosFFT::ifft(out1, out2, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/1); - KokkosFFT::ifft(out2, out3, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/0); + KokkosFFT::ifft(x, out1, KokkosFFT::Normalization::BACKWARD, /*axis=*/2); + KokkosFFT::ifft(out1, out2, KokkosFFT::Normalization::BACKWARD, /*axis=*/1); + KokkosFFT::ifft(out2, out3, KokkosFFT::Normalization::BACKWARD, /*axis=*/0); - KokkosFFT::ifftn(x, out); // default: KokkosFFT::FFT_Normalization::BACKWARD - KokkosFFT::ifftn(x, out_b, KokkosFFT::FFT_Normalization::BACKWARD); - KokkosFFT::ifftn(x, out_o, KokkosFFT::FFT_Normalization::ORTHO); - KokkosFFT::ifftn(x, out_f, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::ifftn(x, out); // default: KokkosFFT::Normalization::BACKWARD + KokkosFFT::ifftn(x, out_b, KokkosFFT::Normalization::BACKWARD); + KokkosFFT::ifftn(x, out_o, KokkosFFT::Normalization::ORTHO); + KokkosFFT::ifftn(x, out_f, KokkosFFT::Normalization::FORWARD); multiply(out_o, 1.0/sqrt(static_cast(n0 * n1 * n2))); multiply(out_f, 1.0/static_cast(n0 * n1 * n2)); @@ -835,10 +835,10 @@ void test_ifftn_3dfft_3dview() { // np.ifftn for 3D array is identical to np.ifft(np.ifft(np.ifft(x, axis=2), axis=1), axis=0) using axes_type = KokkosFFT::axis_type<3>; - KokkosFFT::ifftn(x, out, axes_type{-3, -2, -1}); // default: KokkosFFT::FFT_Normalization::BACKWARD - KokkosFFT::ifftn(x, out_b, axes_type{-3, -2, -1}, KokkosFFT::FFT_Normalization::BACKWARD); - KokkosFFT::ifftn(x, out_o, axes_type{-3, -2, -1}, KokkosFFT::FFT_Normalization::ORTHO); - KokkosFFT::ifftn(x, out_f, axes_type{-3, -2, -1}, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::ifftn(x, out, axes_type{-3, -2, -1}); // default: KokkosFFT::Normalization::BACKWARD + KokkosFFT::ifftn(x, out_b, axes_type{-3, -2, -1}, KokkosFFT::Normalization::BACKWARD); + KokkosFFT::ifftn(x, out_o, axes_type{-3, -2, -1}, KokkosFFT::Normalization::ORTHO); + KokkosFFT::ifftn(x, out_f, axes_type{-3, -2, -1}, KokkosFFT::Normalization::FORWARD); multiply(out_o, 1.0/sqrt(static_cast(n0 * n1 * n2))); multiply(out_f, 1.0/static_cast(n0 * n1 * n2)); @@ -865,20 +865,20 @@ void test_rfftn_2dfft_2dview() { Kokkos::fence(); // np.rfftn for 2D array is identical to np.fft(np.rfft(x, axis=1), axis=0) - KokkosFFT::rfft(x, out1, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/1); - KokkosFFT::fft(out1, out2, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/0); + KokkosFFT::rfft(x, out1, KokkosFFT::Normalization::BACKWARD, /*axis=*/1); + KokkosFFT::fft(out1, out2, KokkosFFT::Normalization::BACKWARD, /*axis=*/0); Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfftn(x, out); // default: KokkosFFT::FFT_Normalization::BACKWARD + KokkosFFT::rfftn(x, out); // default: KokkosFFT::Normalization::BACKWARD Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfftn(x, out_b, KokkosFFT::FFT_Normalization::BACKWARD); + KokkosFFT::rfftn(x, out_b, KokkosFFT::Normalization::BACKWARD); Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfftn(x, out_o, KokkosFFT::FFT_Normalization::ORTHO); + KokkosFFT::rfftn(x, out_o, KokkosFFT::Normalization::ORTHO); Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfftn(x, out_f, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::rfftn(x, out_f, KokkosFFT::Normalization::FORWARD); multiply(out_o, sqrt(static_cast(n0 * n1))); multiply(out_f, static_cast(n0 * n1)); @@ -893,16 +893,16 @@ void test_rfftn_2dfft_2dview() { using axes_type = KokkosFFT::axis_type<2>; Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfftn(x, out, axes_type{-2, -1}); // default: KokkosFFT::FFT_Normalization::BACKWARD + KokkosFFT::rfftn(x, out, axes_type{-2, -1}); // default: KokkosFFT::Normalization::BACKWARD Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfftn(x, out_b, axes_type{-2, -1}, KokkosFFT::FFT_Normalization::BACKWARD); + KokkosFFT::rfftn(x, out_b, axes_type{-2, -1}, KokkosFFT::Normalization::BACKWARD); Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfftn(x, out_o, axes_type{-2, -1}, KokkosFFT::FFT_Normalization::ORTHO); + KokkosFFT::rfftn(x, out_o, axes_type{-2, -1}, KokkosFFT::Normalization::ORTHO); Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfftn(x, out_f, axes_type{-2, -1}, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::rfftn(x, out_f, axes_type{-2, -1}, KokkosFFT::Normalization::FORWARD); multiply(out_o, sqrt(static_cast(n0 * n1))); multiply(out_f, static_cast(n0 * n1)); @@ -929,21 +929,21 @@ void test_rfftn_3dfft_3dview() { Kokkos::fence(); // np.rfftn for 3D array is identical to np.fft(np.fft(np.rfft(x, axis=2), axis=1), axis=0) - KokkosFFT::rfft(x, out1, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/2); - KokkosFFT::fft(out1, out2, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/1); - KokkosFFT::fft(out2, out3, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/0); + KokkosFFT::rfft(x, out1, KokkosFFT::Normalization::BACKWARD, /*axis=*/2); + KokkosFFT::fft(out1, out2, KokkosFFT::Normalization::BACKWARD, /*axis=*/1); + KokkosFFT::fft(out2, out3, KokkosFFT::Normalization::BACKWARD, /*axis=*/0); Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfftn(x, out); // default: KokkosFFT::FFT_Normalization::BACKWARD + KokkosFFT::rfftn(x, out); // default: KokkosFFT::Normalization::BACKWARD Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfftn(x, out_b, KokkosFFT::FFT_Normalization::BACKWARD); + KokkosFFT::rfftn(x, out_b, KokkosFFT::Normalization::BACKWARD); Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfftn(x, out_o, KokkosFFT::FFT_Normalization::ORTHO); + KokkosFFT::rfftn(x, out_o, KokkosFFT::Normalization::ORTHO); Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfftn(x, out_f, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::rfftn(x, out_f, KokkosFFT::Normalization::FORWARD); multiply(out_o, sqrt(static_cast(n0 * n1 * n2))); multiply(out_f, static_cast(n0 * n1 * n2)); @@ -958,16 +958,16 @@ void test_rfftn_3dfft_3dview() { using axes_type = KokkosFFT::axis_type<3>; Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfftn(x, out, axes_type{-3, -2, -1}); // default: KokkosFFT::FFT_Normalization::BACKWARD + KokkosFFT::rfftn(x, out, axes_type{-3, -2, -1}); // default: KokkosFFT::Normalization::BACKWARD Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfftn(x, out_b, axes_type{-3, -2, -1}, KokkosFFT::FFT_Normalization::BACKWARD); + KokkosFFT::rfftn(x, out_b, axes_type{-3, -2, -1}, KokkosFFT::Normalization::BACKWARD); Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfftn(x, out_o, axes_type{-3, -2, -1}, KokkosFFT::FFT_Normalization::ORTHO); + KokkosFFT::rfftn(x, out_o, axes_type{-3, -2, -1}, KokkosFFT::Normalization::ORTHO); Kokkos::deep_copy(x, x_ref); - KokkosFFT::rfftn(x, out_f, axes_type{-3, -2, -1}, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::rfftn(x, out_f, axes_type{-3, -2, -1}, KokkosFFT::Normalization::FORWARD); multiply(out_o, sqrt(static_cast(n0 * n1 * n2))); multiply(out_f, static_cast(n0 * n1 * n2)); @@ -995,20 +995,20 @@ void test_irfftn_2dfft_2dview() { Kokkos::deep_copy(x_ref, x); // np.irfftn for 2D array is identical to np.irfft(np.ifft(x, axis=0), axis=1) - KokkosFFT::ifft(x, out1, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/0); - KokkosFFT::irfft(out1, out2, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/1); + KokkosFFT::ifft(x, out1, KokkosFFT::Normalization::BACKWARD, /*axis=*/0); + KokkosFFT::irfft(out1, out2, KokkosFFT::Normalization::BACKWARD, /*axis=*/1); Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfftn(x, out); // default: KokkosFFT::FFT_Normalization::BACKWARD + KokkosFFT::irfftn(x, out); // default: KokkosFFT::Normalization::BACKWARD Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfftn(x, out_b, KokkosFFT::FFT_Normalization::BACKWARD); + KokkosFFT::irfftn(x, out_b, KokkosFFT::Normalization::BACKWARD); Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfftn(x, out_o, KokkosFFT::FFT_Normalization::ORTHO); + KokkosFFT::irfftn(x, out_o, KokkosFFT::Normalization::ORTHO); Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfftn(x, out_f, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::irfftn(x, out_f, KokkosFFT::Normalization::FORWARD); multiply(out_o, 1.0/sqrt(static_cast(n0 * n1))); multiply(out_f, 1.0/static_cast(n0 * n1)); @@ -1023,16 +1023,16 @@ void test_irfftn_2dfft_2dview() { using axes_type = KokkosFFT::axis_type<2>; Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfftn(x, out, axes_type{-2, -1}); // default: KokkosFFT::FFT_Normalization::BACKWARD + KokkosFFT::irfftn(x, out, axes_type{-2, -1}); // default: KokkosFFT::Normalization::BACKWARD Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfftn(x, out_b, axes_type{-2, -1}, KokkosFFT::FFT_Normalization::BACKWARD); + KokkosFFT::irfftn(x, out_b, axes_type{-2, -1}, KokkosFFT::Normalization::BACKWARD); Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfftn(x, out_o, axes_type{-2, -1}, KokkosFFT::FFT_Normalization::ORTHO); + KokkosFFT::irfftn(x, out_o, axes_type{-2, -1}, KokkosFFT::Normalization::ORTHO); Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfftn(x, out_f, axes_type{-2, -1}, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::irfftn(x, out_f, axes_type{-2, -1}, KokkosFFT::Normalization::FORWARD); multiply(out_o, 1.0/sqrt(static_cast(n0 * n1))); multiply(out_f, 1.0/static_cast(n0 * n1)); @@ -1060,21 +1060,21 @@ void test_irfftn_3dfft_3dview() { Kokkos::deep_copy(x_ref, x); // np.irfftn for 3D array is identical to np.irfft(np.ifft(np.ifft(x, axis=0), axis=1), axis=2) - KokkosFFT::ifft(x, out1, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/0); - KokkosFFT::ifft(out1, out2, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/1); - KokkosFFT::irfft(out2, out3, KokkosFFT::FFT_Normalization::BACKWARD, /*axis=*/2); + KokkosFFT::ifft(x, out1, KokkosFFT::Normalization::BACKWARD, /*axis=*/0); + KokkosFFT::ifft(out1, out2, KokkosFFT::Normalization::BACKWARD, /*axis=*/1); + KokkosFFT::irfft(out2, out3, KokkosFFT::Normalization::BACKWARD, /*axis=*/2); Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfftn(x, out); // default: KokkosFFT::FFT_Normalization::BACKWARD + KokkosFFT::irfftn(x, out); // default: KokkosFFT::Normalization::BACKWARD Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfftn(x, out_b, KokkosFFT::FFT_Normalization::BACKWARD); + KokkosFFT::irfftn(x, out_b, KokkosFFT::Normalization::BACKWARD); Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfftn(x, out_o, KokkosFFT::FFT_Normalization::ORTHO); + KokkosFFT::irfftn(x, out_o, KokkosFFT::Normalization::ORTHO); Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfftn(x, out_f, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::irfftn(x, out_f, KokkosFFT::Normalization::FORWARD); multiply(out_o, 1.0/sqrt(static_cast(n0 * n1 * n2))); multiply(out_f, 1.0/static_cast(n0 * n1 * n2)); @@ -1089,16 +1089,16 @@ void test_irfftn_3dfft_3dview() { using axes_type = KokkosFFT::axis_type<3>; Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfftn(x, out, axes_type{-3, -2, -1}); // default: KokkosFFT::FFT_Normalization::BACKWARD + KokkosFFT::irfftn(x, out, axes_type{-3, -2, -1}); // default: KokkosFFT::Normalization::BACKWARD Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfftn(x, out_b, axes_type{-3, -2, -1}, KokkosFFT::FFT_Normalization::BACKWARD); + KokkosFFT::irfftn(x, out_b, axes_type{-3, -2, -1}, KokkosFFT::Normalization::BACKWARD); Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfftn(x, out_o, axes_type{-3, -2, -1}, KokkosFFT::FFT_Normalization::ORTHO); + KokkosFFT::irfftn(x, out_o, axes_type{-3, -2, -1}, KokkosFFT::Normalization::ORTHO); Kokkos::deep_copy(x, x_ref); - KokkosFFT::irfftn(x, out_f, axes_type{-3, -2, -1}, KokkosFFT::FFT_Normalization::FORWARD); + KokkosFFT::irfftn(x, out_f, axes_type{-3, -2, -1}, KokkosFFT::Normalization::FORWARD); multiply(out_o, 1.0/sqrt(static_cast(n0 * n1 * n2))); multiply(out_f, 1.0/static_cast(n0 * n1 * n2));