From e0e8328dfcbc0fc2a0f6792db9ce50c7af407f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Thu, 24 Oct 2024 18:30:53 +0200 Subject: [PATCH] #373: update View of Views usage --- src/checkpoint/container/view_serialize.h | 24 +++++---------- tests/unit/test_kokkos_serialize_array.cc | 2 +- .../unit/test_kokkos_serialize_integration.cc | 29 ++++++++++++------- 3 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/checkpoint/container/view_serialize.h b/src/checkpoint/container/view_serialize.h index e4dfe742..0f62171b 100644 --- a/src/checkpoint/container/view_serialize.h +++ b/src/checkpoint/container/view_serialize.h @@ -45,10 +45,8 @@ #define INCLUDED_SRC_CHECKPOINT_CONTAINER_VIEW_SERIALIZE_H #include "checkpoint/common.h" -#include "checkpoint/serializers/serializers_headers.h" #include "checkpoint/container/view_traits_extract.h" #include "checkpoint/container/view_traverse_manual.h" -#include "checkpoint/container/view_traverse_ndim.h" #if MAGISTRATE_KOKKOS_ENABLED @@ -56,32 +54,24 @@ #include #include -#if KOKKOS_VERSION > 30699L -#define CHECKPOINT_KOKKOS_WITHOUTINIT Kokkos::WithoutInitializing, -#else -#define CHECKPOINT_KOKKOS_WITHOUTINIT -#endif - #if MAGISTRATE_KOKKOS_KERNELS_ENABLED #include #include #endif -#include #include -#include -#include -#include #include -#include #include -#define CHECKPOINT_DEBUG_ENABLED 0 - // I am shutting the n-dim traversal off by default for now, due to the extra // template complexity that needs to be tested more extensively on different // compiler versions #define CHECKPOINT_KOKKOS_NDIM_TRAVERSE 0 +#if CHECKPOINT_KOKKOS_NDIM_TRAVERSE +#include "checkpoint/container/view_traverse_ndim.h" +#endif + +#define CHECKPOINT_DEBUG_ENABLED 0 #if CHECKPOINT_DEBUG_ENABLED #define DEBUG_PRINT_CHECKPOINT(ser, str, ...) do { \ @@ -192,7 +182,7 @@ inline void serialize( // Kokkos::deep_copy between DynamicView instances is not yet implemented #if 0 - auto host_view = Kokkos::create_mirror_view(CHECKPOINT_KOKKOS_WITHOUTINIT view); + auto host_view = Kokkos::create_mirror_view(Kokkos::WithoutInitializing, view); if (s.isPacking()) { deepCopyWithLocalFence(host_view, view); } @@ -282,7 +272,7 @@ inline void serialize_impl(SerializerT& s, Kokkos::DynRankView& view) s | init; if (init) { - auto host_view = Kokkos::create_mirror_view(CHECKPOINT_KOKKOS_WITHOUTINIT view); + auto host_view = Kokkos::create_mirror_view(Kokkos::WithoutInitializing, view); using HostViewType = decltype(host_view); if (s.isPacking()) { diff --git a/tests/unit/test_kokkos_serialize_array.cc b/tests/unit/test_kokkos_serialize_array.cc index 78ebc01b..ba691858 100644 --- a/tests/unit/test_kokkos_serialize_array.cc +++ b/tests/unit/test_kokkos_serialize_array.cc @@ -41,8 +41,8 @@ //@HEADER */ -#include #if MAGISTRATE_KOKKOS_ENABLED +#include #include "test_commons.h" diff --git a/tests/unit/test_kokkos_serialize_integration.cc b/tests/unit/test_kokkos_serialize_integration.cc index 69dd3a4f..17810e5f 100644 --- a/tests/unit/test_kokkos_serialize_integration.cc +++ b/tests/unit/test_kokkos_serialize_integration.cc @@ -41,9 +41,7 @@ //@HEADER */ #if MAGISTRATE_KOKKOS_ENABLED - -#include "test_harness.h" -#include "test_commons.h" +#include #include "test_kokkos_integration_commons.h" @@ -89,16 +87,25 @@ struct KokkosViewOfVIewTest : KokkosBaseTest { }; TEST_F(KokkosViewOfVIewTest, test_view_of_view_init_1) { using namespace checkpoint; - using ViewType = Kokkos::View[3]>; + using Kokkos::view_alloc; + using InnerViewType = Kokkos::View; + using OuterViewType = Kokkos::View; + constexpr int size_outer = 3; // Default construct - ViewType test_data = Kokkos::View[3]>("test"); - test_data(0) = Kokkos::View(); - test_data(1) = Kokkos::View(); - test_data(2) = Kokkos::View(); - - auto ret = serialize(test_data); - deserialize(std::move(ret)); + OuterViewType test_data = OuterViewType( view_alloc("outer", Kokkos::WithoutInitializing), size_outer); + new (&test_data(0)) InnerViewType(view_alloc("inner-0", Kokkos::WithoutInitializing), 4); + new (&test_data(1)) InnerViewType(view_alloc("inner-1", Kokkos::WithoutInitializing), 4); + new (&test_data(2)) InnerViewType(view_alloc("inner-2", Kokkos::WithoutInitializing), 4); + + auto ret = serialize(test_data); + deserialize(std::move(ret)); + + Kokkos::fence(); + for (int i = 0; i < size_outer; i++) { + test_data(i).~InnerViewType(); + } + test_data = OuterViewType(); } TEST_F(KokkosViewOfVIewTest, test_view_of_view_init_2) {