Skip to content

Commit

Permalink
#197: Add explicit test of serializing View<..., CudaSpace>
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilMiller committed Jun 1, 2022
1 parent 3508ee1 commit 18e6b42
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion tests/unit/test_kokkos_serialize_special.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ 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) {
TEST_F(KokkosViewContentsTest, test_logical_device_view_contents) {
// Create an inaccessible View
using LogicalViewType = Kokkos::View<int*, fake_memory_space>;
auto lv = LogicalViewType("lv", 1);
Expand All @@ -144,6 +144,29 @@ TEST_F(KokkosViewContentsTest, test_device_view_contents) {
EXPECT_EQ(mirror(0), 3);
}

#if defined(KOKKOS_ENABLE_CUDA)

TEST_F(KokkosViewContentsTest, test_cuda_device_view_contents) {
// Create an inaccessible View
using LogicalViewType = Kokkos::View<int*, Kokkos::CudaSpace>;
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), std::size_t(1));

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

EXPECT_EQ(mirror(0), 3);
}

#endif

struct KokkosViewExtentTest : virtual testing::Test { };

Expand Down

0 comments on commit 18e6b42

Please sign in to comment.