diff --git a/common/unit_test/Test_Transpose.cpp b/common/unit_test/Test_Transpose.cpp index 9a76135e..ceec28dd 100644 --- a/common/unit_test/Test_Transpose.cpp +++ b/common/unit_test/Test_Transpose.cpp @@ -46,6 +46,61 @@ struct TestTranspose3D : public ::testing::Test { using layout_type2 = typename T::second_type; }; +/// \brief Helper function to create a reference after transpose +/// \tparam ViewType1 The type of the input view +/// \tparam ViewType2 The type of the output view +/// \tparam DIM The rank of the Views +/// +/// \param[in] x The input view +/// \param[out] xT The output view permuted according to map +/// \param[in] map The map for permutation +template +void make_transposed(const ViewType1& x, const ViewType2& xT, + const KokkosFFT::axis_type& map) { + static_assert(ViewType1::rank() == DIM && ViewType2::rank() == DIM, + "make_transposed: Rank of Views must be equal to Rank of " + "transpose axes."); + auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x); + auto h_xT = Kokkos::create_mirror_view(xT); + + for (std::size_t i0 = 0; i0 < h_x.extent(0); i0++) { + for (std::size_t i1 = 0; i1 < h_x.extent(1); i1++) { + for (std::size_t i2 = 0; i2 < h_x.extent(2); i2++) { + for (std::size_t i3 = 0; i3 < h_x.extent(3); i3++) { + for (std::size_t i4 = 0; i4 < h_x.extent(4); i4++) { + for (std::size_t i5 = 0; i5 < h_x.extent(5); i5++) { + for (std::size_t i6 = 0; i6 < h_x.extent(6); i6++) { + for (std::size_t i7 = 0; i7 < h_x.extent(7); i7++) { + std::array src{i0, i1, i2, i3, + i4, i5, i6, i7}; + std::array dst = src; + bool in_bound = true; + for (std::size_t i = 0; i < ViewType1::rank; ++i) { + dst.at(i) = src.at(map.at(i)); + in_bound &= dst.at(i) < h_xT.extent(i); + } + if (in_bound) { + // if i > ViewType1::rank: + // - dst[i] is 0 since we haven't touched it in the + // previous loop + // - src[i] is also 0 because h_x.extent(i) is 1 + // => We respect `access` constraints. + h_xT.access(dst[0], dst[1], dst[2], dst[3], dst[4], dst[5], + dst[6], dst[7]) = + h_x.access(src[0], src[1], src[2], src[3], src[4], + src[5], src[6], src[7]); + } + } + } + } + } + } + } + } + } + Kokkos::deep_copy(xT, h_xT); +} + // Tests for map axes over ND views template void test_map_axes1d() { @@ -408,8 +463,6 @@ void test_transpose_1d_3dview() { Kokkos::fill_random(exec, x, random_pool, 1.0); exec.fence(); - auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x); - // Transposed views axes_type default_axes({0, 1, 2}); @@ -428,21 +481,7 @@ void test_transpose_1d_3dview() { } else { // Transposed Views View3DLayout2type ref("ref", nt0, nt1, nt2); - auto h_ref = Kokkos::create_mirror_view(ref); - // Filling the transposed View - for (std::size_t i0 = 0; i0 < h_x.extent(0); i0++) { - for (std::size_t i1 = 0; i1 < h_x.extent(1); i1++) { - for (std::size_t i2 = 0; i2 < h_x.extent(2); i2++) { - std::size_t dst_i0 = (map[0] == 1) ? i1 : (map[0] == 2) ? i2 : i0; - std::size_t dst_i1 = (map[1] == 0) ? i0 : (map[1] == 2) ? i2 : i1; - std::size_t dst_i2 = (map[2] == 0) ? i0 : (map[2] == 1) ? i1 : i2; - - h_ref(dst_i0, dst_i1, dst_i2) = h_x(i0, i1, i2); - } - } - } - - Kokkos::deep_copy(ref, h_ref); + make_transposed(x, ref, map); KokkosFFT::Impl::transpose(exec, x, xt, map); EXPECT_TRUE(allclose(exec, xt, ref, 1.e-5, 1.e-12)); @@ -471,8 +510,6 @@ void test_transpose_1d_4dview() { Kokkos::fill_random(exec, x, random_pool, 1.0); exec.fence(); - auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x); - // Transposed views axes_type default_axes({0, 1, 2, 3}); @@ -491,36 +528,7 @@ void test_transpose_1d_4dview() { } else { // Transposed Views View4DLayout2type ref("ref", nt0, nt1, nt2, nt3); - auto h_ref = Kokkos::create_mirror_view(ref); - // Filling the transposed View - for (std::size_t i0 = 0; i0 < h_x.extent(0); i0++) { - for (std::size_t i1 = 0; i1 < h_x.extent(1); i1++) { - for (std::size_t i2 = 0; i2 < h_x.extent(2); i2++) { - for (std::size_t i3 = 0; i3 < h_x.extent(3); i3++) { - std::size_t dst_i0 = (map[0] == 1) ? i1 - : (map[0] == 2) ? i2 - : (map[0] == 3) ? i3 - : i0; - std::size_t dst_i1 = (map[1] == 0) ? i0 - : (map[1] == 2) ? i2 - : (map[1] == 3) ? i3 - : i1; - std::size_t dst_i2 = (map[2] == 0) ? i0 - : (map[2] == 1) ? i1 - : (map[2] == 3) ? i3 - : i2; - std::size_t dst_i3 = (map[3] == 0) ? i0 - : (map[3] == 1) ? i1 - : (map[3] == 2) ? i2 - : i3; - - h_ref(dst_i0, dst_i1, dst_i2, dst_i3) = h_x(i0, i1, i2, i3); - } - } - } - } - - Kokkos::deep_copy(ref, h_ref); + make_transposed(x, ref, map); KokkosFFT::Impl::transpose(exec, x, xt, map); EXPECT_TRUE(allclose(exec, xt, ref, 1.e-5, 1.e-12)); @@ -549,8 +557,6 @@ void test_transpose_1d_5dview() { Kokkos::fill_random(exec, x, random_pool, 1.0); exec.fence(); - auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x); - // Transposed views axes_type default_axes({0, 1, 2, 3, 4}); @@ -569,47 +575,7 @@ void test_transpose_1d_5dview() { } else { // Transposed Views View5DLayout2type ref("ref", nt0, nt1, nt2, nt3, nt4); - auto h_ref = Kokkos::create_mirror_view(ref); - // Filling the transposed View - for (std::size_t i0 = 0; i0 < h_x.extent(0); i0++) { - for (std::size_t i1 = 0; i1 < h_x.extent(1); i1++) { - for (std::size_t i2 = 0; i2 < h_x.extent(2); i2++) { - for (std::size_t i3 = 0; i3 < h_x.extent(3); i3++) { - for (std::size_t i4 = 0; i4 < h_x.extent(4); i4++) { - std::size_t dst_i0 = (map[0] == 1) ? i1 - : (map[0] == 2) ? i2 - : (map[0] == 3) ? i3 - : (map[0] == 4) ? i4 - : i0; - std::size_t dst_i1 = (map[1] == 0) ? i0 - : (map[1] == 2) ? i2 - : (map[1] == 3) ? i3 - : (map[1] == 4) ? i4 - : i1; - std::size_t dst_i2 = (map[2] == 0) ? i0 - : (map[2] == 1) ? i1 - : (map[2] == 3) ? i3 - : (map[2] == 4) ? i4 - : i2; - std::size_t dst_i3 = (map[3] == 0) ? i0 - : (map[3] == 1) ? i1 - : (map[3] == 2) ? i2 - : (map[3] == 4) ? i4 - : i3; - std::size_t dst_i4 = (map[4] == 0) ? i0 - : (map[4] == 1) ? i1 - : (map[4] == 2) ? i2 - : (map[4] == 3) ? i3 - : i4; - h_ref(dst_i0, dst_i1, dst_i2, dst_i3, dst_i4) = - h_x(i0, i1, i2, i3, i4); - } - } - } - } - } - - Kokkos::deep_copy(ref, h_ref); + make_transposed(x, ref, map); KokkosFFT::Impl::transpose(exec, x, xt, map); EXPECT_TRUE(allclose(exec, xt, ref, 1.e-5, 1.e-12)); @@ -638,8 +604,6 @@ void test_transpose_1d_6dview() { Kokkos::fill_random(exec, x, random_pool, 1.0); exec.fence(); - auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x); - // Transposed views axes_type default_axes({0, 1, 2, 3, 4, 5}); @@ -658,60 +622,7 @@ void test_transpose_1d_6dview() { } else { // Transposed Views View6DLayout2type ref("ref", nt0, nt1, nt2, nt3, nt4, nt5); - auto h_ref = Kokkos::create_mirror_view(ref); - // Filling the transposed View - for (std::size_t i0 = 0; i0 < h_x.extent(0); i0++) { - for (std::size_t i1 = 0; i1 < h_x.extent(1); i1++) { - for (std::size_t i2 = 0; i2 < h_x.extent(2); i2++) { - for (std::size_t i3 = 0; i3 < h_x.extent(3); i3++) { - for (std::size_t i4 = 0; i4 < h_x.extent(4); i4++) { - for (std::size_t i5 = 0; i5 < h_x.extent(5); i5++) { - std::size_t dst_i0 = (map[0] == 1) ? i1 - : (map[0] == 2) ? i2 - : (map[0] == 3) ? i3 - : (map[0] == 4) ? i4 - : (map[0] == 5) ? i5 - : i0; - std::size_t dst_i1 = (map[1] == 0) ? i0 - : (map[1] == 2) ? i2 - : (map[1] == 3) ? i3 - : (map[1] == 4) ? i4 - : (map[1] == 5) ? i5 - : i1; - std::size_t dst_i2 = (map[2] == 0) ? i0 - : (map[2] == 1) ? i1 - : (map[2] == 3) ? i3 - : (map[2] == 4) ? i4 - : (map[2] == 5) ? i5 - : i2; - std::size_t dst_i3 = (map[3] == 0) ? i0 - : (map[3] == 1) ? i1 - : (map[3] == 2) ? i2 - : (map[3] == 4) ? i4 - : (map[3] == 5) ? i5 - : i3; - std::size_t dst_i4 = (map[4] == 0) ? i0 - : (map[4] == 1) ? i1 - : (map[4] == 2) ? i2 - : (map[4] == 3) ? i3 - : (map[4] == 5) ? i5 - : i4; - std::size_t dst_i5 = (map[5] == 0) ? i0 - : (map[5] == 1) ? i1 - : (map[5] == 2) ? i2 - : (map[5] == 3) ? i3 - : (map[5] == 4) ? i4 - : i5; - h_ref(dst_i0, dst_i1, dst_i2, dst_i3, dst_i4, dst_i5) = - h_x(i0, i1, i2, i3, i4, i5); - } - } - } - } - } - } - - Kokkos::deep_copy(ref, h_ref); + make_transposed(x, ref, map); KokkosFFT::Impl::transpose(exec, x, xt, map); EXPECT_TRUE(allclose(exec, xt, ref, 1.e-5, 1.e-12)); @@ -740,8 +651,6 @@ void test_transpose_1d_7dview() { Kokkos::fill_random(exec, x, random_pool, 1.0); exec.fence(); - auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x); - // Transposed views axes_type default_axes({0, 1, 2, 3, 4, 5, 6}); @@ -760,75 +669,7 @@ void test_transpose_1d_7dview() { } else { // Transposed Views View7DLayout2type ref("ref", nt0, nt1, nt2, nt3, nt4, nt5, nt6); - auto h_ref = Kokkos::create_mirror_view(ref); - // Filling the transposed View - for (std::size_t i0 = 0; i0 < h_x.extent(0); i0++) { - for (std::size_t i1 = 0; i1 < h_x.extent(1); i1++) { - for (std::size_t i2 = 0; i2 < h_x.extent(2); i2++) { - for (std::size_t i3 = 0; i3 < h_x.extent(3); i3++) { - for (std::size_t i4 = 0; i4 < h_x.extent(4); i4++) { - for (std::size_t i5 = 0; i5 < h_x.extent(5); i5++) { - for (std::size_t i6 = 0; i6 < h_x.extent(6); i6++) { - std::size_t dst_i0 = (map[0] == 1) ? i1 - : (map[0] == 2) ? i2 - : (map[0] == 3) ? i3 - : (map[0] == 4) ? i4 - : (map[0] == 5) ? i5 - : (map[0] == 6) ? i6 - : i0; - std::size_t dst_i1 = (map[1] == 0) ? i0 - : (map[1] == 2) ? i2 - : (map[1] == 3) ? i3 - : (map[1] == 4) ? i4 - : (map[1] == 5) ? i5 - : (map[1] == 6) ? i6 - : i1; - std::size_t dst_i2 = (map[2] == 0) ? i0 - : (map[2] == 1) ? i1 - : (map[2] == 3) ? i3 - : (map[2] == 4) ? i4 - : (map[2] == 5) ? i5 - : (map[2] == 6) ? i6 - : i2; - std::size_t dst_i3 = (map[3] == 0) ? i0 - : (map[3] == 1) ? i1 - : (map[3] == 2) ? i2 - : (map[3] == 4) ? i4 - : (map[3] == 5) ? i5 - : (map[3] == 6) ? i6 - : i3; - std::size_t dst_i4 = (map[4] == 0) ? i0 - : (map[4] == 1) ? i1 - : (map[4] == 2) ? i2 - : (map[4] == 3) ? i3 - : (map[4] == 5) ? i5 - : (map[4] == 6) ? i6 - : i4; - std::size_t dst_i5 = (map[5] == 0) ? i0 - : (map[5] == 1) ? i1 - : (map[5] == 2) ? i2 - : (map[5] == 3) ? i3 - : (map[5] == 4) ? i4 - : (map[5] == 6) ? i6 - : i5; - std::size_t dst_i6 = (map[6] == 0) ? i0 - : (map[6] == 1) ? i1 - : (map[6] == 2) ? i2 - : (map[6] == 3) ? i3 - : (map[6] == 4) ? i4 - : (map[6] == 5) ? i5 - : i6; - h_ref(dst_i0, dst_i1, dst_i2, dst_i3, dst_i4, dst_i5, - dst_i6) = h_x(i0, i1, i2, i3, i4, i5, i6); - } - } - } - } - } - } - } - - Kokkos::deep_copy(ref, h_ref); + make_transposed(x, ref, map); KokkosFFT::Impl::transpose(exec, x, xt, map); EXPECT_TRUE(allclose(exec, xt, ref, 1.e-5, 1.e-12)); @@ -857,8 +698,6 @@ void test_transpose_1d_8dview() { Kokkos::fill_random(exec, x, random_pool, 1.0); exec.fence(); - auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x); - // Transposed views axes_type default_axes({0, 1, 2, 3, 4, 5, 6, 7}); @@ -877,93 +716,7 @@ void test_transpose_1d_8dview() { } else { // Transposed Views View8DLayout2type ref("ref", nt0, nt1, nt2, nt3, nt4, nt5, nt6, nt7); - auto h_ref = Kokkos::create_mirror_view(ref); - // Filling the transposed View - for (std::size_t i0 = 0; i0 < h_x.extent(0); i0++) { - for (std::size_t i1 = 0; i1 < h_x.extent(1); i1++) { - for (std::size_t i2 = 0; i2 < h_x.extent(2); i2++) { - for (std::size_t i3 = 0; i3 < h_x.extent(3); i3++) { - for (std::size_t i4 = 0; i4 < h_x.extent(4); i4++) { - for (std::size_t i5 = 0; i5 < h_x.extent(5); i5++) { - for (std::size_t i6 = 0; i6 < h_x.extent(6); i6++) { - for (std::size_t i7 = 0; i7 < h_x.extent(7); i7++) { - std::size_t dst_i0 = (map[0] == 1) ? i1 - : (map[0] == 2) ? i2 - : (map[0] == 3) ? i3 - : (map[0] == 4) ? i4 - : (map[0] == 5) ? i5 - : (map[0] == 6) ? i6 - : (map[0] == 7) ? i7 - : i0; - std::size_t dst_i1 = (map[1] == 0) ? i0 - : (map[1] == 2) ? i2 - : (map[1] == 3) ? i3 - : (map[1] == 4) ? i4 - : (map[1] == 5) ? i5 - : (map[1] == 6) ? i6 - : (map[1] == 7) ? i7 - : i1; - std::size_t dst_i2 = (map[2] == 0) ? i0 - : (map[2] == 1) ? i1 - : (map[2] == 3) ? i3 - : (map[2] == 4) ? i4 - : (map[2] == 5) ? i5 - : (map[2] == 6) ? i6 - : (map[2] == 7) ? i7 - : i2; - std::size_t dst_i3 = (map[3] == 0) ? i0 - : (map[3] == 1) ? i1 - : (map[3] == 2) ? i2 - : (map[3] == 4) ? i4 - : (map[3] == 5) ? i5 - : (map[3] == 6) ? i6 - : (map[3] == 7) ? i7 - : i3; - std::size_t dst_i4 = (map[4] == 0) ? i0 - : (map[4] == 1) ? i1 - : (map[4] == 2) ? i2 - : (map[4] == 3) ? i3 - : (map[4] == 5) ? i5 - : (map[4] == 6) ? i6 - : (map[4] == 7) ? i7 - : i4; - std::size_t dst_i5 = (map[5] == 0) ? i0 - : (map[5] == 1) ? i1 - : (map[5] == 2) ? i2 - : (map[5] == 3) ? i3 - : (map[5] == 4) ? i4 - : (map[5] == 6) ? i6 - : (map[5] == 7) ? i7 - : i5; - std::size_t dst_i6 = (map[6] == 0) ? i0 - : (map[6] == 1) ? i1 - : (map[6] == 2) ? i2 - : (map[6] == 3) ? i3 - : (map[6] == 4) ? i4 - : (map[6] == 5) ? i5 - : (map[6] == 7) ? i7 - : i6; - std::size_t dst_i7 = (map[7] == 0) ? i0 - : (map[7] == 1) ? i1 - : (map[7] == 2) ? i2 - : (map[7] == 3) ? i3 - : (map[7] == 4) ? i4 - : (map[7] == 5) ? i5 - : (map[7] == 6) ? i6 - : i7; - h_ref(dst_i0, dst_i1, dst_i2, dst_i3, dst_i4, dst_i5, - dst_i6, dst_i7) = - h_x(i0, i1, i2, i3, i4, i5, i6, i7); - } - } - } - } - } - } - } - } - - Kokkos::deep_copy(ref, h_ref); + make_transposed(x, ref, map); KokkosFFT::Impl::transpose(exec, x, xt, map); EXPECT_TRUE(allclose(exec, xt, ref, 1.e-5, 1.e-12)); @@ -1032,15 +785,13 @@ void test_transpose_2d_3dview() { Kokkos::fill_random(exec, x, random_pool, 1.0); exec.fence(); - auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x); - // Transposed views axes_type default_axes({0, 1, 2}); for (int axis0 = 0; axis0 < DIM; axis0++) { for (int axis1 = 0; axis1 < DIM; axis1++) { if (axis0 == axis1) continue; - KokkosFFT::axis_type<2> axes = {axis0, axis1}; + KokkosFFT::axis_type<2> axes{axis0, axis1}; auto [map, map_inv] = KokkosFFT::Impl::get_map_axes(x, axes); axes_type out_extents; @@ -1056,21 +807,7 @@ void test_transpose_2d_3dview() { } else { // Transposed Views View3DLayout2type ref("ref", nt0, nt1, nt2); - auto h_ref = Kokkos::create_mirror_view(ref); - // Filling the transposed View - for (std::size_t i0 = 0; i0 < h_x.extent(0); i0++) { - for (std::size_t i1 = 0; i1 < h_x.extent(1); i1++) { - for (std::size_t i2 = 0; i2 < h_x.extent(2); i2++) { - std::size_t dst_i0 = (map[0] == 1) ? i1 : (map[0] == 2) ? i2 : i0; - std::size_t dst_i1 = (map[1] == 0) ? i0 : (map[1] == 2) ? i2 : i1; - std::size_t dst_i2 = (map[2] == 0) ? i0 : (map[2] == 1) ? i1 : i2; - - h_ref(dst_i0, dst_i1, dst_i2) = h_x(i0, i1, i2); - } - } - } - - Kokkos::deep_copy(ref, h_ref); + make_transposed(x, ref, map); KokkosFFT::Impl::transpose(exec, x, xt, map); EXPECT_TRUE(allclose(exec, xt, ref, 1.e-5, 1.e-12)); @@ -1100,15 +837,13 @@ void test_transpose_2d_4dview() { Kokkos::fill_random(exec, x, random_pool, 1.0); exec.fence(); - auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x); - // Transposed views axes_type default_axes({0, 1, 2, 3}); for (int axis0 = 0; axis0 < DIM; axis0++) { for (int axis1 = 0; axis1 < DIM; axis1++) { if (axis0 == axis1) continue; - KokkosFFT::axis_type<2> axes = {axis0, axis1}; + KokkosFFT::axis_type<2> axes{axis0, axis1}; auto [map, map_inv] = KokkosFFT::Impl::get_map_axes(x, axes); axes_type out_extents; @@ -1124,36 +859,7 @@ void test_transpose_2d_4dview() { } else { // Transposed Views View4DLayout2type ref("ref", nt0, nt1, nt2, nt3); - auto h_ref = Kokkos::create_mirror_view(ref); - // Filling the transposed View - for (std::size_t i0 = 0; i0 < h_x.extent(0); i0++) { - for (std::size_t i1 = 0; i1 < h_x.extent(1); i1++) { - for (std::size_t i2 = 0; i2 < h_x.extent(2); i2++) { - for (std::size_t i3 = 0; i3 < h_x.extent(3); i3++) { - std::size_t dst_i0 = (map[0] == 1) ? i1 - : (map[0] == 2) ? i2 - : (map[0] == 3) ? i3 - : i0; - std::size_t dst_i1 = (map[1] == 0) ? i0 - : (map[1] == 2) ? i2 - : (map[1] == 3) ? i3 - : i1; - std::size_t dst_i2 = (map[2] == 0) ? i0 - : (map[2] == 1) ? i1 - : (map[2] == 3) ? i3 - : i2; - std::size_t dst_i3 = (map[3] == 0) ? i0 - : (map[3] == 1) ? i1 - : (map[3] == 2) ? i2 - : i3; - - h_ref(dst_i0, dst_i1, dst_i2, dst_i3) = h_x(i0, i1, i2, i3); - } - } - } - } - - Kokkos::deep_copy(ref, h_ref); + make_transposed(x, ref, map); KokkosFFT::Impl::transpose(exec, x, xt, map); EXPECT_TRUE(allclose(exec, xt, ref, 1.e-5, 1.e-12)); @@ -1183,15 +889,13 @@ void test_transpose_2d_5dview() { Kokkos::fill_random(exec, x, random_pool, 1.0); exec.fence(); - auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x); - // Transposed views axes_type default_axes({0, 1, 2, 3, 4}); for (int axis0 = 0; axis0 < DIM; axis0++) { for (int axis1 = 0; axis1 < DIM; axis1++) { if (axis0 == axis1) continue; - KokkosFFT::axis_type<2> axes = {axis0, axis1}; + KokkosFFT::axis_type<2> axes{axis0, axis1}; auto [map, map_inv] = KokkosFFT::Impl::get_map_axes(x, axes); axes_type out_extents; @@ -1207,47 +911,7 @@ void test_transpose_2d_5dview() { } else { // Transposed Views View5DLayout2type ref("ref", nt0, nt1, nt2, nt3, nt4); - auto h_ref = Kokkos::create_mirror_view(ref); - // Filling the transposed View - for (std::size_t i0 = 0; i0 < h_x.extent(0); i0++) { - for (std::size_t i1 = 0; i1 < h_x.extent(1); i1++) { - for (std::size_t i2 = 0; i2 < h_x.extent(2); i2++) { - for (std::size_t i3 = 0; i3 < h_x.extent(3); i3++) { - for (std::size_t i4 = 0; i4 < h_x.extent(4); i4++) { - std::size_t dst_i0 = (map[0] == 1) ? i1 - : (map[0] == 2) ? i2 - : (map[0] == 3) ? i3 - : (map[0] == 4) ? i4 - : i0; - std::size_t dst_i1 = (map[1] == 0) ? i0 - : (map[1] == 2) ? i2 - : (map[1] == 3) ? i3 - : (map[1] == 4) ? i4 - : i1; - std::size_t dst_i2 = (map[2] == 0) ? i0 - : (map[2] == 1) ? i1 - : (map[2] == 3) ? i3 - : (map[2] == 4) ? i4 - : i2; - std::size_t dst_i3 = (map[3] == 0) ? i0 - : (map[3] == 1) ? i1 - : (map[3] == 2) ? i2 - : (map[3] == 4) ? i4 - : i3; - std::size_t dst_i4 = (map[4] == 0) ? i0 - : (map[4] == 1) ? i1 - : (map[4] == 2) ? i2 - : (map[4] == 3) ? i3 - : i4; - h_ref(dst_i0, dst_i1, dst_i2, dst_i3, dst_i4) = - h_x(i0, i1, i2, i3, i4); - } - } - } - } - } - - Kokkos::deep_copy(ref, h_ref); + make_transposed(x, ref, map); KokkosFFT::Impl::transpose(exec, x, xt, map); EXPECT_TRUE(allclose(exec, xt, ref, 1.e-5, 1.e-12)); @@ -1277,15 +941,13 @@ void test_transpose_2d_6dview() { Kokkos::fill_random(exec, x, random_pool, 1.0); exec.fence(); - auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x); - // Transposed views axes_type default_axes({0, 1, 2, 3, 4, 5}); for (int axis0 = 0; axis0 < DIM; axis0++) { for (int axis1 = 0; axis1 < DIM; axis1++) { if (axis0 == axis1) continue; - KokkosFFT::axis_type<2> axes = {axis0, axis1}; + KokkosFFT::axis_type<2> axes{axis0, axis1}; auto [map, map_inv] = KokkosFFT::Impl::get_map_axes(x, axes); axes_type out_extents; @@ -1301,60 +963,7 @@ void test_transpose_2d_6dview() { } else { // Transposed Views View6DLayout2type ref("ref", nt0, nt1, nt2, nt3, nt4, nt5); - auto h_ref = Kokkos::create_mirror_view(ref); - // Filling the transposed View - for (std::size_t i0 = 0; i0 < h_x.extent(0); i0++) { - for (std::size_t i1 = 0; i1 < h_x.extent(1); i1++) { - for (std::size_t i2 = 0; i2 < h_x.extent(2); i2++) { - for (std::size_t i3 = 0; i3 < h_x.extent(3); i3++) { - for (std::size_t i4 = 0; i4 < h_x.extent(4); i4++) { - for (std::size_t i5 = 0; i5 < h_x.extent(5); i5++) { - std::size_t dst_i0 = (map[0] == 1) ? i1 - : (map[0] == 2) ? i2 - : (map[0] == 3) ? i3 - : (map[0] == 4) ? i4 - : (map[0] == 5) ? i5 - : i0; - std::size_t dst_i1 = (map[1] == 0) ? i0 - : (map[1] == 2) ? i2 - : (map[1] == 3) ? i3 - : (map[1] == 4) ? i4 - : (map[1] == 5) ? i5 - : i1; - std::size_t dst_i2 = (map[2] == 0) ? i0 - : (map[2] == 1) ? i1 - : (map[2] == 3) ? i3 - : (map[2] == 4) ? i4 - : (map[2] == 5) ? i5 - : i2; - std::size_t dst_i3 = (map[3] == 0) ? i0 - : (map[3] == 1) ? i1 - : (map[3] == 2) ? i2 - : (map[3] == 4) ? i4 - : (map[3] == 5) ? i5 - : i3; - std::size_t dst_i4 = (map[4] == 0) ? i0 - : (map[4] == 1) ? i1 - : (map[4] == 2) ? i2 - : (map[4] == 3) ? i3 - : (map[4] == 5) ? i5 - : i4; - std::size_t dst_i5 = (map[5] == 0) ? i0 - : (map[5] == 1) ? i1 - : (map[5] == 2) ? i2 - : (map[5] == 3) ? i3 - : (map[5] == 4) ? i4 - : i5; - h_ref(dst_i0, dst_i1, dst_i2, dst_i3, dst_i4, dst_i5) = - h_x(i0, i1, i2, i3, i4, i5); - } - } - } - } - } - } - - Kokkos::deep_copy(ref, h_ref); + make_transposed(x, ref, map); KokkosFFT::Impl::transpose(exec, x, xt, map); EXPECT_TRUE(allclose(exec, xt, ref, 1.e-5, 1.e-12)); @@ -1384,15 +993,13 @@ void test_transpose_2d_7dview() { Kokkos::fill_random(exec, x, random_pool, 1.0); exec.fence(); - auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x); - // Transposed views axes_type default_axes({0, 1, 2, 3, 4, 5, 6}); for (int axis0 = 0; axis0 < DIM; axis0++) { for (int axis1 = 0; axis1 < DIM; axis1++) { if (axis0 == axis1) continue; - KokkosFFT::axis_type<2> axes = {axis0, axis1}; + KokkosFFT::axis_type<2> axes{axis0, axis1}; auto [map, map_inv] = KokkosFFT::Impl::get_map_axes(x, axes); axes_type out_extents; @@ -1408,75 +1015,7 @@ void test_transpose_2d_7dview() { } else { // Transposed Views View7DLayout2type ref("ref", nt0, nt1, nt2, nt3, nt4, nt5, nt6); - auto h_ref = Kokkos::create_mirror_view(ref); - // Filling the transposed View - for (std::size_t i0 = 0; i0 < h_x.extent(0); i0++) { - for (std::size_t i1 = 0; i1 < h_x.extent(1); i1++) { - for (std::size_t i2 = 0; i2 < h_x.extent(2); i2++) { - for (std::size_t i3 = 0; i3 < h_x.extent(3); i3++) { - for (std::size_t i4 = 0; i4 < h_x.extent(4); i4++) { - for (std::size_t i5 = 0; i5 < h_x.extent(5); i5++) { - for (std::size_t i6 = 0; i6 < h_x.extent(6); i6++) { - std::size_t dst_i0 = (map[0] == 1) ? i1 - : (map[0] == 2) ? i2 - : (map[0] == 3) ? i3 - : (map[0] == 4) ? i4 - : (map[0] == 5) ? i5 - : (map[0] == 6) ? i6 - : i0; - std::size_t dst_i1 = (map[1] == 0) ? i0 - : (map[1] == 2) ? i2 - : (map[1] == 3) ? i3 - : (map[1] == 4) ? i4 - : (map[1] == 5) ? i5 - : (map[1] == 6) ? i6 - : i1; - std::size_t dst_i2 = (map[2] == 0) ? i0 - : (map[2] == 1) ? i1 - : (map[2] == 3) ? i3 - : (map[2] == 4) ? i4 - : (map[2] == 5) ? i5 - : (map[2] == 6) ? i6 - : i2; - std::size_t dst_i3 = (map[3] == 0) ? i0 - : (map[3] == 1) ? i1 - : (map[3] == 2) ? i2 - : (map[3] == 4) ? i4 - : (map[3] == 5) ? i5 - : (map[3] == 6) ? i6 - : i3; - std::size_t dst_i4 = (map[4] == 0) ? i0 - : (map[4] == 1) ? i1 - : (map[4] == 2) ? i2 - : (map[4] == 3) ? i3 - : (map[4] == 5) ? i5 - : (map[4] == 6) ? i6 - : i4; - std::size_t dst_i5 = (map[5] == 0) ? i0 - : (map[5] == 1) ? i1 - : (map[5] == 2) ? i2 - : (map[5] == 3) ? i3 - : (map[5] == 4) ? i4 - : (map[5] == 6) ? i6 - : i5; - std::size_t dst_i6 = (map[6] == 0) ? i0 - : (map[6] == 1) ? i1 - : (map[6] == 2) ? i2 - : (map[6] == 3) ? i3 - : (map[6] == 4) ? i4 - : (map[6] == 5) ? i5 - : i6; - h_ref(dst_i0, dst_i1, dst_i2, dst_i3, dst_i4, dst_i5, - dst_i6) = h_x(i0, i1, i2, i3, i4, i5, i6); - } - } - } - } - } - } - } - - Kokkos::deep_copy(ref, h_ref); + make_transposed(x, ref, map); KokkosFFT::Impl::transpose(exec, x, xt, map); EXPECT_TRUE(allclose(exec, xt, ref, 1.e-5, 1.e-12)); @@ -1506,15 +1045,13 @@ void test_transpose_2d_8dview() { Kokkos::fill_random(exec, x, random_pool, 1.0); exec.fence(); - auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x); - // Transposed views axes_type default_axes({0, 1, 2, 3, 4, 5, 6, 7}); for (int axis0 = 0; axis0 < DIM; axis0++) { for (int axis1 = 0; axis1 < DIM; axis1++) { if (axis0 == axis1) continue; - KokkosFFT::axis_type<2> axes = {axis0, axis1}; + KokkosFFT::axis_type<2> axes{axis0, axis1}; auto [map, map_inv] = KokkosFFT::Impl::get_map_axes(x, axes); axes_type out_extents; @@ -1530,93 +1067,7 @@ void test_transpose_2d_8dview() { } else { // Transposed Views View8DLayout2type ref("ref", nt0, nt1, nt2, nt3, nt4, nt5, nt6, nt7); - auto h_ref = Kokkos::create_mirror_view(ref); - // Filling the transposed View - for (std::size_t i0 = 0; i0 < h_x.extent(0); i0++) { - for (std::size_t i1 = 0; i1 < h_x.extent(1); i1++) { - for (std::size_t i2 = 0; i2 < h_x.extent(2); i2++) { - for (std::size_t i3 = 0; i3 < h_x.extent(3); i3++) { - for (std::size_t i4 = 0; i4 < h_x.extent(4); i4++) { - for (std::size_t i5 = 0; i5 < h_x.extent(5); i5++) { - for (std::size_t i6 = 0; i6 < h_x.extent(6); i6++) { - for (std::size_t i7 = 0; i7 < h_x.extent(7); i7++) { - std::size_t dst_i0 = (map[0] == 1) ? i1 - : (map[0] == 2) ? i2 - : (map[0] == 3) ? i3 - : (map[0] == 4) ? i4 - : (map[0] == 5) ? i5 - : (map[0] == 6) ? i6 - : (map[0] == 7) ? i7 - : i0; - std::size_t dst_i1 = (map[1] == 0) ? i0 - : (map[1] == 2) ? i2 - : (map[1] == 3) ? i3 - : (map[1] == 4) ? i4 - : (map[1] == 5) ? i5 - : (map[1] == 6) ? i6 - : (map[1] == 7) ? i7 - : i1; - std::size_t dst_i2 = (map[2] == 0) ? i0 - : (map[2] == 1) ? i1 - : (map[2] == 3) ? i3 - : (map[2] == 4) ? i4 - : (map[2] == 5) ? i5 - : (map[2] == 6) ? i6 - : (map[2] == 7) ? i7 - : i2; - std::size_t dst_i3 = (map[3] == 0) ? i0 - : (map[3] == 1) ? i1 - : (map[3] == 2) ? i2 - : (map[3] == 4) ? i4 - : (map[3] == 5) ? i5 - : (map[3] == 6) ? i6 - : (map[3] == 7) ? i7 - : i3; - std::size_t dst_i4 = (map[4] == 0) ? i0 - : (map[4] == 1) ? i1 - : (map[4] == 2) ? i2 - : (map[4] == 3) ? i3 - : (map[4] == 5) ? i5 - : (map[4] == 6) ? i6 - : (map[4] == 7) ? i7 - : i4; - std::size_t dst_i5 = (map[5] == 0) ? i0 - : (map[5] == 1) ? i1 - : (map[5] == 2) ? i2 - : (map[5] == 3) ? i3 - : (map[5] == 4) ? i4 - : (map[5] == 6) ? i6 - : (map[5] == 7) ? i7 - : i5; - std::size_t dst_i6 = (map[6] == 0) ? i0 - : (map[6] == 1) ? i1 - : (map[6] == 2) ? i2 - : (map[6] == 3) ? i3 - : (map[6] == 4) ? i4 - : (map[6] == 5) ? i5 - : (map[6] == 7) ? i7 - : i6; - std::size_t dst_i7 = (map[7] == 0) ? i0 - : (map[7] == 1) ? i1 - : (map[7] == 2) ? i2 - : (map[7] == 3) ? i3 - : (map[7] == 4) ? i4 - : (map[7] == 5) ? i5 - : (map[7] == 6) ? i6 - : i7; - h_ref(dst_i0, dst_i1, dst_i2, dst_i3, dst_i4, dst_i5, - dst_i6, dst_i7) = - h_x(i0, i1, i2, i3, i4, i5, i6, i7); - } - } - } - } - } - } - } - } - - Kokkos::deep_copy(ref, h_ref); + make_transposed(x, ref, map); KokkosFFT::Impl::transpose(exec, x, xt, map); EXPECT_TRUE(allclose(exec, xt, ref, 1.e-5, 1.e-12)); @@ -1729,8 +1180,6 @@ void test_transpose_3d_4dview() { Kokkos::fill_random(exec, x, random_pool, 1.0); exec.fence(); - auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x); - // Transposed views axes_type default_axes({0, 1, 2, 3}); @@ -1738,7 +1187,7 @@ void test_transpose_3d_4dview() { for (int axis1 = 0; axis1 < DIM; axis1++) { for (int axis2 = 0; axis2 < DIM; axis2++) { if (axis0 == axis1 || axis0 == axis2 || axis1 == axis2) continue; - KokkosFFT::axis_type<3> axes = {axis0, axis1, axis2}; + KokkosFFT::axis_type<3> axes{axis0, axis1, axis2}; auto [map, map_inv] = KokkosFFT::Impl::get_map_axes(x, axes); axes_type out_extents; @@ -1754,36 +1203,7 @@ void test_transpose_3d_4dview() { } else { // Transposed Views View4DLayout2type ref("ref", nt0, nt1, nt2, nt3); - auto h_ref = Kokkos::create_mirror_view(ref); - // Filling the transposed View - for (std::size_t i0 = 0; i0 < h_x.extent(0); i0++) { - for (std::size_t i1 = 0; i1 < h_x.extent(1); i1++) { - for (std::size_t i2 = 0; i2 < h_x.extent(2); i2++) { - for (std::size_t i3 = 0; i3 < h_x.extent(3); i3++) { - std::size_t dst_i0 = (map[0] == 1) ? i1 - : (map[0] == 2) ? i2 - : (map[0] == 3) ? i3 - : i0; - std::size_t dst_i1 = (map[1] == 0) ? i0 - : (map[1] == 2) ? i2 - : (map[1] == 3) ? i3 - : i1; - std::size_t dst_i2 = (map[2] == 0) ? i0 - : (map[2] == 1) ? i1 - : (map[2] == 3) ? i3 - : i2; - std::size_t dst_i3 = (map[3] == 0) ? i0 - : (map[3] == 1) ? i1 - : (map[3] == 2) ? i2 - : i3; - - h_ref(dst_i0, dst_i1, dst_i2, dst_i3) = h_x(i0, i1, i2, i3); - } - } - } - } - - Kokkos::deep_copy(ref, h_ref); + make_transposed(x, ref, map); KokkosFFT::Impl::transpose(exec, x, xt, map); EXPECT_TRUE(allclose(exec, xt, ref, 1.e-5, 1.e-12)); @@ -1814,8 +1234,6 @@ void test_transpose_3d_5dview() { Kokkos::fill_random(exec, x, random_pool, 1.0); exec.fence(); - auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x); - // Transposed views axes_type default_axes({0, 1, 2, 3, 4}); @@ -1824,7 +1242,7 @@ void test_transpose_3d_5dview() { for (int axis2 = 0; axis2 < DIM; axis2++) { if (axis0 == axis1 || axis0 == axis2 || axis1 == axis2) continue; - KokkosFFT::axis_type<3> axes = {axis0, axis1, axis2}; + KokkosFFT::axis_type<3> axes{axis0, axis1, axis2}; auto [map, map_inv] = KokkosFFT::Impl::get_map_axes(x, axes); axes_type out_extents; @@ -1840,47 +1258,7 @@ void test_transpose_3d_5dview() { } else { // Transposed Views View5DLayout2type ref("ref", nt0, nt1, nt2, nt3, nt4); - auto h_ref = Kokkos::create_mirror_view(ref); - // Filling the transposed View - for (std::size_t i0 = 0; i0 < h_x.extent(0); i0++) { - for (std::size_t i1 = 0; i1 < h_x.extent(1); i1++) { - for (std::size_t i2 = 0; i2 < h_x.extent(2); i2++) { - for (std::size_t i3 = 0; i3 < h_x.extent(3); i3++) { - for (std::size_t i4 = 0; i4 < h_x.extent(4); i4++) { - std::size_t dst_i0 = (map[0] == 1) ? i1 - : (map[0] == 2) ? i2 - : (map[0] == 3) ? i3 - : (map[0] == 4) ? i4 - : i0; - std::size_t dst_i1 = (map[1] == 0) ? i0 - : (map[1] == 2) ? i2 - : (map[1] == 3) ? i3 - : (map[1] == 4) ? i4 - : i1; - std::size_t dst_i2 = (map[2] == 0) ? i0 - : (map[2] == 1) ? i1 - : (map[2] == 3) ? i3 - : (map[2] == 4) ? i4 - : i2; - std::size_t dst_i3 = (map[3] == 0) ? i0 - : (map[3] == 1) ? i1 - : (map[3] == 2) ? i2 - : (map[3] == 4) ? i4 - : i3; - std::size_t dst_i4 = (map[4] == 0) ? i0 - : (map[4] == 1) ? i1 - : (map[4] == 2) ? i2 - : (map[4] == 3) ? i3 - : i4; - h_ref(dst_i0, dst_i1, dst_i2, dst_i3, dst_i4) = - h_x(i0, i1, i2, i3, i4); - } - } - } - } - } - - Kokkos::deep_copy(ref, h_ref); + make_transposed(x, ref, map); KokkosFFT::Impl::transpose(exec, x, xt, map); EXPECT_TRUE(allclose(exec, xt, ref, 1.e-5, 1.e-12)); @@ -1911,8 +1289,6 @@ void test_transpose_3d_6dview() { Kokkos::fill_random(exec, x, random_pool, 1.0); exec.fence(); - auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x); - // Transposed views axes_type default_axes({0, 1, 2, 3, 4, 5}); @@ -1921,7 +1297,7 @@ void test_transpose_3d_6dview() { for (int axis2 = 0; axis2 < DIM; axis2++) { if (axis0 == axis1 || axis0 == axis2 || axis1 == axis2) continue; - KokkosFFT::axis_type<3> axes = {axis0, axis1, axis2}; + KokkosFFT::axis_type<3> axes{axis0, axis1, axis2}; auto [map, map_inv] = KokkosFFT::Impl::get_map_axes(x, axes); axes_type out_extents; @@ -1937,60 +1313,7 @@ void test_transpose_3d_6dview() { } else { // Transposed Views View6DLayout2type ref("ref", nt0, nt1, nt2, nt3, nt4, nt5); - auto h_ref = Kokkos::create_mirror_view(ref); - // Filling the transposed View - for (std::size_t i0 = 0; i0 < h_x.extent(0); i0++) { - for (std::size_t i1 = 0; i1 < h_x.extent(1); i1++) { - for (std::size_t i2 = 0; i2 < h_x.extent(2); i2++) { - for (std::size_t i3 = 0; i3 < h_x.extent(3); i3++) { - for (std::size_t i4 = 0; i4 < h_x.extent(4); i4++) { - for (std::size_t i5 = 0; i5 < h_x.extent(5); i5++) { - std::size_t dst_i0 = (map[0] == 1) ? i1 - : (map[0] == 2) ? i2 - : (map[0] == 3) ? i3 - : (map[0] == 4) ? i4 - : (map[0] == 5) ? i5 - : i0; - std::size_t dst_i1 = (map[1] == 0) ? i0 - : (map[1] == 2) ? i2 - : (map[1] == 3) ? i3 - : (map[1] == 4) ? i4 - : (map[1] == 5) ? i5 - : i1; - std::size_t dst_i2 = (map[2] == 0) ? i0 - : (map[2] == 1) ? i1 - : (map[2] == 3) ? i3 - : (map[2] == 4) ? i4 - : (map[2] == 5) ? i5 - : i2; - std::size_t dst_i3 = (map[3] == 0) ? i0 - : (map[3] == 1) ? i1 - : (map[3] == 2) ? i2 - : (map[3] == 4) ? i4 - : (map[3] == 5) ? i5 - : i3; - std::size_t dst_i4 = (map[4] == 0) ? i0 - : (map[4] == 1) ? i1 - : (map[4] == 2) ? i2 - : (map[4] == 3) ? i3 - : (map[4] == 5) ? i5 - : i4; - std::size_t dst_i5 = (map[5] == 0) ? i0 - : (map[5] == 1) ? i1 - : (map[5] == 2) ? i2 - : (map[5] == 3) ? i3 - : (map[5] == 4) ? i4 - : i5; - h_ref(dst_i0, dst_i1, dst_i2, dst_i3, dst_i4, dst_i5) = - h_x(i0, i1, i2, i3, i4, i5); - } - } - } - } - } - } - - Kokkos::deep_copy(ref, h_ref); + make_transposed(x, ref, map); KokkosFFT::Impl::transpose(exec, x, xt, map); EXPECT_TRUE(allclose(exec, xt, ref, 1.e-5, 1.e-12)); @@ -2021,8 +1344,6 @@ void test_transpose_3d_7dview() { Kokkos::fill_random(exec, x, random_pool, 1.0); exec.fence(); - auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x); - // Transposed views axes_type default_axes({0, 1, 2, 3, 4, 5, 6}); @@ -2031,7 +1352,7 @@ void test_transpose_3d_7dview() { for (int axis2 = 0; axis2 < DIM; axis2++) { if (axis0 == axis1 || axis0 == axis2 || axis1 == axis2) continue; - KokkosFFT::axis_type<3> axes = {axis0, axis1, axis2}; + KokkosFFT::axis_type<3> axes{axis0, axis1, axis2}; auto [map, map_inv] = KokkosFFT::Impl::get_map_axes(x, axes); axes_type out_extents; @@ -2047,75 +1368,7 @@ void test_transpose_3d_7dview() { } else { // Transposed Views View7DLayout2type ref("ref", nt0, nt1, nt2, nt3, nt4, nt5, nt6); - auto h_ref = Kokkos::create_mirror_view(ref); - // Filling the transposed View - for (std::size_t i0 = 0; i0 < h_x.extent(0); i0++) { - for (std::size_t i1 = 0; i1 < h_x.extent(1); i1++) { - for (std::size_t i2 = 0; i2 < h_x.extent(2); i2++) { - for (std::size_t i3 = 0; i3 < h_x.extent(3); i3++) { - for (std::size_t i4 = 0; i4 < h_x.extent(4); i4++) { - for (std::size_t i5 = 0; i5 < h_x.extent(5); i5++) { - for (std::size_t i6 = 0; i6 < h_x.extent(6); i6++) { - std::size_t dst_i0 = (map[0] == 1) ? i1 - : (map[0] == 2) ? i2 - : (map[0] == 3) ? i3 - : (map[0] == 4) ? i4 - : (map[0] == 5) ? i5 - : (map[0] == 6) ? i6 - : i0; - std::size_t dst_i1 = (map[1] == 0) ? i0 - : (map[1] == 2) ? i2 - : (map[1] == 3) ? i3 - : (map[1] == 4) ? i4 - : (map[1] == 5) ? i5 - : (map[1] == 6) ? i6 - : i1; - std::size_t dst_i2 = (map[2] == 0) ? i0 - : (map[2] == 1) ? i1 - : (map[2] == 3) ? i3 - : (map[2] == 4) ? i4 - : (map[2] == 5) ? i5 - : (map[2] == 6) ? i6 - : i2; - std::size_t dst_i3 = (map[3] == 0) ? i0 - : (map[3] == 1) ? i1 - : (map[3] == 2) ? i2 - : (map[3] == 4) ? i4 - : (map[3] == 5) ? i5 - : (map[3] == 6) ? i6 - : i3; - std::size_t dst_i4 = (map[4] == 0) ? i0 - : (map[4] == 1) ? i1 - : (map[4] == 2) ? i2 - : (map[4] == 3) ? i3 - : (map[4] == 5) ? i5 - : (map[4] == 6) ? i6 - : i4; - std::size_t dst_i5 = (map[5] == 0) ? i0 - : (map[5] == 1) ? i1 - : (map[5] == 2) ? i2 - : (map[5] == 3) ? i3 - : (map[5] == 4) ? i4 - : (map[5] == 6) ? i6 - : i5; - std::size_t dst_i6 = (map[6] == 0) ? i0 - : (map[6] == 1) ? i1 - : (map[6] == 2) ? i2 - : (map[6] == 3) ? i3 - : (map[6] == 4) ? i4 - : (map[6] == 5) ? i5 - : i6; - h_ref(dst_i0, dst_i1, dst_i2, dst_i3, dst_i4, dst_i5, - dst_i6) = h_x(i0, i1, i2, i3, i4, i5, i6); - } - } - } - } - } - } - } - - Kokkos::deep_copy(ref, h_ref); + make_transposed(x, ref, map); KokkosFFT::Impl::transpose(exec, x, xt, map); EXPECT_TRUE(allclose(exec, xt, ref, 1.e-5, 1.e-12)); @@ -2146,8 +1399,6 @@ void test_transpose_3d_8dview() { Kokkos::fill_random(exec, x, random_pool, 1.0); exec.fence(); - auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x); - // Transposed views axes_type default_axes({0, 1, 2, 3, 4, 5, 6, 7}); @@ -2156,7 +1407,7 @@ void test_transpose_3d_8dview() { for (int axis2 = 0; axis2 < DIM; axis2++) { if (axis0 == axis1 || axis0 == axis2 || axis1 == axis2) continue; - KokkosFFT::axis_type<3> axes = {axis0, axis1, axis2}; + KokkosFFT::axis_type<3> axes{axis0, axis1, axis2}; auto [map, map_inv] = KokkosFFT::Impl::get_map_axes(x, axes); axes_type out_extents; @@ -2172,93 +1423,7 @@ void test_transpose_3d_8dview() { } else { // Transposed Views View8DLayout2type ref("ref", nt0, nt1, nt2, nt3, nt4, nt5, nt6, nt7); - auto h_ref = Kokkos::create_mirror_view(ref); - // Filling the transposed View - for (std::size_t i0 = 0; i0 < h_x.extent(0); i0++) { - for (std::size_t i1 = 0; i1 < h_x.extent(1); i1++) { - for (std::size_t i2 = 0; i2 < h_x.extent(2); i2++) { - for (std::size_t i3 = 0; i3 < h_x.extent(3); i3++) { - for (std::size_t i4 = 0; i4 < h_x.extent(4); i4++) { - for (std::size_t i5 = 0; i5 < h_x.extent(5); i5++) { - for (std::size_t i6 = 0; i6 < h_x.extent(6); i6++) { - for (std::size_t i7 = 0; i7 < h_x.extent(7); i7++) { - std::size_t dst_i0 = (map[0] == 1) ? i1 - : (map[0] == 2) ? i2 - : (map[0] == 3) ? i3 - : (map[0] == 4) ? i4 - : (map[0] == 5) ? i5 - : (map[0] == 6) ? i6 - : (map[0] == 7) ? i7 - : i0; - std::size_t dst_i1 = (map[1] == 0) ? i0 - : (map[1] == 2) ? i2 - : (map[1] == 3) ? i3 - : (map[1] == 4) ? i4 - : (map[1] == 5) ? i5 - : (map[1] == 6) ? i6 - : (map[1] == 7) ? i7 - : i1; - std::size_t dst_i2 = (map[2] == 0) ? i0 - : (map[2] == 1) ? i1 - : (map[2] == 3) ? i3 - : (map[2] == 4) ? i4 - : (map[2] == 5) ? i5 - : (map[2] == 6) ? i6 - : (map[2] == 7) ? i7 - : i2; - std::size_t dst_i3 = (map[3] == 0) ? i0 - : (map[3] == 1) ? i1 - : (map[3] == 2) ? i2 - : (map[3] == 4) ? i4 - : (map[3] == 5) ? i5 - : (map[3] == 6) ? i6 - : (map[3] == 7) ? i7 - : i3; - std::size_t dst_i4 = (map[4] == 0) ? i0 - : (map[4] == 1) ? i1 - : (map[4] == 2) ? i2 - : (map[4] == 3) ? i3 - : (map[4] == 5) ? i5 - : (map[4] == 6) ? i6 - : (map[4] == 7) ? i7 - : i4; - std::size_t dst_i5 = (map[5] == 0) ? i0 - : (map[5] == 1) ? i1 - : (map[5] == 2) ? i2 - : (map[5] == 3) ? i3 - : (map[5] == 4) ? i4 - : (map[5] == 6) ? i6 - : (map[5] == 7) ? i7 - : i5; - std::size_t dst_i6 = (map[6] == 0) ? i0 - : (map[6] == 1) ? i1 - : (map[6] == 2) ? i2 - : (map[6] == 3) ? i3 - : (map[6] == 4) ? i4 - : (map[6] == 5) ? i5 - : (map[6] == 7) ? i7 - : i6; - std::size_t dst_i7 = (map[7] == 0) ? i0 - : (map[7] == 1) ? i1 - : (map[7] == 2) ? i2 - : (map[7] == 3) ? i3 - : (map[7] == 4) ? i4 - : (map[7] == 5) ? i5 - : (map[7] == 6) ? i6 - : i7; - h_ref(dst_i0, dst_i1, dst_i2, dst_i3, dst_i4, dst_i5, - dst_i6, dst_i7) = - h_x(i0, i1, i2, i3, i4, i5, i6, i7); - } - } - } - } - } - } - } - } - - Kokkos::deep_copy(ref, h_ref); + make_transposed(x, ref, map); KokkosFFT::Impl::transpose(exec, x, xt, map); EXPECT_TRUE(allclose(exec, xt, ref, 1.e-5, 1.e-12)); @@ -2418,6 +1583,11 @@ TYPED_TEST(TestTranspose3D, 4DView) { using layout_type1 = typename TestFixture::layout_type1; using layout_type2 = typename TestFixture::layout_type2; + if constexpr (!std::is_same_v) { + GTEST_SKIP() << "FIXME: This triggers a failure in FFT shifts test on Cuda " + "backend with Release build"; + } + test_transpose_3d_4dview(); }