Merge branch 'develop'

This commit is contained in:
Axel Kohlmeyer
2023-02-01 03:42:34 -05:00
25 changed files with 318 additions and 306 deletions

View File

@ -1,6 +1,6 @@
set(PACELIB_URL "https://github.com/ICAMS/lammps-user-pace/archive/refs/tags/v.2023.01.3.tar.gz" CACHE STRING "URL for PACE evaluator library sources") set(PACELIB_URL "https://github.com/ICAMS/lammps-user-pace/archive/refs/tags/v.2023.01.3.fix.tar.gz" CACHE STRING "URL for PACE evaluator library sources")
set(PACELIB_MD5 "f418d32b60e531063ac4285bf702b468" CACHE STRING "MD5 checksum of PACE evaluator library tarball") set(PACELIB_MD5 "4f0b3b5b14456fe9a73b447de3765caa" CACHE STRING "MD5 checksum of PACE evaluator library tarball")
mark_as_advanced(PACELIB_URL) mark_as_advanced(PACELIB_URL)
mark_as_advanced(PACELIB_MD5) mark_as_advanced(PACELIB_MD5)

View File

@ -6,7 +6,7 @@
pair_style pace command pair_style pace command
======================= =======================
Accelerator Variants: *pace/kk* Accelerator Variants: *pace/kk*, *pace/extrapolation/kk*
pair_style pace/extrapolation command pair_style pace/extrapolation command
===================================== =====================================

View File

@ -18,11 +18,11 @@ from install_helpers import fullpath, geturl, checkmd5sum
# settings # settings
thisdir = fullpath('.') thisdir = fullpath('.')
version ='v.2023.01.3' version ='v.2023.01.3.fix'
# known checksums for different PACE versions. used to validate the download. # known checksums for different PACE versions. used to validate the download.
checksums = { \ checksums = { \
'v.2023.01.3': 'f418d32b60e531063ac4285bf702b468' 'v.2023.01.3.fix': '4f0b3b5b14456fe9a73b447de3765caa'
} }
parser = ArgumentParser(prog='Install.py', description="LAMMPS library build wrapper script") parser = ArgumentParser(prog='Install.py', description="LAMMPS library build wrapper script")

View File

@ -175,8 +175,6 @@ void FixQEqReaxFFKokkos<DeviceType>::init_hist()
template<class DeviceType> template<class DeviceType>
void FixQEqReaxFFKokkos<DeviceType>::setup_pre_force(int vflag) void FixQEqReaxFFKokkos<DeviceType>::setup_pre_force(int vflag)
{ {
//neighbor->build_one(list);
pre_force(vflag); pre_force(vflag);
} }

View File

