Update Kokkos library in LAMMPS to v3.2

This commit is contained in:
Stan Moore
2020-08-25 20:21:48 -06:00
parent 450fd12d31
commit 4d90c2b74b
1410 changed files with 19364 additions and 71953 deletions

View File

@ -55,9 +55,9 @@ namespace {
template <class ExecSpace, class ScheduleType>
struct TestTeamPolicy {
typedef typename Kokkos::TeamPolicy<ScheduleType, ExecSpace>::member_type
team_member;
typedef Kokkos::View<int **, ExecSpace> view_type;
using team_member =
typename Kokkos::TeamPolicy<ScheduleType, ExecSpace>::member_type;
using view_type = Kokkos::View<int **, ExecSpace>;
view_type m_flags;
@ -120,9 +120,9 @@ struct TestTeamPolicy {
static void test_for(const size_t league_size) {
TestTeamPolicy functor(league_size);
typedef Kokkos::TeamPolicy<ScheduleType, ExecSpace> policy_type;
typedef Kokkos::TeamPolicy<ScheduleType, ExecSpace, VerifyInitTag>
policy_type_init;
using policy_type = Kokkos::TeamPolicy<ScheduleType, ExecSpace>;
using policy_type_init =
Kokkos::TeamPolicy<ScheduleType, ExecSpace, VerifyInitTag>;
const int team_size = policy_type(league_size, 1)
.team_size_max(functor, Kokkos::ParallelForTag());
@ -139,7 +139,7 @@ struct TestTeamPolicy {
struct ReduceTag {};
typedef int64_t value_type;
using value_type = int64_t;
KOKKOS_INLINE_FUNCTION
void operator()(const team_member &member, value_type &update) const {
@ -156,9 +156,9 @@ struct TestTeamPolicy {
static void test_reduce(const size_t league_size) {
TestTeamPolicy functor(league_size);
typedef Kokkos::TeamPolicy<ScheduleType, ExecSpace> policy_type;
typedef Kokkos::TeamPolicy<ScheduleType, ExecSpace, ReduceTag>
policy_type_reduce;
using policy_type = Kokkos::TeamPolicy<ScheduleType, ExecSpace>;
using policy_type_reduce =
Kokkos::TeamPolicy<ScheduleType, ExecSpace, ReduceTag>;
const int team_size =
policy_type_reduce(league_size, 1)
@ -189,9 +189,9 @@ namespace Test {
template <typename ScalarType, class DeviceType, class ScheduleType>
class ReduceTeamFunctor {
public:
typedef DeviceType execution_space;
typedef Kokkos::TeamPolicy<ScheduleType, execution_space> policy_type;
typedef typename execution_space::size_type size_type;
using execution_space = DeviceType;
using policy_type = Kokkos::TeamPolicy<ScheduleType, execution_space>;
using size_type = typename execution_space::size_type;
struct value_type {
ScalarType value[3];
@ -245,18 +245,18 @@ namespace {
template <typename ScalarType, class DeviceType, class ScheduleType>
class TestReduceTeam {
public:
typedef DeviceType execution_space;
typedef Kokkos::TeamPolicy<ScheduleType, execution_space> policy_type;
typedef typename execution_space::size_type size_type;
using execution_space = DeviceType;
using policy_type = Kokkos::TeamPolicy<ScheduleType, execution_space>;
using size_type = typename execution_space::size_type;
TestReduceTeam(const size_type &nwork) { run_test(nwork); }
void run_test(const size_type &nwork) {
typedef Test::ReduceTeamFunctor<ScalarType, execution_space, ScheduleType>
functor_type;
typedef typename functor_type::value_type value_type;
typedef Kokkos::View<value_type, Kokkos::HostSpace, Kokkos::MemoryUnmanaged>
result_type;
using functor_type =
Test::ReduceTeamFunctor<ScalarType, execution_space, ScheduleType>;
using value_type = typename functor_type::value_type;
using result_type =
Kokkos::View<value_type, Kokkos::HostSpace, Kokkos::MemoryUnmanaged>;
enum { Count = 3 };
enum { Repeat = 100 };
@ -299,9 +299,9 @@ namespace Test {
template <class DeviceType, class ScheduleType>
class ScanTeamFunctor {
public:
typedef DeviceType execution_space;
typedef Kokkos::TeamPolicy<ScheduleType, execution_space> policy_type;
typedef int64_t value_type;
using execution_space = DeviceType;
using policy_type = Kokkos::TeamPolicy<ScheduleType, execution_space>;
using value_type = int64_t;
Kokkos::View<value_type, execution_space> accum;
Kokkos::View<value_type, execution_space> total;
@ -318,7 +318,7 @@ class ScanTeamFunctor {
}
struct JoinMax {
typedef int64_t value_type;
using value_type = int64_t;
KOKKOS_INLINE_FUNCTION
void join(value_type volatile &dst,
@ -341,11 +341,14 @@ class ScanTeamFunctor {
if (m != ind.league_rank() + (ind.team_size() - 1)) {
printf(
"ScanTeamFunctor[%d.%d of %d.%d] reduce_max_answer(%ld) != "
"reduce_max(%ld)\n",
ind.league_rank(), ind.team_rank(), ind.league_size(),
ind.team_size(), (int64_t)(ind.league_rank() + (ind.team_size() - 1)),
m);
"ScanTeamFunctor[%i.%i of %i.%i] reduce_max_answer(%li) != "
"reduce_max(%li)\n",
static_cast<int>(ind.league_rank()),
static_cast<int>(ind.team_rank()),
static_cast<int>(ind.league_size()),
static_cast<int>(ind.team_size()),
static_cast<long>(ind.league_rank() + (ind.team_size() - 1)),
static_cast<long>(m));
}
// Scan:
@ -360,10 +363,13 @@ class ScanTeamFunctor {
if (answer != result || answer != result2) {
printf(
"ScanTeamFunctor[%d.%d of %d.%d] answer(%ld) != scan_first(%ld) or "
"scan_second(%ld)\n",
ind.league_rank(), ind.team_rank(), ind.league_size(),
ind.team_size(), answer, result, result2);
"ScanTeamFunctor[%i.%i of %i.%i] answer(%li) != scan_first(%li) or "
"scan_second(%li)\n",
static_cast<int>(ind.league_rank()),
static_cast<int>(ind.team_rank()),
static_cast<int>(ind.league_size()),
static_cast<int>(ind.team_size()), static_cast<long>(answer),
static_cast<long>(result), static_cast<long>(result2));
error = 1;
}
@ -377,16 +383,16 @@ class ScanTeamFunctor {
template <class DeviceType, class ScheduleType>
class TestScanTeam {
public:
typedef DeviceType execution_space;
typedef int64_t value_type;
typedef Kokkos::TeamPolicy<ScheduleType, execution_space> policy_type;
typedef Test::ScanTeamFunctor<DeviceType, ScheduleType> functor_type;
using execution_space = DeviceType;
using value_type = int64_t;
using policy_type = Kokkos::TeamPolicy<ScheduleType, execution_space>;
using functor_type = Test::ScanTeamFunctor<DeviceType, ScheduleType>;
TestScanTeam(const size_t nteam) { run_test(nteam); }
void run_test(const size_t nteam) {
typedef Kokkos::View<int64_t, Kokkos::HostSpace, Kokkos::MemoryUnmanaged>
result_type;
using result_type =
Kokkos::View<int64_t, Kokkos::HostSpace, Kokkos::MemoryUnmanaged>;
const unsigned REPEAT = 100000;
unsigned Repeat;
@ -431,17 +437,17 @@ namespace Test {
template <class ExecSpace, class ScheduleType>
struct SharedTeamFunctor {
typedef ExecSpace execution_space;
typedef int value_type;
typedef Kokkos::TeamPolicy<ScheduleType, execution_space> policy_type;
using execution_space = ExecSpace;
using value_type = int;
using policy_type = Kokkos::TeamPolicy<ScheduleType, execution_space>;
enum { SHARED_COUNT = 1000 };
typedef typename ExecSpace::scratch_memory_space shmem_space;
using shmem_space = typename ExecSpace::scratch_memory_space;
// TBD: MemoryUnmanaged should be the default for shared memory space.
typedef Kokkos::View<int *, shmem_space, Kokkos::MemoryUnmanaged>
shared_int_array_type;
using shared_int_array_type =
Kokkos::View<int *, shmem_space, Kokkos::MemoryUnmanaged>;
// Tell how much shared memory will be required by this functor.
inline unsigned team_shmem_size(int /*team_size*/) const {
@ -458,10 +464,12 @@ struct SharedTeamFunctor {
if ((shared_A.data() == nullptr && SHARED_COUNT > 0) ||
(shared_B.data() == nullptr && SHARED_COUNT > 0)) {
printf(
"member( %d/%d , %d/%d ) Failed to allocate shared memory of size "
"member( %i/%i , %i/%i ) Failed to allocate shared memory of size "
"%lu\n",
ind.league_rank(), ind.league_size(), ind.team_rank(),
ind.team_size(), static_cast<uint64_t>(SHARED_COUNT));
static_cast<int>(ind.league_rank()),
static_cast<int>(ind.league_size()),
static_cast<int>(ind.team_rank()), static_cast<int>(ind.team_size()),
static_cast<unsigned long>(SHARED_COUNT));
++update; // Failure to allocate is an error.
} else {
@ -496,10 +504,10 @@ struct TestSharedTeam {
TestSharedTeam() { run(); }
void run() {
typedef Test::SharedTeamFunctor<ExecSpace, ScheduleType> Functor;
typedef Kokkos::View<typename Functor::value_type, Kokkos::HostSpace,
Kokkos::MemoryUnmanaged>
result_type;
using Functor = Test::SharedTeamFunctor<ExecSpace, ScheduleType>;
using result_type =
Kokkos::View<typename Functor::value_type, Kokkos::HostSpace,
Kokkos::MemoryUnmanaged>;
const size_t team_size =
Kokkos::TeamPolicy<ScheduleType, ExecSpace>(8192, 1).team_size_max(
@ -527,18 +535,15 @@ struct TestLambdaSharedTeam {
TestLambdaSharedTeam() { run(); }
void run() {
typedef Test::SharedTeamFunctor<ExecSpace, ScheduleType> Functor;
// typedef Kokkos::View< typename Functor::value_type, Kokkos::HostSpace,
// Kokkos::MemoryUnmanaged > result_type;
typedef Kokkos::View<typename Functor::value_type, MemorySpace,
Kokkos::MemoryUnmanaged>
result_type;
using Functor = Test::SharedTeamFunctor<ExecSpace, ScheduleType>;
using result_type = Kokkos::View<typename Functor::value_type, MemorySpace,
Kokkos::MemoryUnmanaged>;
typedef typename ExecSpace::scratch_memory_space shmem_space;
using shmem_space = typename ExecSpace::scratch_memory_space;
// TBD: MemoryUnmanaged should be the default for shared memory space.
typedef Kokkos::View<int *, shmem_space, Kokkos::MemoryUnmanaged>
shared_int_array_type;
using shared_int_array_type =
Kokkos::View<int *, shmem_space, Kokkos::MemoryUnmanaged>;
const int SHARED_COUNT = 1000;
int team_size = 1;
@ -566,7 +571,7 @@ struct TestLambdaSharedTeam {
if ((shared_A.data() == nullptr && SHARED_COUNT > 0) ||
(shared_B.data() == nullptr && SHARED_COUNT > 0)) {
printf("Failed to allocate shared memory of size %lu\n",
static_cast<uint64_t>(SHARED_COUNT));
static_cast<unsigned long>(SHARED_COUNT));
++update; // Failure to allocate is an error.
} else {
@ -606,18 +611,18 @@ namespace Test {
template <class ExecSpace, class ScheduleType>
struct ScratchTeamFunctor {
typedef ExecSpace execution_space;
typedef int value_type;
typedef Kokkos::TeamPolicy<ScheduleType, execution_space> policy_type;
using execution_space = ExecSpace;
using value_type = int;
using policy_type = Kokkos::TeamPolicy<ScheduleType, execution_space>;
enum { SHARED_TEAM_COUNT = 100 };
enum { SHARED_THREAD_COUNT = 10 };
typedef typename ExecSpace::scratch_memory_space shmem_space;
using shmem_space = typename ExecSpace::scratch_memory_space;
// TBD: MemoryUnmanaged should be the default for shared memory space.
typedef Kokkos::View<size_t *, shmem_space, Kokkos::MemoryUnmanaged>
shared_int_array_type;
using shared_int_array_type =
Kokkos::View<size_t *, shmem_space, Kokkos::MemoryUnmanaged>;
KOKKOS_INLINE_FUNCTION
void operator()(const typename policy_type::member_type &ind,
@ -633,7 +638,7 @@ struct ScratchTeamFunctor {
(scratch_A.data() == nullptr && SHARED_TEAM_COUNT > 0) ||
(scratch_B.data() == nullptr && SHARED_THREAD_COUNT > 0)) {
printf("Failed to allocate shared memory of size %lu\n",
static_cast<uint64_t>(SHARED_TEAM_COUNT));
static_cast<unsigned long>(SHARED_TEAM_COUNT));
++update; // Failure to allocate is an error.
} else {
@ -684,11 +689,11 @@ struct TestScratchTeam {
TestScratchTeam() { run(); }
void run() {
typedef Test::ScratchTeamFunctor<ExecSpace, ScheduleType> Functor;
typedef Kokkos::View<typename Functor::value_type, Kokkos::HostSpace,
Kokkos::MemoryUnmanaged>
result_type;
typedef Kokkos::TeamPolicy<ScheduleType, ExecSpace> p_type;
using Functor = Test::ScratchTeamFunctor<ExecSpace, ScheduleType>;
using result_type =
Kokkos::View<typename Functor::value_type, Kokkos::HostSpace,
Kokkos::MemoryUnmanaged>;
using p_type = Kokkos::TeamPolicy<ScheduleType, ExecSpace>;
typename Functor::value_type error_count = 0;
@ -842,8 +847,8 @@ struct TagFor {};
template <class ExecSpace, class ScheduleType>
struct ClassNoShmemSizeFunction {
typedef typename Kokkos::TeamPolicy<ExecSpace, ScheduleType>::member_type
member_type;
using member_type =
typename Kokkos::TeamPolicy<ExecSpace, ScheduleType>::member_type;
Kokkos::View<int, ExecSpace, Kokkos::MemoryTraits<Kokkos::Atomic> > errors;
@ -924,8 +929,8 @@ struct ClassNoShmemSizeFunction {
template <class ExecSpace, class ScheduleType>
struct ClassWithShmemSizeFunction {
typedef typename Kokkos::TeamPolicy<ExecSpace, ScheduleType>::member_type
member_type;
using member_type =
typename Kokkos::TeamPolicy<ExecSpace, ScheduleType>::member_type;
Kokkos::View<int, ExecSpace, Kokkos::MemoryTraits<Kokkos::Atomic> > errors;
@ -1097,7 +1102,7 @@ struct TestShmemSize {
TestShmemSize() { run(); }
void run() {
typedef Kokkos::View<int64_t ***, ExecSpace> view_type;
using view_type = Kokkos::View<int64_t ***, ExecSpace>;
size_t d1 = 5;
size_t d2 = 6;
@ -1196,9 +1201,9 @@ struct TestTeamBroadcast<
const value_type off) {
TestTeamBroadcast functor(league_size, off);
typedef Kokkos::TeamPolicy<ScheduleType, ExecSpace> policy_type;
typedef Kokkos::TeamPolicy<ScheduleType, ExecSpace, BroadcastTag>
policy_type_f;
using policy_type = Kokkos::TeamPolicy<ScheduleType, ExecSpace>;
using policy_type_f =
Kokkos::TeamPolicy<ScheduleType, ExecSpace, BroadcastTag>;
const int team_size =
policy_type_f(league_size, 1)
@ -1341,9 +1346,9 @@ struct TestTeamBroadcast<
const value_type off) {
TestTeamBroadcast functor(league_size, off);
typedef Kokkos::TeamPolicy<ScheduleType, ExecSpace> policy_type;
typedef Kokkos::TeamPolicy<ScheduleType, ExecSpace, BroadcastTag>
policy_type_f;
using policy_type = Kokkos::TeamPolicy<ScheduleType, ExecSpace>;
using policy_type_f =
Kokkos::TeamPolicy<ScheduleType, ExecSpace, BroadcastTag>;
const int team_size =
policy_type_f(league_size, 1)
@ -1397,10 +1402,10 @@ struct TestScratchAlignment {
test(true);
test(false);
}
typedef Kokkos::View<TestScalar *, typename ExecSpace::scratch_memory_space>
ScratchView;
typedef Kokkos::View<int *, typename ExecSpace::scratch_memory_space>
ScratchViewInt;
using ScratchView =
Kokkos::View<TestScalar *, typename ExecSpace::scratch_memory_space>;
using ScratchViewInt =
Kokkos::View<int *, typename ExecSpace::scratch_memory_space>;
void test(bool allocate_small) {
int shmem_size = ScratchView::shmem_size(11);
if (allocate_small) shmem_size += ScratchViewInt::shmem_size(1);