git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@14064 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -55,16 +55,30 @@ action bond_harmonic_kokkos.cpp bond_harmonic.cpp
|
||||
action bond_harmonic_kokkos.h bond_harmonic.h
|
||||
action comm_kokkos.cpp
|
||||
action comm_kokkos.h
|
||||
action compute_temp_kokkos.cpp
|
||||
action compute_temp_kokkos.h
|
||||
action dihedral_charmm_kokkos.cpp dihedral_charmm.cpp
|
||||
action dihedral_charmm_kokkos.h dihedral_charmm.h
|
||||
action dihedral_opls_kokkos.cpp dihedral_opls.cpp
|
||||
action dihedral_opls_kokkos.h dihedral_opls.h
|
||||
action domain_kokkos.cpp
|
||||
action domain_kokkos.h
|
||||
action fix_deform_kokkos.cpp
|
||||
action fix_deform_kokkos.h
|
||||
action fix_langevin_kokkos.cpp
|
||||
action fix_langevin_kokkos.h
|
||||
action fix_nh_kokkos.cpp
|
||||
action fix_nh_kokkos.h
|
||||
action fix_nph_kokkos.cpp
|
||||
action fix_nph_kokkos.h
|
||||
action fix_npt_kokkos.cpp
|
||||
action fix_npt_kokkos.h
|
||||
action fix_nve_kokkos.cpp
|
||||
action fix_nve_kokkos.h
|
||||
action fix_nvt_kokkos.cpp
|
||||
action fix_nvt_kokkos.h
|
||||
action fix_wall_reflect_kokkos.cpp
|
||||
action fix_wall_reflect_kokkos.h
|
||||
action improper_harmonic_kokkos.cpp improper_harmonic.cpp
|
||||
action improper_harmonic_kokkos.h improper_harmonic.h
|
||||
action kokkos.cpp
|
||||
|
||||
@ -205,3 +205,214 @@ void DomainKokkos::pbc()
|
||||
LMPDeviceType::fence();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
remap all points into the periodic box no matter how far away
|
||||
adjust 3 image flags encoded in image accordingly
|
||||
resulting coord must satisfy lo <= coord < hi
|
||||
MAX is important since coord - prd < lo can happen when coord = hi
|
||||
for triclinic, point is converted to lamda coords (0-1) before doing remap
|
||||
image = 10 bits for each dimension
|
||||
increment/decrement in wrap-around fashion
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void DomainKokkos::remap_all()
|
||||
{
|
||||
atomKK->sync(Device,X_MASK | IMAGE_MASK);
|
||||
atomKK->modified(Device,X_MASK | IMAGE_MASK);
|
||||
|
||||
x = atomKK->k_x.view<LMPDeviceType>();
|
||||
image = atomKK->k_image.view<LMPDeviceType>();
|
||||
int nlocal = atomKK->nlocal;
|
||||
|
||||
if (triclinic == 0) {
|
||||
for (int i=0; i<3; i++) {
|
||||
lo[i] = boxlo[i];
|
||||
hi[i] = boxhi[i];
|
||||
period[i] = prd[i];
|
||||
}
|
||||
} else {
|
||||
for (int i=0; i<3; i++) {
|
||||
lo[i] = boxlo_lamda[i];
|
||||
hi[i] = boxhi_lamda[i];
|
||||
period[i] = prd_lamda[i];
|
||||
}
|
||||
x2lamda(nlocal);
|
||||
}
|
||||
|
||||
copymode = 1;
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<LMPDeviceType, TagDomain_remap_all>(0,nlocal),*this);
|
||||
LMPDeviceType::fence();
|
||||
copymode = 0;
|
||||
|
||||
if (triclinic) lamda2x(nlocal);
|
||||
}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void DomainKokkos::operator()(TagDomain_remap_all, const int &i) const {
|
||||
imageint idim,otherdims;
|
||||
if (xperiodic) {
|
||||
while (x(i,0) < lo[0]) {
|
||||
x(i,0) += period[0];
|
||||
idim = image[i] & IMGMASK;
|
||||
otherdims = image[i] ^ idim;
|
||||
idim--;
|
||||
idim &= IMGMASK;
|
||||
image[i] = otherdims | idim;
|
||||
}
|
||||
while (x(i,0) >= hi[0]) {
|
||||
x(i,0) -= period[0];
|
||||
idim = image[i] & IMGMASK;
|
||||
otherdims = image[i] ^ idim;
|
||||
idim++;
|
||||
idim &= IMGMASK;
|
||||
image[i] = otherdims | idim;
|
||||
}
|
||||
x(i,0) = MAX(x(i,0),lo[0]);
|
||||
}
|
||||
|
||||
if (yperiodic) {
|
||||
while (x(i,1) < lo[1]) {
|
||||
x(i,1) += period[1];
|
||||
idim = (image[i] >> IMGBITS) & IMGMASK;
|
||||
otherdims = image[i] ^ (idim << IMGBITS);
|
||||
idim--;
|
||||
idim &= IMGMASK;
|
||||
image[i] = otherdims | (idim << IMGBITS);
|
||||
}
|
||||
while (x(i,1) >= hi[1]) {
|
||||
x(i,1) -= period[1];
|
||||
idim = (image[i] >> IMGBITS) & IMGMASK;
|
||||
otherdims = image[i] ^ (idim << IMGBITS);
|
||||
idim++;
|
||||
idim &= IMGMASK;
|
||||
image[i] = otherdims | (idim << IMGBITS);
|
||||
}
|
||||
x(i,1) = MAX(x(i,1),lo[1]);
|
||||
}
|
||||
|
||||
if (zperiodic) {
|
||||
while (x(i,2) < lo[2]) {
|
||||
x(i,2) += period[2];
|
||||
idim = image[i] >> IMG2BITS;
|
||||
otherdims = image[i] ^ (idim << IMG2BITS);
|
||||
idim--;
|
||||
idim &= IMGMASK;
|
||||
image[i] = otherdims | (idim << IMG2BITS);
|
||||
}
|
||||
while (x(i,2) >= hi[2]) {
|
||||
x(i,2) -= period[2];
|
||||
idim = image[i] >> IMG2BITS;
|
||||
otherdims = image[i] ^ (idim << IMG2BITS);
|
||||
idim++;
|
||||
idim &= IMGMASK;
|
||||
image[i] = otherdims | (idim << IMG2BITS);
|
||||
}
|
||||
x(i,2) = MAX(x(i,2),lo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
adjust image flags due to triclinic box flip
|
||||
flip operation is changing box vectors A,B,C to new A',B',C'
|
||||
A' = A (A does not change)
|
||||
B' = B + mA (B shifted by A)
|
||||
C' = C + pB + nA (C shifted by B and/or A)
|
||||
this requires the image flags change from (a,b,c) to (a',b',c')
|
||||
so that x_unwrap for each atom is same before/after
|
||||
x_unwrap_before = xlocal + aA + bB + cC
|
||||
x_unwrap_after = xlocal + a'A' + b'B' + c'C'
|
||||
this requires:
|
||||
c' = c
|
||||
b' = b - cp
|
||||
a' = a - (b-cp)m - cn = a - b'm - cn
|
||||
in other words, for xy flip, change in x flag depends on current y flag
|
||||
this is b/c the xy flip dramatically changes which tiled image of
|
||||
simulation box an unwrapped point maps to
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void DomainKokkos::image_flip(int m_in, int n_in, int p_in)
|
||||
{
|
||||
m_flip = m_in;
|
||||
n_flip = n_in;
|
||||
p_flip = p_in;
|
||||
|
||||
atomKK->sync(Device,IMAGE_MASK);
|
||||
atomKK->modified(Device,IMAGE_MASK);
|
||||
|
||||
image = atomKK->k_image.view<LMPDeviceType>();
|
||||
int nlocal = atomKK->nlocal;
|
||||
|
||||
copymode = 1;
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<LMPDeviceType, TagDomain_image_flip>(0,nlocal),*this);
|
||||
LMPDeviceType::fence();
|
||||
copymode = 0;
|
||||
}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void DomainKokkos::operator()(TagDomain_image_flip, const int &i) const {
|
||||
int xbox = (image[i] & IMGMASK) - IMGMAX;
|
||||
int ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
||||
int zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
||||
|
||||
ybox -= p_flip*zbox;
|
||||
xbox -= m_flip*ybox + n_flip*zbox;
|
||||
|
||||
image[i] = ((imageint) (xbox + IMGMAX) & IMGMASK) |
|
||||
(((imageint) (ybox + IMGMAX) & IMGMASK) << IMGBITS) |
|
||||
(((imageint) (zbox + IMGMAX) & IMGMASK) << IMG2BITS);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
convert triclinic 0-1 lamda coords to box coords for all N atoms
|
||||
x = H lamda + x0;
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void DomainKokkos::lamda2x(int n)
|
||||
{
|
||||
atomKK->sync(Device,X_MASK);
|
||||
atomKK->modified(Device,X_MASK);
|
||||
|
||||
x = atomKK->k_x.view<LMPDeviceType>();
|
||||
|
||||
copymode = 1;
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<LMPDeviceType, TagDomain_lamda2x>(0,n),*this);
|
||||
LMPDeviceType::fence();
|
||||
copymode = 0;
|
||||
}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void DomainKokkos::operator()(TagDomain_lamda2x, const int &i) const {
|
||||
x(i,0) = h[0]*x(i,0) + h[5]*x(i,1) + h[4]*x(i,2) + boxlo[0];
|
||||
x(i,1) = h[1]*x(i,1) + h[3]*x(i,2) + boxlo[1];
|
||||
x(i,2) = h[2]*x(i,2) + boxlo[2];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
convert box coords to triclinic 0-1 lamda coords for all N atoms
|
||||
lamda = H^-1 (x - x0)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void DomainKokkos::x2lamda(int n)
|
||||
{
|
||||
atomKK->sync(Device,X_MASK);
|
||||
atomKK->modified(Device,X_MASK);
|
||||
|
||||
x = atomKK->k_x.view<LMPDeviceType>();
|
||||
|
||||
copymode = 1;
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<LMPDeviceType, TagDomain_x2lamda>(0,n),*this);
|
||||
LMPDeviceType::fence();
|
||||
copymode = 0;
|
||||
}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void DomainKokkos::operator()(TagDomain_x2lamda, const int &i) const {
|
||||
F_FLOAT delta[3];
|
||||
delta[0] = x(i,0) - boxlo[0];
|
||||
delta[1] = x(i,1) - boxlo[1];
|
||||
delta[2] = x(i,2) - boxlo[2];
|
||||
|
||||
x(i,0) = h_inv[0]*delta[0] + h_inv[5]*delta[1] + h_inv[4]*delta[2];
|
||||
x(i,1) = h_inv[1]*delta[1] + h_inv[3]*delta[2];
|
||||
x(i,2) = h_inv[2]*delta[2];
|
||||
}
|
||||
|
||||
@ -19,14 +19,41 @@
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
struct TagDomain_remap_all{};
|
||||
struct TagDomain_image_flip{};
|
||||
struct TagDomain_lamda2x{};
|
||||
struct TagDomain_x2lamda{};
|
||||
|
||||
class DomainKokkos : public Domain {
|
||||
public:
|
||||
|
||||
|
||||
DomainKokkos(class LAMMPS *);
|
||||
~DomainKokkos() {}
|
||||
void init();
|
||||
void pbc();
|
||||
void remap_all();
|
||||
void image_flip(int, int, int);
|
||||
void x2lamda(int);
|
||||
void lamda2x(int);
|
||||
|
||||
int closest_image(const int, int) const;
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagDomain_remap_all, const int&) const;
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagDomain_image_flip, const int&) const;
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagDomain_lamda2x, const int&) const;
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagDomain_x2lamda, const int&) const;
|
||||
|
||||
private:
|
||||
double lo[3],hi[3],period[3];
|
||||
int n_flip, m_flip, p_flip;
|
||||
ArrayTypes<LMPDeviceType>::t_x_array x;
|
||||
ArrayTypes<LMPDeviceType>::t_imageint_1d image;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -101,6 +101,12 @@ Compute::Compute(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
|
||||
datamask = ALL_MASK;
|
||||
datamask_ext = ALL_MASK;
|
||||
|
||||
execution_space = Host;
|
||||
datamask_read = ALL_MASK;
|
||||
datamask_modify = ALL_MASK;
|
||||
|
||||
copymode = 0;
|
||||
|
||||
// force init to zero in case these are used as logicals
|
||||
|
||||
vector = vector_atom = vector_local = NULL;
|
||||
@ -111,6 +117,8 @@ Compute::Compute(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
|
||||
|
||||
Compute::~Compute()
|
||||
{
|
||||
if (copymode) return;
|
||||
|
||||
delete [] id;
|
||||
delete [] style;
|
||||
memory->destroy(tlist);
|
||||
|
||||
@ -87,6 +87,13 @@ class Compute : protected Pointers {
|
||||
unsigned int datamask;
|
||||
unsigned int datamask_ext;
|
||||
|
||||
// KOKKOS host/device flag and data masks
|
||||
|
||||
ExecutionSpace execution_space;
|
||||
unsigned int datamask_read,datamask_modify;
|
||||
|
||||
int copymode;
|
||||
|
||||
int cudable; // 1 if compute is CUDA-enabled
|
||||
|
||||
Compute(class LAMMPS *, int, char **);
|
||||
|
||||
@ -44,6 +44,7 @@ ComputeTemp::ComputeTemp(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
ComputeTemp::~ComputeTemp()
|
||||
{
|
||||
if (!copymode)
|
||||
delete [] vector;
|
||||
}
|
||||
|
||||
|
||||
@ -30,8 +30,8 @@ class ComputeTemp : public Compute {
|
||||
virtual ~ComputeTemp();
|
||||
void init() {}
|
||||
void setup();
|
||||
double compute_scalar();
|
||||
void compute_vector();
|
||||
virtual double compute_scalar();
|
||||
virtual void compute_vector();
|
||||
|
||||
protected:
|
||||
double tfactor;
|
||||
|
||||
@ -103,12 +103,16 @@ Domain::Domain(LAMMPS *lmp) : Pointers(lmp)
|
||||
|
||||
nregion = maxregion = 0;
|
||||
regions = NULL;
|
||||
|
||||
copymode = 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
Domain::~Domain()
|
||||
{
|
||||
if (copymode) return;
|
||||
|
||||
delete lattice;
|
||||
for (int i = 0; i < nregion; i++) delete regions[i];
|
||||
memory->sfree(regions);
|
||||
|
||||
@ -90,6 +90,8 @@ class Domain : protected Pointers {
|
||||
int maxregion; // max # list can hold
|
||||
class Region **regions; // list of defined Regions
|
||||
|
||||
int copymode;
|
||||
|
||||
Domain(class LAMMPS *);
|
||||
virtual ~Domain();
|
||||
virtual void init();
|
||||
|
||||
@ -30,14 +30,14 @@ class FixDeform : public Fix {
|
||||
int dimflag[6]; // which dims are deformed
|
||||
|
||||
FixDeform(class LAMMPS *, int, char **);
|
||||
~FixDeform();
|
||||
virtual ~FixDeform();
|
||||
int setmask();
|
||||
void init();
|
||||
void pre_exchange();
|
||||
void end_of_step();
|
||||
virtual void pre_exchange();
|
||||
virtual void end_of_step();
|
||||
double memory_usage();
|
||||
|
||||
private:
|
||||
protected:
|
||||
int triclinic,scaleflag,flipflag;
|
||||
int flip,flipxy,flipxz,flipyz;
|
||||
double *h_rate,*h_ratelo;
|
||||
|
||||
@ -534,6 +534,8 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
|
||||
|
||||
FixNH::~FixNH()
|
||||
{
|
||||
if (copymode) return;
|
||||
|
||||
delete [] id_dilate;
|
||||
delete [] rfix;
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ class FixNH : public Fix {
|
||||
virtual void final_integrate();
|
||||
void initial_integrate_respa(int, int, int);
|
||||
void final_integrate_respa(int, int);
|
||||
void pre_exchange();
|
||||
virtual void pre_exchange();
|
||||
double compute_scalar();
|
||||
virtual double compute_vector(int);
|
||||
void write_restart(FILE *);
|
||||
@ -120,7 +120,7 @@ class FixNH : public Fix {
|
||||
double fixedpoint[3]; // location of dilation fixed-point
|
||||
|
||||
void couple();
|
||||
void remap();
|
||||
virtual void remap();
|
||||
void nhc_temp_integrate();
|
||||
void nhc_press_integrate();
|
||||
|
||||
|
||||
@ -142,6 +142,8 @@ FixWallReflect::FixWallReflect(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
FixWallReflect::~FixWallReflect()
|
||||
{
|
||||
if (copymode) return;
|
||||
|
||||
for (int m = 0; m < nwall; m++)
|
||||
if (wallstyle[m] == VARIABLE) delete [] varstr[m];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user