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

@ -67,10 +67,10 @@
// instance method.
struct hello_world {
// If a functor has an "execution_space" (or "execution_space", for
// backwards compatibility) public typedef, parallel_* will only run
// backwards compatibility) public alias, parallel_* will only run
// the functor in that execution space. That's a good way to mark a
// functor as specific to an execution space. If the functor lacks
// this typedef, parallel_for will run it in the default execution
// this alias, parallel_for will run it in the default execution
// space, unless you tell it otherwise (that's an advanced topic;
// see "execution policies").
@ -107,7 +107,7 @@ int main(int argc, char* argv[]) {
// Run the above functor on the default Kokkos execution space in
// parallel, with a parallel for loop count of 15.
//
// The Kokkos::DefaultExecutionSpace typedef gives the default
// The Kokkos::DefaultExecutionSpace alias gives the default
// execution space. Depending on how Kokkos was configured, this
// could be OpenMP, Threads, Cuda, Serial, or even some other
// execution space.

View File

@ -63,8 +63,8 @@
// it defaults to binary operator+ (adding numbers together).
struct squaresum {
// Specify the type of the reduction value with a "value_type"
// typedef. In this case, the reduction value has type int.
typedef int value_type;
// alias. In this case, the reduction value has type int.
using value_type = int;
// The reduction functor's operator() looks a little different than
// the parallel_for functor's operator(). For the reduction, we

View File

@ -67,7 +67,7 @@
//
// The first dimension of the View is the dimension over which it is
// efficient for Kokkos to parallelize.
typedef Kokkos::View<double * [3]> view_type;
using view_type = Kokkos::View<double * [3]>;
// parallel_for functor that fills the View given to its constructor.
// The View must already have been allocated.
@ -102,8 +102,8 @@ struct ReduceFunctor {
ReduceFunctor(view_type a_) : a(a_) {}
// If you write a functor to do a reduction, you must specify the
// type of the reduction result via a public 'value_type' typedef.
typedef double value_type;
// type of the reduction result via a public 'value_type' alias.
using value_type = double;
KOKKOS_INLINE_FUNCTION
void operator()(int i, double& lsum) const {

View File

@ -66,7 +66,7 @@
//
// The first dimension of the View is the dimension over which it is
// efficient for Kokkos to parallelize.
typedef Kokkos::View<double * [3]> view_type;
using view_type = Kokkos::View<double * [3]>;
int main(int argc, char* argv[]) {
Kokkos::initialize(argc, argv);

View File

@ -47,7 +47,7 @@
// The type of a two-dimensional N x 3 array of double.
// It lives in Kokkos' default memory space.
typedef Kokkos::View<double * [3]> view_type;
using view_type = Kokkos::View<double * [3]>;
// The "HostMirror" type corresponding to view_type above is also a
// two-dimensional N x 3 array of double. However, it lives in the
@ -61,12 +61,12 @@ typedef Kokkos::View<double * [3]> view_type;
// performance penalties then it is its own host_mirror_space. This is
// the case for HostSpace, CudaUVMSpace and CudaHostPinnedSpace.
typedef view_type::HostMirror host_view_type;
using host_view_type = view_type::HostMirror;
struct ReduceFunctor {
view_type a;
ReduceFunctor(view_type a_) : a(a_) {}
typedef int value_type; // Specify type for reduction value, lsum
using value_type = int; // Specify type for reduction value, lsum
KOKKOS_INLINE_FUNCTION
void operator()(int i, int &lsum) const {

View File

@ -48,8 +48,8 @@
#include <cmath>
// Type of a one-dimensional length-N array of int.
typedef Kokkos::View<int*> view_type;
typedef view_type::HostMirror host_view_type;
using view_type = Kokkos::View<int*>;
using host_view_type = view_type::HostMirror;
// This is a "zero-dimensional" View, that is, a View of a single
// value (an int, in this case). Access the value using operator()
// with no arguments: e.g., 'count()'.
@ -57,8 +57,8 @@ typedef view_type::HostMirror host_view_type;
// Zero-dimensional Views are useful for reduction results that stay
// resident in device memory, as well as for irregularly updated
// shared state. We use it for the latter in this example.
typedef Kokkos::View<int> count_type;
typedef count_type::HostMirror host_count_type;
using count_type = Kokkos::View<int>;
using host_count_type = count_type::HostMirror;
// Functor for finding a list of primes in a given set of numbers. If
// run in parallel, the order of results is nondeterministic, because
@ -118,7 +118,7 @@ int main() {
host_view_type h_result = Kokkos::create_mirror_view(result);
host_count_type h_count = Kokkos::create_mirror_view(count);
typedef view_type::size_type size_type;
using size_type = view_type::size_type;
// Fill the 'data' array on the host with random numbers. We assume
// that they come from some process which is only implemented on the
// host, via some library. (That's true in this case.)

View File

@ -62,7 +62,7 @@
// Simple functor for computing/storing the product of indices in a View v
template <class ViewType>
struct MDFunctor {
typedef long value_type;
using value_type = long;
ViewType v;
size_t size;
@ -105,16 +105,16 @@ int main(int argc, char* argv[]) {
// Bound(s) for MDRangePolicy
const int n = 100;
// ViewType typedefs for Rank<2>, Rank<3> for example usage
typedef double ScalarType;
typedef typename Kokkos::View<ScalarType**> ViewType_2D;
typedef typename Kokkos::View<ScalarType***> ViewType_3D;
// ViewType aliases for Rank<2>, Rank<3> for example usage
using ScalarType = double;
using ViewType_2D = typename Kokkos::View<ScalarType**>;
using ViewType_3D = typename Kokkos::View<ScalarType***>;
/////////////////////////////////////////////////////////////////////////////
// Explanation of MDRangePolicy usage, template parameters, constructor
// arguments
//
// MDRangePolicy typedefs for Rank<2>, Rank<3> cases
// MDRangePolicy aliases for Rank<2>, Rank<3> cases
// Required template parameters:
// Kokkos::Rank<N>: where N=rank
//
@ -126,7 +126,7 @@ int main(int argc, char* argv[]) {
// tiles;
// defaults based on the execution space similar to Kokkos::Layout
//
// e.g. typedef Rank<2, Iterate::Left, Iterate::Left> rank2ll;
// e.g. using rank2ll = Rank<2, Iterate::Left, Iterate::Left>;
//
//
// Optional template parameters to MDRangePolicy:
@ -160,9 +160,8 @@ int main(int argc, char* argv[]) {
long incorrect_count_2d = 0;
{
// Rank<2> Case: Rank is provided, all other parameters are default
typedef typename Kokkos::Experimental::MDRangePolicy<
Kokkos::Experimental::Rank<2> >
MDPolicyType_2D;
using MDPolicyType_2D = typename Kokkos::Experimental::MDRangePolicy<
Kokkos::Experimental::Rank<2> >;
// Construct 2D MDRangePolicy: lower and upper bounds provided, tile dims
// defaulted
@ -186,10 +185,9 @@ int main(int argc, char* argv[]) {
long incorrect_count_3d = 0;
{
// Rank<3> Case: Rank, inner iterate pattern, outer iterate pattern provided
typedef typename Kokkos::Experimental::MDRangePolicy<
using MDPolicyType_3D = typename Kokkos::Experimental::MDRangePolicy<
Kokkos::Experimental::Rank<3, Kokkos::Experimental::Iterate::Left,
Kokkos::Experimental::Iterate::Left> >
MDPolicyType_3D;
Kokkos::Experimental::Iterate::Left> >;
// Construct 3D MDRangePolicy: lower, upper bounds, tile dims provided
MDPolicyType_3D mdpolicy_3d({{0, 0, 0}}, {{n, n, n}}, {{4, 4, 4}});

View File

@ -51,14 +51,14 @@
// which means "column major," the same as in Fortran, the BLAS, or
// LAPACK. right_type has "layout right," which means "row major,"
// the same as in C, C++, or Java.
typedef Kokkos::View<double**, Kokkos::LayoutLeft> left_type;
typedef Kokkos::View<double**, Kokkos::LayoutRight> right_type;
using left_type = Kokkos::View<double**, Kokkos::LayoutLeft>;
using right_type = Kokkos::View<double**, Kokkos::LayoutRight>;
// This is a one-dimensional View, so the layout matters less.
// However, it still has a layout! Since its layout is not specified
// explicitly in the type, its layout is a function of the memory
// space. For example, the default Cuda layout is LayoutLeft, and the
// default Host layout is LayoutRight.
typedef Kokkos::View<double*> view_type;
using view_type = Kokkos::View<double*>;
// parallel_for functor that fills the given View with some data. It
// expects to access the View by rows in parallel: each call i of
@ -114,7 +114,7 @@ struct contraction {
struct dot {
view_type a;
dot(view_type a_) : a(a_) {}
typedef double value_type; // Specify type for reduction target, lsum
using value_type = double; // Specify type for reduction target, lsum
KOKKOS_INLINE_FUNCTION
void operator()(const view_type::size_type i, double& lsum) const {
lsum += a(i) * a(i);

View File

@ -47,7 +47,7 @@
#include <cstdio>
#include <cstdlib>
typedef Kokkos::View<double*> view_type;
using view_type = Kokkos::View<double*>;
// Kokkos::Views have an MemoryTraits template parameter which
// allows users to specify usage scenarios of a View.
// Some of those act simply as hints, which can be used to insert
@ -71,10 +71,10 @@ typedef Kokkos::View<double*> view_type;
// data (i.e. const double* and double*). While these pointers can point to the
// same data you should not use them together if that brakes the const guarantee
// of the first pointer.
typedef Kokkos::View<const double*, Kokkos::MemoryTraits<Kokkos::RandomAccess> >
view_type_rnd;
typedef Kokkos::View<int**> idx_type;
typedef idx_type::HostMirror idx_type_host;
using view_type_rnd =
Kokkos::View<const double*, Kokkos::MemoryTraits<Kokkos::RandomAccess> >;
using idx_type = Kokkos::View<int**>;
using idx_type_host = idx_type::HostMirror;
// We template this functor on the ViewTypes to show the effect of the
// RandomAccess trait.

View File

@ -52,7 +52,7 @@
#include <impl/Kokkos_Timer.hpp>
#include <cstdio>
typedef Kokkos::View<double***, Kokkos::LayoutRight> mesh_type;
using mesh_type = Kokkos::View<double***, Kokkos::LayoutRight>;
// These View types represent subviews of the mesh. Some of the Views
// have layout LayoutStride, meaning that they have run-time "strides"
@ -63,10 +63,10 @@ typedef Kokkos::View<double***, Kokkos::LayoutRight> mesh_type;
// may safely always use a LayoutStride layout when taking a subview
// of a LayoutRight or LayoutLeft subview, but strided accesses may
// cost a bit more, especially for 1-D Views.
typedef Kokkos::View<double**, Kokkos::LayoutStride> xz_plane_type;
typedef Kokkos::View<double**, Kokkos::LayoutRight> yz_plane_type;
typedef Kokkos::View<double**, Kokkos::LayoutStride> xy_plane_type;
typedef Kokkos::View<double***, Kokkos::LayoutStride> inner_mesh_type;
using xz_plane_type = Kokkos::View<double**, Kokkos::LayoutStride>;
using yz_plane_type = Kokkos::View<double**, Kokkos::LayoutRight>;
using xy_plane_type = Kokkos::View<double**, Kokkos::LayoutStride>;
using inner_mesh_type = Kokkos::View<double***, Kokkos::LayoutStride>;
// Functor to set all entries of a boundary of the mesh to a constant
// value. The functor is templated on ViewType because different
@ -98,7 +98,7 @@ struct set_inner {
KOKKOS_INLINE_FUNCTION
void operator()(const typename ViewType::size_type i) const {
typedef typename ViewType::size_type size_type;
using size_type = typename ViewType::size_type;
for (size_type j = 0; j < a.extent(1); ++j) {
for (size_type k = 0; k < a.extent(2); ++k) {
a(i, j, k) = value;
@ -118,7 +118,7 @@ struct update {
KOKKOS_INLINE_FUNCTION
void operator()(typename ViewType::size_type i) const {
typedef typename ViewType::size_type size_type;
using size_type = typename ViewType::size_type;
i++;
for (size_type j = 1; j < a.extent(1) - 1; j++) {
for (size_type k = 1; k < a.extent(2) - 1; k++) {
@ -134,7 +134,7 @@ int main(int narg, char* arg[]) {
using Kokkos::pair;
using Kokkos::parallel_for;
using Kokkos::subview;
typedef mesh_type::size_type size_type;
using size_type = mesh_type::size_type;
Kokkos::initialize(narg, arg);

View File

@ -66,30 +66,30 @@
// operations to help you manage memory take almost no time in that
// case. This makes your code even more performance portable.
typedef Kokkos::DualView<double*> view_type;
typedef Kokkos::DualView<int**> idx_type;
using view_type = Kokkos::DualView<double*>;
using idx_type = Kokkos::DualView<int**>;
template <class ExecutionSpace>
struct localsum {
// If the functor has a public 'execution_space' typedef, that defines
// If the functor has a public 'execution_space' alias, that defines
// the functor's execution space (where it runs in parallel). This
// overrides Kokkos' default execution space.
typedef ExecutionSpace execution_space;
using execution_space = ExecutionSpace;
typedef typename Kokkos::Impl::if_c<
using memory_space = typename Kokkos::Impl::if_c<
std::is_same<ExecutionSpace, Kokkos::DefaultExecutionSpace>::value,
idx_type::memory_space, idx_type::host_mirror_space>::type memory_space;
idx_type::memory_space, idx_type::host_mirror_space>::type;
// Get the view types on the particular device for which the functor
// is instantiated.
//
// "const_data_type" is a typedef in View (and DualView) which is
// "const_data_type" is an alias in View (and DualView) which is
// the const version of the first template parameter of the View.
// For example, the const_data_type version of double** is const
// double**.
Kokkos::View<idx_type::const_data_type, idx_type::array_layout, memory_space>
idx;
// "scalar_array_type" is a typedef in ViewTraits (and DualView) which is the
// "scalar_array_type" is an alias in ViewTraits (and DualView) which is the
// array version of the value(s) stored in the View.
Kokkos::View<view_type::scalar_array_type, view_type::array_layout,
memory_space>
@ -150,7 +150,7 @@ class ParticleType {
protected:
};
typedef Kokkos::DualView<ParticleType[10]> ParticleTypes;
using ParticleTypes = Kokkos::DualView<ParticleType[10]>;
int main(int narg, char* arg[]) {
Kokkos::initialize(narg, arg);

View File

@ -49,18 +49,18 @@
#include <cstdlib>
#ifdef KOKKOS_ENABLE_CUDA
typedef Kokkos::View<double*, Kokkos::CudaUVMSpace> view_type;
typedef Kokkos::View<int**, Kokkos::CudaUVMSpace> idx_type;
using view_type = Kokkos::View<double*, Kokkos::CudaUVMSpace>;
using idx_type = Kokkos::View<int**, Kokkos::CudaUVMSpace>;
#else
typedef Kokkos::View<double*, Kokkos::HostSpace> view_type;
typedef Kokkos::View<int**, Kokkos::HostSpace> idx_type;
using view_type = Kokkos::View<double*, Kokkos::HostSpace>;
using idx_type = Kokkos::View<int**, Kokkos::HostSpace>;
#endif
template <class Device>
struct localsum {
// Define the execution space for the functor (overrides the
// DefaultExecutionSpace)
typedef Device execution_space;
using execution_space = Device;
// Get the view types on the particular device the functor is instantiated for
idx_type::const_type idx;

View File

@ -106,7 +106,7 @@ struct MergeDevice {
int main(int argc, char* argv[]) {
int size = 100000000;
Kokkos::initialize();
int synch = atoi(argv[1]);
int synch = std::stoi(argv[1]);
Kokkos::View<double*, Kokkos::LayoutLeft, Kokkos::CudaSpace> d_a("Device A",
size);
Kokkos::View<double*, Kokkos::LayoutLeft, Kokkos::CudaSpace> d_b("Device B",

View File

@ -48,7 +48,7 @@
#include <impl/Kokkos_Timer.hpp>
#include <cstdlib>
typedef Kokkos::HostSpace::execution_space DefaultHostType;
using DefaultHostType = Kokkos::HostSpace::execution_space;
// Kokkos provides two different random number generators with a 64 bit and a
// 1024 bit state. These generators are based on Vigna, Sebastiano (2014). "An
@ -108,8 +108,8 @@ int main(int argc, char* args[]) {
} else {
// Initialize Kokkos
Kokkos::initialize(argc, args);
int size = atoi(args[1]);
int samples = atoi(args[2]);
int size = std::stoi(args[1]);
int samples = std::stoi(args[2]);
// Create two random number generator pools one for 64bit states and one for
// 1024 bit states Both take an 64 bit unsigned integer seed to initialize a

View File

@ -57,12 +57,12 @@
// league_size) is not limited by physical constraints. Its a pure logical
// number.
typedef Kokkos::TeamPolicy<> team_policy;
typedef team_policy::member_type team_member;
using team_policy = Kokkos::TeamPolicy<>;
using team_member = team_policy::member_type;
// Define a functor which can be launched using the TeamPolicy
struct hello_world {
typedef int value_type; // Specify value type for reduction target, sum
using value_type = int; // Specify value type for reduction target, sum
// This is a reduction operator which now takes as first argument the
// TeamPolicy member_type. Every member of the team contributes to the

View File

@ -56,8 +56,8 @@
int main(int narg, char* args[]) {
using Kokkos::parallel_reduce;
typedef Kokkos::TeamPolicy<> team_policy;
typedef typename team_policy::member_type team_member;
using team_policy = Kokkos::TeamPolicy<>;
using team_member = typename team_policy::member_type;
Kokkos::initialize(narg, args);

View File

@ -46,11 +46,11 @@
#include <cstdio>
// See 01_thread_teams for an explanation of a basic TeamPolicy
typedef Kokkos::TeamPolicy<> team_policy;
typedef typename team_policy::member_type team_member;
using team_policy = Kokkos::TeamPolicy<>;
using team_member = typename team_policy::member_type;
struct hello_world {
typedef int value_type; // Specify value type for reduction target, sum
using value_type = int; // Specify value type for reduction target, sum
KOKKOS_INLINE_FUNCTION
void operator()(const team_member& thread, int& sum) const {
sum += 1;

View File

@ -60,13 +60,13 @@
// a thread execute every line of the operator as long as there are no
// restricitons on them. Code lines can be restricted using Kokkos::single to
// either execute once PerThread or execute once PerTeam.
typedef typename Kokkos::TeamPolicy<>::member_type team_member;
using team_member = typename Kokkos::TeamPolicy<>::member_type;
struct SomeCorrelation {
typedef int value_type; // Specify value type for reduction target, sum
typedef Kokkos::DefaultExecutionSpace::scratch_memory_space shared_space;
typedef Kokkos::View<int*, shared_space, Kokkos::MemoryUnmanaged>
shared_1d_int;
using value_type = int; // Specify value type for reduction target, sum
using shared_space = Kokkos::DefaultExecutionSpace::scratch_memory_space;
using shared_1d_int =
Kokkos::View<int*, shared_space, Kokkos::MemoryUnmanaged>;
Kokkos::View<const int***, Kokkos::LayoutRight> data;
Kokkos::View<int> gsum;
@ -136,7 +136,7 @@ struct SomeCorrelation {
// The functor needs to define how much shared memory it requests given a
// team_size.
size_t team_shmem_size(int team_size) const {
size_t team_shmem_size(int /*team_size*/) const {
return shared_1d_int::shmem_size(data.extent(1));
}
};

View File

@ -48,11 +48,11 @@
#include <cstdio>
#include <cstdlib>
typedef Kokkos::DefaultExecutionSpace Device;
typedef Kokkos::HostSpace::execution_space Host;
using Device = Kokkos::DefaultExecutionSpace;
using Host = Kokkos::HostSpace::execution_space;
typedef Kokkos::TeamPolicy<Device> team_policy;
typedef team_policy::member_type team_member;
using team_policy = Kokkos::TeamPolicy<Device>;
using team_member = team_policy::member_type;
static const int TEAM_SIZE = 16;

View File

@ -60,7 +60,7 @@ struct collision {
// one i.
// This function was chosen as one that very simply can increase the
// register count.
typedef int value_type;
using value_type = int;
KOKKOS_INLINE_FUNCTION
int hash(int q) const {