Kokkos updates by Stan

This commit is contained in:
Steve Plimpton
2016-11-17 08:58:22 -07:00
parent 9806da69f3
commit 8756a1017d
11 changed files with 114 additions and 79 deletions

View File

@ -38,9 +38,17 @@ The pressure is computed by the formula
where N is the number of atoms in the system (see discussion of DOF
below), Kb is the Boltzmann constant, T is the temperature, d is the
dimensionality of the system (2 or 3 for 2d/3d), V is the system
volume (or area in 2d), and the second term is the virial, computed
within LAMMPS for all pairwise as well as 2-body, 3-body, and 4-body,
and long-range interactions. "Fixes"_fix.html that impose constraints
volume (or area in 2d).
The second term is the virial, -dU/dV, computed within LAMMPS for all
pairwise as well as 2-body, 3-body, 4-body, many-body, and
long-range interactions, where r_i and f_i are the position and
force vector of atom i, and the big black dot indicates dot product.
When periodic boundary conditions are used, the summation includes
contributions from periodic images of the atoms in the central box,
which involves computing partial forces on local and ghost atoms.
A detailed description of how partial forces for 2-body and manybody
potentials are computed is provided in "(Thompson)"_#Thompson.
"Fixes"_fix.html that impose constraints
(e.g. the "fix shake"_fix_shake.html command) also contribute to the
virial term.

View File

@ -53,6 +53,7 @@ fi
if (test $1 = "CLASS2") then
depend GPU
depend KOKKOS
depend USER-OMP
fi

View File

