Skip to content

Commit

Permalink
#197: Avoid external synchronization of host/device copies
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilMiller authored and cz4rs committed Jun 10, 2021
1 parent 50b157d commit 337cf83
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/checkpoint/container/view_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,10 @@ inline void serialize_impl(SerializerT& s, Kokkos::View<T,Args...>& view) {
if (init) {
auto host_view = Kokkos::create_mirror_view(view);
if (s.isPacking()) {
Kokkos::deep_copy(host_view, view);
// Create and use an execution space to avoid a global Kokkos::fence()
auto exec_space = Kokkos::HostSpace{};
Kokkos::deep_copy(exec_space, host_view, view);
exec_space.fence();
}

// Serialize the actual data owned by the Kokkos::View
Expand All @@ -474,7 +477,10 @@ inline void serialize_impl(SerializerT& s, Kokkos::View<T,Args...>& view) {
}

if (s.isUnpacking()) {
Kokkos::deep_copy(view, host_view);
// Create and use an execution space to avoid a global Kokkos::fence()
auto exec_space = Kokkos::HostSpace{};
Kokkos::deep_copy(exec_space, view, host_view);
exec_space.fence();
}
}
}
Expand Down

0 comments on commit 337cf83

Please sign in to comment.