diff --git a/common/src/KokkosFFT_padding.hpp b/common/src/KokkosFFT_padding.hpp index d8f22f5e..fe100356 100644 --- a/common/src/KokkosFFT_padding.hpp +++ b/common/src/KokkosFFT_padding.hpp @@ -91,256 +91,28 @@ auto is_crop_or_pad_needed(const ViewType& view, return not_same; } -template -void crop_or_pad_impl(const ExecutionSpace& exec_space, const InViewType& in, - OutViewType& out, shape_type<1> s) { - auto s0 = s.at(0); - out = OutViewType("out", s0); - - auto n0 = std::min(s0, in.extent(0)); - - Kokkos::parallel_for( - "KokkosFFT::crop_or_pad", - Kokkos::RangePolicy>( - exec_space, 0, n0), - KOKKOS_LAMBDA(std::size_t i0) { out(i0) = in(i0); }); -} - -template -void crop_or_pad_impl(const ExecutionSpace& exec_space, const InViewType& in, - OutViewType& out, shape_type<2> s) { - constexpr std::size_t DIM = 2; - - auto [s0, s1] = s; - out = OutViewType("out", s0, s1); - - int n0 = std::min(s0, in.extent(0)); - int n1 = std::min(s1, in.extent(1)); - - using range_type = Kokkos::MDRangePolicy< - ExecutionSpace, - Kokkos::Rank>; - using tile_type = typename range_type::tile_type; - using point_type = typename range_type::point_type; - - range_type range( - exec_space, point_type{{0, 0}}, point_type{{n0, n1}}, tile_type{{4, 4}} - // [TO DO] Choose optimal tile sizes for each device - ); - - Kokkos::parallel_for( - "KokkosFFT::crop_or_pad", range, - KOKKOS_LAMBDA(int i0, int i1) { out(i0, i1) = in(i0, i1); }); -} - -template -void crop_or_pad_impl(const ExecutionSpace& exec_space, const InViewType& in, - OutViewType& out, shape_type<3> s) { - constexpr std::size_t DIM = 3; - - auto [s0, s1, s2] = s; - out = OutViewType("out", s0, s1, s2); - - int n0 = std::min(s0, in.extent(0)); - int n1 = std::min(s1, in.extent(1)); - int n2 = std::min(s2, in.extent(2)); - - using range_type = Kokkos::MDRangePolicy< - ExecutionSpace, - Kokkos::Rank>; - using tile_type = typename range_type::tile_type; - using point_type = typename range_type::point_type; - - range_type range( - exec_space, point_type{{0, 0, 0}}, point_type{{n0, n1, n2}}, - tile_type{{4, 4, 4}} // [TO DO] Choose optimal tile sizes for each device - ); - - Kokkos::parallel_for( - "KokkosFFT::crop_or_pad", range, KOKKOS_LAMBDA(int i0, int i1, int i2) { - out(i0, i1, i2) = in(i0, i1, i2); - }); -} - -template -void crop_or_pad_impl(const ExecutionSpace& exec_space, const InViewType& in, - OutViewType& out, shape_type<4> s) { - constexpr std::size_t DIM = 4; - - auto [s0, s1, s2, s3] = s; - out = OutViewType("out", s0, s1, s2, s3); - - int n0 = std::min(s0, in.extent(0)); - int n1 = std::min(s1, in.extent(1)); - int n2 = std::min(s2, in.extent(2)); - int n3 = std::min(s3, in.extent(3)); - - using range_type = Kokkos::MDRangePolicy< - ExecutionSpace, - Kokkos::Rank>; - using tile_type = typename range_type::tile_type; - using point_type = typename range_type::point_type; - - range_type range(exec_space, point_type{{0, 0, 0, 0}}, - point_type{{n0, n1, n2, n3}}, tile_type{{4, 4, 4, 4}} - // [TO DO] Choose optimal tile sizes for each device - ); - - Kokkos::parallel_for( - "KokkosFFT::crop_or_pad", range, - KOKKOS_LAMBDA(int i0, int i1, int i2, int i3) { - out(i0, i1, i2, i3) = in(i0, i1, i2, i3); - }); -} - -template -void crop_or_pad_impl(const ExecutionSpace& exec_space, const InViewType& in, - OutViewType& out, shape_type<5> s) { - constexpr std::size_t DIM = 5; - - auto [s0, s1, s2, s3, s4] = s; - out = OutViewType("out", s0, s1, s2, s3, s4); - - int n0 = std::min(s0, in.extent(0)); - int n1 = std::min(s1, in.extent(1)); - int n2 = std::min(s2, in.extent(2)); - int n3 = std::min(s3, in.extent(3)); - int n4 = std::min(s4, in.extent(4)); - - using range_type = Kokkos::MDRangePolicy< - ExecutionSpace, - Kokkos::Rank>; - using tile_type = typename range_type::tile_type; - using point_type = typename range_type::point_type; - - range_type range(exec_space, point_type{{0, 0, 0, 0, 0}}, - point_type{{n0, n1, n2, n3, n4}}, tile_type{{4, 4, 4, 4, 1}} - // [TO DO] Choose optimal tile sizes for each device - ); - - Kokkos::parallel_for( - "KokkosFFT::crop_or_pad", range, - KOKKOS_LAMBDA(int i0, int i1, int i2, int i3, int i4) { - out(i0, i1, i2, i3, i4) = in(i0, i1, i2, i3, i4); - }); -} - -template -void crop_or_pad_impl(const ExecutionSpace& exec_space, const InViewType& in, - OutViewType& out, shape_type<6> s) { - constexpr std::size_t DIM = 6; - - auto [s0, s1, s2, s3, s4, s5] = s; - out = OutViewType("out", s0, s1, s2, s3, s4, s5); - - int n0 = std::min(s0, in.extent(0)); - int n1 = std::min(s1, in.extent(1)); - int n2 = std::min(s2, in.extent(2)); - int n3 = std::min(s3, in.extent(3)); - int n4 = std::min(s4, in.extent(4)); - int n5 = std::min(s5, in.extent(5)); - - using range_type = Kokkos::MDRangePolicy< - ExecutionSpace, - Kokkos::Rank>; - using tile_type = typename range_type::tile_type; - using point_type = typename range_type::point_type; - - range_type range(exec_space, point_type{{0, 0, 0, 0, 0, 0}}, - point_type{{n0, n1, n2, n3, n4, n5}}, - tile_type{{4, 4, 4, 4, 1, 1}} - // [TO DO] Choose optimal tile sizes for each device - ); - - Kokkos::parallel_for( - "KokkosFFT::crop_or_pad", range, - KOKKOS_LAMBDA(int i0, int i1, int i2, int i3, int i4, int i5) { - out(i0, i1, i2, i3, i4, i5) = in(i0, i1, i2, i3, i4, i5); - }); -} - -template +template void crop_or_pad_impl(const ExecutionSpace& exec_space, const InViewType& in, - OutViewType& out, shape_type<7> s) { - constexpr std::size_t DIM = 6; - - auto [s0, s1, s2, s3, s4, s5, s6] = s; - out = OutViewType("out", s0, s1, s2, s3, s4, s5, s6); + const OutViewType& out, std::index_sequence) { + constexpr std::size_t rank = InViewType::rank(); + using extents_type = std::array; - int n0 = std::min(s0, in.extent(0)); - int n1 = std::min(s1, in.extent(1)); - int n2 = std::min(s2, in.extent(2)); - int n3 = std::min(s3, in.extent(3)); - int n4 = std::min(s4, in.extent(4)); - int n5 = std::min(s5, in.extent(5)); - int n6 = std::min(s6, in.extent(6)); - - using range_type = Kokkos::MDRangePolicy< - ExecutionSpace, - Kokkos::Rank>; - using tile_type = typename range_type::tile_type; - using point_type = typename range_type::point_type; - - range_type range(exec_space, point_type{{0, 0, 0, 0, 0, 0}}, - point_type{{n0, n1, n2, n3, n4, n5}}, - tile_type{{4, 4, 4, 4, 1, 1}} - // [TO DO] Choose optimal tile sizes for each device - ); + extents_type extents; + for (std::size_t i = 0; i < rank; i++) { + extents.at(i) = std::min(in.extent(i), out.extent(i)); + } - Kokkos::parallel_for( - "KokkosFFT::crop_or_pad", range, - KOKKOS_LAMBDA(int i0, int i1, int i2, int i3, int i4, int i5) { - for (int i6 = 0; i6 < n6; i6++) { - out(i0, i1, i2, i3, i4, i5, i6) = in(i0, i1, i2, i3, i4, i5, i6); - } - }); + auto sub_in = Kokkos::subview( + in, std::make_pair(std::size_t(0), std::get(extents))...); + auto sub_out = Kokkos::subview( + out, std::make_pair(std::size_t(0), std::get(extents))...); + Kokkos::deep_copy(exec_space, sub_out, sub_in); } template -void crop_or_pad_impl(const ExecutionSpace& exec_space, const InViewType& in, - OutViewType& out, shape_type<8> s) { - constexpr std::size_t DIM = 6; - - auto [s0, s1, s2, s3, s4, s5, s6, s7] = s; - out = OutViewType("out", s0, s1, s2, s3, s4, s5, s6, s7); - - int n0 = std::min(s0, in.extent(0)); - int n1 = std::min(s1, in.extent(1)); - int n2 = std::min(s2, in.extent(2)); - int n3 = std::min(s3, in.extent(3)); - int n4 = std::min(s4, in.extent(4)); - int n5 = std::min(s5, in.extent(5)); - int n6 = std::min(s6, in.extent(6)); - int n7 = std::min(s7, in.extent(7)); - - using range_type = Kokkos::MDRangePolicy< - ExecutionSpace, - Kokkos::Rank>; - using tile_type = typename range_type::tile_type; - using point_type = typename range_type::point_type; - - range_type range(exec_space, point_type{{0, 0, 0, 0, 0, 0}}, - point_type{{n0, n1, n2, n3, n4, n5}}, - tile_type{{4, 4, 4, 4, 1, 1}} - // [TO DO] Choose optimal tile sizes for each device - ); - - Kokkos::parallel_for( - "KokkosFFT::crop_or_pad", range, - KOKKOS_LAMBDA(int i0, int i1, int i2, int i3, int i4, int i5) { - for (int i6 = 0; i6 < n6; i6++) { - for (int i7 = 0; i7 < n7; i7++) { - out(i0, i1, i2, i3, i4, i5, i6, i7) = - in(i0, i1, i2, i3, i4, i5, i6, i7); - } - } - }); -} - -template void crop_or_pad(const ExecutionSpace& exec_space, const InViewType& in, - OutViewType& out, shape_type s) { + const OutViewType& out) { static_assert( KokkosFFT::Impl::are_operatable_views_v, @@ -349,7 +121,8 @@ void crop_or_pad(const ExecutionSpace& exec_space, const InViewType& in, "type (float/double), the same layout (LayoutLeft/LayoutRight), and the " "same rank. ExecutionSpace must be accessible to the data in InViewType " "and OutViewType."); - crop_or_pad_impl(exec_space, in, out, s); + crop_or_pad_impl(exec_space, in, out, + std::make_index_sequence{}); } } // namespace Impl } // namespace KokkosFFT diff --git a/common/src/KokkosFFT_utils.hpp b/common/src/KokkosFFT_utils.hpp index f110f4c6..c0829d7c 100644 --- a/common/src/KokkosFFT_utils.hpp +++ b/common/src/KokkosFFT_utils.hpp @@ -209,13 +209,16 @@ auto extract_extents(const ViewType& view) { return extents; } -template -Layout create_layout(const std::array& extents) { +template +Layout create_layout(const std::array& extents) { + static_assert(std::is_integral_v, + "create_layout: IntType must be an integral type"); static_assert(std::is_same_v || std::is_same_v, "create_layout: Layout must be either Kokkos::LayoutLeft or " "Kokkos::LayoutRight."); Layout layout; + // const std::size_t N = extents.size(); std::copy_n(extents.begin(), N, layout.dimension); return layout; } diff --git a/common/unit_test/Test_Padding.cpp b/common/unit_test/Test_Padding.cpp index d9823e3d..cc2c58fe 100644 --- a/common/unit_test/Test_Padding.cpp +++ b/common/unit_test/Test_Padding.cpp @@ -913,7 +913,8 @@ TEST(CropOrPad1D, 1DView) { const int len = 30, len_pad = 32, len_crop = 28; View1D x("x", len); - View1D x_out, x_out_pad, x_out_crop; + View1D x_out("x_out", len), x_out_pad("x_out_pad", len_pad), + x_out_crop("x_out_crop", len_crop); View1D ref_x("ref_x", len), ref_x_pad("ref_x_pad", len_pad), ref_x_crop("ref_x_crop", len_crop); @@ -932,11 +933,9 @@ TEST(CropOrPad1D, 1DView) { auto sub_x = Kokkos::subview(x, range1); Kokkos::deep_copy(ref_x_crop, sub_x); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out, shape_type<1>{len}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_pad, - shape_type<1>{len_pad}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_crop, - shape_type<1>{len_crop}); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_pad); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_crop); EXPECT_TRUE(allclose(x_out, ref_x, 1.e-5, 1.e-12)); EXPECT_TRUE(allclose(x_out_pad, ref_x_pad, 1.e-5, 1.e-12)); @@ -948,8 +947,11 @@ TEST(CropOrPad1D, 2DView) { const int n1 = 5, n1_pad = 7, n1_crop = 3; View2D x("x", n0, n1); - View2D x_out, x_out_pad_axis0, x_out_pad_axis1, x_out_crop_axis0, - x_out_crop_axis1; + View2D x_out("x_out", n0, n1), + x_out_pad_axis0("x_out_pad_axis0", n0_pad, n1), + x_out_pad_axis1("x_out_pad_axis1", n0, n1_pad), + x_out_crop_axis0("x_out_crop_axis0", n0_crop, n1), + x_out_crop_axis1("x_out_crop_axis1", n0, n1_crop); View2D ref_x("ref_x", n0, n1), ref_x_pad_axis0("ref_x_pad_axis0", n0_pad, n1), ref_x_crop_axis0("ref_x_crop_axis0", n0_crop, n1); @@ -1002,17 +1004,12 @@ TEST(CropOrPad1D, 2DView) { Kokkos::deep_copy(ref_x_pad_axis1, h_ref_x_pad_axis1); Kokkos::deep_copy(ref_x_crop_axis1, h_ref_x_crop_axis1); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out, - shape_type<2>{n0, n1}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_pad_axis0, - shape_type<2>{n0_pad, n1}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_crop_axis0, - shape_type<2>{n0_crop, n1}); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_pad_axis0); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_crop_axis0); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_pad_axis1, - shape_type<2>{n0, n1_pad}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_crop_axis1, - shape_type<2>{n0, n1_crop}); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_pad_axis1); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_crop_axis1); EXPECT_TRUE(allclose(x_out, ref_x, 1.e-5, 1.e-12)); EXPECT_TRUE(allclose(x_out_pad_axis0, ref_x_pad_axis0, 1.e-5, 1.e-12)); @@ -1027,8 +1024,13 @@ TEST(CropOrPad1D, 3DView) { const int n2 = 8, n2_pad = 10, n2_crop = 6; View3D x("x", n0, n1, n2); - View3D x_out, x_out_pad_axis0, x_out_crop_axis0, x_out_pad_axis1, - x_out_crop_axis1, x_out_pad_axis2, x_out_crop_axis2; + View3D x_out("x_out", n0, n1, n2), + x_out_pad_axis0("x_out_pad_axis0", n0_pad, n1, n2), + x_out_crop_axis0("x_out_crop_axis0", n0_crop, n1, n2), + x_out_pad_axis1("x_out_pad_axis1", n0, n1_pad, n2), + x_out_crop_axis1("x_out_crop_axis1", n0, n1_crop, n2), + x_out_pad_axis2("x_out_pad_axis2", n0, n1, n2_pad), + x_out_crop_axis2("x_out_crop_axis2", n0, n1, n2_crop); View3D ref_x("ref_x", n0, n1, n2), ref_x_pad_axis0("ref_x_pad_axis0", n0_pad, n1, n2), ref_x_crop_axis0("ref_x_crop_axis0", n0_crop, n1, n2); @@ -1109,22 +1111,15 @@ TEST(CropOrPad1D, 3DView) { Kokkos::deep_copy(ref_x_pad_axis2, h_ref_x_pad_axis2); Kokkos::deep_copy(ref_x_crop_axis2, h_ref_x_crop_axis2); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out, - shape_type<3>{n0, n1, n2}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_pad_axis0, - shape_type<3>{n0_pad, n1, n2}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_crop_axis0, - shape_type<3>{n0_crop, n1, n2}); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_pad_axis0); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_crop_axis0); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_pad_axis1, - shape_type<3>{n0, n1_pad, n2}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_crop_axis1, - shape_type<3>{n0, n1_crop, n2}); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_pad_axis1); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_crop_axis1); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_pad_axis2, - shape_type<3>{n0, n1, n2_pad}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_crop_axis2, - shape_type<3>{n0, n1, n2_crop}); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_pad_axis2); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_crop_axis2); EXPECT_TRUE(allclose(x_out, ref_x, 1.e-5, 1.e-12)); EXPECT_TRUE(allclose(x_out_pad_axis0, ref_x_pad_axis0, 1.e-5, 1.e-12)); @@ -1140,8 +1135,14 @@ TEST(CropOrPad2D, 2DView) { const int n1 = 5, n1_pad = 7, n1_crop = 3; View2D x("x", n0, n1); - View2D x_out, x_out_0_1p, x_out_0_1c, x_out_0p_1, x_out_0p_1p, - x_out_0p_1c, x_out_0c_1, x_out_0c_1p, x_out_0c_1c; + View2D x_out("x_out", n0, n1), x_out_0_1p("x_out_0_1p", n0, n1_pad), + x_out_0_1c("x_out_0_1c", n0, n1_crop), + x_out_0p_1("x_out_0p_1", n0_pad, n1), + x_out_0p_1p("x_out_0p_1p", n0_pad, n1_pad), + x_out_0p_1c("x_out_0p_1c", n0_pad, n1_crop), + x_out_0c_1("x_out_0c_1", n0_crop, n1), + x_out_0c_1p("x_out_0c_1p", n0_crop, n1_pad), + x_out_0c_1c("x_out_0c_1c", n0_crop, n1_crop); View2D ref_x("ref_x", n0, n1), ref_x_0_1p("ref_x_0_1p", n0, n1_pad), ref_x_0_1c("ref_x_0_1c", n0, n1_crop); View2D ref_x_0p_1("ref_x_0p_1", n0_pad, n1), @@ -1215,24 +1216,15 @@ TEST(CropOrPad2D, 2DView) { Kokkos::deep_copy(ref_x_0c_1p, h_ref_x_0c_1p); Kokkos::deep_copy(ref_x_0c_1c, h_ref_x_0c_1c); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out, - shape_type<2>{n0, n1}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0_1p, - shape_type<2>{n0, n1_pad}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0_1c, - shape_type<2>{n0, n1_crop}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0p_1, - shape_type<2>{n0_pad, n1}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0p_1p, - shape_type<2>{n0_pad, n1_pad}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0p_1c, - shape_type<2>{n0_pad, n1_crop}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0c_1, - shape_type<2>{n0_crop, n1}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0c_1p, - shape_type<2>{n0_crop, n1_pad}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0c_1c, - shape_type<2>{n0_crop, n1_crop}); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0_1p); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0_1c); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0p_1); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0p_1p); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0p_1c); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0c_1); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0c_1p); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0c_1c); EXPECT_TRUE(allclose(x_out, ref_x, 1.e-5, 1.e-12)); EXPECT_TRUE(allclose(x_out_0_1p, ref_x_0_1p, 1.e-5, 1.e-12)); @@ -1251,8 +1243,15 @@ TEST(CropOrPad2D, 3DView) { const int n2 = 8; View3D x("x", n0, n1, n2); - View3D x_out, x_out_0_1p, x_out_0_1c, x_out_0p_1, x_out_0p_1p, - x_out_0p_1c, x_out_0c_1, x_out_0c_1p, x_out_0c_1c; + View3D x_out("x_out", n0, n1, n2), + x_out_0_1p("x_out_0_1p", n0, n1_pad, n2), + x_out_0_1c("x_out_0_1c", n0, n1_crop, n2), + x_out_0p_1("x_out_0p_1", n0_pad, n1, n2), + x_out_0p_1p("x_out_0p_1p", n0_pad, n1_pad, n2), + x_out_0p_1c("x_out_0p_1c", n0_pad, n1_crop, n2), + x_out_0c_1("x_out_0c_1", n0_crop, n1, n2), + x_out_0c_1p("x_out_0c_1p", n0_crop, n1_pad, n2), + x_out_0c_1c("x_out_0c_1c", n0_crop, n1_crop, n2); View3D ref_x("ref_x", n0, n1, n2), ref_x_0_1p("ref_x_0_1p", n0, n1_pad, n2), ref_x_0_1c("ref_x_0_1c", n0, n1_crop, n2); @@ -1329,24 +1328,15 @@ TEST(CropOrPad2D, 3DView) { Kokkos::deep_copy(ref_x_0c_1p, h_ref_x_0c_1p); Kokkos::deep_copy(ref_x_0c_1c, h_ref_x_0c_1c); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out, - shape_type<3>{n0, n1, n2}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0_1p, - shape_type<3>{n0, n1_pad, n2}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0_1c, - shape_type<3>{n0, n1_crop, n2}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0p_1, - shape_type<3>{n0_pad, n1, n2}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0p_1p, - shape_type<3>{n0_pad, n1_pad, n2}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0p_1c, - shape_type<3>{n0_pad, n1_crop, n2}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0c_1, - shape_type<3>{n0_crop, n1, n2}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0c_1p, - shape_type<3>{n0_crop, n1_pad, n2}); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0c_1c, - shape_type<3>{n0_crop, n1_crop, n2}); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0_1p); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0_1c); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0p_1); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0p_1p); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0p_1c); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0c_1); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0c_1p); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out_0c_1c); EXPECT_TRUE(allclose(x_out, ref_x, 1.e-5, 1.e-12)); EXPECT_TRUE(allclose(x_out_0_1p, ref_x_0_1p, 1.e-5, 1.e-12)); @@ -1371,12 +1361,11 @@ TEST(CropOrPad3D, 3DView) { for (int d0 = -1; d0 <= 1; d0++) { for (int d1 = -1; d1 <= 1; d1++) { for (int d2 = -1; d2 <= 1; d2++) { - std::size_t n0_new = static_cast(n0 + d0); - std::size_t n1_new = static_cast(n1 + d1); - std::size_t n2_new = static_cast(n2 + d2); - shape_type<3> shape_new = {n0_new, n1_new, n2_new}; + std::size_t n0_new = static_cast(n0 + d0); + std::size_t n1_new = static_cast(n1 + d1); + std::size_t n2_new = static_cast(n2 + d2); - View3D x_out; + View3D x_out("x_out", n0_new, n1_new, n2_new); View3D ref_x("ref_x", n0_new, n1_new, n2_new); auto h_ref_x = Kokkos::create_mirror_view(ref_x); @@ -1393,7 +1382,7 @@ TEST(CropOrPad3D, 3DView) { } Kokkos::deep_copy(ref_x, h_ref_x); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out, shape_new); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out); EXPECT_TRUE(allclose(x_out, ref_x, 1.e-5, 1.e-12)); } } @@ -1415,14 +1404,13 @@ TEST(CropOrPad4D, 4DView) { for (int d0 = -1; d0 <= 1; d0++) { for (int d1 = -1; d1 <= 1; d1++) { for (int d2 = -1; d2 <= 1; d2++) { - int d3 = rand_dist(rand_engine); - std::size_t n0_new = static_cast(n0 + d0); - std::size_t n1_new = static_cast(n1 + d1); - std::size_t n2_new = static_cast(n2 + d2); - std::size_t n3_new = static_cast(n3 + d3); - shape_type<4> shape_new = {n0_new, n1_new, n2_new, n3_new}; - - View4D x_out; + int d3 = rand_dist(rand_engine); + std::size_t n0_new = static_cast(n0 + d0); + std::size_t n1_new = static_cast(n1 + d1); + std::size_t n2_new = static_cast(n2 + d2); + std::size_t n3_new = static_cast(n3 + d3); + + View4D x_out("x_out", n0_new, n1_new, n2_new, n3_new); View4D ref_x("ref_x", n0_new, n1_new, n2_new, n3_new); auto h_ref_x = Kokkos::create_mirror_view(ref_x); @@ -1443,7 +1431,7 @@ TEST(CropOrPad4D, 4DView) { } Kokkos::deep_copy(ref_x, h_ref_x); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out, shape_new); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out); EXPECT_TRUE(allclose(x_out, ref_x, 1.e-5, 1.e-12)); } } @@ -1465,16 +1453,15 @@ TEST(CropOrPad5D, 5DView) { for (int d0 = -1; d0 <= 1; d0++) { for (int d1 = -1; d1 <= 1; d1++) { for (int d2 = -1; d2 <= 1; d2++) { - int d3 = rand_dist(rand_engine); - int d4 = rand_dist(rand_engine); - std::size_t n0_new = static_cast(n0 + d0); - std::size_t n1_new = static_cast(n1 + d1); - std::size_t n2_new = static_cast(n2 + d2); - std::size_t n3_new = static_cast(n3 + d3); - std::size_t n4_new = static_cast(n4 + d4); - shape_type<5> shape_new = {n0_new, n1_new, n2_new, n3_new, n4_new}; - - View5D x_out; + int d3 = rand_dist(rand_engine); + int d4 = rand_dist(rand_engine); + std::size_t n0_new = static_cast(n0 + d0); + std::size_t n1_new = static_cast(n1 + d1); + std::size_t n2_new = static_cast(n2 + d2); + std::size_t n3_new = static_cast(n3 + d3); + std::size_t n4_new = static_cast(n4 + d4); + + View5D x_out("x_out", n0_new, n1_new, n2_new, n3_new, n4_new); View5D ref_x("ref_x", n0_new, n1_new, n2_new, n3_new, n4_new); auto h_ref_x = Kokkos::create_mirror_view(ref_x); @@ -1497,7 +1484,7 @@ TEST(CropOrPad5D, 5DView) { } Kokkos::deep_copy(ref_x, h_ref_x); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out, shape_new); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out); EXPECT_TRUE(allclose(x_out, ref_x, 1.e-5, 1.e-12)); } } @@ -1519,19 +1506,18 @@ TEST(CropOrPad6D, 6DView) { for (int d0 = -1; d0 <= 1; d0++) { for (int d1 = -1; d1 <= 1; d1++) { for (int d2 = -1; d2 <= 1; d2++) { - int d3 = rand_dist(rand_engine); - int d4 = rand_dist(rand_engine); - int d5 = rand_dist(rand_engine); - std::size_t n0_new = static_cast(n0 + d0); - std::size_t n1_new = static_cast(n1 + d1); - std::size_t n2_new = static_cast(n2 + d2); - std::size_t n3_new = static_cast(n3 + d3); - std::size_t n4_new = static_cast(n4 + d4); - std::size_t n5_new = static_cast(n5 + d5); - shape_type<6> shape_new = {n0_new, n1_new, n2_new, - n3_new, n4_new, n5_new}; - - View6D x_out; + int d3 = rand_dist(rand_engine); + int d4 = rand_dist(rand_engine); + int d5 = rand_dist(rand_engine); + std::size_t n0_new = static_cast(n0 + d0); + std::size_t n1_new = static_cast(n1 + d1); + std::size_t n2_new = static_cast(n2 + d2); + std::size_t n3_new = static_cast(n3 + d3); + std::size_t n4_new = static_cast(n4 + d4); + std::size_t n5_new = static_cast(n5 + d5); + + View6D x_out("x_out", n0_new, n1_new, n2_new, n3_new, n4_new, + n5_new); View6D ref_x("ref_x", n0_new, n1_new, n2_new, n3_new, n4_new, n5_new); @@ -1559,7 +1545,7 @@ TEST(CropOrPad6D, 6DView) { } Kokkos::deep_copy(ref_x, h_ref_x); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out, shape_new); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out); EXPECT_TRUE(allclose(x_out, ref_x, 1.e-5, 1.e-12)); } } @@ -1581,21 +1567,20 @@ TEST(CropOrPad7D, 7DView) { for (int d0 = -1; d0 <= 1; d0++) { for (int d1 = -1; d1 <= 1; d1++) { for (int d2 = -1; d2 <= 1; d2++) { - int d3 = rand_dist(rand_engine); - int d4 = rand_dist(rand_engine); - int d5 = rand_dist(rand_engine); - int d6 = rand_dist(rand_engine); - std::size_t n0_new = static_cast(n0 + d0); - std::size_t n1_new = static_cast(n1 + d1); - std::size_t n2_new = static_cast(n2 + d2); - std::size_t n3_new = static_cast(n3 + d3); - std::size_t n4_new = static_cast(n4 + d4); - std::size_t n5_new = static_cast(n5 + d5); - std::size_t n6_new = static_cast(n6 + d6); - shape_type<7> shape_new = {n0_new, n1_new, n2_new, n3_new, - n4_new, n5_new, n6_new}; - - View7D x_out; + int d3 = rand_dist(rand_engine); + int d4 = rand_dist(rand_engine); + int d5 = rand_dist(rand_engine); + int d6 = rand_dist(rand_engine); + std::size_t n0_new = static_cast(n0 + d0); + std::size_t n1_new = static_cast(n1 + d1); + std::size_t n2_new = static_cast(n2 + d2); + std::size_t n3_new = static_cast(n3 + d3); + std::size_t n4_new = static_cast(n4 + d4); + std::size_t n5_new = static_cast(n5 + d5); + std::size_t n6_new = static_cast(n6 + d6); + + View7D x_out("x_out", n0_new, n1_new, n2_new, n3_new, n4_new, + n5_new, n6_new); View7D ref_x("ref_x", n0_new, n1_new, n2_new, n3_new, n4_new, n5_new, n6_new); @@ -1626,7 +1611,7 @@ TEST(CropOrPad7D, 7DView) { } Kokkos::deep_copy(ref_x, h_ref_x); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out, shape_new); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out); EXPECT_TRUE(allclose(x_out, ref_x, 1.e-5, 1.e-12)); } } @@ -1648,23 +1633,22 @@ TEST(CropOrPad8D, 8DView) { for (int d0 = -1; d0 <= 1; d0++) { for (int d1 = -1; d1 <= 1; d1++) { for (int d2 = -1; d2 <= 1; d2++) { - int d3 = rand_dist(rand_engine); - int d4 = rand_dist(rand_engine); - int d5 = rand_dist(rand_engine); - int d6 = rand_dist(rand_engine); - int d7 = rand_dist(rand_engine); - std::size_t n0_new = static_cast(n0 + d0); - std::size_t n1_new = static_cast(n1 + d1); - std::size_t n2_new = static_cast(n2 + d2); - std::size_t n3_new = static_cast(n3 + d3); - std::size_t n4_new = static_cast(n4 + d4); - std::size_t n5_new = static_cast(n5 + d5); - std::size_t n6_new = static_cast(n6 + d6); - std::size_t n7_new = static_cast(n7 + d7); - shape_type<8> shape_new = {n0_new, n1_new, n2_new, n3_new, - n4_new, n5_new, n6_new, n7_new}; - - View8D x_out; + int d3 = rand_dist(rand_engine); + int d4 = rand_dist(rand_engine); + int d5 = rand_dist(rand_engine); + int d6 = rand_dist(rand_engine); + int d7 = rand_dist(rand_engine); + std::size_t n0_new = static_cast(n0 + d0); + std::size_t n1_new = static_cast(n1 + d1); + std::size_t n2_new = static_cast(n2 + d2); + std::size_t n3_new = static_cast(n3 + d3); + std::size_t n4_new = static_cast(n4 + d4); + std::size_t n5_new = static_cast(n5 + d5); + std::size_t n6_new = static_cast(n6 + d6); + std::size_t n7_new = static_cast(n7 + d7); + + View8D x_out("x_out", n0_new, n1_new, n2_new, n3_new, n4_new, + n5_new, n6_new, n7_new); View8D ref_x("ref_x", n0_new, n1_new, n2_new, n3_new, n4_new, n5_new, n6_new, n7_new); @@ -1698,7 +1682,7 @@ TEST(CropOrPad8D, 8DView) { } Kokkos::deep_copy(ref_x, h_ref_x); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out, shape_new); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, x_out); EXPECT_TRUE(allclose(x_out, ref_x, 1.e-5, 1.e-12)); } } diff --git a/fft/src/KokkosFFT_Plans.hpp b/fft/src/KokkosFFT_Plans.hpp index b1c59dbe..a1892338 100644 --- a/fft/src/KokkosFFT_Plans.hpp +++ b/fft/src/KokkosFFT_Plans.hpp @@ -314,10 +314,14 @@ class Plan { typename KokkosFFT::Impl::manageable_view_type::type; using ManagableOutViewType = typename KokkosFFT::Impl::manageable_view_type::type; + ManagableInViewType in_s; InViewType in_tmp; if (m_is_crop_or_pad_needed) { - KokkosFFT::Impl::crop_or_pad(m_exec_space, in, in_s, m_shape); + using LayoutType = typename ManagableInViewType::array_layout; + in_s = ManagableInViewType( + "in_s", KokkosFFT::Impl::create_layout(m_shape)); + KokkosFFT::Impl::crop_or_pad(m_exec_space, in, in_s); in_tmp = in_s; } else { in_tmp = in; diff --git a/fft/unit_test/Test_Transform.cpp b/fft/unit_test/Test_Transform.cpp index e95539ca..1a793533 100644 --- a/fft/unit_test/Test_Transform.cpp +++ b/fft/unit_test/Test_Transform.cpp @@ -920,9 +920,11 @@ void test_fft1_1dfft_5dview(T atol = 1.e-12) { auto [s0, s1, s2, s3, s4] = shape; auto [sr0, sr1, sr2, sr3, sr4] = shape_c2r; ComplexView5DType inv_x_hat("inv_x_hat", s0, s1, s2, s3, s4), - x_hat("x_hat", s0, s1, s2, s3, s4), ref_x; + x_hat("x_hat", s0, s1, s2, s3, s4), + ref_x("ref_x", s0, s1, s2, s3, s4); RealView5DType xr("xr", s0, s1, s2, s3, s4), - inv_xr_hat("inv_xr_hat", s0, s1, s2, s3, s4), ref_xr; + inv_xr_hat("inv_xr_hat", s0, s1, s2, s3, s4), + ref_xr("ref_xr", s0, s1, s2, s3, s4); ComplexView5DType xr_hat("xr_hat", sr0, sr1, sr2, sr3, sr4); const Kokkos::complex z(1.0, 1.0); @@ -930,8 +932,8 @@ void test_fft1_1dfft_5dview(T atol = 1.e-12) { Kokkos::fill_random(x, random_pool, z); Kokkos::fill_random(xr, random_pool, 1); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x, shape); - KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr, shape); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x); + KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr); Kokkos::fence(); @@ -975,9 +977,11 @@ void test_fft1_1dfft_6dview(T atol = 1.e-12) { auto [s0, s1, s2, s3, s4, s5] = shape; auto [sr0, sr1, sr2, sr3, sr4, sr5] = shape_c2r; ComplexView6DType inv_x_hat("inv_x_hat", s0, s1, s2, s3, s4, s5), - x_hat("x_hat", s0, s1, s2, s3, s4, s5), ref_x; + x_hat("x_hat", s0, s1, s2, s3, s4, s5), + ref_x("ref_x", s0, s1, s2, s3, s4, s5); RealView6DType xr("xr", s0, s1, s2, s3, s4, s5), - inv_xr_hat("inv_xr_hat", s0, s1, s2, s3, s4, s5), ref_xr; + inv_xr_hat("inv_xr_hat", s0, s1, s2, s3, s4, s5), + ref_xr("ref_xr", s0, s1, s2, s3, s4, s5); ComplexView6DType xr_hat("xr_hat", sr0, sr1, sr2, sr3, sr4, sr5); const Kokkos::complex z(1.0, 1.0); @@ -985,8 +989,8 @@ void test_fft1_1dfft_6dview(T atol = 1.e-12) { Kokkos::fill_random(x, random_pool, z); Kokkos::fill_random(xr, random_pool, 1); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x, shape); - KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr, shape); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x); + KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr); Kokkos::fence(); @@ -1030,9 +1034,11 @@ void test_fft1_1dfft_7dview(T atol = 1.e-12) { auto [s0, s1, s2, s3, s4, s5, s6] = shape; auto [sr0, sr1, sr2, sr3, sr4, sr5, sr6] = shape_c2r; ComplexView7DType inv_x_hat("inv_x_hat", s0, s1, s2, s3, s4, s5, s6), - x_hat("x_hat", s0, s1, s2, s3, s4, s5, s6), ref_x; + x_hat("x_hat", s0, s1, s2, s3, s4, s5, s6), + ref_x("ref_x", s0, s1, s2, s3, s4, s5, s6); RealView7DType xr("xr", s0, s1, s2, s3, s4, s5, s6), - inv_xr_hat("inv_xr_hat", s0, s1, s2, s3, s4, s5, s6), ref_xr; + inv_xr_hat("inv_xr_hat", s0, s1, s2, s3, s4, s5, s6), + ref_xr("ref_xr", s0, s1, s2, s3, s4, s5, s6); ComplexView7DType xr_hat("xr_hat", sr0, sr1, sr2, sr3, sr4, sr5, sr6); const Kokkos::complex z(1.0, 1.0); @@ -1040,8 +1046,8 @@ void test_fft1_1dfft_7dview(T atol = 1.e-12) { Kokkos::fill_random(x, random_pool, z); Kokkos::fill_random(xr, random_pool, 1); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x, shape); - KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr, shape); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x); + KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr); Kokkos::fence(); @@ -1085,9 +1091,11 @@ void test_fft1_1dfft_8dview(T atol = 1.e-12) { auto [s0, s1, s2, s3, s4, s5, s6, s7] = shape; auto [sr0, sr1, sr2, sr3, sr4, sr5, sr6, sr7] = shape_c2r; ComplexView8DType inv_x_hat("inv_x_hat", s0, s1, s2, s3, s4, s5, s6, s7), - x_hat("x_hat", s0, s1, s2, s3, s4, s5, s6, s7), ref_x; + x_hat("x_hat", s0, s1, s2, s3, s4, s5, s6, s7), + ref_x("ref_x", s0, s1, s2, s3, s4, s5, s6, s7); RealView8DType xr("xr", s0, s1, s2, s3, s4, s5, s6, s7), - inv_xr_hat("inv_xr_hat", s0, s1, s2, s3, s4, s5, s6, s7), ref_xr; + inv_xr_hat("inv_xr_hat", s0, s1, s2, s3, s4, s5, s6, s7), + ref_xr("ref_xr", s0, s1, s2, s3, s4, s5, s6, s7); ComplexView8DType xr_hat("xr_hat", sr0, sr1, sr2, sr3, sr4, sr5, sr6, sr7); @@ -1096,8 +1104,8 @@ void test_fft1_1dfft_8dview(T atol = 1.e-12) { Kokkos::fill_random(x, random_pool, z); Kokkos::fill_random(xr, random_pool, 1); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x, shape); - KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr, shape); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x); + KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr); Kokkos::fence(); @@ -1814,9 +1822,10 @@ void test_fft2_2dfft_3dview(T atol = 1.e-12) { auto [sr0, sr1, sr2] = shape_c2r; ComplexView3DType inv_x_hat("inv_x_hat", s0, s1, s2), - x_hat("x_hat", s0, s1, s2), ref_x; + x_hat("x_hat", s0, s1, s2), ref_x("ref_x", s0, s1, s2); RealView3DType xr("xr", s0, s1, s2), - inv_xr_hat("inv_xr_hat", s0, s1, s2), ref_xr; + inv_xr_hat("inv_xr_hat", s0, s1, s2), + ref_xr("ref_xr", s0, s1, s2); ComplexView3DType xr_hat("xr_hat", sr0, sr1, sr2); const Kokkos::complex z(1.0, 1.0); @@ -1824,8 +1833,8 @@ void test_fft2_2dfft_3dview(T atol = 1.e-12) { Kokkos::fill_random(x, random_pool, z); Kokkos::fill_random(xr, random_pool, 1); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x, shape); - KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr, shape); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x); + KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr); Kokkos::fence(); @@ -1893,9 +1902,10 @@ void test_fft2_2dfft_4dview(T atol = 1.e-12) { auto [sr0, sr1, sr2, sr3] = shape_c2r; ComplexView4DType inv_x_hat("inv_x_hat", s0, s1, s2, s3), - x_hat("x_hat", s0, s1, s2, s3), ref_x; + x_hat("x_hat", s0, s1, s2, s3), ref_x("ref_x", s0, s1, s2, s3); RealView4DType xr("xr", s0, s1, s2, s3), - inv_xr_hat("inv_xr_hat", s0, s1, s2, s3), ref_xr; + inv_xr_hat("inv_xr_hat", s0, s1, s2, s3), + ref_xr("ref_xr", s0, s1, s2, s3); ComplexView4DType xr_hat("xr_hat", sr0, sr1, sr2, sr3); const Kokkos::complex z(1.0, 1.0); @@ -1903,8 +1913,8 @@ void test_fft2_2dfft_4dview(T atol = 1.e-12) { Kokkos::fill_random(x, random_pool, z); Kokkos::fill_random(xr, random_pool, 1); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x, shape); - KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr, shape); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x); + KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr); Kokkos::fence(); @@ -1972,9 +1982,11 @@ void test_fft2_2dfft_5dview(T atol = 1.e-12) { auto [sr0, sr1, sr2, sr3, sr4] = shape_c2r; ComplexView5DType inv_x_hat("inv_x_hat", s0, s1, s2, s3, s4), - x_hat("x_hat", s0, s1, s2, s3, s4), ref_x; + x_hat("x_hat", s0, s1, s2, s3, s4), + ref_x("ref_x", s0, s1, s2, s3, s4); RealView5DType xr("xr", s0, s1, s2, s3, s4), - inv_xr_hat("inv_xr_hat", s0, s1, s2, s3, s4), ref_xr; + inv_xr_hat("inv_xr_hat", s0, s1, s2, s3, s4), + ref_xr("ref_xr", s0, s1, s2, s3, s4); ComplexView5DType xr_hat("xr_hat", sr0, sr1, sr2, sr3, sr4); const Kokkos::complex z(1.0, 1.0); @@ -1982,8 +1994,8 @@ void test_fft2_2dfft_5dview(T atol = 1.e-12) { Kokkos::fill_random(x, random_pool, z); Kokkos::fill_random(xr, random_pool, 1); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x, shape); - KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr, shape); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x); + KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr); Kokkos::fence(); @@ -2051,9 +2063,11 @@ void test_fft2_2dfft_6dview(T atol = 1.e-12) { auto [sr0, sr1, sr2, sr3, sr4, sr5] = shape_c2r; ComplexView6DType inv_x_hat("inv_x_hat", s0, s1, s2, s3, s4, s5), - x_hat("x_hat", s0, s1, s2, s3, s4, s5), ref_x; + x_hat("x_hat", s0, s1, s2, s3, s4, s5), + ref_x("ref_x", s0, s1, s2, s3, s4, s5); RealView6DType xr("xr", s0, s1, s2, s3, s4, s5), - inv_xr_hat("inv_xr_hat", s0, s1, s2, s3, s4, s5), ref_xr; + inv_xr_hat("inv_xr_hat", s0, s1, s2, s3, s4, s5), + ref_xr("ref_xr", s0, s1, s2, s3, s4, s5); ComplexView6DType xr_hat("xr_hat", sr0, sr1, sr2, sr3, sr4, sr5); const Kokkos::complex z(1.0, 1.0); @@ -2061,8 +2075,8 @@ void test_fft2_2dfft_6dview(T atol = 1.e-12) { Kokkos::fill_random(x, random_pool, z); Kokkos::fill_random(xr, random_pool, 1); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x, shape); - KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr, shape); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x); + KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr); Kokkos::fence(); @@ -2129,10 +2143,12 @@ void test_fft2_2dfft_7dview(T atol = 1.e-12) { auto [sr0, sr1, sr2, sr3, sr4, sr5, sr6] = shape_c2r; ComplexView7DType inv_x_hat("inv_x_hat", s0, s1, s2, s3, s4, s5, s6), - x_hat("x_hat", s0, s1, s2, s3, s4, s5, s6), ref_x; + x_hat("x_hat", s0, s1, s2, s3, s4, s5, s6), + ref_x("ref_x", s0, s1, s2, s3, s4, s5, s6); RealView7DType xr("xr", s0, s1, s2, s3, s4, s5, s6), - inv_xr_hat("inv_xr_hat", s0, s1, s2, s3, s4, s5, s6), ref_xr; + inv_xr_hat("inv_xr_hat", s0, s1, s2, s3, s4, s5, s6), + ref_xr("ref_xr", s0, s1, s2, s3, s4, s5, s6); ComplexView7DType xr_hat("xr_hat", sr0, sr1, sr2, sr3, sr4, sr5, sr6); @@ -2141,8 +2157,8 @@ void test_fft2_2dfft_7dview(T atol = 1.e-12) { Kokkos::fill_random(x, random_pool, z); Kokkos::fill_random(xr, random_pool, 1); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x, shape); - KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr, shape); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x); + KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr); Kokkos::fence(); @@ -2210,10 +2226,12 @@ void test_fft2_2dfft_8dview(T atol = 1.e-12) { ComplexView8DType inv_x_hat("inv_x_hat", s0, s1, s2, s3, s4, s5, s6, s7), - x_hat("x_hat", s0, s1, s2, s3, s4, s5, s6, s7), ref_x; + x_hat("x_hat", s0, s1, s2, s3, s4, s5, s6, s7), + ref_x("ref_x", s0, s1, s2, s3, s4, s5, s6, s7); RealView8DType xr("xr", s0, s1, s2, s3, s4, s5, s6, s7), - inv_xr_hat("inv_xr_hat", s0, s1, s2, s3, s4, s5, s6, s7), ref_xr; + inv_xr_hat("inv_xr_hat", s0, s1, s2, s3, s4, s5, s6, s7), + ref_xr("ref_xr", s0, s1, s2, s3, s4, s5, s6, s7); ComplexView8DType xr_hat("xr_hat", sr0, sr1, sr2, sr3, sr4, sr5, sr6, sr7); @@ -2223,8 +2241,8 @@ void test_fft2_2dfft_8dview(T atol = 1.e-12) { Kokkos::fill_random(x, random_pool, z); Kokkos::fill_random(xr, random_pool, 1); - KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x, shape); - KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr, shape); + KokkosFFT::Impl::crop_or_pad(execution_space(), x, ref_x); + KokkosFFT::Impl::crop_or_pad(execution_space(), xr, ref_xr); Kokkos::fence();