From 434e9ff036bb8529d4746941dd2a350ab55e5a93 Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Wed, 1 Jun 2022 18:16:01 -0600 Subject: [PATCH] #245: Serialize View through a non-const alias of the data, rather than copying --- src/checkpoint/container/view_serialize.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/checkpoint/container/view_serialize.h b/src/checkpoint/container/view_serialize.h index 764b513d..4f61ae29 100644 --- a/src/checkpoint/container/view_serialize.h +++ b/src/checkpoint/container/view_serialize.h @@ -534,11 +534,9 @@ inline void serialize_impl(SerializerT& s, Kokkos::View& view) { template inline void serialize_const(SerializerT& s, Kokkos::View& view) { using ViewType = Kokkos::View; - using T_non_const = typename ViewType::traits::non_const_data_type; - Kokkos::View tmp_non_const(view.label(), view.layout()); - if (s.isPacking()) { - deepCopyWithLocalFence(tmp_non_const, view); - } + using V_non_const = typename ViewType::non_const_type; + using T_non_const = typename ViewType::traits::non_const_value_type; + V_non_const tmp_non_const(const_cast(view.data()), view.layout()); serialize_impl(s, tmp_non_const); if (s.isUnpacking()) { view = tmp_non_const;