Update Kokkos library in LAMMPS to v4.5.0

This commit is contained in:
Stan Moore
2024-12-13 09:23:03 -07:00
parent a78aee5731
commit 7f68aeb6d5
617 changed files with 21499 additions and 17255 deletions

View File

@ -71,7 +71,7 @@ struct test_dualview_copy_construction_and_assignment {
using SrcViewType = Kokkos::DualView<Scalar**, Kokkos::LayoutLeft, Device>;
using DstViewType =
Kokkos::DualView<const Scalar * [m], Kokkos::LayoutLeft, Device>;
Kokkos::DualView<const Scalar* [m], Kokkos::LayoutLeft, Device>;
SrcViewType a("A", n, m);
@ -520,58 +520,26 @@ namespace {
* that we keep the semantics of UVM DualViews intact.
*/
// modify if we have other UVM enabled backends
#if defined(KOKKOS_ENABLE_CUDA) || defined(KOKKOS_ENABLE_SYCL) || \
defined(KOKKOS_ENABLE_HIP) // OR other UVM builds
#define UVM_ENABLED_BUILD
#endif
#ifdef UVM_ENABLED_BUILD
template <typename ExecSpace>
struct UVMSpaceFor;
#endif
#ifdef KOKKOS_ENABLE_CUDA // specific to CUDA
template <>
struct UVMSpaceFor<Kokkos::Cuda> {
using type = Kokkos::CudaUVMSpace;
};
#endif
#ifdef KOKKOS_ENABLE_SYCL // specific to SYCL
template <>
struct UVMSpaceFor<Kokkos::Experimental::SYCL> {
using type = Kokkos::Experimental::SYCLSharedUSMSpace;
};
#endif
#ifdef KOKKOS_ENABLE_HIP // specific to HIP
template <>
struct UVMSpaceFor<Kokkos::HIP> {
using type = Kokkos::HIPManagedSpace;
};
#endif
#ifdef UVM_ENABLED_BUILD
template <>
struct UVMSpaceFor<Kokkos::DefaultHostExecutionSpace> {
using type = typename UVMSpaceFor<Kokkos::DefaultExecutionSpace>::type;
};
#ifdef KOKKOS_HAS_SHARED_SPACE
template <typename ExecutionSpace>
using TestSharedSpace = Kokkos::SharedSpace;
#else
template <typename ExecSpace>
struct UVMSpaceFor {
using type = typename ExecSpace::memory_space;
};
template <typename ExecutionSpace>
using TestSharedSpace = typename ExecutionSpace::memory_space;
#endif
using ExecSpace = Kokkos::DefaultExecutionSpace;
using MemSpace = typename UVMSpaceFor<Kokkos::DefaultExecutionSpace>::type;
using MemSpace = TestSharedSpace<Kokkos::DefaultExecutionSpace>;
using DeviceType = Kokkos::Device<ExecSpace, MemSpace>;
using DualViewType = Kokkos::DualView<double*, Kokkos::LayoutLeft, DeviceType>;
using d_device = DeviceType;
using h_device = Kokkos::Device<
Kokkos::DefaultHostExecutionSpace,
typename UVMSpaceFor<Kokkos::DefaultHostExecutionSpace>::type>;
using ConstDualViewType =
Kokkos::DualView<const double*, Kokkos::LayoutLeft, DeviceType>;
using d_device = DeviceType;
using h_device =
Kokkos::Device<Kokkos::DefaultHostExecutionSpace,
TestSharedSpace<Kokkos::DefaultHostExecutionSpace>>;
TEST(TEST_CATEGORY, dualview_device_correct_kokkos_device) {
DualViewType dv("myView", 100);
@ -635,14 +603,69 @@ TEST(TEST_CATEGORY,
dualview_template_views_return_correct_executionspace_views) {
DualViewType dv("myView", 100);
dv.clear_sync_state();
using hvt = decltype(dv.view<typename Kokkos::DefaultHostExecutionSpace>());
using dvt = decltype(dv.view<typename Kokkos::DefaultExecutionSpace>());
using hvt = decltype(dv.view<Kokkos::DefaultHostExecutionSpace>());
using dvt = decltype(dv.view<Kokkos::DefaultExecutionSpace>());
ASSERT_STREQ(Kokkos::DefaultExecutionSpace::name(),
dvt::device_type::execution_space::name());
ASSERT_STREQ(Kokkos::DefaultHostExecutionSpace::name(),
hvt::device_type::execution_space::name());
}
TEST(TEST_CATEGORY,
dualview_template_views_return_correct_views_from_const_dual_view) {
DualViewType dv("myView", 100);
ConstDualViewType const_dv = dv;
dv.clear_sync_state();
ASSERT_EQ(dv.view<Kokkos::DefaultHostExecutionSpace>(),
const_dv.view<Kokkos::DefaultHostExecutionSpace>());
ASSERT_EQ(dv.view<Kokkos::DefaultExecutionSpace>(),
const_dv.view<Kokkos::DefaultExecutionSpace>());
}
// User-defined types with a View data member, only host-constructible
template <class V>
class S {
V v_;
public:
template <class... Extents>
S(std::string label, Extents... extents) : v_(std::move(label), extents...) {}
S() : v_("v", 10) {}
};
template <typename V>
auto initialize_view_of_views() {
Kokkos::DualView<V*, TEST_EXECSPACE> dv_v(
Kokkos::view_alloc("myView", Kokkos::SequentialHostInit), 3u);
V v("v", 2);
V w("w", 2);
dv_v.h_view(0) = v;
dv_v.h_view(1) = w;
dv_v.modify_host();
dv_v.sync_device();
return dv_v;
}
TEST(TEST_CATEGORY, dualview_sequential_host_init) {
auto dv_v = initialize_view_of_views<Kokkos::View<double*, TEST_EXECSPACE>>();
dv_v.resize(Kokkos::view_alloc(Kokkos::SequentialHostInit), 2u);
ASSERT_EQ(dv_v.d_view.size(), 2u);
ASSERT_EQ(dv_v.h_view.size(), 2u);
initialize_view_of_views<S<Kokkos::View<double*, TEST_EXECSPACE>>>();
Kokkos::DualView<double*> dv(
Kokkos::view_alloc("myView", Kokkos::SequentialHostInit), 1u);
dv.resize(Kokkos::view_alloc(Kokkos::SequentialHostInit), 2u);
ASSERT_EQ(dv.d_view.size(), 2u);
ASSERT_EQ(dv.h_view.size(), 2u);
dv.realloc(Kokkos::view_alloc(Kokkos::SequentialHostInit), 3u);
ASSERT_EQ(dv.d_view.size(), 3u);
ASSERT_EQ(dv.h_view.size(), 3u);
}
} // anonymous namespace
} // namespace Test