@ -28,8 +28,8 @@ namespace LAMMPS_NS {
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
template<class DeviceType, int HALF_NEIGH, int GHOST, int TRI, int SIZE> template<class DeviceType, int HALF, int NEWTON, int GHOST, int TRI, int SIZE>
NPairKokkos<DeviceType,HALF_NEIGH,GHOST,TRI,SIZE>::NPairKokkos(LAMMPS *lmp) : NPair(lmp) { NPairKokkos<DeviceType,HALF,NEWTON,GHOST,TRI,SIZE>::NPairKokkos(LAMMPS *lmp) : NPair(lmp) {
last_stencil_old = -1; last_stencil_old = -1;
@ -49,8 +49,8 @@ NPairKokkos<DeviceType,HALF_NEIGH,GHOST,TRI,SIZE>::NPairKokkos(LAMMPS *lmp) : NP
copy needed info from Neighbor class to this build class copy needed info from Neighbor class to this build class
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
template<class DeviceType, int HALF_NEIGH, int GHOST, int TRI, int SIZE> template<class DeviceType, int HALF, int NEWTON, int GHOST, int TRI, int SIZE>
void NPairKokkos<DeviceType,HALF_NEIGH,GHOST,TRI,SIZE>::copy_neighbor_info() void NPairKokkos<DeviceType,HALF,NEWTON,GHOST,TRI,SIZE>::copy_neighbor_info()
{ {
NPair::copy_neighbor_info(); NPair::copy_neighbor_info();
@ -58,7 +58,6 @@ void NPairKokkos<DeviceType,HALF_NEIGH,GHOST,TRI,SIZE>::copy_neighbor_info()
// general params // general params
newton_pair = force->newton_pair;
k_cutneighsq = neighborKK->k_cutneighsq; k_cutneighsq = neighborKK->k_cutneighsq;
// overwrite per-type Neighbor cutoffs with custom value set by requestor // overwrite per-type Neighbor cutoffs with custom value set by requestor
@ -93,8 +92,8 @@ void NPairKokkos<DeviceType,HALF_NEIGH,GHOST,TRI,SIZE>::copy_neighbor_info()
copy per-atom and per-bin vectors from NBin class to this build class copy per-atom and per-bin vectors from NBin class to this build class
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
template<class DeviceType, int HALF_NEIGH, int GHOST, int TRI, int SIZE> template<class DeviceType, int HALF, int NEWTON, int GHOST, int TRI, int SIZE>
void NPairKokkos<DeviceType,HALF_NEIGH,GHOST,TRI,SIZE>::copy_bin_info() void NPairKokkos<DeviceType,HALF,NEWTON,GHOST,TRI,SIZE>::copy_bin_info()
{ {
NPair::copy_bin_info(); NPair::copy_bin_info();
@ -110,8 +109,8 @@ void NPairKokkos<DeviceType,HALF_NEIGH,GHOST,TRI,SIZE>::copy_bin_info()
copy needed info from NStencil class to this build class copy needed info from NStencil class to this build class
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
template<class DeviceType, int HALF_NEIGH, int GHOST, int TRI, int SIZE> template<class DeviceType, int HALF, int NEWTON, int GHOST, int TRI, int SIZE>
void NPairKokkos<DeviceType,HALF_NEIGH,GHOST,TRI,SIZE>::copy_stencil_info() void NPairKokkos<DeviceType,HALF,NEWTON,GHOST,TRI,SIZE>::copy_stencil_info()
{ {
NPair::copy_stencil_info(); NPair::copy_stencil_info();
nstencil = ns->nstencil; nstencil = ns->nstencil;
@ -145,8 +144,8 @@ void NPairKokkos<DeviceType,HALF_NEIGH,GHOST,TRI,SIZE>::copy_stencil_info()
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
template<class DeviceType, int HALF_NEIGH, int GHOST, int TRI, int SIZE> template<class DeviceType, int HALF, int NEWTON, int GHOST, int TRI, int SIZE>
void NPairKokkos<DeviceType,HALF_NEIGH,GHOST,TRI,SIZE>::build(NeighList *list_) void NPairKokkos<DeviceType,HALF,NEWTON,GHOST,TRI,SIZE>::build(NeighList *list_)
{ {
NeighListKokkos<DeviceType>* list = (NeighListKokkos<DeviceType>*) list_; NeighListKokkos<DeviceType>* list = (NeighListKokkos<DeviceType>*) list_;
const int nlocal = includegroup?atom->nfirst:atom->nlocal; const int nlocal = includegroup?atom->nfirst:atom->nlocal;
@ -244,7 +243,7 @@ void NPairKokkos<DeviceType,HALF_NEIGH,GHOST,TRI,SIZE>::build(NeighList *list_)
#endif #endif
if (GHOST) { if (GHOST) {
NPairKokkosBuildFunctorGhost<DeviceType,HALF_NEIGH> f(data,atoms_per_bin * 5 * sizeof(X_FLOAT) * factor); NPairKokkosBuildFunctorGhost<DeviceType,HALF> f(data,atoms_per_bin * 5 * sizeof(X_FLOAT) * factor);
#ifdef LMP_KOKKOS_GPU #ifdef LMP_KOKKOS_GPU
if (ExecutionSpaceFromDevice<DeviceType>::space == Device) { if (ExecutionSpaceFromDevice<DeviceType>::space == Device) {
int team_size = atoms_per_bin*factor; int team_size = atoms_per_bin*factor;
@ -262,82 +261,42 @@ void NPairKokkos<DeviceType,HALF_NEIGH,GHOST,TRI,SIZE>::build(NeighList *list_)
Kokkos::parallel_for(nall, f); Kokkos::parallel_for(nall, f);
#endif #endif
} else { } else {
if (newton_pair) { if (SIZE) {
if (SIZE) { NPairKokkosBuildFunctorSize<DeviceType,TRI?0:HALF,NEWTON,TRI> f(data,atoms_per_bin * 6 * sizeof(X_FLOAT) * factor);
NPairKokkosBuildFunctorSize<DeviceType,TRI?0:HALF_NEIGH,1,TRI> f(data,atoms_per_bin * 6 * sizeof(X_FLOAT) * factor);
#ifdef LMP_KOKKOS_GPU #ifdef LMP_KOKKOS_GPU
if (ExecutionSpaceFromDevice<DeviceType>::space == Device) { if (ExecutionSpaceFromDevice<DeviceType>::space == Device) {
int team_size = atoms_per_bin*factor; int team_size = atoms_per_bin*factor;
int team_size_max = Kokkos::TeamPolicy<DeviceType>(team_size,Kokkos::AUTO).team_size_max(f,Kokkos::ParallelForTag()); int team_size_max = Kokkos::TeamPolicy<DeviceType>(team_size,Kokkos::AUTO).team_size_max(f,Kokkos::ParallelForTag());
if (team_size <= team_size_max) { if (team_size <= team_size_max) {
Kokkos::TeamPolicy<DeviceType> config((mbins+factor-1)/factor,team_size); Kokkos::TeamPolicy<DeviceType> config((mbins+factor-1)/factor,team_size);
Kokkos::parallel_for(config, f); Kokkos::parallel_for(config, f);
} else { // fall back to flat method } else { // fall back to flat method
f.sharedsize = 0; f.sharedsize = 0;
Kokkos::parallel_for(nall, f);
}
} else
Kokkos::parallel_for(nall, f); Kokkos::parallel_for(nall, f);
#else }
} else
Kokkos::parallel_for(nall, f); Kokkos::parallel_for(nall, f);
#endif
} else {
NPairKokkosBuildFunctor<DeviceType,TRI?0:HALF_NEIGH,1,TRI> f(data,atoms_per_bin * 5 * sizeof(X_FLOAT) * factor);
#ifdef LMP_KOKKOS_GPU
if (ExecutionSpaceFromDevice<DeviceType>::space == Device) {
int team_size = atoms_per_bin*factor;
int team_size_max = Kokkos::TeamPolicy<DeviceType>(team_size,Kokkos::AUTO).team_size_max(f,Kokkos::ParallelForTag());
if (team_size <= team_size_max) {
Kokkos::TeamPolicy<DeviceType> config((mbins+factor-1)/factor,team_size);
Kokkos::parallel_for(config, f);
} else { // fall back to flat method
f.sharedsize = 0;
Kokkos::parallel_for(nall, f);
}
} else
Kokkos::parallel_for(nall, f);
#else #else
Kokkos::parallel_for(nall, f); Kokkos::parallel_for(nall, f);
#endif #endif
}
} else { } else {
if (SIZE) { NPairKokkosBuildFunctor<DeviceType,TRI?0:HALF,NEWTON,TRI> f(data,atoms_per_bin * 5 * sizeof(X_FLOAT) * factor);
NPairKokkosBuildFunctorSize<DeviceType,HALF_NEIGH,0,0> f(data,atoms_per_bin * 5 * sizeof(X_FLOAT) * factor);
#ifdef LMP_KOKKOS_GPU #ifdef LMP_KOKKOS_GPU
if (ExecutionSpaceFromDevice<DeviceType>::space == Device) { if (ExecutionSpaceFromDevice<DeviceType>::space == Device) {
int team_size = atoms_per_bin*factor; int team_size = atoms_per_bin*factor;
int team_size_max = Kokkos::TeamPolicy<DeviceType>(team_size,Kokkos::AUTO).team_size_max(f,Kokkos::ParallelForTag()); int team_size_max = Kokkos::TeamPolicy<DeviceType>(team_size,Kokkos::AUTO).team_size_max(f,Kokkos::ParallelForTag());
if (team_size <= team_size_max) { if (team_size <= team_size_max) {
Kokkos::TeamPolicy<DeviceType> config((mbins+factor-1)/factor,team_size); Kokkos::TeamPolicy<DeviceType> config((mbins+factor-1)/factor,team_size);
Kokkos::parallel_for(config, f); Kokkos::parallel_for(config, f);
} else { // fall back to flat method } else { // fall back to flat method
f.sharedsize = 0; f.sharedsize = 0;
Kokkos::parallel_for(nall, f);
}
} else
Kokkos::parallel_for(nall, f); Kokkos::parallel_for(nall, f);
#else }
} else
Kokkos::parallel_for(nall, f); Kokkos::parallel_for(nall, f);
#endif
} else {
NPairKokkosBuildFunctor<DeviceType,HALF_NEIGH,0,0> f(data,atoms_per_bin * 5 * sizeof(X_FLOAT) * factor);
#ifdef LMP_KOKKOS_GPU
if (ExecutionSpaceFromDevice<DeviceType>::space == Device) {
int team_size = atoms_per_bin*factor;
int team_size_max = Kokkos::TeamPolicy<DeviceType>(team_size,Kokkos::AUTO).team_size_max(f,Kokkos::ParallelForTag());
if (team_size <= team_size_max) {
Kokkos::TeamPolicy<DeviceType> config((mbins+factor-1)/factor,team_size);
Kokkos::parallel_for(config, f);
} else { // fall back to flat method
f.sharedsize = 0;
Kokkos::parallel_for(nall, f);
}
} else
Kokkos::parallel_for(nall, f);
#else #else
Kokkos::parallel_for(nall, f); Kokkos::parallel_for(nall, f);
#endif #endif
}
} }
} }
Kokkos::deep_copy(h_scalars, d_scalars); Kokkos::deep_copy(h_scalars, d_scalars);
@ -1402,20 +1361,30 @@ void NeighborKokkosExecute<DeviceType>::build_ItemSizeGPU(typename Kokkos::TeamP
} }
namespace LAMMPS_NS { namespace LAMMPS_NS {
template class NPairKokkos<LMPDeviceType,0,0,0,0>; template class NPairKokkos<LMPDeviceType,0,0,0,0,0>;
template class NPairKokkos<LMPDeviceType,0,1,0,0>; template class NPairKokkos<LMPDeviceType,0,0,1,0,0>;
template class NPairKokkos<LMPDeviceType,1,0,0,0>; template class NPairKokkos<LMPDeviceType,1,1,0,0,0>;
template class NPairKokkos<LMPDeviceType,1,1,0,0>; template class NPairKokkos<LMPDeviceType,1,0,0,0,0>;
template class NPairKokkos<LMPDeviceType,1,0,1,0>; template class NPairKokkos<LMPDeviceType,1,1,1,0,0>;
template class NPairKokkos<LMPDeviceType,1,0,0,1>; template class NPairKokkos<LMPDeviceType,1,0,1,0,0>;
template class NPairKokkos<LMPDeviceType,1,0,1,1>; template class NPairKokkos<LMPDeviceType,1,1,0,1,0>;
template class NPairKokkos<LMPDeviceType,1,0,0,1,0>;
template class NPairKokkos<LMPDeviceType,1,1,0,0,1>;
template class NPairKokkos<LMPDeviceType,1,0,0,0,1>;
template class NPairKokkos<LMPDeviceType,1,1,0,1,1>;
template class NPairKokkos<LMPDeviceType,1,0,0,1,1>;
#ifdef LMP_KOKKOS_GPU #ifdef LMP_KOKKOS_GPU
template class NPairKokkos<LMPHostType,0,0,0,0>; template class NPairKokkos<LMPHostType,0,0,0,0,0>;
template class NPairKokkos<LMPHostType,0,1,0,0>; template class NPairKokkos<LMPHostType,0,0,1,0,0>;
template class NPairKokkos<LMPHostType,1,0,0,0>; template class NPairKokkos<LMPHostType,1,1,0,0,0>;
template class NPairKokkos<LMPHostType,1,1,0,0>; template class NPairKokkos<LMPHostType,1,0,0,0,0>;
template class NPairKokkos<LMPHostType,1,0,1,0>; template class NPairKokkos<LMPHostType,1,1,1,0,0>;
template class NPairKokkos<LMPHostType,1,0,0,1>; template class NPairKokkos<LMPHostType,1,0,1,0,0>;
template class NPairKokkos<LMPHostType,1,0,1,1>; template class NPairKokkos<LMPHostType,1,1,0,1,0>;
template class NPairKokkos<LMPHostType,1,0,0,1,0>;
template class NPairKokkos<LMPHostType,1,1,0,0,1>;
template class NPairKokkos<LMPHostType,1,0,0,0,1>;
template class NPairKokkos<LMPHostType,1,1,0,1,1>;
template class NPairKokkos<LMPHostType,1,0,0,1,1>;
#endif #endif
} }

View File

@ -13,75 +13,125 @@
#ifdef NPAIR_CLASS #ifdef NPAIR_CLASS
// clang-format off // clang-format off
typedef NPairKokkos<LMPHostType,0,0,0,0> NPairKokkosFullBinHost; typedef NPairKokkos<LMPHostType,0,0,0,0,0> NPairKokkosFullBinHost;
NPairStyle(full/bin/kk/host, NPairStyle(full/bin/kk/host,
NPairKokkosFullBinHost, NPairKokkosFullBinHost,
NP_FULL | NP_BIN | NP_KOKKOS_HOST | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); NP_BIN | NP_KOKKOS_HOST | NP_FULL | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI);
typedef NPairKokkos<LMPDeviceType,0,0,0,0> NPairKokkosFullBinDevice; typedef NPairKokkos<LMPDeviceType,0,0,0,0,0> NPairKokkosFullBinDevice;
NPairStyle(full/bin/kk/device, NPairStyle(full/bin/kk/device,
NPairKokkosFullBinDevice, NPairKokkosFullBinDevice,
NP_FULL | NP_BIN | NP_KOKKOS_DEVICE | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); NP_BIN | NP_KOKKOS_DEVICE | NP_FULL | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI);
typedef NPairKokkos<LMPHostType,0,1,0,0> NPairKokkosFullBinGhostHost; typedef NPairKokkos<LMPHostType,0,0,1,0,0> NPairKokkosFullBinGhostHost;
NPairStyle(full/bin/ghost/kk/host, NPairStyle(full/bin/ghost/kk/host,
NPairKokkosFullBinGhostHost, NPairKokkosFullBinGhostHost,
NP_FULL | NP_BIN | NP_KOKKOS_HOST | NP_NEWTON | NP_NEWTOFF | NP_GHOST | NP_ORTHO | NP_TRI); NP_BIN | NP_KOKKOS_HOST | NP_FULL | NP_NEWTON | NP_NEWTOFF | NP_GHOST | NP_ORTHO | NP_TRI);
typedef NPairKokkos<LMPDeviceType,0,1,0,0> NPairKokkosFullBinGhostDevice; typedef NPairKokkos<LMPDeviceType,0,0,1,0,0> NPairKokkosFullBinGhostDevice;
NPairStyle(full/bin/ghost/kk/device, NPairStyle(full/bin/ghost/kk/device,
NPairKokkosFullBinGhostDevice, NPairKokkosFullBinGhostDevice,
NP_FULL | NP_BIN | NP_KOKKOS_DEVICE | NP_NEWTON | NP_NEWTOFF | NP_GHOST | NP_ORTHO | NP_TRI); NP_BIN | NP_KOKKOS_DEVICE | NP_FULL | NP_NEWTON | NP_NEWTOFF | NP_GHOST | NP_ORTHO | NP_TRI);
typedef NPairKokkos<LMPHostType,1,0,0,0> NPairKokkosHalfBinHost; typedef NPairKokkos<LMPHostType,1,1,0,0,0> NPairKokkosHalfBinNewtonHost;
NPairStyle(half/bin/kk/host, NPairStyle(half/bin/newton/kk/host,
NPairKokkosHalfBinHost, NPairKokkosHalfBinNewtonHost,
NP_HALF | NP_BIN | NP_KOKKOS_HOST | NP_NEWTON | NP_NEWTOFF | NP_ORTHO); NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTON | NP_ORTHO);
typedef NPairKokkos<LMPDeviceType,1,0,0,0> NPairKokkosHalfBinDevice; typedef NPairKokkos<LMPHostType,1,0,0,0,0> NPairKokkosHalfBinNewtoffHost;
NPairStyle(half/bin/kk/device, NPairStyle(half/bin/newtoff/kk/host,
NPairKokkosHalfBinDevice, NPairKokkosHalfBinNewtoffHost,
NP_HALF | NP_BIN | NP_KOKKOS_DEVICE | NP_NEWTON | NP_NEWTOFF | NP_ORTHO); NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTOFF | NP_ORTHO);
typedef NPairKokkos<LMPHostType,1,0,1,0> NPairKokkosHalfBinHostTri; typedef NPairKokkos<LMPDeviceType,1,1,0,0,0> NPairKokkosHalfBinNewtonDevice;
NPairStyle(half/bin/kk/host, NPairStyle(half/bin/newton/kk/device,
NPairKokkosHalfBinHostTri, NPairKokkosHalfBinNewtonDevice,
NP_HALF | NP_BIN | NP_KOKKOS_HOST | NP_NEWTON | NP_NEWTOFF | NP_TRI); NP_KOKKOS_DEVICE | NP_HALF | NP_BIN | NP_NEWTON | NP_ORTHO);
typedef NPairKokkos<LMPDeviceType,1,0,1,0> NPairKokkosHalfBinDeviceTri; typedef NPairKokkos<LMPDeviceType,1,0,0,0,0> NPairKokkosHalfBinNewtoffDevice;
NPairStyle(half/bin/kk/device, NPairStyle(half/bin/newtoff/kk/device,
NPairKokkosHalfBinDeviceTri, NPairKokkosHalfBinNewtoffDevice,
NP_HALF | NP_BIN | NP_KOKKOS_DEVICE | NP_NEWTON | NP_NEWTOFF | NP_TRI); NP_KOKKOS_DEVICE | NP_HALF | NP_BIN | NP_NEWTOFF | NP_ORTHO);
typedef NPairKokkos<LMPHostType,1,1,0,0> NPairKokkosHalfBinGhostHost; typedef NPairKokkos<LMPHostType,1,1,0,1,0> NPairKokkosHalfBinNewtonTriHost;
NPairStyle(half/bin/ghost/kk/host, NPairStyle(half/bin/newton/kk/host,
NPairKokkosHalfBinGhostHost, NPairKokkosHalfBinNewtonTriHost,
NP_HALF | NP_BIN | NP_KOKKOS_HOST | NP_NEWTON | NP_NEWTOFF | NP_GHOST | NP_ORTHO | NP_TRI); NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTON | NP_TRI);
typedef NPairKokkos<LMPDeviceType,1,1,0,0> NPairKokkosHalfBinGhostDevice; typedef NPairKokkos<LMPHostType,1,0,0,1,0> NPairKokkosHalfBinNewtoffTriHost;
NPairStyle(half/bin/ghost/kk/device, NPairStyle(half/bin/newtoff/kk/host,
NPairKokkosHalfBinGhostDevice, NPairKokkosHalfBinNewtoffTriHost,
NP_HALF | NP_BIN | NP_KOKKOS_DEVICE | NP_NEWTON | NP_NEWTOFF | NP_GHOST | NP_ORTHO | NP_TRI); NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTOFF | NP_TRI);
typedef NPairKokkos<LMPHostType,1,0,0,1> NPairKokkosHalfSizeBinHost; typedef NPairKokkos<LMPDeviceType,1,1,0,1,0> NPairKokkosHalfBinNewtonTriDevice;
NPairStyle(half/size/bin/kk/host, NPairStyle(half/bin/newton/kk/device,
NPairKokkosHalfSizeBinHost, NPairKokkosHalfBinNewtonTriDevice,
NP_HALF | NP_SIZE | NP_BIN | NP_KOKKOS_HOST | NP_NEWTON | NP_NEWTOFF | NP_ORTHO); NP_KOKKOS_DEVICE | NP_HALF | NP_BIN | NP_NEWTON | NP_TRI);
typedef NPairKokkos<LMPDeviceType,1,0,0,1> NPairKokkosHalfSizeBinDevice; typedef NPairKokkos<LMPDeviceType,1,0,0,1,0> NPairKokkosHalfBinNewtoffTriDevice;
NPairStyle(half/size/bin/kk/device, NPairStyle(half/bin/newtoff/kk/device,
NPairKokkosHalfSizeBinDevice, NPairKokkosHalfBinNewtoffTriDevice,
NP_HALF | NP_SIZE | NP_BIN | NP_KOKKOS_DEVICE | NP_NEWTON | NP_NEWTOFF | NP_ORTHO); NP_KOKKOS_DEVICE | NP_HALF | NP_BIN | NP_NEWTOFF | NP_TRI);
typedef NPairKokkos<LMPHostType,1,0,1,1> NPairKokkosHalfSizeBinHostTri; typedef NPairKokkos<LMPHostType,1,1,1,0,0> NPairKokkosHalfBinNewtonGhostHost;
NPairStyle(half/size/bin/kk/host, NPairStyle(half/bin/newton/ghost/kk/host,
NPairKokkosHalfSizeBinHostTri, NPairKokkosHalfBinNewtonGhostHost,
NP_HALF | NP_SIZE | NP_BIN | NP_KOKKOS_HOST | NP_NEWTON | NP_NEWTOFF | NP_TRI); NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTON | NP_GHOST | NP_ORTHO | NP_TRI);
typedef NPairKokkos<LMPDeviceType,1,0,1,1> NPairKokkosHalfSizeBinDeviceTri; typedef NPairKokkos<LMPHostType,1,0,1,0,0> NPairKokkosHalfBinNewtoffGhostHost;
NPairStyle(half/size/bin/kk/device, NPairStyle(half/bin/newtoff/ghost/kk/host,
NPairKokkosHalfSizeBinDeviceTri, NPairKokkosHalfBinNewtoffGhostHost,
NP_HALF | NP_SIZE | NP_BIN | NP_KOKKOS_DEVICE | NP_NEWTON | NP_NEWTOFF | NP_TRI); NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTOFF | NP_GHOST | NP_ORTHO | NP_TRI);
typedef NPairKokkos<LMPDeviceType,1,1,1,0,0> NPairKokkosHalfBinNewtonGhostDevice;
NPairStyle(half/bin/newton/ghost/kk/device,
NPairKokkosHalfBinNewtonGhostDevice,
NP_KOKKOS_DEVICE | NP_HALF | NP_BIN | NP_NEWTON | NP_GHOST | NP_ORTHO | NP_TRI);
typedef NPairKokkos<LMPDeviceType,1,0,1,0,0> NPairKokkosHalfBinNewtoffGhostDevice;
NPairStyle(half/bin/newtoff/ghost/kk/device,
NPairKokkosHalfBinNewtoffGhostDevice,
NP_KOKKOS_DEVICE | NP_HALF | NP_BIN | NP_NEWTOFF | NP_GHOST | NP_ORTHO | NP_TRI);
typedef NPairKokkos<LMPHostType,1,1,0,0,1> NPairKokkosHalfBinNewtonSizeHost;
NPairStyle(half/bin/newton/size/kk/host,
NPairKokkosHalfBinNewtonSizeHost,
NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTON | NP_SIZE | NP_ORTHO);
typedef NPairKokkos<LMPHostType,1,0,0,0,1> NPairKokkosHalfBinNewtoffSizeHost;
NPairStyle(half/bin/newtoff/size/kk/host,
NPairKokkosHalfBinNewtoffSizeHost,
NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTOFF | NP_SIZE | NP_ORTHO);
typedef NPairKokkos<LMPDeviceType,1,1,0,0,1> NPairKokkosHalfBinNewtonSizeDevice;
NPairStyle(half/bin/newton/size/kk/device,
NPairKokkosHalfBinNewtonSizeDevice,
NP_KOKKOS_DEVICE | NP_HALF | NP_BIN | NP_NEWTON | NP_SIZE | NP_ORTHO);
typedef NPairKokkos<LMPDeviceType,1,0,0,0,1> NPairKokkosHalfBinNewtoffSizeDevice;
NPairStyle(half/bin/newtoff/size/kk/device,
NPairKokkosHalfBinNewtoffSizeDevice,
NP_KOKKOS_DEVICE | NP_HALF | NP_BIN | NP_NEWTOFF | NP_SIZE | NP_ORTHO);
typedef NPairKokkos<LMPHostType,1,1,0,1,1> NPairKokkosHalfBinNewtonSizeTriHost;
NPairStyle(half/bin/newton/size/kk/host,
NPairKokkosHalfBinNewtonSizeTriHost,
NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTON | NP_SIZE | NP_TRI);
typedef NPairKokkos<LMPHostType,1,0,0,1,1> NPairKokkosHalfBinNewtoffSizeTriHost;
NPairStyle(half/bin/newtoff/size/kk/host,
NPairKokkosHalfBinNewtoffSizeTriHost,
NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTOFF | NP_SIZE | NP_TRI);
typedef NPairKokkos<LMPDeviceType,1,1,0,1,1> NPairKokkosHalfBinNewtonSizeTriDevice;
NPairStyle(half/bin/newton/size/kk/device,
NPairKokkosHalfBinNewtonSizeTriDevice,
NP_KOKKOS_DEVICE | NP_HALF | NP_BIN | NP_NEWTON | NP_SIZE | NP_TRI);
typedef NPairKokkos<LMPDeviceType,1,0,0,1,1> NPairKokkosHalfBinNewtoffSizeTriDevice;
NPairStyle(half/bin/newtoff/size/kk/device,
NPairKokkosHalfBinNewtoffSizeTriDevice,
NP_KOKKOS_DEVICE | NP_HALF | NP_BIN | NP_NEWTOFF | NP_SIZE | NP_TRI);
// clang-format on // clang-format on
#else #else
@ -94,7 +144,7 @@ NPairStyle(half/size/bin/kk/device,
namespace LAMMPS_NS { namespace LAMMPS_NS {
template<class DeviceType, int HALF_NEIGH, int GHOST, int TRI, int SIZE> template<class DeviceType, int HALF_NEIGH, int NEWTON, int GHOST, int TRI, int SIZE>
class NPairKokkos : public NPair { class NPairKokkos : public NPair {
typedef ArrayTypes<DeviceType> AT; typedef ArrayTypes<DeviceType> AT;
@ -379,7 +429,7 @@ class NeighborKokkosExecute
}; };
template<class DeviceType, int HALF_NEIGH, int GHOST_NEWTON, int TRI> template<class DeviceType, int HALF_NEIGH, int NEWTON, int TRI>
struct NPairKokkosBuildFunctor { struct NPairKokkosBuildFunctor {
typedef DeviceType device_type; typedef DeviceType device_type;
@ -392,19 +442,19 @@ struct NPairKokkosBuildFunctor {
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
void operator() (const int & i) const { void operator() (const int & i) const {
c.template build_Item<HALF_NEIGH,GHOST_NEWTON,TRI>(i); c.template build_Item<HALF_NEIGH,NEWTON,TRI>(i);
} }
#ifdef LMP_KOKKOS_GPU #ifdef LMP_KOKKOS_GPU
LAMMPS_DEVICE_FUNCTION inline LAMMPS_DEVICE_FUNCTION inline
void operator() (typename Kokkos::TeamPolicy<DeviceType>::member_type dev) const { void operator() (typename Kokkos::TeamPolicy<DeviceType>::member_type dev) const {
c.template build_ItemGPU<HALF_NEIGH,GHOST_NEWTON,TRI>(dev, sharedsize); c.template build_ItemGPU<HALF_NEIGH,NEWTON,TRI>(dev, sharedsize);
} }
size_t team_shmem_size(const int team_size) const { (void) team_size; return sharedsize; } size_t team_shmem_size(const int team_size) const { (void) team_size; return sharedsize; }
#endif #endif
}; };
template<int HALF_NEIGH, int GHOST_NEWTON, int TRI> template<int HALF_NEIGH, int NEWTON, int TRI>
struct NPairKokkosBuildFunctor<LMPHostType,HALF_NEIGH,GHOST_NEWTON,TRI> { struct NPairKokkosBuildFunctor<LMPHostType,HALF_NEIGH,NEWTON,TRI> {
typedef LMPHostType device_type; typedef LMPHostType device_type;
const NeighborKokkosExecute<LMPHostType> c; const NeighborKokkosExecute<LMPHostType> c;
@ -416,7 +466,7 @@ struct NPairKokkosBuildFunctor<LMPHostType,HALF_NEIGH,GHOST_NEWTON,TRI> {
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
void operator() (const int & i) const { void operator() (const int & i) const {
c.template build_Item<HALF_NEIGH,GHOST_NEWTON,TRI>(i); c.template build_Item<HALF_NEIGH,NEWTON,TRI>(i);
} }
void operator() (typename Kokkos::TeamPolicy<LMPHostType>::member_type /*dev*/) const {} // Should error out void operator() (typename Kokkos::TeamPolicy<LMPHostType>::member_type /*dev*/) const {} // Should error out
@ -466,7 +516,7 @@ struct NPairKokkosBuildFunctorGhost<LMPHostType,HALF_NEIGH> {
void operator() (typename Kokkos::TeamPolicy<LMPHostType>::member_type /*dev*/) const {} // Should error out void operator() (typename Kokkos::TeamPolicy<LMPHostType>::member_type /*dev*/) const {} // Should error out
}; };
template <class DeviceType, int HALF_NEIGH, int GHOST_NEWTON, int TRI> template <class DeviceType, int HALF_NEIGH, int NEWTON, int TRI>
struct NPairKokkosBuildFunctorSize { struct NPairKokkosBuildFunctorSize {
typedef DeviceType device_type; typedef DeviceType device_type;
@ -478,20 +528,20 @@ struct NPairKokkosBuildFunctorSize {
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
void operator() (const int & i) const { void operator() (const int & i) const {
c.template build_ItemSize<HALF_NEIGH,GHOST_NEWTON,TRI>(i); c.template build_ItemSize<HALF_NEIGH,NEWTON,TRI>(i);
} }
#ifdef LMP_KOKKOS_GPU #ifdef LMP_KOKKOS_GPU
LAMMPS_DEVICE_FUNCTION inline LAMMPS_DEVICE_FUNCTION inline
void operator() (typename Kokkos::TeamPolicy<DeviceType>::member_type dev) const { void operator() (typename Kokkos::TeamPolicy<DeviceType>::member_type dev) const {
c.template build_ItemSizeGPU<HALF_NEIGH,GHOST_NEWTON,TRI>(dev, sharedsize); c.template build_ItemSizeGPU<HALF_NEIGH,NEWTON,TRI>(dev, sharedsize);
} }
size_t team_shmem_size(const int team_size) const { (void) team_size; return sharedsize; } size_t team_shmem_size(const int team_size) const { (void) team_size; return sharedsize; }
#endif #endif
}; };
template <int HALF_NEIGH, int GHOST_NEWTON, int TRI> template <int HALF_NEIGH, int NEWTON, int TRI>
struct NPairKokkosBuildFunctorSize<LMPHostType,HALF_NEIGH,GHOST_NEWTON,TRI> { struct NPairKokkosBuildFunctorSize<LMPHostType,HALF_NEIGH,NEWTON,TRI> {
typedef LMPHostType device_type; typedef LMPHostType device_type;
const NeighborKokkosExecute<LMPHostType> c; const NeighborKokkosExecute<LMPHostType> c;
@ -502,7 +552,7 @@ struct NPairKokkosBuildFunctorSize<LMPHostType,HALF_NEIGH,GHOST_NEWTON,TRI> {
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
void operator() (const int & i) const { void operator() (const int & i) const {
c.template build_ItemSize<HALF_NEIGH,GHOST_NEWTON,TRI>(i); c.template build_ItemSize<HALF_NEIGH,NEWTON,TRI>(i);
} }
void operator() (typename Kokkos::TeamPolicy<LMPHostType>::member_type /*dev*/) const {} // Should error out void operator() (typename Kokkos::TeamPolicy<LMPHostType>::member_type /*dev*/) const {} // Should error out

View File

@ -130,6 +130,7 @@ void PairLJCutKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
if (vflag_fdotr) pair_virial_fdotr_compute(this); if (vflag_fdotr) pair_virial_fdotr_compute(this);
copymode = 0;
} }
template<class DeviceType> template<class DeviceType>

View File

@ -95,6 +95,8 @@ PairReaxFFKokkos<DeviceType>::~PairReaxFFKokkos()
{ {
if (copymode) return; if (copymode) return;
DeAllocate_System(api->system);
memoryKK->destroy_kokkos(k_eatom,eatom); memoryKK->destroy_kokkos(k_eatom,eatom);
memoryKK->destroy_kokkos(k_vatom,vatom); memoryKK->destroy_kokkos(k_vatom,vatom);
@ -184,6 +186,8 @@ void PairReaxFFKokkos<DeviceType>::init_style()
if (neighflag == FULL) if (neighflag == FULL)
error->all(FLERR,"Must use half neighbor list with pair style reaxff/kk"); error->all(FLERR,"Must use half neighbor list with pair style reaxff/kk");
need_dup = lmp->kokkos->need_dup<DeviceType>();
allocate(); allocate();
setup(); setup();
init_md(); init_md();
@ -577,17 +581,17 @@ void PairReaxFFKokkos<DeviceType>::Deallocate_Lookup_Tables()
for (j = i; j <= ntypes; ++j) { for (j = i; j <= ntypes; ++j) {
if (map[i] == -1) continue; if (map[i] == -1) continue;
if (LR[i][j].n) { if (LR[i][j].n) {
sfree(api->control->error_ptr, LR[i][j].y, "LR[i,j].y"); sfree(LR[i][j].y);
sfree(api->control->error_ptr, LR[i][j].H, "LR[i,j].H"); sfree(LR[i][j].H);
sfree(api->control->error_ptr, LR[i][j].vdW, "LR[i,j].vdW"); sfree(LR[i][j].vdW);
sfree(api->control->error_ptr, LR[i][j].CEvd, "LR[i,j].CEvd"); sfree(LR[i][j].CEvd);
sfree(api->control->error_ptr, LR[i][j].ele, "LR[i,j].ele"); sfree(LR[i][j].ele);
sfree(api->control->error_ptr, LR[i][j].CEclmb, "LR[i,j].CEclmb"); sfree(LR[i][j].CEclmb);
} }
} }
sfree(api->control->error_ptr, LR[i], "LR[i]"); sfree(LR[i]);
} }
sfree(api->control->error_ptr, LR, "LR"); sfree(LR);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -738,8 +742,6 @@ void PairReaxFFKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
} }
} }
need_dup = lmp->kokkos->need_dup<DeviceType>();
// allocate duplicated memory // allocate duplicated memory
if (need_dup) { if (need_dup) {
dup_f = Kokkos::Experimental::create_scatter_view<Kokkos::Experimental::ScatterSum, Kokkos::Experimental::ScatterDuplicated>(f); dup_f = Kokkos::Experimental::create_scatter_view<Kokkos::Experimental::ScatterSum, Kokkos::Experimental::ScatterDuplicated>(f);

View File

@ -47,7 +47,6 @@ PairSWKokkos<DeviceType>::PairSWKokkos(LAMMPS *lmp) : PairSW(lmp)
{ {
respa_enable = 0; respa_enable = 0;
kokkosable = 1; kokkosable = 1;
atomKK = (AtomKokkos *) atom; atomKK = (AtomKokkos *) atom;
execution_space = ExecutionSpaceFromDevice<DeviceType>::space; execution_space = ExecutionSpaceFromDevice<DeviceType>::space;
@ -138,6 +137,7 @@ void PairSWKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
} }
if ((int)d_numneigh_short.extent(0) < ignum) if ((int)d_numneigh_short.extent(0) < ignum)
d_numneigh_short = Kokkos::View<int*,DeviceType>("SW::numneighs_short",ignum*1.2); d_numneigh_short = Kokkos::View<int*,DeviceType>("SW::numneighs_short",ignum*1.2);
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType,TagPairSWComputeShortNeigh>(0,inum), *this); Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType,TagPairSWComputeShortNeigh>(0,inum), *this);
// loop over neighbor list of my atoms // loop over neighbor list of my atoms

View File

@ -117,24 +117,23 @@ void PairVashishtaKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
EV_FLOAT ev; EV_FLOAT ev;
EV_FLOAT ev_all; EV_FLOAT ev_all;
// build short neighbor list
int max_neighs = d_neighbors.extent(1); int max_neighs = d_neighbors.extent(1);
if (((int)d_neighbors_short_2body.extent(1) != max_neighs) || if (((int)d_neighbors_short_2body.extent(1) < max_neighs) ||
((int)d_neighbors_short_2body.extent(0) != ignum)) { ((int)d_neighbors_short_2body.extent(0) < ignum)) {
d_neighbors_short_2body = Kokkos::View<int**,DeviceType>("Vashishta::neighbors_short_2body",ignum,max_neighs); d_neighbors_short_2body = Kokkos::View<int**,DeviceType>("Vashishta::neighbors_short_2body",ignum*1.2,max_neighs);
}
if ((int)d_numneigh_short_2body.extent(0)!=ignum) {
d_numneigh_short_2body = Kokkos::View<int*,DeviceType>("Vashishta::numneighs_short_2body",ignum);
} }
if ((int)d_numneigh_short_2body.extent(0) < ignum)
d_numneigh_short_2body = Kokkos::View<int*,DeviceType>("Vashishta::numneighs_short_2body",ignum*1.2);
if (((int)d_neighbors_short_3body.extent(1) != max_neighs) || if (((int)d_neighbors_short_3body.extent(1) < max_neighs) ||
((int)d_neighbors_short_3body.extent(0) != ignum)) { ((int)d_neighbors_short_3body.extent(0) < ignum)) {
d_neighbors_short_3body = Kokkos::View<int**,DeviceType>("Vashishta::neighbors_short_3body",ignum,max_neighs); d_neighbors_short_3body = Kokkos::View<int**,DeviceType>("Vashishta::neighbors_short_3body",ignum*1.2,max_neighs);
}
if ((int)d_numneigh_short_3body.extent(0)!=ignum) {
d_numneigh_short_3body = Kokkos::View<int*,DeviceType>("Vashishta::numneighs_short_3body",ignum);
} }
if ((int)d_numneigh_short_3body.extent(0) < ignum)
d_numneigh_short_3body = Kokkos::View<int*,DeviceType>("Vashishta::numneighs_short_3body",ignum*1.2);
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType,TagPairVashishtaComputeShortNeigh>(0,neighflag==FULL?ignum:inum), *this); Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType,TagPairVashishtaComputeShortNeigh>(0,neighflag==FULL?ignum:inum), *this);
@ -217,17 +216,17 @@ void PairVashishtaKokkos<DeviceType>::operator()(TagPairVashishtaComputeShortNei
const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; const F_FLOAT rsq = delx*delx + dely*dely + delz*delz;
if (rsq < d_params[ijparam].cutsq) { if (rsq < d_params[ijparam].cutsq) {
d_neighbors_short_2body(i,inside_2body) = j; d_neighbors_short_2body(ii,inside_2body) = j;
inside_2body++; inside_2body++;
} }
if (rsq < d_params[ijparam].cutsq2) { if (rsq < d_params[ijparam].cutsq2) {
d_neighbors_short_3body(i,inside_3body) = j; d_neighbors_short_3body(ii,inside_3body) = j;
inside_3body++; inside_3body++;
} }
} }
d_numneigh_short_2body(i) = inside_2body; d_numneigh_short_2body(ii) = inside_2body;
d_numneigh_short_3body(i) = inside_3body; d_numneigh_short_3body(ii) = inside_3body;
} }
template<class DeviceType> template<class DeviceType>
@ -252,14 +251,14 @@ void PairVashishtaKokkos<DeviceType>::operator()(TagPairVashishtaComputeHalf<NEI
// two-body interactions, skip half of them // two-body interactions, skip half of them
const int jnum = d_numneigh_short_2body[i]; const int jnum = d_numneigh_short_2body[ii];
F_FLOAT fxtmpi = 0.0; F_FLOAT fxtmpi = 0.0;
F_FLOAT fytmpi = 0.0; F_FLOAT fytmpi = 0.0;
F_FLOAT fztmpi = 0.0; F_FLOAT fztmpi = 0.0;
for (int jj = 0; jj < jnum; jj++) { for (int jj = 0; jj < jnum; jj++) {
int j = d_neighbors_short_2body(i,jj); int j = d_neighbors_short_2body(ii,jj);
j &= NEIGHMASK; j &= NEIGHMASK;
const tagint jtag = tag[j]; const tagint jtag = tag[j];
@ -297,10 +296,10 @@ void PairVashishtaKokkos<DeviceType>::operator()(TagPairVashishtaComputeHalf<NEI
} }
} }
const int jnumm1 = d_numneigh_short_3body[i]; const int jnumm1 = d_numneigh_short_3body[ii];
for (int jj = 0; jj < jnumm1-1; jj++) { for (int jj = 0; jj < jnumm1-1; jj++) {
int j = d_neighbors_short_3body(i,jj); int j = d_neighbors_short_3body(ii,jj);
j &= NEIGHMASK; j &= NEIGHMASK;
const int jtype = d_map[type[j]]; const int jtype = d_map[type[j]];
const int ijparam = d_elem3param(itype,jtype,jtype); const int ijparam = d_elem3param(itype,jtype,jtype);
@ -314,7 +313,7 @@ void PairVashishtaKokkos<DeviceType>::operator()(TagPairVashishtaComputeHalf<NEI
F_FLOAT fztmpj = 0.0; F_FLOAT fztmpj = 0.0;
for (int kk = jj+1; kk < jnumm1; kk++) { for (int kk = jj+1; kk < jnumm1; kk++) {
int k = d_neighbors_short_3body(i,kk); int k = d_neighbors_short_3body(ii,kk);
k &= NEIGHMASK; k &= NEIGHMASK;
const int ktype = d_map[type[k]]; const int ktype = d_map[type[k]];
const int ikparam = d_elem3param(itype,ktype,ktype); const int ikparam = d_elem3param(itype,ktype,ktype);
@ -382,14 +381,14 @@ void PairVashishtaKokkos<DeviceType>::operator()(TagPairVashishtaComputeFullA<NE
// two-body interactions // two-body interactions
const int jnum = d_numneigh_short_2body[i]; const int jnum = d_numneigh_short_2body[ii];
F_FLOAT fxtmpi = 0.0; F_FLOAT fxtmpi = 0.0;
F_FLOAT fytmpi = 0.0; F_FLOAT fytmpi = 0.0;
F_FLOAT fztmpi = 0.0; F_FLOAT fztmpi = 0.0;
for (int jj = 0; jj < jnum; jj++) { for (int jj = 0; jj < jnum; jj++) {
int j = d_neighbors_short_2body(i,jj); int j = d_neighbors_short_2body(ii,jj);
j &= NEIGHMASK; j &= NEIGHMASK;
const int jtype = d_map[type[j]]; const int jtype = d_map[type[j]];
@ -413,10 +412,10 @@ void PairVashishtaKokkos<DeviceType>::operator()(TagPairVashishtaComputeFullA<NE
} }
} }
const int jnumm1 = d_numneigh_short_3body[i]; const int jnumm1 = d_numneigh_short_3body[ii];
for (int jj = 0; jj < jnumm1-1; jj++) { for (int jj = 0; jj < jnumm1-1; jj++) {
int j = d_neighbors_short_3body(i,jj); int j = d_neighbors_short_3body(ii,jj);
j &= NEIGHMASK; j &= NEIGHMASK;
const int jtype = d_map[type[j]]; const int jtype = d_map[type[j]];
const int ijparam = d_elem3param(itype,jtype,jtype); const int ijparam = d_elem3param(itype,jtype,jtype);
@ -426,7 +425,7 @@ void PairVashishtaKokkos<DeviceType>::operator()(TagPairVashishtaComputeFullA<NE
const F_FLOAT rsq1 = delr1[0]*delr1[0] + delr1[1]*delr1[1] + delr1[2]*delr1[2]; const F_FLOAT rsq1 = delr1[0]*delr1[0] + delr1[1]*delr1[1] + delr1[2]*delr1[2];
for (int kk = jj+1; kk < jnumm1; kk++) { for (int kk = jj+1; kk < jnumm1; kk++) {
int k = d_neighbors_short_3body(i,kk); int k = d_neighbors_short_3body(ii,kk);
k &= NEIGHMASK; k &= NEIGHMASK;
const int ktype = d_map[type[k]]; const int ktype = d_map[type[k]];
const int ikparam = d_elem3param(itype,ktype,ktype); const int ikparam = d_elem3param(itype,ktype,ktype);
@ -481,14 +480,14 @@ void PairVashishtaKokkos<DeviceType>::operator()(TagPairVashishtaComputeFullB<NE
const X_FLOAT ytmpi = x(i,1); const X_FLOAT ytmpi = x(i,1);
const X_FLOAT ztmpi = x(i,2); const X_FLOAT ztmpi = x(i,2);
const int jnum = d_numneigh_short_3body[i]; const int jnum = d_numneigh_short_3body[ii];
F_FLOAT fxtmpi = 0.0; F_FLOAT fxtmpi = 0.0;
F_FLOAT fytmpi = 0.0; F_FLOAT fytmpi = 0.0;
F_FLOAT fztmpi = 0.0; F_FLOAT fztmpi = 0.0;
for (int jj = 0; jj < jnum; jj++) { for (int jj = 0; jj < jnum; jj++) {
int j = d_neighbors_short_3body(i,jj); int j = d_neighbors_short_3body(ii,jj);
j &= NEIGHMASK; j &= NEIGHMASK;
if (j >= nlocal) continue; if (j >= nlocal) continue;
const int jtype = d_map[type[j]]; const int jtype = d_map[type[j]];
@ -502,10 +501,10 @@ void PairVashishtaKokkos<DeviceType>::operator()(TagPairVashishtaComputeFullB<NE
delr1[2] = ztmpi - ztmpj; delr1[2] = ztmpi - ztmpj;
const F_FLOAT rsq1 = delr1[0]*delr1[0] + delr1[1]*delr1[1] + delr1[2]*delr1[2]; const F_FLOAT rsq1 = delr1[0]*delr1[0] + delr1[1]*delr1[1] + delr1[2]*delr1[2];
const int j_jnum = d_numneigh_short_3body[j]; const int j_jnum = d_numneigh_short_3body[jj];
for (int kk = 0; kk < j_jnum; kk++) { for (int kk = 0; kk < j_jnum; kk++) {
int k = d_neighbors_short_3body(j,kk); int k = d_neighbors_short_3body(jj,kk);
k &= NEIGHMASK; k &= NEIGHMASK;
if (k == i) continue; if (k == i) continue;
const int ktype = d_map[type[k]]; const int ktype = d_map[type[k]];

View File

@ -93,7 +93,7 @@ PairReaxFFOMP::~PairReaxFFOMP()
if (setup_flag) { if (setup_flag) {
reax_list * bonds = api->lists+BONDS; reax_list * bonds = api->lists+BONDS;
for (int i=0; i<bonds->num_intrs; ++i) for (int i=0; i<bonds->num_intrs; ++i)
sfree(error, bonds->select.bond_list[i].bo_data.CdboReduction, "CdboReduction"); sfree(bonds->select.bond_list[i].bo_data.CdboReduction);
} }
memory->destroy(num_nbrs_offset); memory->destroy(num_nbrs_offset);
} }

View File

@ -99,6 +99,7 @@ namespace ReaxFF {
/* set the pointers */ /* set the pointers */
type_i = system->my_atoms[i].type; type_i = system->my_atoms[i].type;
type_j = system->my_atoms[j].type; type_j = system->my_atoms[j].type;
if ((type_i < 0) || (type_j < 0)) continue;
sbp_i = &(system->reax_param.sbp[type_i]); sbp_i = &(system->reax_param.sbp[type_i]);
sbp_j = &(system->reax_param.sbp[type_j]); sbp_j = &(system->reax_param.sbp[type_j]);
twbp = &(system->reax_param.tbp[type_i][type_j]); twbp = &(system->reax_param.tbp[type_i][type_j]);

View File

@ -265,6 +265,7 @@ namespace ReaxFF {
for (int i = 0; i < system->N; ++i) { for (int i = 0; i < system->N; ++i) {
atom_i = &(system->my_atoms[i]); atom_i = &(system->my_atoms[i]);
type_i = atom_i->type; type_i = atom_i->type;
if (type_i < 0) continue;
sbp_i = &(system->reax_param.sbp[type_i]); sbp_i = &(system->reax_param.sbp[type_i]);
start_i = Start_Index(i, far_nbrs); start_i = Start_Index(i, far_nbrs);
@ -276,6 +277,7 @@ namespace ReaxFF {
int j = nbr_pj->nbr; int j = nbr_pj->nbr;
atom_j = &(system->my_atoms[j]); atom_j = &(system->my_atoms[j]);
type_j = atom_j->type; type_j = atom_j->type;
if (type_j < 0) continue;
sbp_j = &(system->reax_param.sbp[type_j]); sbp_j = &(system->reax_param.sbp[type_j]);
twbp = &(system->reax_param.tbp[type_i][type_j]); twbp = &(system->reax_param.tbp[type_i][type_j]);
@ -376,6 +378,7 @@ namespace ReaxFF {
for (int i = 0; i < system->n; ++i) { for (int i = 0; i < system->n; ++i) {
atom_i = &(system->my_atoms[i]); atom_i = &(system->my_atoms[i]);
type_i = atom_i->type; type_i = atom_i->type;
if (type_i < 0) continue;
sbp_i = &(system->reax_param.sbp[type_i]); sbp_i = &(system->reax_param.sbp[type_i]);
ihb = sbp_i->p_hbond; ihb = sbp_i->p_hbond;

View File

@ -98,14 +98,14 @@ namespace ReaxFF {
// for (j = 0; j < system->n; ++j) // for (j = 0; j < system->n; ++j)
for (j = ifrom; j < ito; ++j) { for (j = ifrom; j < ito; ++j) {
/* j has to be of type H */ /* j has to be of type H */
if (system->reax_param.sbp[system->my_atoms[j].type].p_hbond == 1) { type_j = system->my_atoms[j].type;
if (type_j < 0) continue;
if (system->reax_param.sbp[type_j].p_hbond == 1) {
/*set j's variables */ /*set j's variables */
type_j = system->my_atoms[j].type;
start_j = Start_Index(j, bonds); start_j = Start_Index(j, bonds);
end_j = End_Index(j, bonds); end_j = End_Index(j, bonds);
hb_start_j = Start_Index(system->my_atoms[j].Hindex, hbonds); hb_start_j = Start_Index(system->my_atoms[j].Hindex, hbonds);
hb_end_j = End_Index(system->my_atoms[j].Hindex, hbonds); hb_end_j = End_Index(system->my_atoms[j].Hindex, hbonds);
if (type_j < 0) continue;
top = 0; top = 0;
for (pi = start_j; pi < end_j; ++pi) { for (pi = start_j; pi < end_j; ++pi) {

View File

@ -110,9 +110,7 @@ PairReaxFF::PairReaxFF(LAMMPS *lmp) : Pair(lmp)
setup_flag = 0; setup_flag = 0;
fixspecies_flag = 0; fixspecies_flag = 0;
nmax = 0; nmax = 0;
list_blocking_flag = 0; list_blocking_flag = 0;
} }
@ -130,13 +128,13 @@ PairReaxFF::~PairReaxFF()
// deallocate reax data-structures // deallocate reax data-structures
if (api->control->tabulate) Deallocate_Lookup_Tables(api->system); if (api->control->tabulate) Deallocate_Lookup_Tables(api->system);
if (api->control->hbond_cut > 0) Delete_List(api->lists+HBONDS); if (api->control->hbond_cut > 0) Delete_List(api->lists+HBONDS);
Delete_List(api->lists+BONDS); Delete_List(api->lists+BONDS);
Delete_List(api->lists+THREE_BODIES); Delete_List(api->lists+THREE_BODIES);
Delete_List(api->lists+FAR_NBRS); Delete_List(api->lists+FAR_NBRS);
DeAllocate_Workspace(api->control, api->workspace); DeAllocate_Workspace(api->workspace);
DeAllocate_System(api->system); DeAllocate_System(api->system);
} }
@ -153,17 +151,16 @@ PairReaxFF::~PairReaxFF()
memory->destroy(cutsq); memory->destroy(cutsq);
memory->destroy(cutghost); memory->destroy(cutghost);
delete [] chi; delete[] chi;
delete [] eta; delete[] eta;
delete [] gamma; delete[] gamma;
delete [] bcut_acks2; delete[] bcut_acks2;
} }
memory->destroy(tmpid); memory->destroy(tmpid);
memory->destroy(tmpbo); memory->destroy(tmpbo);
delete [] pvector; delete[] pvector;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -282,11 +279,6 @@ void PairReaxFF::coeff(int nargs, char **args)
if (nargs != 3 + atom->ntypes) if (nargs != 3 + atom->ntypes)
error->all(FLERR,"Incorrect args for pair coefficients"); error->all(FLERR,"Incorrect args for pair coefficients");
// ensure I,J args are * *
if (strcmp(args[0],"*") != 0 || strcmp(args[1],"*") != 0)
error->all(FLERR,"Incorrect args for pair coefficients");
// read ffield file // read ffield file
Read_Force_Field(args[2], &(api->system->reax_param), api->control, world); Read_Force_Field(args[2], &(api->system->reax_param), api->control, world);
@ -536,7 +528,6 @@ void PairReaxFF::compute(int eflag, int vflag)
} }
FindBond(); FindBond();
} }
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -654,7 +645,7 @@ int PairReaxFF::write_reax_lists()
jlist = firstneigh[i]; jlist = firstneigh[i];
Set_Start_Index(i, num_nbrs, far_nbrs); Set_Start_Index(i, num_nbrs, far_nbrs);
if (i < inum) if (itr_i < inum)
cutoff_sqr = SQR(api->control->nonb_cut); cutoff_sqr = SQR(api->control->nonb_cut);
else else
cutoff_sqr = SQR(api->control->bond_cut); cutoff_sqr = SQR(api->control->bond_cut);

View File

@ -62,11 +62,10 @@ namespace ReaxFF {
void DeAllocate_System(reax_system *system) void DeAllocate_System(reax_system *system)
{ {
auto error = system->error_ptr;
auto memory = system->mem_ptr; auto memory = system->mem_ptr;
// deallocate the atom list // deallocate the atom list
sfree(error, system->my_atoms, "system->my_atoms"); sfree(system->my_atoms);
// deallocate the ffield parameters storage // deallocate the ffield parameters storage
memory->destroy(system->reax_param.gp.l); memory->destroy(system->reax_param.gp.l);
@ -78,45 +77,44 @@ namespace ReaxFF {
} }
/************* workspace *************/ /************* workspace *************/
void DeAllocate_Workspace(control_params *control, storage *workspace) void DeAllocate_Workspace(storage *workspace)
{ {
if (!workspace->allocated) if (!workspace->allocated)
return; return;
workspace->allocated = 0; workspace->allocated = 0;
auto error = control->error_ptr;
/* bond order storage */ /* bond order storage */
sfree(error, workspace->total_bond_order, "total_bo"); sfree(workspace->total_bond_order);
sfree(error, workspace->Deltap, "Deltap"); sfree(workspace->Deltap);
sfree(error, workspace->Deltap_boc, "Deltap_boc"); sfree(workspace->Deltap_boc);
sfree(error, workspace->dDeltap_self, "dDeltap_self"); sfree(workspace->dDeltap_self);
sfree(error, workspace->Delta, "Delta"); sfree(workspace->Delta);
sfree(error, workspace->Delta_lp, "Delta_lp"); sfree(workspace->Delta_lp);
sfree(error, workspace->Delta_lp_temp, "Delta_lp_temp"); sfree(workspace->Delta_lp_temp);
sfree(error, workspace->dDelta_lp, "dDelta_lp"); sfree(workspace->dDelta_lp);
sfree(error, workspace->dDelta_lp_temp, "dDelta_lp_temp"); sfree(workspace->dDelta_lp_temp);
sfree(error, workspace->Delta_e, "Delta_e"); sfree(workspace->Delta_e);
sfree(error, workspace->Delta_boc, "Delta_boc"); sfree(workspace->Delta_boc);
sfree(error, workspace->Delta_val, "Delta_val"); sfree(workspace->Delta_val);
sfree(error, workspace->nlp, "nlp"); sfree(workspace->nlp);
sfree(error, workspace->nlp_temp, "nlp_temp"); sfree(workspace->nlp_temp);
sfree(error, workspace->Clp, "Clp"); sfree(workspace->Clp);
sfree(error, workspace->vlpex, "vlpex"); sfree(workspace->vlpex);
sfree(error, workspace->bond_mark, "bond_mark"); sfree(workspace->bond_mark);
/* force related storage */ /* force related storage */
sfree(error, workspace->f, "f"); sfree(workspace->f);
sfree(error, workspace->CdDelta, "CdDelta"); sfree(workspace->CdDelta);
/* reductions */ /* reductions */
if (workspace->CdDeltaReduction) if (workspace->CdDeltaReduction)
sfree(error, workspace->CdDeltaReduction, "cddelta_reduce"); sfree(workspace->CdDeltaReduction);
if (workspace->forceReduction) if (workspace->forceReduction)
sfree(error, workspace->forceReduction, "f_reduce"); sfree(workspace->forceReduction);
if (workspace->valence_angle_atom_myoffset) if (workspace->valence_angle_atom_myoffset)
sfree(error, workspace->valence_angle_atom_myoffset, "valence_angle_atom_myoffset"); sfree(workspace->valence_angle_atom_myoffset);
} }
void Allocate_Workspace(control_params *control, storage *workspace, int total_cap) void Allocate_Workspace(control_params *control, storage *workspace, int total_cap)
@ -206,7 +204,7 @@ namespace ReaxFF {
if (system->omp_active) if (system->omp_active)
for (i = 0; i < bonds->num_intrs; ++i) for (i = 0; i < bonds->num_intrs; ++i)
sfree(system->error_ptr, bonds->select.bond_list[i].bo_data.CdboReduction, "CdboReduction"); sfree(bonds->select.bond_list[i].bo_data.CdboReduction);
Delete_List(bonds); Delete_List(bonds);
Make_List(system->total_cap, *total_bonds, TYP_BOND, bonds); Make_List(system->total_cap, *total_bonds, TYP_BOND, bonds);
@ -245,7 +243,7 @@ namespace ReaxFF {
system->my_atoms = (reax_atom *)::realloc(system->my_atoms, system->my_atoms = (reax_atom *)::realloc(system->my_atoms,
system->total_cap*sizeof(reax_atom)); system->total_cap*sizeof(reax_atom));
/* workspace */ /* workspace */
DeAllocate_Workspace(control, workspace); DeAllocate_Workspace(workspace);
Allocate_Workspace(control, workspace, system->total_cap); Allocate_Workspace(control, workspace, system->total_cap);
} }
@ -292,8 +290,7 @@ namespace ReaxFF {
reax_list *bonds = (*lists)+BONDS; reax_list *bonds = (*lists)+BONDS;
for (int i = 0; i < bonds->num_intrs; ++i) { for (int i = 0; i < bonds->num_intrs; ++i) {
sfree(error, bonds->select.bond_list[i].bo_data.CdboReduction, sfree(bonds->select.bond_list[i].bo_data.CdboReduction);
"CdboReduction");
bonds->select.bond_list[i].bo_data.CdboReduction = bonds->select.bond_list[i].bo_data.CdboReduction =
(double*) smalloc(error, sizeof(double)*nthreads, "CdboReduction"); (double*) smalloc(error, sizeof(double)*nthreads, "CdboReduction");

View File

@ -41,7 +41,7 @@ struct API {
extern void Allocate_Workspace(control_params *, storage *, int); extern void Allocate_Workspace(control_params *, storage *, int);
extern void DeAllocate_System(reax_system *); extern void DeAllocate_System(reax_system *);
extern void DeAllocate_Workspace(control_params *, storage *); extern void DeAllocate_Workspace(storage *);
extern void PreAllocate_Space(reax_system *, storage *); extern void PreAllocate_Space(reax_system *, storage *);
extern void ReAllocate(reax_system *, control_params *, simulation_data *, storage *, reax_list **); extern void ReAllocate(reax_system *, control_params *, simulation_data *, storage *, reax_list **);
@ -142,7 +142,7 @@ extern void Reset_Workspace(reax_system *, storage *);
extern void *scalloc(LAMMPS_NS::Error *, rc_bigint, rc_bigint, const std::string &); extern void *scalloc(LAMMPS_NS::Error *, rc_bigint, rc_bigint, const std::string &);
extern void *smalloc(LAMMPS_NS::Error *, rc_bigint, const std::string &); extern void *smalloc(LAMMPS_NS::Error *, rc_bigint, const std::string &);
extern void sfree(LAMMPS_NS::Error *, void *, const std::string &); extern void sfree(void *);
// torsion angles // torsion angles

View File

@ -75,6 +75,7 @@ namespace ReaxFF {
/* set the pointers */ /* set the pointers */
type_i = system->my_atoms[i].type; type_i = system->my_atoms[i].type;
type_j = system->my_atoms[j].type; type_j = system->my_atoms[j].type;
if ((type_i < 0) || (type_j < 0)) continue;
sbp_i = &(system->reax_param.sbp[type_i]); sbp_i = &(system->reax_param.sbp[type_i]);
sbp_j = &(system->reax_param.sbp[type_j]); sbp_j = &(system->reax_param.sbp[type_j]);
twbp = &(system->reax_param.tbp[type_i][type_j]); twbp = &(system->reax_param.tbp[type_i][type_j]);

View File

@ -59,14 +59,14 @@ namespace ReaxFF {
hbonds = (*lists) + HBONDS; hbonds = (*lists) + HBONDS;
hbond_list = hbonds->select.hbond_list; hbond_list = hbonds->select.hbond_list;
for (j = 0; j < system->n; ++j) for (j = 0; j < system->n; ++j) {
if (system->reax_param.sbp[system->my_atoms[j].type].p_hbond == 1) { type_j = system->my_atoms[j].type;
type_j = system->my_atoms[j].type; if (type_j < 0) continue;
if (system->reax_param.sbp[type_j].p_hbond == 1) {
start_j = Start_Index(j, bonds); start_j = Start_Index(j, bonds);
end_j = End_Index(j, bonds); end_j = End_Index(j, bonds);
hb_start_j = Start_Index(system->my_atoms[j].Hindex, hbonds); hb_start_j = Start_Index(system->my_atoms[j].Hindex, hbonds);
hb_end_j = End_Index(system->my_atoms[j].Hindex, hbonds); hb_end_j = End_Index(system->my_atoms[j].Hindex, hbonds);
if (type_j < 0) continue;
top = 0; top = 0;
for (pi = start_j; pi < end_j; ++pi) { for (pi = start_j; pi < end_j; ++pi) {
@ -154,5 +154,6 @@ namespace ReaxFF {
} }
} }
} }
}
} }
} }

View File

@ -56,7 +56,8 @@ namespace ReaxFF {
if (control->hbond_cut > 0) if (control->hbond_cut > 0)
for (i = 0; i < system->n; ++i) { for (i = 0; i < system->n; ++i) {
atom = &(system->my_atoms[i]); atom = &(system->my_atoms[i]);
if (system->reax_param.sbp[atom->type].p_hbond == 1 && atom->type >= 0) if ((atom->type >= 0)
&& (system->reax_param.sbp[atom->type].p_hbond == 1 && atom->type >= 0))
atom->Hindex = system->numH++; atom->Hindex = system->numH++;
else atom->Hindex = -1; else atom->Hindex = -1;
} }

View File

@ -39,8 +39,8 @@ namespace ReaxFF {
l->n = n; l->n = n;
l->num_intrs = num_intrs; l->num_intrs = num_intrs;
if (l->index) sfree(l->error_ptr, l->index, "list:index"); if (l->index) sfree(l->index);
if (l->end_index) sfree(l->error_ptr, l->end_index, "list:end_index"); if (l->end_index) sfree(l->end_index);
l->index = (int*) smalloc(l->error_ptr, n * sizeof(int), "list:index"); l->index = (int*) smalloc(l->error_ptr, n * sizeof(int), "list:index");
l->end_index = (int*) smalloc(l->error_ptr, n * sizeof(int), "list:end_index"); l->end_index = (int*) smalloc(l->error_ptr, n * sizeof(int), "list:end_index");
@ -48,26 +48,26 @@ namespace ReaxFF {
switch(l->type) { switch(l->type) {
case TYP_THREE_BODY: case TYP_THREE_BODY:
if (l->select.three_body_list) sfree(l->error_ptr, l->select.three_body_list,"list:three_bodies"); if (l->select.three_body_list) sfree(l->select.three_body_list);
l->select.three_body_list = (three_body_interaction_data*) l->select.three_body_list = (three_body_interaction_data*)
smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(three_body_interaction_data), smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(three_body_interaction_data),
"list:three_bodies"); "list:three_bodies");
break; break;
case TYP_BOND: case TYP_BOND:
if (l->select.bond_list) sfree(l->error_ptr, l->select.bond_list,"list:bonds"); if (l->select.bond_list) sfree(l->select.bond_list);
l->select.bond_list = (bond_data*) l->select.bond_list = (bond_data*)
smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(bond_data), "list:bonds"); smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(bond_data), "list:bonds");
break; break;
case TYP_FAR_NEIGHBOR: case TYP_FAR_NEIGHBOR:
if (l->select.far_nbr_list) sfree(l->error_ptr, l->select.far_nbr_list,"list:far_nbrs"); if (l->select.far_nbr_list) sfree(l->select.far_nbr_list);
l->select.far_nbr_list = (far_neighbor_data*) l->select.far_nbr_list = (far_neighbor_data*)
smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(far_neighbor_data), "list:far_nbrs"); smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(far_neighbor_data), "list:far_nbrs");
break; break;
case TYP_HBOND: case TYP_HBOND:
if (l->select.hbond_list) sfree(l->error_ptr, l->select.hbond_list,"list:hbonds"); if (l->select.hbond_list) sfree(l->select.hbond_list);
l->select.hbond_list = (hbond_data*) l->select.hbond_list = (hbond_data*)
smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(hbond_data), "list:hbonds"); smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(hbond_data), "list:hbonds");
break; break;
@ -83,26 +83,26 @@ namespace ReaxFF {
return; return;
l->allocated = 0; l->allocated = 0;
sfree(l->error_ptr, l->index, "list:index"); sfree(l->index);
sfree(l->error_ptr, l->end_index, "list:end_index"); sfree(l->end_index);
l->index = nullptr; l->index = nullptr;
l->end_index = nullptr; l->end_index = nullptr;
switch(l->type) { switch(l->type) {
case TYP_HBOND: case TYP_HBOND:
sfree(l->error_ptr, l->select.hbond_list, "list:hbonds"); sfree(l->select.hbond_list);
l->select.hbond_list = nullptr; l->select.hbond_list = nullptr;
break; break;
case TYP_FAR_NEIGHBOR: case TYP_FAR_NEIGHBOR:
sfree(l->error_ptr, l->select.far_nbr_list, "list:far_nbrs"); sfree(l->select.far_nbr_list);
l->select.far_nbr_list = nullptr; l->select.far_nbr_list = nullptr;
break; break;
case TYP_BOND: case TYP_BOND:
sfree(l->error_ptr, l->select.bond_list, "list:bonds"); sfree(l->select.bond_list);
l->select.bond_list = nullptr; l->select.bond_list = nullptr;
break; break;
case TYP_THREE_BODY: case TYP_THREE_BODY:
sfree(l->error_ptr, l->select.three_body_list, "list:three_bodies"); sfree(l->select.three_body_list);
l->select.three_body_list = nullptr; l->select.three_body_list = nullptr;
break; break;

View File

@ -90,11 +90,11 @@ namespace ReaxFF {
coef[i-1].a = f[i]; coef[i-1].a = f[i];
} }
sfree(error_ptr, a, "cubic_spline:a"); sfree(a);
sfree(error_ptr, b, "cubic_spline:b"); sfree(b);
sfree(error_ptr, c, "cubic_spline:c"); sfree(c);
sfree(error_ptr, d, "cubic_spline:d"); sfree(d);
sfree(error_ptr, v, "cubic_spline:v"); sfree(v);
} }
void Complete_Cubic_Spline(LAMMPS_NS::Error* error_ptr, const double *h, void Complete_Cubic_Spline(LAMMPS_NS::Error* error_ptr, const double *h,
@ -138,11 +138,11 @@ namespace ReaxFF {
coef[i-1].a = f[i]; coef[i-1].a = f[i];
} }
sfree(error_ptr, a, "cubic_spline:a"); sfree(a);
sfree(error_ptr, b, "cubic_spline:b"); sfree(b);
sfree(error_ptr, c, "cubic_spline:c"); sfree(c);
sfree(error_ptr, d, "cubic_spline:d"); sfree(d);
sfree(error_ptr, v, "cubic_spline:v"); sfree(v);
} }
void Init_Lookup_Tables(reax_system *system, control_params *control, void Init_Lookup_Tables(reax_system *system, control_params *control,
@ -276,16 +276,16 @@ namespace ReaxFF {
for (i = 0; i < ntypes; ++i) { for (i = 0; i < ntypes; ++i) {
for (j = i; j < ntypes; ++j) for (j = i; j < ntypes; ++j)
if (LR[i][j].n) { if (LR[i][j].n) {
sfree(system->error_ptr, LR[i][j].y, "LR[i,j].y"); sfree(LR[i][j].y);
sfree(system->error_ptr, LR[i][j].H, "LR[i,j].H"); sfree(LR[i][j].H);
sfree(system->error_ptr, LR[i][j].vdW, "LR[i,j].vdW"); sfree(LR[i][j].vdW);
sfree(system->error_ptr, LR[i][j].CEvd, "LR[i,j].CEvd"); sfree(LR[i][j].CEvd);
sfree(system->error_ptr, LR[i][j].ele, "LR[i,j].ele"); sfree(LR[i][j].ele);
sfree(system->error_ptr, LR[i][j].CEclmb, "LR[i,j].CEclmb"); sfree(LR[i][j].CEclmb);
} }
sfree(system->error_ptr, LR[i], "LR[i]"); sfree(LR[i]);
} }
sfree(system->error_ptr, LR, "LR"); sfree(LR);
} }
} }

View File

@ -233,8 +233,8 @@ namespace ReaxFF {
flag = 0; flag = 0;
/* kinetic energy terms */ /* kinetic energy terms */
double xcut = 0.5 * ( system->reax_param.sbp[ system->my_atoms[i].type ].bcut_acks2 double xcut = 0.5 * (system->reax_param.sbp[system->my_atoms[i].type].bcut_acks2
+ system->reax_param.sbp[ system->my_atoms[j].type ].bcut_acks2 ); + system->reax_param.sbp[system->my_atoms[j].type].bcut_acks2);
if(nbr_pj->d <= xcut) { if(nbr_pj->d <= xcut) {
if (j < natoms) flag = 1; if (j < natoms) flag = 1;
@ -409,8 +409,8 @@ namespace ReaxFF {
flag = 0; flag = 0;
/* kinetic energy terms */ /* kinetic energy terms */
double xcut = 0.5 * ( system->reax_param.sbp[ system->my_atoms[i].type ].bcut_acks2 double xcut = 0.5 * (system->reax_param.sbp[ system->my_atoms[i].type ].bcut_acks2
+ system->reax_param.sbp[ system->my_atoms[j].type ].bcut_acks2 ); + system->reax_param.sbp[ system->my_atoms[j].type ].bcut_acks2);
if(nbr_pj->d <= xcut) { if(nbr_pj->d <= xcut) {
if (j < natoms) flag = 1; if (j < natoms) flag = 1;

View File

@ -96,16 +96,9 @@ void *scalloc(LAMMPS_NS::Error *error_ptr, rc_bigint n, rc_bigint size, const st
} }
/* safe free */ /* safe free */
void sfree(LAMMPS_NS::Error *error_ptr, void *ptr, const std::string &name) void sfree(void *ptr)
{ {
if (ptr == nullptr) { if (ptr == nullptr) return;
auto errmsg = std::string("Trying to free the already free()'d pointer: ") + name;
if (error_ptr)
error_ptr->one(FLERR, errmsg);
else
fputs(errmsg.c_str(), stderr);
return;
}
free(ptr); free(ptr);
ptr = nullptr; ptr = nullptr;

View File

@ -304,8 +304,6 @@ void PairHybrid::settings(int narg, char **arg)
// allocate list of sub-styles as big as possibly needed if no extra args // allocate list of sub-styles as big as possibly needed if no extra args
styles = new Pair *[narg]; styles = new Pair *[narg];
cutmax_style = new double[narg];
memset(cutmax_style, 0.0, narg*sizeof(double));
keywords = new char *[narg]; keywords = new char *[narg];
multiple = new int[narg]; multiple = new int[narg];
@ -347,6 +345,10 @@ void PairHybrid::settings(int narg, char **arg)
nstyles++; nstyles++;
} }
delete[] cutmax_style;
cutmax_style = new double[nstyles];
memset(cutmax_style, 0, nstyles*sizeof(double));
// multiple[i] = 1 to M if sub-style used multiple times, else 0 // multiple[i] = 1 to M if sub-style used multiple times, else 0
int num_tip4p = 0, num_coul = 0; // count sub-styles with tip4p and coulomb int num_tip4p = 0, num_coul = 0; // count sub-styles with tip4p and coulomb
@ -582,6 +584,8 @@ void PairHybrid::init_style()
{ {
int i,m,itype,jtype,used,istyle,skip; int i,m,itype,jtype,used,istyle,skip;
memset(cutmax_style, 0, nstyles*sizeof(double));
// error if a sub-style is not used // error if a sub-style is not used
int ntypes = atom->ntypes; int ntypes = atom->ntypes;
@ -750,7 +754,7 @@ double PairHybrid::init_one(int i, int j)
cutmax_style[istyle] = cut; cutmax_style[istyle] = cut;
for (auto &request : neighbor->get_pair_requests()) { for (auto &request : neighbor->get_pair_requests()) {
if (styles[istyle] == request->get_requestor() && styles[istyle]->trim_flag) { if (styles[istyle] == request->get_requestor()) {
request->set_cutoff(cutmax_style[istyle]); request->set_cutoff(cutmax_style[istyle]);
break; break;
} }
@ -819,8 +823,9 @@ void PairHybrid::read_restart(FILE *fp)
delete[] compute_tally; delete[] compute_tally;
styles = new Pair*[nstyles]; styles = new Pair*[nstyles];
delete[] cutmax_style;
cutmax_style = new double[nstyles]; cutmax_style = new double[nstyles];
memset(cutmax_style, 0.0, nstyles*sizeof(double)); memset(cutmax_style, 0, nstyles*sizeof(double));
keywords = new char*[nstyles]; keywords = new char*[nstyles];
multiple = new int[nstyles]; multiple = new int[nstyles];