From 1788f0603908b147e88d766d885a246f195be205 Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Thu, 24 Oct 2024 16:09:12 +0900 Subject: [PATCH] Do not use Unmanaged traits explicitly --- common/unit_test/Test_Utils.cpp | 4 +--- fft/src/KokkosFFT_Plans.hpp | 5 +--- fft/unit_test/Test_Transform.cpp | 39 ++++++++++++++------------------ 3 files changed, 19 insertions(+), 29 deletions(-) diff --git a/common/unit_test/Test_Utils.cpp b/common/unit_test/Test_Utils.cpp index ec16eec2..e4c66453 100644 --- a/common/unit_test/Test_Utils.cpp +++ b/common/unit_test/Test_Utils.cpp @@ -569,15 +569,13 @@ template void test_are_pointers_aliasing() { using View1 = Kokkos::View; using View2 = Kokkos::View; - using UView2 = Kokkos::View>; const int n1 = 10; // sizeof ValeuType2 is larger or equal to ValueType1 const int n2 = sizeof(ValueType1) == sizeof(ValueType2) ? n1 : n1 / 2 + 1; View1 view1("view1", n1); View2 view2("view2", n1); - UView2 uview2(reinterpret_cast(view1.data()), n2); + View2 uview2(reinterpret_cast(view1.data()), n2); EXPECT_TRUE(KokkosFFT::Impl::are_aliasing(view1.data(), uview2.data())); EXPECT_FALSE(KokkosFFT::Impl::are_aliasing(view1.data(), view2.data())); diff --git a/fft/src/KokkosFFT_Plans.hpp b/fft/src/KokkosFFT_Plans.hpp index 6c5e29e9..e4d8a91b 100644 --- a/fft/src/KokkosFFT_Plans.hpp +++ b/fft/src/KokkosFFT_Plans.hpp @@ -362,10 +362,7 @@ class Plan { // For the in-place Complex to Real transform, the output must be // reshaped to fit the original size (in.size() * 2) for correct // normalization - using UnmanagedOutViewType = - Kokkos::View>; - UnmanagedOutViewType out_tmp(out.data(), in.size() * 2); + Kokkos::View out_tmp(out.data(), in.size() * 2); KokkosFFT::Impl::normalize(m_exec_space, out_tmp, m_direction, norm, m_fft_size); return; diff --git a/fft/unit_test/Test_Transform.cpp b/fft/unit_test/Test_Transform.cpp index 23db4dce..28f699fe 100644 --- a/fft/unit_test/Test_Transform.cpp +++ b/fft/unit_test/Test_Transform.cpp @@ -76,23 +76,18 @@ void test_fft1_identity(T atol = 1.0e-12) { template void test_fft1_identity_inplace(T atol = 1.0e-12) { - const int maxlen = 32; - using RealView1DType = Kokkos::View; - using RealUView1DType = Kokkos::View>; + const int maxlen = 32; + using RealView1DType = Kokkos::View; using ComplexView1DType = Kokkos::View*, LayoutType, execution_space>; - using ComplexUView1DType = - Kokkos::View*, LayoutType, execution_space, - Kokkos::MemoryTraits>; for (int i = 1; i < maxlen; i++) { ComplexView1DType a("a", i), a_ref("a_ref", i); - ComplexUView1DType a_hat(a.data(), i), inv_a_hat(a.data(), i); + ComplexView1DType a_hat(a.data(), i), inv_a_hat(a.data(), i); // Used for Real transforms ComplexView1DType ar_hat("ar_hat", i / 2 + 1); - RealUView1DType ar(reinterpret_cast(ar_hat.data()), i), + RealView1DType ar(reinterpret_cast(ar_hat.data()), i), inv_ar_hat(reinterpret_cast(ar_hat.data()), i); RealView1DType ar_ref("ar_ref", i); @@ -1675,17 +1670,12 @@ void test_fft2_2dfft_2dview_shape(T atol = 1.0e-12) { template void test_fft2_2dfft_2dview_inplace([[maybe_unused]] T atol = 1.0e-12) { const int n0 = 4, n1 = 6; - using RealView2DType = Kokkos::View; - using RealUView2DType = Kokkos::View>; + using RealView2DType = Kokkos::View; using ComplexView2DType = Kokkos::View**, LayoutType, execution_space>; - using ComplexUView2DType = - Kokkos::View**, LayoutType, execution_space, - Kokkos::MemoryTraits>; ComplexView2DType x("x", n0, n1), x_ref("x_ref", n0, n1); - ComplexUView2DType x_hat(x.data(), n0, n1), inv_x_hat(x.data(), n0, n1); + ComplexView2DType x_hat(x.data(), n0, n1), inv_x_hat(x.data(), n0, n1); // Used for real transforms ComplexView2DType xr_hat("xr_hat", n0, n1 / 2 + 1), @@ -1695,16 +1685,16 @@ void test_fft2_2dfft_2dview_inplace([[maybe_unused]] T atol = 1.0e-12) { inv_xr_hat_ref("inv_xr_hat_ref", n0, n1); // Unmanged views for in-place transforms - RealUView2DType xr(reinterpret_cast(xr_hat.data()), n0, n1), + RealView2DType xr(reinterpret_cast(xr_hat.data()), n0, n1), inv_xr_hat(reinterpret_cast(xr_hat.data()), n0, n1); - RealUView2DType xr_padded(reinterpret_cast(xr_hat.data()), n0, - (n1 / 2 + 1) * 2), + RealView2DType xr_padded(reinterpret_cast(xr_hat.data()), n0, + (n1 / 2 + 1) * 2), inv_xr_hat_padded(reinterpret_cast(xr_hat.data()), n0, (n1 / 2 + 1) * 2); // Initialize xr_hat through xr_padded auto sub_xr_padded = - Kokkos::subview(xr_padded, Kokkos::ALL(), Kokkos::pair(0, n1)); + Kokkos::subview(xr_padded, Kokkos::ALL, Kokkos::pair(0, n1)); const Kokkos::complex z(1.0, 1.0); Kokkos::Random_XorShift64_Pool<> random_pool(12345); @@ -1736,6 +1726,8 @@ void test_fft2_2dfft_2dview_inplace([[maybe_unused]] T atol = 1.0e-12) { KokkosFFT::Normalization::backward, axes); KokkosFFT::ifft2(execution_space(), x_hat, inv_x_hat, KokkosFFT::Normalization::backward, axes); + + Kokkos::fence(); EXPECT_TRUE(allclose(inv_x_hat, x_ref, 1.e-5, atol)); // In-place transforms @@ -1745,6 +1737,8 @@ void test_fft2_2dfft_2dview_inplace([[maybe_unused]] T atol = 1.0e-12) { // Out-of-place transforms (reference) KokkosFFT::rfft2(execution_space(), xr_ref, xr_hat_ref, KokkosFFT::Normalization::backward, axes); + + Kokkos::fence(); EXPECT_TRUE(allclose(xr_hat, xr_hat_ref, 1.e-5, atol)); // In-place transforms @@ -1757,8 +1751,9 @@ void test_fft2_2dfft_2dview_inplace([[maybe_unused]] T atol = 1.0e-12) { KokkosFFT::irfft2(execution_space(), xr_hat_ref, inv_xr_hat_ref, KokkosFFT::Normalization::backward, axes); - auto sub_inv_xr_hat_padded = Kokkos::subview( - inv_xr_hat_padded, Kokkos::ALL(), Kokkos::pair(0, n1)); + Kokkos::fence(); + auto sub_inv_xr_hat_padded = Kokkos::subview(inv_xr_hat_padded, Kokkos::ALL, + Kokkos::pair(0, n1)); Kokkos::deep_copy(inv_xr_hat_unpadded, sub_inv_xr_hat_padded); EXPECT_TRUE(allclose(inv_xr_hat_unpadded, inv_xr_hat_ref, 1.e-5, atol));