Update Kokkos library in LAMMPS to v4.4.0
This commit is contained in:
@ -837,18 +837,15 @@ struct TestViewMirror {
|
||||
view_const_cast(v));
|
||||
}
|
||||
|
||||
template <class MemoryTraits, class Space>
|
||||
template <class View>
|
||||
struct CopyUnInit {
|
||||
using mirror_view_type = typename Kokkos::Impl::MirrorViewType<
|
||||
Space, double *, Layout, Kokkos::HostSpace, MemoryTraits>::view_type;
|
||||
|
||||
mirror_view_type a_d;
|
||||
View a_d;
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
CopyUnInit(mirror_view_type &a_d_) : a_d(a_d_) {}
|
||||
explicit CopyUnInit(View const &a_d_) : a_d(a_d_) {}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(const typename Space::size_type i) const {
|
||||
void operator()(const typename View::size_type i) const {
|
||||
a_d(i) = (double)(10 - i);
|
||||
}
|
||||
};
|
||||
@ -875,7 +872,8 @@ struct TestViewMirror {
|
||||
|
||||
Kokkos::parallel_for(
|
||||
Kokkos::RangePolicy<typename DeviceType::execution_space>(0, int(10)),
|
||||
CopyUnInit<MemoryTraits, DeviceType>(a_d));
|
||||
// decltype required for Intel classics, that doesn't recognize the CTAD
|
||||
CopyUnInit<decltype(a_d)>(a_d));
|
||||
|
||||
Kokkos::deep_copy(a_h, a_d);
|
||||
|
||||
@ -1339,6 +1337,40 @@ class TestViewAPI {
|
||||
ASSERT_EQ(dz.data(), nullptr);
|
||||
}
|
||||
|
||||
struct test_refcount_poison_copy_functor {
|
||||
using view_type = Kokkos::View<double *>;
|
||||
explicit test_refcount_poison_copy_functor(view_type v) : view(v) {}
|
||||
|
||||
test_refcount_poison_copy_functor(
|
||||
const test_refcount_poison_copy_functor &other)
|
||||
: view(other.view) {
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION void operator()(int) const {}
|
||||
|
||||
view_type view;
|
||||
};
|
||||
|
||||
static void run_test_refcount_exception() {
|
||||
using view_type = typename test_refcount_poison_copy_functor::view_type;
|
||||
view_type original("original", N0);
|
||||
ASSERT_EQ(original.use_count(), 1);
|
||||
|
||||
// test_refcount_poison_copy_functor throws during copy construction
|
||||
try {
|
||||
Kokkos::parallel_for(
|
||||
Kokkos::RangePolicy<typename DeviceType::execution_space>(0, N0),
|
||||
test_refcount_poison_copy_functor(original));
|
||||
} catch (const std::bad_alloc &) {
|
||||
}
|
||||
|
||||
// Ensure refcounting is enabled, we should increment here
|
||||
auto copy = original;
|
||||
ASSERT_EQ(original.use_count(), 2);
|
||||
ASSERT_EQ(copy.use_count(), 2);
|
||||
}
|
||||
|
||||
static void run_test_deep_copy_empty() {
|
||||
// Check Deep Copy of LayoutLeft to LayoutRight
|
||||
{
|
||||
@ -1539,56 +1571,6 @@ class TestViewAPI {
|
||||
typename multivector_type::const_type cmvX(cmv);
|
||||
typename const_multivector_type::const_type ccmvX(cmv);
|
||||
}
|
||||
|
||||
static void run_test_error() {
|
||||
#ifdef KOKKOS_ENABLE_OPENMPTARGET
|
||||
if (std::is_same<typename dView1::memory_space,
|
||||
Kokkos::Experimental::OpenMPTargetSpace>::value)
|
||||
return;
|
||||
#endif
|
||||
// FIXME_MSVC_WITH_CUDA
|
||||
// This test doesn't behave as expected on Windows with CUDA
|
||||
#if defined(_WIN32) && defined(KOKKOS_ENABLE_CUDA)
|
||||
if (std::is_same<typename dView1::memory_space,
|
||||
Kokkos::CudaUVMSpace>::value)
|
||||
return;
|
||||
#endif
|
||||
bool did_throw = false;
|
||||
auto alloc_size = std::numeric_limits<size_t>::max() - 42;
|
||||
try {
|
||||
auto should_always_fail = dView1("hello_world_failure", alloc_size);
|
||||
} catch (std::runtime_error const &error) {
|
||||
// TODO once we remove the conversion to std::runtime_error, catch the
|
||||
// appropriate Kokkos error here
|
||||
std::string msg = error.what();
|
||||
ASSERT_PRED_FORMAT2(::testing::IsSubstring, "hello_world_failure", msg);
|
||||
ASSERT_PRED_FORMAT2(::testing::IsSubstring,
|
||||
typename device::memory_space{}.name(), msg);
|
||||
// Can't figure out how to make assertions either/or, so we'll just use
|
||||
// an if statement here for now. Test failure message will be a bit
|
||||
// misleading, but developers should figure out what's going on pretty
|
||||
// quickly.
|
||||
if (msg.find("is not a valid size") != std::string::npos) {
|
||||
ASSERT_PRED_FORMAT2(::testing::IsSubstring, "is not a valid size", msg);
|
||||
} else
|
||||
#ifdef KOKKOS_ENABLE_SYCL
|
||||
if (msg.find("insufficient memory") != std::string::npos)
|
||||
#endif
|
||||
{
|
||||
ASSERT_PRED_FORMAT2(::testing::IsSubstring, "insufficient memory", msg);
|
||||
}
|
||||
// SYCL cannot tell the reason why a memory allocation failed
|
||||
#ifdef KOKKOS_ENABLE_SYCL
|
||||
else {
|
||||
// Otherwise, there has to be some sort of "unknown error" error
|
||||
ASSERT_PRED_FORMAT2(::testing::IsSubstring,
|
||||
"because of an unknown error.", msg);
|
||||
}
|
||||
#endif
|
||||
did_throw = true;
|
||||
}
|
||||
ASSERT_TRUE(did_throw);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Test
|
||||
|
||||
Reference in New Issue
Block a user