Skip to content

Commit

Permalink
#197: Add a test of mirrored View serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilMiller committed Jun 1, 2022
1 parent f827a64 commit 04876d4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/unit/test_kokkos_serialize_dynrankview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#if KOKKOS_ENABLED_CHECKPOINT

#include "test_commons.h"
#include "test_harness.h"
#include "test_kokkos_1d_commons.h"
#include "test_kokkos_2d_commons.h"
#include "test_kokkos_3d_commons.h"
Expand Down
29 changes: 29 additions & 0 deletions tests/unit/test_kokkos_serialize_special.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,35 @@ TEST_F(KokkosViewContentsTest, test_view_contents_2d_layout) {
EXPECT_EQ(40, alias(1,1));
}

struct TestSpaceNamer {
static constexpr const char* get_name() { return "TestSpace"; }
};

using fake_memory_space = Kokkos::Experimental::LogicalMemorySpace<
Kokkos::HostSpace, Kokkos::DefaultHostExecutionSpace, TestSpaceNamer,
Kokkos::Experimental::LogicalSpaceSharesAccess::no_shared_access>;

TEST_F(KokkosViewContentsTest, test_device_view_contents) {
// Create an inaccessible View
using LogicalViewType = Kokkos::View<int*, fake_memory_space>;
auto lv = LogicalViewType("lv", 1);

// Initialize a value
Kokkos::deep_copy(lv, 3);

auto ret = checkpoint::serialize<LogicalViewType>(lv);
auto out_view = checkpoint::deserialize<LogicalViewType>(ret->getBuffer());
auto const& out_view_ref = *out_view;

EXPECT_EQ(out_view_ref.extent(0), 1);

auto mirror = create_mirror_view(out_view_ref);
Kokkos::deep_copy(mirror, out_view_ref);

EXPECT_EQ(mirror(0), 3);
}


struct KokkosViewExtentTest : virtual testing::Test { };


Expand Down

0 comments on commit 04876d4

Please sign in to comment.