Update Kokkos library in LAMMPS to v3.1
This commit is contained in:
@ -54,9 +54,10 @@ template <class ExecSpace, class ScheduleType>
|
||||
struct TestRange {
|
||||
typedef int value_type; ///< typedef required for the parallel_reduce
|
||||
|
||||
typedef Kokkos::View<int *, ExecSpace> view_type;
|
||||
typedef Kokkos::View<value_type *, ExecSpace> view_type;
|
||||
|
||||
view_type m_flags;
|
||||
view_type result_view;
|
||||
|
||||
struct VerifyInitTag {};
|
||||
struct ResetTag {};
|
||||
@ -65,9 +66,19 @@ struct TestRange {
|
||||
struct VerifyOffsetTag {};
|
||||
|
||||
int N;
|
||||
#ifndef KOKKOS_WORKAROUND_OPENMPTARGET_GCC
|
||||
static const int offset = 13;
|
||||
#else
|
||||
int offset;
|
||||
#endif
|
||||
TestRange(const size_t N_)
|
||||
: m_flags(Kokkos::ViewAllocateWithoutInitializing("flags"), N_), N(N_) {}
|
||||
: m_flags(Kokkos::ViewAllocateWithoutInitializing("flags"), N_),
|
||||
result_view(Kokkos::ViewAllocateWithoutInitializing("results"), N_),
|
||||
N(N_) {
|
||||
#ifdef KOKKOS_WORKAROUND_OPENMPTARGET_GCC
|
||||
offset = 13;
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_for() {
|
||||
typename view_type::HostMirror host_flags =
|
||||
@ -185,7 +196,7 @@ struct TestRange {
|
||||
//----------------------------------------
|
||||
|
||||
void test_reduce() {
|
||||
int total = 0;
|
||||
value_type total = 0;
|
||||
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<ExecSpace, ScheduleType>(0, N),
|
||||
*this);
|
||||
@ -220,15 +231,31 @@ struct TestRange {
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<ExecSpace, ScheduleType>(0, N),
|
||||
*this);
|
||||
|
||||
auto check_scan_results = [&]() {
|
||||
auto const host_mirror =
|
||||
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), result_view);
|
||||
for (int i = 0; i < N; ++i) {
|
||||
if (((i + 1) * i) / 2 != host_mirror(i)) {
|
||||
std::cout << "Error at " << i << std::endl;
|
||||
EXPECT_EQ(size_t(((i + 1) * i) / 2), size_t(host_mirror(i)));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Kokkos::parallel_scan(
|
||||
"TestKernelScan",
|
||||
Kokkos::RangePolicy<ExecSpace, ScheduleType, OffsetTag>(0, N), *this);
|
||||
|
||||
int total = 0;
|
||||
check_scan_results();
|
||||
|
||||
value_type total = 0;
|
||||
Kokkos::parallel_scan(
|
||||
"TestKernelScanWithTotal",
|
||||
Kokkos::RangePolicy<ExecSpace, ScheduleType, OffsetTag>(0, N), *this,
|
||||
total);
|
||||
|
||||
check_scan_results();
|
||||
|
||||
ASSERT_EQ(size_t((N - 1) * (N) / 2), size_t(total)); // sum( 0 .. N-1 )
|
||||
}
|
||||
|
||||
@ -239,16 +266,16 @@ struct TestRange {
|
||||
|
||||
if (final) {
|
||||
if (update != (i * (i + 1)) / 2) {
|
||||
printf("TestRange::test_scan error %d : %d != %d\n", i,
|
||||
(i * (i + 1)) / 2, m_flags(i));
|
||||
printf("TestRange::test_scan error (%d,%d) : %d != %d\n", i, m_flags(i),
|
||||
(i * (i + 1)) / 2, update);
|
||||
}
|
||||
result_view(i) = update;
|
||||
}
|
||||
}
|
||||
|
||||
void test_dynamic_policy() {
|
||||
auto const N_no_implicit_capture = N;
|
||||
#if defined(KOKKOS_ENABLE_CXX11_DISPATCH_LAMBDA)
|
||||
#if !defined(KOKKOS_ENABLE_CUDA) || (8000 <= CUDA_VERSION)
|
||||
auto const N_no_implicit_capture = N;
|
||||
typedef Kokkos::RangePolicy<ExecSpace, Kokkos::Schedule<Kokkos::Dynamic> >
|
||||
policy_t;
|
||||
|
||||
@ -273,7 +300,7 @@ struct TestRange {
|
||||
int error = 0;
|
||||
Kokkos::parallel_reduce(
|
||||
Kokkos::RangePolicy<ExecSpace>(0, N),
|
||||
KOKKOS_LAMBDA(const int &i, int &lsum) {
|
||||
KOKKOS_LAMBDA(const int &i, value_type &lsum) {
|
||||
lsum += (a(i) != (i < N_no_implicit_capture / 2 ? 1 : 10000));
|
||||
},
|
||||
error);
|
||||
@ -300,10 +327,10 @@ struct TestRange {
|
||||
count("Count", ExecSpace::concurrency());
|
||||
Kokkos::View<int *, ExecSpace> a("A", N);
|
||||
|
||||
int sum = 0;
|
||||
value_type sum = 0;
|
||||
Kokkos::parallel_reduce(
|
||||
policy_t(0, N),
|
||||
KOKKOS_LAMBDA(const int &i, int &lsum) {
|
||||
KOKKOS_LAMBDA(const int &i, value_type &lsum) {
|
||||
for (int k = 0; k < (i < N_no_implicit_capture / 2 ? 1 : 10000);
|
||||
k++) {
|
||||
a(i)++;
|
||||
@ -321,7 +348,7 @@ struct TestRange {
|
||||
int error = 0;
|
||||
Kokkos::parallel_reduce(
|
||||
Kokkos::RangePolicy<ExecSpace>(0, N),
|
||||
KOKKOS_LAMBDA(const int &i, int &lsum) {
|
||||
KOKKOS_LAMBDA(const int &i, value_type &lsum) {
|
||||
lsum += (a(i) != (i < N_no_implicit_capture / 2 ? 1 : 10000));
|
||||
},
|
||||
error);
|
||||
@ -342,7 +369,6 @@ struct TestRange {
|
||||
//}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
};
|
||||
@ -417,7 +443,7 @@ TEST(TEST_CATEGORY, range_scan) {
|
||||
TestRange<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> > f(0);
|
||||
f.test_scan();
|
||||
}
|
||||
#if !defined(KOKKOS_ENABLE_CUDA) && !defined(KOKKOS_ENABLE_ROCM)
|
||||
#if !defined(KOKKOS_ENABLE_CUDA) && !defined(KOKKOS_ENABLE_HIP)
|
||||
{
|
||||
TestRange<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> > f(0);
|
||||
f.test_dynamic_policy();
|
||||
@ -432,7 +458,7 @@ TEST(TEST_CATEGORY, range_scan) {
|
||||
TestRange<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> > f(3);
|
||||
f.test_scan();
|
||||
}
|
||||
#if !defined(KOKKOS_ENABLE_CUDA) && !defined(KOKKOS_ENABLE_ROCM)
|
||||
#if !defined(KOKKOS_ENABLE_CUDA) && !defined(KOKKOS_ENABLE_HIP)
|
||||
{
|
||||
TestRange<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> > f(3);
|
||||
f.test_dynamic_policy();
|
||||
@ -447,7 +473,7 @@ TEST(TEST_CATEGORY, range_scan) {
|
||||
TestRange<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> > f(1001);
|
||||
f.test_scan();
|
||||
}
|
||||
#if !defined(KOKKOS_ENABLE_CUDA) && !defined(KOKKOS_ENABLE_ROCM)
|
||||
#if !defined(KOKKOS_ENABLE_CUDA) && !defined(KOKKOS_ENABLE_HIP)
|
||||
{
|
||||
TestRange<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> > f(1001);
|
||||
f.test_dynamic_policy();
|
||||
|
||||
Reference in New Issue
Block a user