From 18399d129e1cdad9dd977fbca9db04ac62265d9d Mon Sep 17 00:00:00 2001 From: thierry antoun Date: Fri, 22 Mar 2024 11:31:40 +0100 Subject: [PATCH 1/2] Remove MirrorType structure --- core/src/Kokkos_CopyViews.hpp | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/core/src/Kokkos_CopyViews.hpp b/core/src/Kokkos_CopyViews.hpp index 51e79b206dd..e7ceeea808d 100644 --- a/core/src/Kokkos_CopyViews.hpp +++ b/core/src/Kokkos_CopyViews.hpp @@ -3432,26 +3432,6 @@ struct MirrorViewType { std::conditional_t; }; -template -struct MirrorType { - // The incoming view_type - using src_view_type = typename Kokkos::View; - // The memory space for the mirror view - using memory_space = typename Space::memory_space; - // Check whether it is the same memory space - enum { - is_same_memspace = - std::is_same::value - }; - // The array_layout - using array_layout = typename src_view_type::array_layout; - // The data type (we probably want it non-const since otherwise we can't even - // deep_copy to it. - using data_type = typename src_view_type::non_const_data_type; - // The destination view type if it is not the same memory space - using view_type = Kokkos::View; -}; - template void check_view_ctor_args_create_mirror() { using alloc_prop_input = Impl::ViewCtorProp; @@ -3481,7 +3461,7 @@ auto create_mirror(const Kokkos::View& src, if constexpr (Impl::ViewCtorProp::has_memory_space) { using memory_space = typename decltype(prop_copy)::memory_space; using dst_type = - typename Impl::MirrorType::view_type; + typename Impl::MirrorViewType::dest_view_type; return dst_type(prop_copy, src.layout()); } else { using dst_type = typename View::HostMirror; From 9712a39773763ade1ddf285e550f28d1a353b90d Mon Sep 17 00:00:00 2001 From: thierry antoun Date: Thu, 4 Apr 2024 14:57:37 +0200 Subject: [PATCH 2/2] Format with Clang --- core/src/Kokkos_CopyViews.hpp | 51 ++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/core/src/Kokkos_CopyViews.hpp b/core/src/Kokkos_CopyViews.hpp index 6f050b1c97d..a126c29ae89 100644 --- a/core/src/Kokkos_CopyViews.hpp +++ b/core/src/Kokkos_CopyViews.hpp @@ -3451,9 +3451,11 @@ void check_view_ctor_args_create_mirror() { "not explicitly allow padding!"); } -// private interface that accepts arbitrary view constructor args passed by a view_alloc +// private interface that accepts arbitrary view constructor args passed by a +// view_alloc template ::specialize>::value>> + class = std::enable_if< + std::is_void::specialize>::value>> auto create_mirror(const Kokkos::View& src, const Impl::ViewCtorProp& arg_prop) { check_view_ctor_args_create_mirror(); @@ -3482,7 +3484,7 @@ auto create_mirror(Kokkos::View const& src) { // public interface that accepts a without initializing flag template auto create_mirror(Kokkos::Impl::WithoutInitializing_t wi, - Kokkos::View const& src) { + Kokkos::View const& src) { return Impl::create_mirror(src, view_alloc(wi)); } @@ -3493,7 +3495,8 @@ auto create_mirror(Space const&, Kokkos::View const& src) { return Impl::create_mirror(src, view_alloc(typename Space::memory_space{})); } -// public interface that accepts arbitrary view constructor args passed by a view_alloc +// public interface that accepts arbitrary view constructor args passed by a +// view_alloc template auto create_mirror(Impl::ViewCtorProp const& arg_prop, Kokkos::View const& src) { @@ -3504,16 +3507,18 @@ auto create_mirror(Impl::ViewCtorProp const& arg_prop, template ::value>> auto create_mirror(Kokkos::Impl::WithoutInitializing_t wi, Space const&, - Kokkos::View const& src) { + Kokkos::View const& src) { return Impl::create_mirror(src, view_alloc(typename Space::memory_space{}, wi)); } namespace Impl { -// private interface that accepts arbitrary view constructor args passed by a view_alloc +// private interface that accepts arbitrary view constructor args passed by a +// view_alloc template ::specialize>::value>> + class = std::enable_if< + std::is_void::specialize>::value>> auto create_mirror_view(const Kokkos::View& src, const Impl::ViewCtorProp& arg_prop) { if constexpr (!Impl::ViewCtorProp::has_memory_space) { @@ -3549,30 +3554,30 @@ auto create_mirror_view(const Kokkos::View& src) { // public interface that accepts a without initializing flag template -auto create_mirror_view( - Kokkos::Impl::WithoutInitializing_t wi, Kokkos::View const& src) { +auto create_mirror_view(Kokkos::Impl::WithoutInitializing_t wi, + Kokkos::View const& src) { return Impl::create_mirror_view(src, view_alloc(wi)); } // public interface that accepts a space template ::value>> -auto create_mirror_view( - const Space& space, const Kokkos::View& src) { - return Impl::create_mirror_view(src, view_alloc(typename Space::memory_space())); +auto create_mirror_view(const Space& space, const Kokkos::View& src) { + return Impl::create_mirror_view(src, + view_alloc(typename Space::memory_space())); } // public interface that accepts a space and a without initializing flag template ::value>> -auto create_mirror_view( - Kokkos::Impl::WithoutInitializing_t wi, Space const&, - Kokkos::View const& src) { +auto create_mirror_view(Kokkos::Impl::WithoutInitializing_t wi, Space const&, + Kokkos::View const& src) { return Impl::create_mirror_view( src, view_alloc(typename Space::memory_space{}, wi)); } -// public interface that accepts arbitrary view constructor args passed by a view_alloc +// public interface that accepts arbitrary view constructor args passed by a +// view_alloc template auto create_mirror_view(const Impl::ViewCtorProp& arg_prop, const Kokkos::View& src) { @@ -3600,11 +3605,13 @@ void check_view_ctor_args_create_mirror_view_and_copy() { "not explicitly allow padding!"); } -} // namespace Impl +} // namespace Impl -// public interface that accepts arbitrary view constructor args passed by a view_alloc +// public interface that accepts arbitrary view constructor args passed by a +// view_alloc template ::specialize>::value>> + class = std::enable_if< + std::is_void::specialize>::value>> auto create_mirror_view_and_copy( const Impl::ViewCtorProp& arg_prop, const Kokkos::View& src) { @@ -3612,11 +3619,13 @@ auto create_mirror_view_and_copy( Impl::check_view_ctor_args_create_mirror_view_and_copy(); - if constexpr (Impl::MirrorViewType::is_same_memspace) { + if constexpr (Impl::MirrorViewType::is_same_memspace) { // same behavior as deep_copy(src, src) if constexpr (!alloc_prop_input::has_execution_space) fence( - "Kokkos::create_mirror_view_and_copy: fence before returning src view"); + "Kokkos::create_mirror_view_and_copy: fence before returning src " + "view"); return src; } else { using Space = typename alloc_prop_input::memory_space;