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

@ -16,7 +16,7 @@
#include <Kokkos_Core.hpp>
namespace TestAtomicViews {
namespace {
//-------------------------------------------------
//-----------atomic view api tests-----------------
@ -124,10 +124,10 @@ class TestAtomicViewAPI {
using dView0 = Kokkos::View<T, device>;
using dView1 = Kokkos::View<T*, device>;
using dView2 = Kokkos::View<T * [N1], device>;
using dView3 = Kokkos::View<T * [N1][N2], device>;
using dView4 = Kokkos::View<T * [N1][N2][N3], device>;
using const_dView4 = Kokkos::View<const T * [N1][N2][N3], device>;
using dView2 = Kokkos::View<T* [N1], device>;
using dView3 = Kokkos::View<T* [N1][N2], device>;
using dView4 = Kokkos::View<T* [N1][N2][N3], device>;
using const_dView4 = Kokkos::View<const T* [N1][N2][N3], device>;
using dView4_unmanaged = Kokkos::View<T****, device, Kokkos::MemoryUnmanaged>;
using host = typename dView0::host_mirror_space;
@ -135,12 +135,12 @@ class TestAtomicViewAPI {
using aView1 =
Kokkos::View<T*, device, Kokkos::MemoryTraits<Kokkos::Atomic> >;
using aView2 =
Kokkos::View<T * [N1], device, Kokkos::MemoryTraits<Kokkos::Atomic> >;
Kokkos::View<T* [N1], device, Kokkos::MemoryTraits<Kokkos::Atomic> >;
using aView3 =
Kokkos::View<T * [N1][N2], device, Kokkos::MemoryTraits<Kokkos::Atomic> >;
using aView4 = Kokkos::View<T * [N1][N2][N3], device,
Kokkos::View<T* [N1][N2], device, Kokkos::MemoryTraits<Kokkos::Atomic> >;
using aView4 = Kokkos::View<T* [N1][N2][N3], device,
Kokkos::MemoryTraits<Kokkos::Atomic> >;
using const_aView4 = Kokkos::View<const T * [N1][N2][N3], device,
using const_aView4 = Kokkos::View<const T* [N1][N2][N3], device,
Kokkos::MemoryTraits<Kokkos::Atomic> >;
using aView4_unmanaged =
@ -415,21 +415,13 @@ T PlusEqualAtomicViewCheck(const int64_t input_length) {
}
template <class T, class DeviceType>
bool PlusEqualAtomicViewTest(int64_t input_length) {
void PlusEqualAtomicViewTest(int64_t input_length) {
T res = PlusEqualAtomicView<T, DeviceType>(input_length);
T resSerial = PlusEqualAtomicViewCheck<T>(input_length);
bool passed = true;
if (resSerial != res) {
passed = false;
std::cout << "Loop<" << typeid(T).name()
<< ">( test = PlusEqualAtomicViewTest"
<< " FAILED : " << resSerial << " != " << res << std::endl;
}
return passed;
ASSERT_EQ(res, resSerial)
<< "PlusEqualAtomicViewTest<" << Kokkos::Impl::TypeInfo<T>::name()
<< ">(length=" << input_length << ")";
}
//---------------------------------------------------
@ -512,21 +504,13 @@ T MinusEqualAtomicViewCheck(const int64_t input_length) {
}
template <class T, class DeviceType>
bool MinusEqualAtomicViewTest(int64_t input_length) {
void MinusEqualAtomicViewTest(int64_t input_length) {
T res = MinusEqualAtomicView<T, DeviceType>(input_length);
T resSerial = MinusEqualAtomicViewCheck<T>(input_length);
bool passed = true;
if (resSerial != res) {
passed = false;
std::cout << "Loop<" << typeid(T).name()
<< ">( test = MinusEqualAtomicViewTest"
<< " FAILED : " << resSerial << " != " << res << std::endl;
}
return passed;
ASSERT_EQ(res, resSerial)
<< "MinusEqualAtomicViewTest<" << Kokkos::Impl::TypeInfo<T>::name()
<< ">(length=" << input_length << ")";
}
//---------------------------------------------------
@ -601,22 +585,14 @@ T TimesEqualAtomicViewCheck(const int64_t input_length,
}
template <class T, class DeviceType>
bool TimesEqualAtomicViewTest(const int64_t input_length) {
void TimesEqualAtomicViewTest(const int64_t input_length) {
const int64_t remainder = 23;
T res = TimesEqualAtomicView<T, DeviceType>(input_length, remainder);
T resSerial = TimesEqualAtomicViewCheck<T>(input_length, remainder);
bool passed = true;
if (resSerial != res) {
passed = false;
std::cout << "Loop<" << typeid(T).name()
<< ">( test = TimesEqualAtomicViewTest"
<< " FAILED : " << resSerial << " != " << res << std::endl;
}
return passed;
ASSERT_EQ(res, resSerial)
<< "TimesEqualAtomicViewTest<" << Kokkos::Impl::TypeInfo<T>::name()
<< ">(length=" << input_length << ")";
}
//---------------------------------------------------
@ -690,23 +666,15 @@ T DivEqualAtomicViewCheck(const int64_t input_length, const int64_t remainder) {
}
template <class T, class DeviceType>
bool DivEqualAtomicViewTest(const int64_t input_length) {
void DivEqualAtomicViewTest(const int64_t input_length) {
const int64_t remainder = 23;
T res = DivEqualAtomicView<T, DeviceType>(input_length, remainder);
T resSerial = DivEqualAtomicViewCheck<T>(input_length, remainder);
bool passed = true;
if (resSerial != res) {
passed = false;
std::cout << "Loop<" << typeid(T).name()
<< ">( test = DivEqualAtomicViewTest"
<< " FAILED : " << resSerial << " != " << res << std::endl;
}
return passed;
ASSERT_EQ(res, resSerial)
<< "DivEqualAtomicViewTest<" << Kokkos::Impl::TypeInfo<T>::name()
<< ">(length=" << input_length << ",remainder=" << remainder << ")";
}
//---------------------------------------------------
@ -780,8 +748,8 @@ T ModEqualAtomicViewCheck(const int64_t input_length, const int64_t remainder) {
}
template <class T, class DeviceType>
bool ModEqualAtomicViewTest(const int64_t input_length) {
static_assert(std::is_integral<T>::value,
void ModEqualAtomicViewTest(const int64_t input_length) {
static_assert(std::is_integral_v<T>,
"ModEqualAtomicView Error: Type must be integral type for this "
"unit test");
@ -790,17 +758,9 @@ bool ModEqualAtomicViewTest(const int64_t input_length) {
T res = ModEqualAtomicView<T, DeviceType>(input_length, remainder);
T resSerial = ModEqualAtomicViewCheck<T>(input_length, remainder);
bool passed = true;
if (resSerial != res) {
passed = false;
std::cout << "Loop<" << typeid(T).name()
<< ">( test = ModEqualAtomicViewTest"
<< " FAILED : " << resSerial << " != " << res << std::endl;
}
return passed;
ASSERT_EQ(res, resSerial)
<< "ModEqualAtomicViewTest<" << Kokkos::Impl::TypeInfo<T>::name()
<< ">(length=" << input_length << ",remainder=" << remainder << ")";
}
//---------------------------------------------------
@ -908,8 +868,8 @@ T RSEqualAtomicViewCheck(const int64_t input_length, const int64_t value,
}
template <class T, class DeviceType>
bool RSEqualAtomicViewTest(const int64_t input_length) {
static_assert(std::is_integral<T>::value,
void RSEqualAtomicViewTest(const int64_t input_length) {
static_assert(std::is_integral_v<T>,
"RSEqualAtomicViewTest: Must be integral type for test");
const int64_t remainder = 61042; // prime - 1
@ -917,17 +877,10 @@ bool RSEqualAtomicViewTest(const int64_t input_length) {
T res = RSEqualAtomicView<T, DeviceType>(input_length, value, remainder);
T resSerial = RSEqualAtomicViewCheck<T>(input_length, value, remainder);
bool passed = true;
if (resSerial != res) {
passed = false;
std::cout << "Loop<" << typeid(T).name()
<< ">( test = RSEqualAtomicViewTest"
<< " FAILED : " << resSerial << " != " << res << std::endl;
}
return passed;
ASSERT_EQ(res, resSerial)
<< "RSEqualAtomicViewTest<" << Kokkos::Impl::TypeInfo<T>::name()
<< ">(length=" << input_length << ",value=" << value
<< ",remainder=" << remainder << ")";
}
//---------------------------------------------------
@ -1035,8 +988,8 @@ T LSEqualAtomicViewCheck(const int64_t input_length, const int64_t value,
}
template <class T, class DeviceType>
bool LSEqualAtomicViewTest(const int64_t input_length) {
static_assert(std::is_integral<T>::value,
void LSEqualAtomicViewTest(const int64_t input_length) {
static_assert(std::is_integral_v<T>,
"LSEqualAtomicViewTest: Must be integral type for test");
const int64_t remainder = 61042; // prime - 1
@ -1044,17 +997,10 @@ bool LSEqualAtomicViewTest(const int64_t input_length) {
T res = LSEqualAtomicView<T, DeviceType>(input_length, value, remainder);
T resSerial = LSEqualAtomicViewCheck<T>(input_length, value, remainder);
bool passed = true;
if (resSerial != res) {
passed = false;
std::cout << "Loop<" << typeid(T).name()
<< ">( test = RSEqualAtomicViewTest"
<< " FAILED : " << resSerial << " != " << res << std::endl;
}
return passed;
ASSERT_EQ(res, resSerial)
<< "LSEqualAtomicViewTest<" << Kokkos::Impl::TypeInfo<T>::name()
<< ">(length=" << input_length << ",value=" << value
<< ",remainder=" << remainder << ")";
}
//---------------------------------------------------
@ -1130,24 +1076,16 @@ T AndEqualAtomicViewCheck(const int64_t input_length) {
}
template <class T, class DeviceType>
bool AndEqualAtomicViewTest(int64_t input_length) {
static_assert(std::is_integral<T>::value,
void AndEqualAtomicViewTest(int64_t input_length) {
static_assert(std::is_integral_v<T>,
"AndEqualAtomicViewTest: Must be integral type for test");
T res = AndEqualAtomicView<T, DeviceType>(input_length);
T resSerial = AndEqualAtomicViewCheck<T>(input_length);
bool passed = true;
if (resSerial != res) {
passed = false;
std::cout << "Loop<" << typeid(T).name()
<< ">( test = AndEqualAtomicViewTest"
<< " FAILED : " << resSerial << " != " << res << std::endl;
}
return passed;
ASSERT_EQ(res, resSerial)
<< "AndEqualAtomicViewTest<" << Kokkos::Impl::TypeInfo<T>::name()
<< ">(length=" << input_length << ")";
}
//---------------------------------------------------
@ -1222,24 +1160,16 @@ T OrEqualAtomicViewCheck(const int64_t input_length) {
}
template <class T, class DeviceType>
bool OrEqualAtomicViewTest(int64_t input_length) {
static_assert(std::is_integral<T>::value,
void OrEqualAtomicViewTest(int64_t input_length) {
static_assert(std::is_integral_v<T>,
"OrEqualAtomicViewTest: Must be integral type for test");
T res = OrEqualAtomicView<T, DeviceType>(input_length);
T resSerial = OrEqualAtomicViewCheck<T>(input_length);
bool passed = true;
if (resSerial != res) {
passed = false;
std::cout << "Loop<" << typeid(T).name()
<< ">( test = OrEqualAtomicViewTest"
<< " FAILED : " << resSerial << " != " << res << std::endl;
}
return passed;
ASSERT_EQ(res, resSerial)
<< "OrEqualAtomicViewTest<" << Kokkos::Impl::TypeInfo<T>::name()
<< ">(length=" << input_length << ")";
}
//---------------------------------------------------
@ -1314,119 +1244,42 @@ T XOrEqualAtomicViewCheck(const int64_t input_length) {
}
template <class T, class DeviceType>
bool XOrEqualAtomicViewTest(int64_t input_length) {
static_assert(std::is_integral<T>::value,
void XOrEqualAtomicViewTest(int64_t input_length) {
static_assert(std::is_integral_v<T>,
"XOrEqualAtomicViewTest: Must be integral type for test");
T res = XOrEqualAtomicView<T, DeviceType>(input_length);
T resSerial = XOrEqualAtomicViewCheck<T>(input_length);
bool passed = true;
if (resSerial != res) {
passed = false;
std::cout << "Loop<" << typeid(T).name()
<< ">( test = XOrEqualAtomicViewTest"
<< " FAILED : " << resSerial << " != " << res << std::endl;
}
return passed;
ASSERT_EQ(res, resSerial)
<< "XOrEqualAtomicViewTest<" << Kokkos::Impl::TypeInfo<T>::name()
<< ">(length=" << input_length << ")";
}
// inc/dec?
//---------------------------------------------------
//--------------atomic_test_control------------------
//---------------------------------------------------
template <class T, class DeviceType>
bool AtomicViewsTestIntegralType(const int length, int test) {
static_assert(std::is_integral<T>::value,
"TestAtomicViews Error: Non-integral type passed into "
"IntegralType tests");
switch (test) {
case 1: return PlusEqualAtomicViewTest<T, DeviceType>(length);
case 2: return MinusEqualAtomicViewTest<T, DeviceType>(length);
case 3: return RSEqualAtomicViewTest<T, DeviceType>(length);
case 4: return LSEqualAtomicViewTest<T, DeviceType>(length);
case 5: return ModEqualAtomicViewTest<T, DeviceType>(length);
case 6: return AndEqualAtomicViewTest<T, DeviceType>(length);
case 7: return OrEqualAtomicViewTest<T, DeviceType>(length);
case 8: return XOrEqualAtomicViewTest<T, DeviceType>(length);
}
return 0;
}
template <class T, class DeviceType>
bool AtomicViewsTestNonIntegralType(const int length, int test) {
switch (test) {
case 1: return PlusEqualAtomicViewTest<T, DeviceType>(length);
case 2: return MinusEqualAtomicViewTest<T, DeviceType>(length);
case 3: return TimesEqualAtomicViewTest<T, DeviceType>(length);
case 4: return DivEqualAtomicViewTest<T, DeviceType>(length);
}
return 0;
}
} // namespace TestAtomicViews
namespace Test {
TEST(TEST_CATEGORY, atomic_views_integral) {
const int64_t length = 1000000;
{
// Integral Types.
ASSERT_TRUE(
(TestAtomicViews::AtomicViewsTestIntegralType<int64_t, TEST_EXECSPACE>(
length, 1)));
ASSERT_TRUE(
(TestAtomicViews::AtomicViewsTestIntegralType<int64_t, TEST_EXECSPACE>(
length, 2)));
ASSERT_TRUE(
(TestAtomicViews::AtomicViewsTestIntegralType<int64_t, TEST_EXECSPACE>(
length, 3)));
ASSERT_TRUE(
(TestAtomicViews::AtomicViewsTestIntegralType<int64_t, TEST_EXECSPACE>(
length, 4)));
ASSERT_TRUE(
(TestAtomicViews::AtomicViewsTestIntegralType<int64_t, TEST_EXECSPACE>(
length, 5)));
ASSERT_TRUE(
(TestAtomicViews::AtomicViewsTestIntegralType<int64_t, TEST_EXECSPACE>(
length, 6)));
ASSERT_TRUE(
(TestAtomicViews::AtomicViewsTestIntegralType<int64_t, TEST_EXECSPACE>(
length, 7)));
ASSERT_TRUE(
(TestAtomicViews::AtomicViewsTestIntegralType<int64_t, TEST_EXECSPACE>(
length, 8)));
}
PlusEqualAtomicViewTest<int64_t, TEST_EXECSPACE>(length);
MinusEqualAtomicViewTest<int64_t, TEST_EXECSPACE>(length);
RSEqualAtomicViewTest<int64_t, TEST_EXECSPACE>(length);
LSEqualAtomicViewTest<int64_t, TEST_EXECSPACE>(length);
ModEqualAtomicViewTest<int64_t, TEST_EXECSPACE>(length);
AndEqualAtomicViewTest<int64_t, TEST_EXECSPACE>(length);
OrEqualAtomicViewTest<int64_t, TEST_EXECSPACE>(length);
XOrEqualAtomicViewTest<int64_t, TEST_EXECSPACE>(length);
}
TEST(TEST_CATEGORY, atomic_views_nonintegral) {
const int64_t length = 1000000;
{
// Non-Integral Types.
ASSERT_TRUE((
TestAtomicViews::AtomicViewsTestNonIntegralType<double, TEST_EXECSPACE>(
length, 1)));
ASSERT_TRUE((
TestAtomicViews::AtomicViewsTestNonIntegralType<double, TEST_EXECSPACE>(
length, 2)));
ASSERT_TRUE((
TestAtomicViews::AtomicViewsTestNonIntegralType<double, TEST_EXECSPACE>(
length, 3)));
ASSERT_TRUE((
TestAtomicViews::AtomicViewsTestNonIntegralType<double, TEST_EXECSPACE>(
length, 4)));
}
PlusEqualAtomicViewTest<double, TEST_EXECSPACE>(length);
MinusEqualAtomicViewTest<double, TEST_EXECSPACE>(length);
TimesEqualAtomicViewTest<double, TEST_EXECSPACE>(length);
DivEqualAtomicViewTest<double, TEST_EXECSPACE>(length);
}
TEST(TEST_CATEGORY, atomic_view_api) {
TestAtomicViews::TestAtomicViewAPI<int, TEST_EXECSPACE>();
TestAtomicViewAPI<int, TEST_EXECSPACE>();
}
} // namespace Test
} // namespace