diff --git a/common/src/KokkosFFT_transpose.hpp b/common/src/KokkosFFT_transpose.hpp index e345258..5442333 100644 --- a/common/src/KokkosFFT_transpose.hpp +++ b/common/src/KokkosFFT_transpose.hpp @@ -75,6 +75,19 @@ auto get_map_axes(const ViewType& view, int axis) { return get_map_axes(view, axis_type<1>({axis})); } +template +axis_type compute_transpose_extents( + ViewType const& view, axis_type const& map) { + constexpr std::size_t rank = ViewType::rank(); + + std::array out_extents; + for (std::size_t i = 0; i < rank; ++i) { + out_extents.at(i) = view.extent(map.at(i)); + } + + return out_extents; +} + template void prep_transpose_view(InViewType& in, OutViewType& out, axis_type map) { @@ -108,8 +121,8 @@ void prep_transpose_view(InViewType& in, OutViewType& out, } template -void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, - OutViewType& out, axis_type<2> _map) { +void transpose_impl(const ExecutionSpace& exec_space, const InViewType& in, + const OutViewType& out, axis_type<2> /*_map*/) { constexpr std::size_t DIM = 2; using range_type = Kokkos::MDRangePolicy< @@ -125,16 +138,14 @@ void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, // [TO DO] Choose optimal tile sizes for each device ); - prep_transpose_view(in, out, _map); - Kokkos::parallel_for( "KokkosFFT::transpose", range, KOKKOS_LAMBDA(int i0, int i1) { out(i1, i0) = in(i0, i1); }); } template -void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, - OutViewType& out, axis_type<3> _map) { +void transpose_impl(const ExecutionSpace& exec_space, const InViewType& in, + const OutViewType& out, axis_type<3> _map) { constexpr std::size_t DIM = 3; constexpr std::size_t rank = InViewType::rank(); @@ -151,8 +162,6 @@ void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, tile_type{{4, 4, 4}} // [TO DO] Choose optimal tile sizes for each device ); - prep_transpose_view(in, out, _map); - Kokkos::Array map = {_map[0], _map[1], _map[2]}; Kokkos::parallel_for( "KokkosFFT::transpose", range, KOKKOS_LAMBDA(int i0, int i1, int i2) { @@ -166,8 +175,8 @@ void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, } template -void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, - OutViewType& out, axis_type<4> _map) { +void transpose_impl(const ExecutionSpace& exec_space, const InViewType& in, + const OutViewType& out, axis_type<4> _map) { constexpr std::size_t DIM = 4; constexpr std::size_t rank = InViewType::rank(); @@ -185,8 +194,6 @@ void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, // [TO DO] Choose optimal tile sizes for each device ); - prep_transpose_view(in, out, _map); - Kokkos::Array map = {_map[0], _map[1], _map[2], _map[3]}; Kokkos::parallel_for( "KokkosFFT::transpose", range, @@ -202,8 +209,8 @@ void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, } template -void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, - OutViewType& out, axis_type<5> _map) { +void transpose_impl(const ExecutionSpace& exec_space, const InViewType& in, + const OutViewType& out, axis_type<5> _map) { constexpr std::size_t DIM = 5; constexpr std::size_t rank = InViewType::rank(); @@ -222,8 +229,6 @@ void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, // [TO DO] Choose optimal tile sizes for each device ); - prep_transpose_view(in, out, _map); - Kokkos::Array map = {_map[0], _map[1], _map[2], _map[3], _map[4]}; Kokkos::parallel_for( "KokkosFFT::transpose", range, @@ -240,8 +245,8 @@ void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, } template -void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, - OutViewType& out, axis_type<6> _map) { +void transpose_impl(const ExecutionSpace& exec_space, const InViewType& in, + const OutViewType& out, axis_type<6> _map) { constexpr std::size_t DIM = 6; constexpr std::size_t rank = InViewType::rank(); @@ -261,8 +266,6 @@ void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, // [TO DO] Choose optimal tile sizes for each device ); - prep_transpose_view(in, out, _map); - Kokkos::Array map = {_map[0], _map[1], _map[2], _map[3], _map[4], _map[5]}; Kokkos::parallel_for( @@ -281,8 +284,8 @@ void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, } template -void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, - OutViewType& out, axis_type<7> _map) { +void transpose_impl(const ExecutionSpace& exec_space, const InViewType& in, + const OutViewType& out, axis_type<7> _map) { constexpr std::size_t DIM = 6; constexpr std::size_t rank = InViewType::rank(); @@ -302,8 +305,6 @@ void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, // [TO DO] Choose optimal tile sizes for each device ); - prep_transpose_view(in, out, _map); - Kokkos::Array map = {_map[0], _map[1], _map[2], _map[3], _map[4], _map[5], _map[6]}; Kokkos::parallel_for( @@ -326,8 +327,8 @@ void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, } template -void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, - OutViewType& out, axis_type<8> _map) { +void transpose_impl(const ExecutionSpace& exec_space, const InViewType& in, + const OutViewType& out, axis_type<8> _map) { constexpr std::size_t DIM = 6; constexpr std::size_t rank = InViewType::rank(); @@ -349,8 +350,6 @@ void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, // [TO DO] Choose optimal tile sizes for each device ); - prep_transpose_view(in, out, _map); - Kokkos::Array map = {_map[0], _map[1], _map[2], _map[3], _map[4], _map[5], _map[6], _map[7]}; Kokkos::parallel_for( @@ -396,8 +395,8 @@ void transpose_impl(const ExecutionSpace& exec_space, InViewType& in, */ template -void transpose(const ExecutionSpace& exec_space, InViewType& in, - OutViewType& out, axis_type map) { +void transpose(const ExecutionSpace& exec_space, const InViewType& in, + const OutViewType& out, axis_type map) { static_assert( KokkosFFT::Impl::are_operatable_views_v, diff --git a/common/src/KokkosFFT_utils.hpp b/common/src/KokkosFFT_utils.hpp index 6e2ca75..1395731 100644 --- a/common/src/KokkosFFT_utils.hpp +++ b/common/src/KokkosFFT_utils.hpp @@ -204,6 +204,13 @@ auto extract_extents(const ViewType& view) { return extents; } +template +Layout create_layout(const std::array& extents) { + Layout layout; + std::copy_n(extents.begin(), N, layout.dimension); + return layout; +} + template void create_view(ViewType& out, const Label& label, const std::array& extents) { diff --git a/common/unit_test/Test_Transpose.cpp b/common/unit_test/Test_Transpose.cpp index 0999245..a59d7de 100644 --- a/common/unit_test/Test_Transpose.cpp +++ b/common/unit_test/Test_Transpose.cpp @@ -339,7 +339,7 @@ void test_transpose_1d_1dview() { // When transpose is not necessary, we should not call transpose method const int len = 30; View1D x("x", len), ref("ref", len); - View1D xt; + View1D xt("xt", len); Kokkos::Random_XorShift64_Pool<> random_pool(12345); Kokkos::fill_random(x, random_pool, 1.0); @@ -377,7 +377,7 @@ void test_transpose_1d_2dview() { } auto [_n0, _n1] = out_extents; - RealView2Dtype xt; + RealView2Dtype xt("xt", _n0, _n1); if (map == default_axes) { EXPECT_THROW(KokkosFFT::Impl::transpose(execution_space(), x, xt, map), // xt is identical to x @@ -401,7 +401,7 @@ void test_transpose_1d_2dview() { EXPECT_TRUE(allclose(xt, ref, 1.e-5, 1.e-12)); // Inverse (transpose of transpose is identical to the original) - RealView2Dtype _x; + RealView2Dtype _x("_x", n0, n1); KokkosFFT::Impl::transpose(execution_space(), xt, _x, map_inv); EXPECT_TRUE(allclose(_x, x, 1.e-5, 1.e-12)); } @@ -432,7 +432,7 @@ void test_transpose_1d_3dview() { } auto [_n0, _n1, _n2] = out_extents; - RealView3Dtype xt; + RealView3Dtype xt("xt", _n0, _n1, _n2); if (map == default_axes) { EXPECT_THROW(KokkosFFT::Impl::transpose(execution_space(), x, xt, map), // xt is identical to x @@ -462,7 +462,7 @@ void test_transpose_1d_3dview() { EXPECT_TRUE(allclose(xt, ref, 1.e-5, 1.e-12)); // Inverse (transpose of transpose is identical to the original) - RealView3Dtype _x; + RealView3Dtype _x("_x", n0, n1, n2); KokkosFFT::Impl::transpose(execution_space(), xt, _x, map_inv); EXPECT_TRUE(allclose(_x, x, 1.e-5, 1.e-12)); } @@ -493,7 +493,7 @@ void test_transpose_1d_4dview() { } auto [_n0, _n1, _n2, _n3] = out_extents; - RealView4Dtype xt; + RealView4Dtype xt("xt", _n0, _n1, _n2, _n3); if (map == default_axes) { EXPECT_THROW(KokkosFFT::Impl::transpose(execution_space(), x, xt, map), // xt is identical to x @@ -539,7 +539,7 @@ void test_transpose_1d_4dview() { EXPECT_TRUE(allclose(xt, ref, 1.e-5, 1.e-12)); // Inverse (transpose of transpose is identical to the original) - RealView4Dtype _x; + RealView4Dtype _x("_x", n0, n1, n2, n3); KokkosFFT::Impl::transpose(execution_space(), xt, _x, map_inv); EXPECT_TRUE(allclose(_x, x, 1.e-5, 1.e-12)); } @@ -570,7 +570,7 @@ void test_transpose_1d_5dview() { } auto [_n0, _n1, _n2, _n3, _n4] = out_extents; - RealView5Dtype xt; + RealView5Dtype xt("xt", _n0, _n1, _n2, _n3, _n4); if (map == default_axes) { EXPECT_THROW(KokkosFFT::Impl::transpose(execution_space(), x, xt, map), // xt is identical to x @@ -627,7 +627,7 @@ void test_transpose_1d_5dview() { EXPECT_TRUE(allclose(xt, ref, 1.e-5, 1.e-12)); // Inverse (transpose of transpose is identical to the original) - RealView5Dtype _x; + RealView5Dtype _x("_x", n0, n1, n2, n3, n4); KokkosFFT::Impl::transpose(execution_space(), xt, _x, map_inv); EXPECT_TRUE(allclose(_x, x, 1.e-5, 1.e-12)); } @@ -659,7 +659,7 @@ void test_transpose_1d_6dview() { } auto [_n0, _n1, _n2, _n3, _n4, _n5] = out_extents; - RealView6Dtype xt; + RealView6Dtype xt("xt", _n0, _n1, _n2, _n3, _n4, _n5); if (map == default_axes) { EXPECT_THROW(KokkosFFT::Impl::transpose(execution_space(), x, xt, map), // xt is identical to x @@ -731,7 +731,7 @@ void test_transpose_1d_6dview() { EXPECT_TRUE(allclose(xt, ref, 1.e-5, 1.e-12)); // Inverse (transpose of transpose is identical to the original) - RealView6Dtype _x; + RealView6Dtype _x("_x", n0, n1, n2, n3, n4, n5); KokkosFFT::Impl::transpose(execution_space(), xt, _x, map_inv); EXPECT_TRUE(allclose(_x, x, 1.e-5, 1.e-12)); } @@ -763,7 +763,7 @@ void test_transpose_1d_7dview() { } auto [_n0, _n1, _n2, _n3, _n4, _n5, _n6] = out_extents; - RealView7Dtype xt; + RealView7Dtype xt("xt", _n0, _n1, _n2, _n3, _n4, _n5, _n6); if (map == default_axes) { EXPECT_THROW(KokkosFFT::Impl::transpose(execution_space(), x, xt, map), // xt is identical to x @@ -851,7 +851,7 @@ void test_transpose_1d_7dview() { EXPECT_TRUE(allclose(xt, ref, 1.e-5, 1.e-12)); // Inverse (transpose of transpose is identical to the original) - RealView7Dtype _x; + RealView7Dtype _x("_x", n0, n1, n2, n3, n4, n5, n6); KokkosFFT::Impl::transpose(execution_space(), xt, _x, map_inv); EXPECT_TRUE(allclose(_x, x, 1.e-5, 1.e-12)); } @@ -883,7 +883,7 @@ void test_transpose_1d_8dview() { } auto [_n0, _n1, _n2, _n3, _n4, _n5, _n6, _n7] = out_extents; - RealView8Dtype xt; + RealView8Dtype xt("xt", _n0, _n1, _n2, _n3, _n4, _n5, _n6, _n7); if (map == default_axes) { EXPECT_THROW(KokkosFFT::Impl::transpose(execution_space(), x, xt, map), // xt is identical to x @@ -989,7 +989,7 @@ void test_transpose_1d_8dview() { EXPECT_TRUE(allclose(xt, ref, 1.e-5, 1.e-12)); // Inverse (transpose of transpose is identical to the original) - RealView8Dtype _x; + RealView8Dtype _x("_x", n0, n1, n2, n3, n4, n5, n6, n7); KokkosFFT::Impl::transpose(execution_space(), xt, _x, map_inv); EXPECT_TRUE(allclose(_x, x, 1.e-5, 1.e-12)); } @@ -1049,7 +1049,7 @@ void test_transpose_2d_2dview() { using RealView2Dtype = Kokkos::View; const int n0 = 3, n1 = 5; RealView2Dtype x("x", n0, n1), _x("_x", n0, n1), ref("ref", n1, n0); - RealView2Dtype xt_axis01, xt_axis10; // views are allocated internally + RealView2Dtype xt_axis01("xt_axis01", n0, n1), xt_axis10("xt_axis10", n1, n0); Kokkos::Random_XorShift64_Pool<> random_pool(12345); Kokkos::fill_random(x, random_pool, 1.0); @@ -1110,7 +1110,7 @@ void test_transpose_2d_3dview() { } auto [_n0, _n1, _n2] = out_extents; - RealView3Dtype xt; + RealView3Dtype xt("xt", _n0, _n1, _n2); if (map == default_axes) { EXPECT_THROW(KokkosFFT::Impl::transpose(execution_space(), x, xt, map), // xt is identical to x @@ -1141,7 +1141,7 @@ void test_transpose_2d_3dview() { EXPECT_TRUE(allclose(xt, ref, 1.e-5, 1.e-12)); // Inverse (transpose of transpose is identical to the original) - RealView3Dtype _x; + RealView3Dtype _x("_x", n0, n1, n2); KokkosFFT::Impl::transpose(execution_space(), xt, _x, map_inv); EXPECT_TRUE(allclose(_x, x, 1.e-5, 1.e-12)); } @@ -1177,7 +1177,7 @@ void test_transpose_2d_4dview() { } auto [_n0, _n1, _n2, _n3] = out_extents; - RealView4Dtype xt; + RealView4Dtype xt("xt", _n0, _n1, _n2, _n3); if (map == default_axes) { EXPECT_THROW(KokkosFFT::Impl::transpose(execution_space(), x, xt, map), // xt is identical to x @@ -1224,7 +1224,7 @@ void test_transpose_2d_4dview() { EXPECT_TRUE(allclose(xt, ref, 1.e-5, 1.e-12)); // Inverse (transpose of transpose is identical to the original) - RealView4Dtype _x; + RealView4Dtype _x("_x", n0, n1, n2, n3); KokkosFFT::Impl::transpose(execution_space(), xt, _x, map_inv); EXPECT_TRUE(allclose(_x, x, 1.e-5, 1.e-12)); } @@ -1260,7 +1260,7 @@ void test_transpose_2d_5dview() { } auto [_n0, _n1, _n2, _n3, _n4] = out_extents; - RealView5Dtype xt; + RealView5Dtype xt("xt", _n0, _n1, _n2, _n3, _n4); if (map == default_axes) { EXPECT_THROW(KokkosFFT::Impl::transpose(execution_space(), x, xt, map), // xt is identical to x @@ -1318,7 +1318,7 @@ void test_transpose_2d_5dview() { EXPECT_TRUE(allclose(xt, ref, 1.e-5, 1.e-12)); // Inverse (transpose of transpose is identical to the original) - RealView5Dtype _x; + RealView5Dtype _x("_x", n0, n1, n2, n3, n4); KokkosFFT::Impl::transpose(execution_space(), xt, _x, map_inv); EXPECT_TRUE(allclose(_x, x, 1.e-5, 1.e-12)); } @@ -1355,7 +1355,7 @@ void test_transpose_2d_6dview() { } auto [_n0, _n1, _n2, _n3, _n4, _n5] = out_extents; - RealView6Dtype xt; + RealView6Dtype xt("xt", _n0, _n1, _n2, _n3, _n4, _n5); if (map == default_axes) { EXPECT_THROW(KokkosFFT::Impl::transpose(execution_space(), x, xt, map), // xt is identical to x @@ -1428,7 +1428,7 @@ void test_transpose_2d_6dview() { EXPECT_TRUE(allclose(xt, ref, 1.e-5, 1.e-12)); // Inverse (transpose of transpose is identical to the original) - RealView6Dtype _x; + RealView6Dtype _x("_x", n0, n1, n2, n3, n4, n5); KokkosFFT::Impl::transpose(execution_space(), xt, _x, map_inv); EXPECT_TRUE(allclose(_x, x, 1.e-5, 1.e-12)); } @@ -1465,7 +1465,7 @@ void test_transpose_2d_7dview() { } auto [_n0, _n1, _n2, _n3, _n4, _n5, _n6] = out_extents; - RealView7Dtype xt; + RealView7Dtype xt("xt", _n0, _n1, _n2, _n3, _n4, _n5, _n6); if (map == default_axes) { EXPECT_THROW(KokkosFFT::Impl::transpose(execution_space(), x, xt, map), // xt is identical to x @@ -1554,7 +1554,7 @@ void test_transpose_2d_7dview() { EXPECT_TRUE(allclose(xt, ref, 1.e-5, 1.e-12)); // Inverse (transpose of transpose is identical to the original) - RealView7Dtype _x; + RealView7Dtype _x("_x", n0, n1, n2, n3, n4, n5, n6); KokkosFFT::Impl::transpose(execution_space(), xt, _x, map_inv); EXPECT_TRUE(allclose(_x, x, 1.e-5, 1.e-12)); } @@ -1591,7 +1591,7 @@ void test_transpose_2d_8dview() { } auto [_n0, _n1, _n2, _n3, _n4, _n5, _n6, _n7] = out_extents; - RealView8Dtype xt; + RealView8Dtype xt("xt", _n0, _n1, _n2, _n3, _n4, _n5, _n6, _n7); if (map == default_axes) { EXPECT_THROW(KokkosFFT::Impl::transpose(execution_space(), x, xt, map), // xt is identical to x @@ -1698,7 +1698,7 @@ void test_transpose_2d_8dview() { EXPECT_TRUE(allclose(xt, ref, 1.e-5, 1.e-12)); // Inverse (transpose of transpose is identical to the original) - RealView8Dtype _x; + RealView8Dtype _x("_x", n0, n1, n2, n3, n4, n5, n6, n7); KokkosFFT::Impl::transpose(execution_space(), xt, _x, map_inv); EXPECT_TRUE(allclose(_x, x, 1.e-5, 1.e-12)); } @@ -1753,8 +1753,12 @@ void test_transpose_3d_3dview() { using RealView3Dtype = Kokkos::View; const int n0 = 3, n1 = 5, n2 = 8; RealView3Dtype x("x", n0, n1, n2); - RealView3Dtype xt_axis012, xt_axis021, xt_axis102, xt_axis120, xt_axis201, - xt_axis210; // views are allocated internally + RealView3Dtype xt_axis012("xt_axis012", n0, n1, n2), + xt_axis021("xt_axis021", n0, n2, n1), + xt_axis102("xt_axis102", n1, n0, n2), + xt_axis120("xt_axis120", n1, n2, n0), + xt_axis201("xt_axis201", n2, n0, n1), + xt_axis210("xt_axis210", n2, n1, n0); // views are allocated internally RealView3Dtype ref_axis021("ref_axis021", n0, n2, n1), ref_axis102("ref_axis102", n1, n0, n2); RealView3Dtype ref_axis120("ref_axis120", n1, n2, n0), @@ -1854,7 +1858,7 @@ void test_transpose_3d_4dview() { } auto [_n0, _n1, _n2, _n3] = out_extents; - RealView4Dtype xt; + RealView4Dtype xt("xt", _n0, _n1, _n2, _n3); if (map == default_axes) { EXPECT_THROW(KokkosFFT::Impl::transpose(execution_space(), x, xt, map), // xt is identical to x @@ -1902,7 +1906,7 @@ void test_transpose_3d_4dview() { EXPECT_TRUE(allclose(xt, ref, 1.e-5, 1.e-12)); // Inverse (transpose of transpose is identical to the original) - RealView4Dtype _x; + RealView4Dtype _x("_x", n0, n1, n2, n3); KokkosFFT::Impl::transpose(execution_space(), xt, _x, map_inv); EXPECT_TRUE(allclose(_x, x, 1.e-5, 1.e-12)); } @@ -1941,7 +1945,7 @@ void test_transpose_3d_5dview() { } auto [_n0, _n1, _n2, _n3, _n4] = out_extents; - RealView5Dtype xt; + RealView5Dtype xt("xt", _n0, _n1, _n2, _n3, _n4); if (map == default_axes) { EXPECT_THROW(KokkosFFT::Impl::transpose(execution_space(), x, xt, map), // xt is identical to x @@ -2000,7 +2004,7 @@ void test_transpose_3d_5dview() { EXPECT_TRUE(allclose(xt, ref, 1.e-5, 1.e-12)); // Inverse (transpose of transpose is identical to the original) - RealView5Dtype _x; + RealView5Dtype _x("_x", n0, n1, n2, n3, n4); KokkosFFT::Impl::transpose(execution_space(), xt, _x, map_inv); EXPECT_TRUE(allclose(_x, x, 1.e-5, 1.e-12)); } @@ -2040,7 +2044,7 @@ void test_transpose_3d_6dview() { } auto [_n0, _n1, _n2, _n3, _n4, _n5] = out_extents; - RealView6Dtype xt; + RealView6Dtype xt("xt", _n0, _n1, _n2, _n3, _n4, _n5); if (map == default_axes) { EXPECT_THROW(KokkosFFT::Impl::transpose(execution_space(), x, xt, map), // xt is identical to x @@ -2114,7 +2118,7 @@ void test_transpose_3d_6dview() { EXPECT_TRUE(allclose(xt, ref, 1.e-5, 1.e-12)); // Inverse (transpose of transpose is identical to the original) - RealView6Dtype _x; + RealView6Dtype _x("_x", n0, n1, n2, n3, n4, n5); KokkosFFT::Impl::transpose(execution_space(), xt, _x, map_inv); EXPECT_TRUE(allclose(_x, x, 1.e-5, 1.e-12)); } @@ -2154,7 +2158,7 @@ void test_transpose_3d_7dview() { } auto [_n0, _n1, _n2, _n3, _n4, _n5, _n6] = out_extents; - RealView7Dtype xt; + RealView7Dtype xt("xt", _n0, _n1, _n2, _n3, _n4, _n5, _n6); if (map == default_axes) { EXPECT_THROW(KokkosFFT::Impl::transpose(execution_space(), x, xt, map), // xt is identical to x @@ -2244,7 +2248,7 @@ void test_transpose_3d_7dview() { EXPECT_TRUE(allclose(xt, ref, 1.e-5, 1.e-12)); // Inverse (transpose of transpose is identical to the original) - RealView7Dtype _x; + RealView7Dtype _x("_x", n0, n1, n2, n3, n4, n5, n6); KokkosFFT::Impl::transpose(execution_space(), xt, _x, map_inv); EXPECT_TRUE(allclose(_x, x, 1.e-5, 1.e-12)); } @@ -2284,7 +2288,7 @@ void test_transpose_3d_8dview() { } auto [_n0, _n1, _n2, _n3, _n4, _n5, _n6, _n7] = out_extents; - RealView8Dtype xt; + RealView8Dtype xt("xt", _n0, _n1, _n2, _n3, _n4, _n5, _n6, _n7); if (map == default_axes) { EXPECT_THROW(KokkosFFT::Impl::transpose(execution_space(), x, xt, map), // xt is identical to x @@ -2393,7 +2397,7 @@ void test_transpose_3d_8dview() { EXPECT_TRUE(allclose(xt, ref, 1.e-5, 1.e-12)); // Inverse (transpose of transpose is identical to the original) - RealView8Dtype _x; + RealView8Dtype _x("_x", n0, n1, n2, n3, n4, n5, n6, n7); KokkosFFT::Impl::transpose(execution_space(), xt, _x, map_inv); EXPECT_TRUE(allclose(_x, x, 1.e-5, 1.e-12)); } diff --git a/examples/07_unmanaged_views/07_unmanaged_views.cpp b/examples/07_unmanaged_views/07_unmanaged_views.cpp index c20fcc5..c1bd3bc 100644 --- a/examples/07_unmanaged_views/07_unmanaged_views.cpp +++ b/examples/07_unmanaged_views/07_unmanaged_views.cpp @@ -14,10 +14,6 @@ using View1D = Kokkos::View; template using View3D = Kokkos::View; -template -using UView3D = Kokkos::View>; - template using axis_type = KokkosFFT::axis_type; template @@ -40,16 +36,16 @@ int main(int argc, char* argv[]) { // combined storage buffer for xc2c and xc2c_inv View1D> storage( - "storage", (UView3D>::required_allocation_size( - n0, n1, n2) + - sizeof(Kokkos::complex)) / - sizeof(Kokkos::complex) * 2); - UView3D> xc2c(storage.data(), n0, n1, n2); + "storage", + (View3D>::required_allocation_size(n0, n1, n2) + + sizeof(Kokkos::complex)) / + sizeof(Kokkos::complex) * 2); + View3D> xc2c(storage.data(), n0, n1, n2); View3D> xc2c_hat("xc2c_hat", n0, n1, n2); - UView3D> xc2c_inv( + View3D> xc2c_inv( storage.data() + - (UView3D>::required_allocation_size(n0, n1, - n2) + + (View3D>::required_allocation_size(n0, n1, + n2) + sizeof(Kokkos::complex)) / sizeof(Kokkos::complex), n0, n1, n2); diff --git a/fft/src/KokkosFFT_Transform.hpp b/fft/src/KokkosFFT_Transform.hpp index b4e6e52..7a2a135 100644 --- a/fft/src/KokkosFFT_Transform.hpp +++ b/fft/src/KokkosFFT_Transform.hpp @@ -99,8 +99,13 @@ void fft_exec_impl( } if (plan.is_transpose_needed()) { - ManagableInViewType in_T; - ManagableOutViewType out_T; + using LayoutType = typename ManagableInViewType::array_layout; + ManagableInViewType const in_T( + "in_T", + create_layout(compute_transpose_extents(_in, plan.map()))); + ManagableOutViewType const out_T( + "out_T", + create_layout(compute_transpose_extents(out, plan.map()))); KokkosFFT::Impl::transpose(exec_space, _in, in_T, plan.map()); KokkosFFT::Impl::transpose(exec_space, out, out_T, plan.map());