@ -83,8 +83,13 @@ class AtomVecKokkos : public AtomVec {
std::is_same<typename ViewType::execution_space,LMPDeviceType>::value,
Kokkos::CudaHostPinnedSpace,typename ViewType::memory_space>::type,
Kokkos::MemoryTraits<Kokkos::Unmanaged> > mirror_type;
if(buffer_size < src.capacity())
if (buffer_size == 0) {
buffer = Kokkos::kokkos_malloc<Kokkos::CudaHostPinnedSpace>(src.capacity());
buffer_size = src.capacity();
} else if (buffer_size < src.capacity()) {
buffer = Kokkos::kokkos_realloc<Kokkos::CudaHostPinnedSpace>(buffer,src.capacity());
buffer_size = src.capacity();
}
return mirror_type( buffer ,
src.dimension_0() ,
src.dimension_1() ,
@ -104,8 +109,13 @@ class AtomVecKokkos : public AtomVec {
std::is_same<typename ViewType::execution_space,LMPDeviceType>::value,
Kokkos::CudaHostPinnedSpace,typename ViewType::memory_space>::type,
Kokkos::MemoryTraits<Kokkos::Unmanaged> > mirror_type;
if(buffer_size < src.capacity())
if (buffer_size == 0) {
buffer = Kokkos::kokkos_malloc<Kokkos::CudaHostPinnedSpace>(src.capacity()*sizeof(typename ViewType::value_type));
buffer_size = src.capacity();
} else if (buffer_size < src.capacity()) {
buffer = Kokkos::kokkos_realloc<Kokkos::CudaHostPinnedSpace>(buffer,src.capacity()*sizeof(typename ViewType::value_type));
buffer_size = src.capacity();
}
mirror_type tmp_view( (typename ViewType::value_type*)buffer ,
src.dimension_0() ,
src.dimension_1() ,

View File

@ -21,6 +21,11 @@
#include "atom_masks.h"
#include "error.h"
#include "kokkos.h"
#include "force.h"
#include "bond.h"
#include "angle.h"
#include "dihedral.h"
#include "improper.h"
using namespace LAMMPS_NS;
@ -601,6 +606,18 @@ void NeighborKokkos::build_topology_kokkos() {
k_anglelist.modify<LMPDeviceType>();
k_dihedrallist.modify<LMPDeviceType>();
k_improperlist.modify<LMPDeviceType>();
// Transfer topology neighbor lists to Host for non-Kokkos styles
if (force->bond && force->bond->execution_space == Host)
k_bondlist.sync<LMPHostType>();
if (force->angle && force->angle->execution_space == Host)
k_anglelist.sync<LMPHostType>();
if (force->dihedral && force->dihedral->execution_space == Host)
k_dihedrallist.sync<LMPHostType>();
if (force->improper && force->improper->execution_space == Host)
k_improperlist.sync<LMPHostType>();
} else {
neighbond_host.build_topology_kk();

View File

@ -126,7 +126,7 @@ void PairTersoffKokkos<DeviceType>::setup_params()
for (i = 1; i <= n; i++)
for (j = 1; j <= n; j++)
for (k = 1; k <= n; k++) {
m = elem2param[i-1][j-1][k-1];
m = elem2param[map[i]][map[j]][map[k]];
k_params.h_view(i,j,k).powerm = params[m].powerm;
k_params.h_view(i,j,k).gamma = params[m].gamma;
k_params.h_view(i,j,k).lam3 = params[m].lam3;

View File

@ -125,7 +125,7 @@ void PairTersoffMODKokkos<DeviceType>::setup_params()
for (i = 1; i <= n; i++)
for (j = 1; j <= n; j++)
for (k = 1; k <= n; k++) {
m = elem2param[i-1][j-1][k-1];
m = elem2param[map[i]][map[j]][map[k]];
k_params.h_view(i,j,k).powerm = params[m].powerm;
k_params.h_view(i,j,k).lam3 = params[m].lam3;
k_params.h_view(i,j,k).h = params[m].h;

View File

@ -136,7 +136,7 @@ void PairTersoffZBLKokkos<DeviceType>::setup_params()
for (i = 1; i <= n; i++)
for (j = 1; j <= n; j++)
for (k = 1; k <= n; k++) {
m = elem2param[i-1][j-1][k-1];
m = elem2param[map[i]][map[j]][map[k]];
k_params.h_view(i,j,k).powerm = params[m].powerm;
k_params.h_view(i,j,k).gamma = params[m].gamma;
k_params.h_view(i,j,k).lam3 = params[m].lam3;

View File

@ -33,10 +33,10 @@ template<class DeviceType>
class RegBlockKokkos : public RegBlock {
friend class FixPour;
public:
typedef DeviceType device_type;
typedef ArrayTypes<DeviceType> AT;
public:
RegBlockKokkos(class LAMMPS *, int, char **);
~RegBlockKokkos();
void match_all_kokkos(int, DAT::t_int_1d);

View File

@ -55,7 +55,8 @@ static const char cite_fix_orient_fcc[] =
FixOrientFCC::FixOrientFCC(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg),
xifilename(NULL), chifilename(NULL), order(NULL), nbr(NULL), sort(NULL), list(NULL)
xifilename(NULL), chifilename(NULL), order(NULL), nbr(NULL),
sort(NULL), list(NULL)
{
if (lmp->citeme) lmp->citeme->add(cite_fix_orient_fcc);

View File

@ -1423,7 +1423,7 @@ void PairSMTBQ::tabqeq()
{
gam = dgam = dza = dzb = d2zaa = d2zab =
d2zbb = d2zra = d2zrb = d2gamr2 = 0.0 ;
aCoeff = bCoeff = dij = 0.0 ;
dij = 0.0 ;
s = static_cast<double>(k)*ds ; r = sqrt(s) ;
if (k==0) r=10e-30;
@ -1438,7 +1438,6 @@ void PairSMTBQ::tabqeq()
// Cutting Fonction
if (dij < 0.01 && ii==0)
{
ii=2;
@ -1452,7 +1451,6 @@ void PairSMTBQ::tabqeq()
ddij = aCoeff*(r- rc-nang) *(2+bCoeff*(r-rc-nang))*exp(bCoeff*r);
}
if (r > (rc+nang)) {dij = 0.0 ; ddij = 0.0;}
fafb[k][m] = potqn[k] - dij ;
@ -1471,7 +1469,6 @@ void PairSMTBQ::tabqeq()
rb = ROxSurf;
zb = (2.0*params[j].ne + 1.0)/(4.0*rb); }
ii = 0 ; nang =cang= 5.0 ;
// --------------------------
for (k = 0; k < kmax+5; k++)

View File

@ -44,8 +44,9 @@ enum{PERATOM,LOCAL};
ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg),
nvalues(0), which(NULL), argindex(NULL), flavor(NULL), value2index(NULL), ids(NULL),
onevec(NULL), replace(NULL), indices(NULL), owner(NULL), idregion(NULL), varatom(NULL)
nvalues(0), which(NULL), argindex(NULL), flavor(NULL),
value2index(NULL), ids(NULL), onevec(NULL), replace(NULL), indices(NULL),
owner(NULL), idregion(NULL), varatom(NULL)
{
int iarg = 0;
if (strcmp(style,"reduce") == 0) {