Skip to content

Commit

Permalink
#245: Serialize View<const T> through a non-const alias of the data, …
Browse files Browse the repository at this point in the history
…rather than copying
  • Loading branch information
PhilMiller committed Nov 11, 2022
1 parent beaf39c commit 434e9ff
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/checkpoint/container/view_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,11 +534,9 @@ inline void serialize_impl(SerializerT& s, Kokkos::View<T,Args...>& view) {
template <typename SerializerT, typename T, typename... Args>
inline void serialize_const(SerializerT& s, Kokkos::View<T,Args...>& view) {
using ViewType = Kokkos::View<T,Args...>;
using T_non_const = typename ViewType::traits::non_const_data_type;
Kokkos::View<T_non_const,Args...> 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<T_non_const*>(view.data()), view.layout());
serialize_impl(s, tmp_non_const);
if (s.isUnpacking()) {
view = tmp_non_const;
Expand Down

0 comments on commit 434e9ff

Please sign in to comment.