Skip to content

Commit

Permalink
Modify test so that source and destination view are of different type
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenarnst committed Oct 3, 2023
1 parent 39316fa commit 94c5d9a
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions containers/unit_tests/TestDualView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,21 @@ struct test_dualview_copy_construction_and_assignment {
using scalar_type = Scalar;
using execution_space = Device;

template <typename ViewType>
void run_me() {
const unsigned int n = 10;
const unsigned int m = 5;
constexpr unsigned int n = 10;
constexpr unsigned int m = 5;

ViewType a("A", n, m);
using SrcViewType = Kokkos::DualView<Scalar**, Kokkos::LayoutLeft, Device>;
using DstViewType =
Kokkos::DualView<const Scalar * [m], Kokkos::LayoutLeft, Device>;

SrcViewType a("A", n, m);

// Copy construction
ViewType b(a);
DstViewType b(a);

// Copy assignment
ViewType c = a;
DstViewType c = a;

// Check equality (shallow) of the host and device views
ASSERT_EQ(a.view_host(), b.view_host());
Expand All @@ -87,7 +90,7 @@ struct test_dualview_copy_construction_and_assignment {

// We can't test shallow equality of modified_flags because it's protected.
// So we test it indirectly through sync state behavior.
if (!std::decay_t<ViewType>::impl_dualview_is_single_device::value) {
if (!std::decay_t<SrcViewType>::impl_dualview_is_single_device::value) {
a.clear_sync_state();
a.modify_host();
ASSERT_TRUE(a.need_sync_device());
Expand All @@ -97,9 +100,7 @@ struct test_dualview_copy_construction_and_assignment {
}
}

test_dualview_copy_construction_and_assignment() {
run_me<Kokkos::DualView<Scalar**, Kokkos::LayoutLeft, Device> >();
}
test_dualview_copy_construction_and_assignment() { run_me(); }
};

template <typename Scalar, class Device>
Expand Down

0 comments on commit 94c5d9a

Please sign in to comment.