whitespace

This commit is contained in:
Stan Moore
2024-10-24 09:43:36 -06:00
parent a844959a07
commit f18850397d
13 changed files with 335 additions and 341 deletions

View File

@ -56,6 +56,7 @@ FixCMAPKokkos<DeviceType>::FixCMAPKokkos(LAMMPS *lmp, int narg, char **arg) :
datamask_modify = F_MASK; datamask_modify = F_MASK;
// allocate memory for CMAP data // allocate memory for CMAP data
memoryKK->create_kokkos(k_g_axis,g_axis,CMAPDIM,"cmap:g_axis"); memoryKK->create_kokkos(k_g_axis,g_axis,CMAPDIM,"cmap:g_axis");
memoryKK->create_kokkos(k_cmapgrid,cmapgrid,CMAPMAX,CMAPDIM,CMAPDIM,"cmap:grid"); memoryKK->create_kokkos(k_cmapgrid,cmapgrid,CMAPMAX,CMAPDIM,CMAPDIM,"cmap:grid");
memoryKK->create_kokkos(k_d1cmapgrid,d1cmapgrid,CMAPMAX,CMAPDIM,CMAPDIM,"cmap:d1grid"); memoryKK->create_kokkos(k_d1cmapgrid,d1cmapgrid,CMAPMAX,CMAPDIM,CMAPDIM,"cmap:d1grid");
@ -69,6 +70,7 @@ FixCMAPKokkos<DeviceType>::FixCMAPKokkos(LAMMPS *lmp, int narg, char **arg) :
d_d12cmapgrid = k_d12cmapgrid.template view<DeviceType>(); d_d12cmapgrid = k_d12cmapgrid.template view<DeviceType>();
// read and setup CMAP data // read and setup CMAP data
read_grid_map(arg[3]); read_grid_map(arg[3]);
int i = 0; int i = 0;
@ -88,6 +90,7 @@ FixCMAPKokkos<DeviceType>::FixCMAPKokkos(LAMMPS *lmp, int narg, char **arg) :
for( int i=0 ; i<CMAPMAX ; i++ ) { for( int i=0 ; i<CMAPMAX ; i++ ) {
// pre-compute the derivatives of the maps // pre-compute the derivatives of the maps
set_map_derivatives(cmapgrid[i],d1cmapgrid[i],d2cmapgrid[i],d12cmapgrid[i]); set_map_derivatives(cmapgrid[i],d1cmapgrid[i],d2cmapgrid[i],d12cmapgrid[i]);
for( int j=0 ; j<CMAPDIM ; j++ ) { for( int j=0 ; j<CMAPDIM ; j++ ) {
@ -111,7 +114,6 @@ FixCMAPKokkos<DeviceType>::FixCMAPKokkos(LAMMPS *lmp, int narg, char **arg) :
k_d1cmapgrid.template sync<DeviceType>(); k_d1cmapgrid.template sync<DeviceType>();
k_d2cmapgrid.template sync<DeviceType>(); k_d2cmapgrid.template sync<DeviceType>();
k_d12cmapgrid.template sync<DeviceType>(); k_d12cmapgrid.template sync<DeviceType>();
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -136,7 +138,6 @@ FixCMAPKokkos<DeviceType>::~FixCMAPKokkos()
memoryKK->destroy_kokkos(k_crossterm_atom5,crossterm_atom5); memoryKK->destroy_kokkos(k_crossterm_atom5,crossterm_atom5);
memoryKK->destroy_kokkos(d_crosstermlist); memoryKK->destroy_kokkos(d_crosstermlist);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -148,6 +149,7 @@ void FixCMAPKokkos<DeviceType>::init()
error->all(FLERR,"Cannot yet use respa with Kokkos"); error->all(FLERR,"Cannot yet use respa with Kokkos");
// on KOKKOS, allocate enough for all crossterms on each GPU to avoid grow operation in device code // on KOKKOS, allocate enough for all crossterms on each GPU to avoid grow operation in device code
maxcrossterm = ncmap; maxcrossterm = ncmap;
memoryKK->create_kokkos(d_crosstermlist,maxcrossterm,CMAPMAX,"cmap:crosstermlist"); memoryKK->create_kokkos(d_crosstermlist,maxcrossterm,CMAPMAX,"cmap:crosstermlist");
} }
@ -159,7 +161,6 @@ void FixCMAPKokkos<DeviceType>::init()
template<class DeviceType> template<class DeviceType>
void FixCMAPKokkos<DeviceType>::pre_neighbor() void FixCMAPKokkos<DeviceType>::pre_neighbor()
{ {
atomKK->sync(execution_space,X_MASK); atomKK->sync(execution_space,X_MASK);
d_x = atomKK->k_x.view<DeviceType>(); d_x = atomKK->k_x.view<DeviceType>();
int nlocal = atomKK->nlocal; int nlocal = atomKK->nlocal;
@ -179,14 +180,12 @@ void FixCMAPKokkos<DeviceType>::pre_neighbor()
copymode = 1; copymode = 1;
Kokkos::parallel_scan(Kokkos::RangePolicy<DeviceType,TagFixCmapPreNeighbor>(0,nlocal),*this,ncrosstermlist); Kokkos::parallel_scan(Kokkos::RangePolicy<DeviceType,TagFixCmapPreNeighbor>(0,nlocal),*this,ncrosstermlist);
copymode = 0; copymode = 0;
} }
template<class DeviceType> template<class DeviceType>
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
void FixCMAPKokkos<DeviceType>::operator()(TagFixCmapPreNeighbor, const int i, int &l_ncrosstermlist, const bool is_final ) const void FixCMAPKokkos<DeviceType>::operator()(TagFixCmapPreNeighbor, const int i, int &l_ncrosstermlist, const bool is_final ) const
{ {
for( int m = 0; m < d_num_crossterm(i); m++) { for( int m = 0; m < d_num_crossterm(i); m++) {
int atom1 = AtomKokkos::map_kokkos<DeviceType>(d_crossterm_atom1(i,m),map_style,k_map_array,k_map_hash); int atom1 = AtomKokkos::map_kokkos<DeviceType>(d_crossterm_atom1(i,m),map_style,k_map_array,k_map_hash);
@ -297,6 +296,7 @@ void FixCMAPKokkos<DeviceType>::operator()(TagFixCmapPostForce, const int n, dou
double vb45z = d_x(i4,2) - d_x(i5,2); double vb45z = d_x(i4,2) - d_x(i5,2);
// calculate normal vectors for planes that define the dihedral angles // calculate normal vectors for planes that define the dihedral angles
double a1x = vb12y*vb23z - vb12z*vb23y; double a1x = vb12y*vb23z - vb12z*vb23y;
double a1y = vb12z*vb23x - vb12x*vb23z; double a1y = vb12z*vb23x - vb12x*vb23z;
double a1z = vb12x*vb23y - vb12y*vb23x; double a1z = vb12x*vb23y - vb12y*vb23x;
@ -325,6 +325,7 @@ void FixCMAPKokkos<DeviceType>::operator()(TagFixCmapPostForce, const int n, dou
if (a1sq<0.0001 || b1sq<0.0001 || a2sq<0.0001 || b2sq<0.0001) return; if (a1sq<0.0001 || b1sq<0.0001 || a2sq<0.0001 || b2sq<0.0001) return;
// vectors needed to calculate the cross-term dihedral angles // vectors needed to calculate the cross-term dihedral angles
double dpr21r32 = vb21x*vb32x + vb21y*vb32y + vb21z*vb32z; double dpr21r32 = vb21x*vb32x + vb21y*vb32y + vb21z*vb32z;
double dpr34r32 = vb34x*vb32x + vb34y*vb32y + vb34z*vb32z; double dpr34r32 = vb34x*vb32x + vb34y*vb32y + vb34z*vb32z;
double dpr32r43 = vb32x*vb43x + vb32y*vb43y + vb32z*vb43z; double dpr32r43 = vb32x*vb43x + vb32y*vb43y + vb32z*vb43z;
@ -388,8 +389,8 @@ void FixCMAPKokkos<DeviceType>::operator()(TagFixCmapPostForce, const int n, dou
bc_interpol(phi,psi,li3,li4,gs,d1gs,d2gs,d12gs,E,dEdPhi,dEdPsi); bc_interpol(phi,psi,li3,li4,gs,d1gs,d2gs,d12gs,E,dEdPhi,dEdPsi);
// sum up cmap energy contributions // sum up cmap energy contributions
// needed for compute_scalar() // needed for compute_scalar()
double engfraction = 0.2 * E; double engfraction = 0.2 * E;
if (i1 < nlocal) ecmapKK += engfraction; if (i1 < nlocal) ecmapKK += engfraction;
if (i2 < nlocal) ecmapKK += engfraction; if (i2 < nlocal) ecmapKK += engfraction;
@ -479,6 +480,7 @@ void FixCMAPKokkos<DeviceType>::grow_arrays(int nmax)
k_crossterm_atom5.template sync<LMPHostType>(); k_crossterm_atom5.template sync<LMPHostType>();
// force reallocation on host // force reallocation on host
k_num_crossterm.template modify<LMPHostType>(); k_num_crossterm.template modify<LMPHostType>();
k_crossterm_type.template modify<LMPHostType>(); k_crossterm_type.template modify<LMPHostType>();
k_crossterm_atom1.template modify<LMPHostType>(); k_crossterm_atom1.template modify<LMPHostType>();
@ -877,8 +879,6 @@ void FixCMAPKokkos<DeviceType>::bc_interpol(double x1, double x2, int low1, int
dEdPsi *= (180.0/MY_PI/CMAPDX); dEdPsi *= (180.0/MY_PI/CMAPDX);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
return local index of atom J or any of its images that is closest to atom I return local index of atom J or any of its images that is closest to atom I
if J is not a valid index like -1, just return it if J is not a valid index like -1, just return it
@ -917,7 +917,6 @@ int FixCMAPKokkos<DeviceType>::closest_image(const int i, int j) const
return closest; return closest;
} }
namespace LAMMPS_NS { namespace LAMMPS_NS {
template class FixCMAPKokkos<LMPDeviceType>; template class FixCMAPKokkos<LMPDeviceType>;
#ifdef LMP_KOKKOS_GPU #ifdef LMP_KOKKOS_GPU

View File

@ -120,7 +120,6 @@ void FixNVELimitKokkos<DeviceType>::initial_integrate(int /*vflag*/)
ncount += d_ncount; ncount += d_ncount;
atomKK->modified(execution_space, X_MASK | V_MASK ); atomKK->modified(execution_space, X_MASK | V_MASK );
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -190,7 +189,6 @@ void FixNVELimitKokkos<DeviceType>::final_integrate()
ncount += d_ncount; ncount += d_ncount;
atomKK->modified(execution_space, V_MASK ); atomKK->modified(execution_space, V_MASK );
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -50,7 +50,6 @@ FixRecenterKokkos<DeviceType>::FixRecenterKokkos(LAMMPS *lmp, int narg, char **a
template<class DeviceType> template<class DeviceType>
void FixRecenterKokkos<DeviceType>::initial_integrate(int /*vflag*/) void FixRecenterKokkos<DeviceType>::initial_integrate(int /*vflag*/)
{ {
atomKK->sync(execution_space,datamask_read); atomKK->sync(execution_space,datamask_read);
int nlocal = atomKK->nlocal; int nlocal = atomKK->nlocal;
if (igroup == atomKK->firstgroup) nlocal = atomKK->nfirst; if (igroup == atomKK->firstgroup) nlocal = atomKK->nfirst;
@ -121,7 +120,6 @@ void FixRecenterKokkos<DeviceType>::initial_integrate(int /*vflag*/)
atomKK->modified(execution_space,datamask_modify); atomKK->modified(execution_space,datamask_modify);
} }
namespace LAMMPS_NS { namespace LAMMPS_NS {
template class FixRecenterKokkos<LMPDeviceType>; template class FixRecenterKokkos<LMPDeviceType>;
#ifdef LMP_KOKKOS_GPU #ifdef LMP_KOKKOS_GPU

View File

@ -91,8 +91,8 @@ void FixWallRegionKokkos<DeviceType>::post_force(int vflag)
// initilize ewall after region->prematch(), // initilize ewall after region->prematch(),
// so a dynamic region can access last timestep values // so a dynamic region can access last timestep values
// energy intialize. // energy intialize
// eflag is used to track whether wall energies have been communicated. // eflag is used to track whether wall energies have been communicated
eflag = 0; eflag = 0;
double result[10]; double result[10];
@ -330,7 +330,6 @@ template <class DeviceType>
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
void FixWallRegionKokkos<DeviceType>::v_tally(value_type result, int i, double *v) const void FixWallRegionKokkos<DeviceType>::v_tally(value_type result, int i, double *v) const
{ {
if (vflag_global) { if (vflag_global) {
result[4] += v[0]; result[4] += v[0];
result[5] += v[1]; result[5] += v[1];
@ -348,7 +347,6 @@ void FixWallRegionKokkos<DeviceType>::v_tally(value_type result, int i, double *
Kokkos::atomic_add(&(d_vatom(i,4)),v[4]); Kokkos::atomic_add(&(d_vatom(i,4)),v[4]);
Kokkos::atomic_add(&(d_vatom(i,5)),v[5]); Kokkos::atomic_add(&(d_vatom(i,5)),v[5]);
} }
} }
namespace LAMMPS_NS { namespace LAMMPS_NS {

View File

@ -71,7 +71,6 @@ double GroupKokkos<DeviceType>::mass(int igroup)
return all; return all;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
compute the center-of-mass coords of group of atoms compute the center-of-mass coords of group of atoms
masstotal = total mass masstotal = total mass

View File

@ -271,7 +271,6 @@ namespace MathSpecialKokkos {
return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2]; return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
} }
} // namespace MathSpecialKokkos } // namespace MathSpecialKokkos
} // namespace LAMMPS_NS } // namespace LAMMPS_NS

View File

@ -61,7 +61,7 @@ class RegBlockKokkos : public RegBlock, public KokkosBase {
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
int surface_kokkos(double x, double y, double z, double cutoff) int surface_kokkos(double x, double y, double z, double cutoff)
{ {
int ncontact; int ncontact;
double xs, ys, zs; double xs, ys, zs;
double xnear[3], xorig[3]; double xnear[3], xorig[3];
@ -97,7 +97,8 @@ class RegBlockKokkos : public RegBlock, public KokkosBase {
} }
return ncontact; return ncontact;
} }
Kokkos::View<Contact*, DeviceType> d_contact; Kokkos::View<Contact*, DeviceType> d_contact;
private: private:
@ -106,9 +107,9 @@ class RegBlockKokkos : public RegBlock, public KokkosBase {
typename AT::t_x_array_randomread d_x; typename AT::t_x_array_randomread d_x;
typename AT::t_int_1d_randomread d_mask; typename AT::t_int_1d_randomread d_mask;
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
int surface_interior_kokkos(double *x, double cutoff) int surface_interior_kokkos(double *x, double cutoff)
{ {
double delta; double delta;
// x is exterior to block // x is exterior to block
@ -177,11 +178,11 @@ int surface_interior_kokkos(double *x, double cutoff)
} }
return n; return n;
} }
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
int surface_exterior_kokkos(double *x, double cutoff) int surface_exterior_kokkos(double *x, double cutoff)
{ {
double xp, yp, zp; double xp, yp, zp;
double xc, yc, zc, dist, mindist; double xc, yc, zc, dist, mindist;
@ -235,11 +236,11 @@ int surface_exterior_kokkos(double *x, double cutoff)
d_contact[0].iwall = 0; d_contact[0].iwall = 0;
if (d_contact[0].r < cutoff) return 1; if (d_contact[0].r < cutoff) return 1;
return 0; return 0;
} }
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
void add_contact(int n, double *x, double xp, double yp, double zp) void add_contact(int n, double *x, double xp, double yp, double zp)
{ {
double delx = x[0] - xp; double delx = x[0] - xp;
double dely = x[1] - yp; double dely = x[1] - yp;
double delz = x[2] - zp; double delz = x[2] - zp;
@ -248,41 +249,41 @@ void add_contact(int n, double *x, double xp, double yp, double zp)
d_contact[n].delx = delx; d_contact[n].delx = delx;
d_contact[n].dely = dely; d_contact[n].dely = dely;
d_contact[n].delz = delz; d_contact[n].delz = delz;
} }
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
int k_inside(double x, double y, double z) const int k_inside(double x, double y, double z) const
{ {
if (x >= xlo && x <= xhi && y >= ylo && y <= yhi && z >= zlo && z <= zhi) if (x >= xlo && x <= xhi && y >= ylo && y <= yhi && z >= zlo && z <= zhi)
return 1; return 1;
return 0; return 0;
} }
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
void forward_transform(double &x, double &y, double &z) const void forward_transform(double &x, double &y, double &z) const
{ {
if (rotateflag) rotate(x, y, z, theta); if (rotateflag) rotate(x, y, z, theta);
if (moveflag) { if (moveflag) {
x += dx; x += dx;
y += dy; y += dy;
z += dz; z += dz;
} }
} }
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
void inverse_transform(double &x, double &y, double &z) const void inverse_transform(double &x, double &y, double &z) const
{ {
if (moveflag) { if (moveflag) {
x -= dx; x -= dx;
y -= dy; y -= dy;
z -= dz; z -= dz;
} }
if (rotateflag) rotate(x,y,z,-theta); if (rotateflag) rotate(x,y,z,-theta);
} }
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
void rotate(double &x, double &y, double &z, double angle) const void rotate(double &x, double &y, double &z, double angle) const
{ {
double a[3],b[3],c[3],d[3],disp[3]; double a[3],b[3],c[3],d[3],disp[3];
double sine = sin(angle); double sine = sin(angle);
@ -306,11 +307,11 @@ void rotate(double &x, double &y, double &z, double angle) const
x = point[0] + c[0] + disp[0]; x = point[0] + c[0] + disp[0];
y = point[1] + c[1] + disp[1]; y = point[1] + c[1] + disp[1];
z = point[2] + c[2] + disp[2]; z = point[2] + c[2] + disp[2];
} }
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
void point_on_line_segment(double *a, double *b, double *c, double *d) void point_on_line_segment(double *a, double *b, double *c, double *d)
{ {
double ba[3], ca[3]; double ba[3], ca[3];
sub3(b, a, ba); sub3(b, a, ba);
@ -329,11 +330,11 @@ void point_on_line_segment(double *a, double *b, double *c, double *d)
d[1] = a[1] + t * ba[1]; d[1] = a[1] + t * ba[1];
d[2] = a[2] + t * ba[2]; d[2] = a[2] + t * ba[2];
} }
} }
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
double inside_face(double *xproj, int iface) double inside_face(double *xproj, int iface)
{ {
if (iface < 2) { if (iface < 2) {
if (xproj[1] > 0 && (xproj[1] < yhi - ylo) && xproj[2] > 0 && (xproj[2] < zhi - zlo)) return 1; if (xproj[1] > 0 && (xproj[1] < yhi - ylo) && xproj[2] > 0 && (xproj[2] < zhi - zlo)) return 1;
} else if (iface < 4) { } else if (iface < 4) {
@ -344,11 +345,11 @@ double inside_face(double *xproj, int iface)
} }
return 0; return 0;
} }
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
double find_closest_point(int i, double *x, double &xc, double &yc, double &zc) double find_closest_point(int i, double *x, double &xc, double &yc, double &zc)
{ {
double dot, d2, d2min; double dot, d2, d2min;
double xr[3], xproj[3], p[3]; double xr[3], xproj[3], p[3];
@ -415,8 +416,7 @@ double find_closest_point(int i, double *x, double &xc, double &yc, double &zc)
} }
return d2min; return d2min;
} }
}; };

View File

@ -75,7 +75,6 @@ void RegSphereKokkos<DeviceType>::operator()(TagRegSphereMatchAll, const int &i)
} }
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
namespace LAMMPS_NS { namespace LAMMPS_NS {

View File

@ -131,6 +131,7 @@ FixCMAP::~FixCMAP()
if (copymode) return; if (copymode) return;
// unregister callbacks to this fix from Atom class // unregister callbacks to this fix from Atom class
atom->delete_callback(id,Atom::GROW); atom->delete_callback(id,Atom::GROW);
atom->delete_callback(id,Atom::RESTART); atom->delete_callback(id,Atom::RESTART);

View File

@ -50,6 +50,7 @@ Region::Region(LAMMPS *lmp, int /*narg*/, char **arg) :
Region::~Region() Region::~Region()
{ {
if (copymode) return; if (copymode) return;
delete[] id; delete[] id;
delete[] style; delete[] style;
delete[] xstr; delete[] xstr;

View File

@ -262,6 +262,7 @@ RegBlock::RegBlock(LAMMPS *lmp, int narg, char **arg) :
RegBlock::~RegBlock() RegBlock::~RegBlock()
{ {
if (copymode) return; if (copymode) return;
delete[] xlostr; delete[] xlostr;
delete[] xhistr; delete[] xhistr;
delete[] ylostr; delete[] ylostr;

View File

@ -102,6 +102,7 @@ RegSphere::RegSphere(LAMMPS *lmp, int narg, char **arg) :
RegSphere::~RegSphere() RegSphere::~RegSphere()
{ {
if (copymode) return; if (copymode) return;
delete[] xstr; delete[] xstr;
delete[] ystr; delete[] ystr;
delete[] zstr; delete[] zstr;