diff --git a/cmake/Modules/Packages/ML-PACE.cmake b/cmake/Modules/Packages/ML-PACE.cmake index b64584e5a7..50581b0676 100644 --- a/cmake/Modules/Packages/ML-PACE.cmake +++ b/cmake/Modules/Packages/ML-PACE.cmake @@ -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_MD5) diff --git a/doc/src/pair_pace.rst b/doc/src/pair_pace.rst index 01f7df63f6..10c91e31e1 100644 --- a/doc/src/pair_pace.rst +++ b/doc/src/pair_pace.rst @@ -6,7 +6,7 @@ pair_style pace command ======================= -Accelerator Variants: *pace/kk* +Accelerator Variants: *pace/kk*, *pace/extrapolation/kk* pair_style pace/extrapolation command ===================================== diff --git a/lib/pace/Install.py b/lib/pace/Install.py index f7f50d4f6d..c72271aa7a 100644 --- a/lib/pace/Install.py +++ b/lib/pace/Install.py @@ -18,11 +18,11 @@ from install_helpers import fullpath, geturl, checkmd5sum # settings thisdir = fullpath('.') -version ='v.2023.01.3' +version ='v.2023.01.3.fix' # known checksums for different PACE versions. used to validate the download. checksums = { \ - 'v.2023.01.3': 'f418d32b60e531063ac4285bf702b468' + 'v.2023.01.3.fix': '4f0b3b5b14456fe9a73b447de3765caa' } parser = ArgumentParser(prog='Install.py', description="LAMMPS library build wrapper script") diff --git a/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp b/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp index 40828013ed..386dba6d1d 100644 --- a/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp @@ -175,8 +175,6 @@ void FixQEqReaxFFKokkos::init_hist() template void FixQEqReaxFFKokkos::setup_pre_force(int vflag) { - //neighbor->build_one(list); - pre_force(vflag); } diff --git a/src/KOKKOS/npair_kokkos.cpp b/src/KOKKOS/npair_kokkos.cpp index aae8592b7a..3ead5a2e34 100644 --- a/src/KOKKOS/npair_kokkos.cpp +++ b/src/KOKKOS/npair_kokkos.cpp @@ -28,8 +28,8 @@ namespace LAMMPS_NS { /* ---------------------------------------------------------------------- */ -template -NPairKokkos::NPairKokkos(LAMMPS *lmp) : NPair(lmp) { +template +NPairKokkos::NPairKokkos(LAMMPS *lmp) : NPair(lmp) { last_stencil_old = -1; @@ -49,8 +49,8 @@ NPairKokkos::NPairKokkos(LAMMPS *lmp) : NP copy needed info from Neighbor class to this build class ------------------------------------------------------------------------- */ -template -void NPairKokkos::copy_neighbor_info() +template +void NPairKokkos::copy_neighbor_info() { NPair::copy_neighbor_info(); @@ -58,7 +58,6 @@ void NPairKokkos::copy_neighbor_info() // general params - newton_pair = force->newton_pair; k_cutneighsq = neighborKK->k_cutneighsq; // overwrite per-type Neighbor cutoffs with custom value set by requestor @@ -93,8 +92,8 @@ void NPairKokkos::copy_neighbor_info() copy per-atom and per-bin vectors from NBin class to this build class ------------------------------------------------------------------------- */ -template -void NPairKokkos::copy_bin_info() +template +void NPairKokkos::copy_bin_info() { NPair::copy_bin_info(); @@ -110,8 +109,8 @@ void NPairKokkos::copy_bin_info() copy needed info from NStencil class to this build class ------------------------------------------------------------------------- */ -template -void NPairKokkos::copy_stencil_info() +template +void NPairKokkos::copy_stencil_info() { NPair::copy_stencil_info(); nstencil = ns->nstencil; @@ -145,8 +144,8 @@ void NPairKokkos::copy_stencil_info() /* ---------------------------------------------------------------------- */ -template -void NPairKokkos::build(NeighList *list_) +template +void NPairKokkos::build(NeighList *list_) { NeighListKokkos* list = (NeighListKokkos*) list_; const int nlocal = includegroup?atom->nfirst:atom->nlocal; @@ -244,7 +243,7 @@ void NPairKokkos::build(NeighList *list_) #endif if (GHOST) { - NPairKokkosBuildFunctorGhost f(data,atoms_per_bin * 5 * sizeof(X_FLOAT) * factor); + NPairKokkosBuildFunctorGhost f(data,atoms_per_bin * 5 * sizeof(X_FLOAT) * factor); #ifdef LMP_KOKKOS_GPU if (ExecutionSpaceFromDevice::space == Device) { int team_size = atoms_per_bin*factor; @@ -262,82 +261,42 @@ void NPairKokkos::build(NeighList *list_) Kokkos::parallel_for(nall, f); #endif } else { - if (newton_pair) { - if (SIZE) { - NPairKokkosBuildFunctorSize f(data,atoms_per_bin * 6 * sizeof(X_FLOAT) * factor); + if (SIZE) { + NPairKokkosBuildFunctorSize f(data,atoms_per_bin * 6 * sizeof(X_FLOAT) * factor); #ifdef LMP_KOKKOS_GPU - if (ExecutionSpaceFromDevice::space == Device) { - int team_size = atoms_per_bin*factor; - int team_size_max = Kokkos::TeamPolicy(team_size,Kokkos::AUTO).team_size_max(f,Kokkos::ParallelForTag()); - if (team_size <= team_size_max) { - Kokkos::TeamPolicy 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 + if (ExecutionSpaceFromDevice::space == Device) { + int team_size = atoms_per_bin*factor; + int team_size_max = Kokkos::TeamPolicy(team_size,Kokkos::AUTO).team_size_max(f,Kokkos::ParallelForTag()); + if (team_size <= team_size_max) { + Kokkos::TeamPolicy 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 + } + } else Kokkos::parallel_for(nall, f); -#endif - } else { - NPairKokkosBuildFunctor f(data,atoms_per_bin * 5 * sizeof(X_FLOAT) * factor); -#ifdef LMP_KOKKOS_GPU - if (ExecutionSpaceFromDevice::space == Device) { - int team_size = atoms_per_bin*factor; - int team_size_max = Kokkos::TeamPolicy(team_size,Kokkos::AUTO).team_size_max(f,Kokkos::ParallelForTag()); - if (team_size <= team_size_max) { - Kokkos::TeamPolicy 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 - Kokkos::parallel_for(nall, f); + Kokkos::parallel_for(nall, f); #endif - } } else { - if (SIZE) { - NPairKokkosBuildFunctorSize f(data,atoms_per_bin * 5 * sizeof(X_FLOAT) * factor); + NPairKokkosBuildFunctor f(data,atoms_per_bin * 5 * sizeof(X_FLOAT) * factor); #ifdef LMP_KOKKOS_GPU - if (ExecutionSpaceFromDevice::space == Device) { - int team_size = atoms_per_bin*factor; - int team_size_max = Kokkos::TeamPolicy(team_size,Kokkos::AUTO).team_size_max(f,Kokkos::ParallelForTag()); - if (team_size <= team_size_max) { - Kokkos::TeamPolicy 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 + if (ExecutionSpaceFromDevice::space == Device) { + int team_size = atoms_per_bin*factor; + int team_size_max = Kokkos::TeamPolicy(team_size,Kokkos::AUTO).team_size_max(f,Kokkos::ParallelForTag()); + if (team_size <= team_size_max) { + Kokkos::TeamPolicy 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 + } + } else Kokkos::parallel_for(nall, f); -#endif - } else { - NPairKokkosBuildFunctor f(data,atoms_per_bin * 5 * sizeof(X_FLOAT) * factor); -#ifdef LMP_KOKKOS_GPU - if (ExecutionSpaceFromDevice::space == Device) { - int team_size = atoms_per_bin*factor; - int team_size_max = Kokkos::TeamPolicy(team_size,Kokkos::AUTO).team_size_max(f,Kokkos::ParallelForTag()); - if (team_size <= team_size_max) { - Kokkos::TeamPolicy 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 - Kokkos::parallel_for(nall, f); + Kokkos::parallel_for(nall, f); #endif - } } } Kokkos::deep_copy(h_scalars, d_scalars); @@ -1402,20 +1361,30 @@ void NeighborKokkosExecute::build_ItemSizeGPU(typename Kokkos::TeamP } namespace LAMMPS_NS { -template class NPairKokkos; -template class NPairKokkos; -template class NPairKokkos; -template class NPairKokkos; -template class NPairKokkos; -template class NPairKokkos; -template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; #ifdef LMP_KOKKOS_GPU -template class NPairKokkos; -template class NPairKokkos; -template class NPairKokkos; -template class NPairKokkos; -template class NPairKokkos; -template class NPairKokkos; -template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; +template class NPairKokkos; #endif } diff --git a/src/KOKKOS/npair_kokkos.h b/src/KOKKOS/npair_kokkos.h index ce63c30c4b..78d735f829 100644 --- a/src/KOKKOS/npair_kokkos.h +++ b/src/KOKKOS/npair_kokkos.h @@ -13,75 +13,125 @@ #ifdef NPAIR_CLASS // clang-format off -typedef NPairKokkos NPairKokkosFullBinHost; +typedef NPairKokkos NPairKokkosFullBinHost; NPairStyle(full/bin/kk/host, 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 NPairKokkosFullBinDevice; +typedef NPairKokkos NPairKokkosFullBinDevice; NPairStyle(full/bin/kk/device, 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 NPairKokkosFullBinGhostHost; +typedef NPairKokkos NPairKokkosFullBinGhostHost; NPairStyle(full/bin/ghost/kk/host, 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 NPairKokkosFullBinGhostDevice; +typedef NPairKokkos NPairKokkosFullBinGhostDevice; NPairStyle(full/bin/ghost/kk/device, 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 NPairKokkosHalfBinHost; -NPairStyle(half/bin/kk/host, - NPairKokkosHalfBinHost, - NP_HALF | NP_BIN | NP_KOKKOS_HOST | NP_NEWTON | NP_NEWTOFF | NP_ORTHO); +typedef NPairKokkos NPairKokkosHalfBinNewtonHost; +NPairStyle(half/bin/newton/kk/host, + NPairKokkosHalfBinNewtonHost, + NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTON | NP_ORTHO); -typedef NPairKokkos NPairKokkosHalfBinDevice; -NPairStyle(half/bin/kk/device, - NPairKokkosHalfBinDevice, - NP_HALF | NP_BIN | NP_KOKKOS_DEVICE | NP_NEWTON | NP_NEWTOFF | NP_ORTHO); +typedef NPairKokkos NPairKokkosHalfBinNewtoffHost; +NPairStyle(half/bin/newtoff/kk/host, + NPairKokkosHalfBinNewtoffHost, + NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTOFF | NP_ORTHO); -typedef NPairKokkos NPairKokkosHalfBinHostTri; -NPairStyle(half/bin/kk/host, - NPairKokkosHalfBinHostTri, - NP_HALF | NP_BIN | NP_KOKKOS_HOST | NP_NEWTON | NP_NEWTOFF | NP_TRI); +typedef NPairKokkos NPairKokkosHalfBinNewtonDevice; +NPairStyle(half/bin/newton/kk/device, + NPairKokkosHalfBinNewtonDevice, + NP_KOKKOS_DEVICE | NP_HALF | NP_BIN | NP_NEWTON | NP_ORTHO); -typedef NPairKokkos NPairKokkosHalfBinDeviceTri; -NPairStyle(half/bin/kk/device, - NPairKokkosHalfBinDeviceTri, - NP_HALF | NP_BIN | NP_KOKKOS_DEVICE | NP_NEWTON | NP_NEWTOFF | NP_TRI); +typedef NPairKokkos NPairKokkosHalfBinNewtoffDevice; +NPairStyle(half/bin/newtoff/kk/device, + NPairKokkosHalfBinNewtoffDevice, + NP_KOKKOS_DEVICE | NP_HALF | NP_BIN | NP_NEWTOFF | NP_ORTHO); -typedef NPairKokkos NPairKokkosHalfBinGhostHost; -NPairStyle(half/bin/ghost/kk/host, - NPairKokkosHalfBinGhostHost, - NP_HALF | NP_BIN | NP_KOKKOS_HOST | NP_NEWTON | NP_NEWTOFF | NP_GHOST | NP_ORTHO | NP_TRI); +typedef NPairKokkos NPairKokkosHalfBinNewtonTriHost; +NPairStyle(half/bin/newton/kk/host, + NPairKokkosHalfBinNewtonTriHost, + NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTON | NP_TRI); -typedef NPairKokkos NPairKokkosHalfBinGhostDevice; -NPairStyle(half/bin/ghost/kk/device, - NPairKokkosHalfBinGhostDevice, - NP_HALF | NP_BIN | NP_KOKKOS_DEVICE | NP_NEWTON | NP_NEWTOFF | NP_GHOST | NP_ORTHO | NP_TRI); +typedef NPairKokkos NPairKokkosHalfBinNewtoffTriHost; +NPairStyle(half/bin/newtoff/kk/host, + NPairKokkosHalfBinNewtoffTriHost, + NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTOFF | NP_TRI); -typedef NPairKokkos NPairKokkosHalfSizeBinHost; -NPairStyle(half/size/bin/kk/host, - NPairKokkosHalfSizeBinHost, - NP_HALF | NP_SIZE | NP_BIN | NP_KOKKOS_HOST | NP_NEWTON | NP_NEWTOFF | NP_ORTHO); +typedef NPairKokkos NPairKokkosHalfBinNewtonTriDevice; +NPairStyle(half/bin/newton/kk/device, + NPairKokkosHalfBinNewtonTriDevice, + NP_KOKKOS_DEVICE | NP_HALF | NP_BIN | NP_NEWTON | NP_TRI); -typedef NPairKokkos NPairKokkosHalfSizeBinDevice; -NPairStyle(half/size/bin/kk/device, - NPairKokkosHalfSizeBinDevice, - NP_HALF | NP_SIZE | NP_BIN | NP_KOKKOS_DEVICE | NP_NEWTON | NP_NEWTOFF | NP_ORTHO); +typedef NPairKokkos NPairKokkosHalfBinNewtoffTriDevice; +NPairStyle(half/bin/newtoff/kk/device, + NPairKokkosHalfBinNewtoffTriDevice, + NP_KOKKOS_DEVICE | NP_HALF | NP_BIN | NP_NEWTOFF | NP_TRI); -typedef NPairKokkos NPairKokkosHalfSizeBinHostTri; -NPairStyle(half/size/bin/kk/host, - NPairKokkosHalfSizeBinHostTri, - NP_HALF | NP_SIZE | NP_BIN | NP_KOKKOS_HOST | NP_NEWTON | NP_NEWTOFF | NP_TRI); +typedef NPairKokkos NPairKokkosHalfBinNewtonGhostHost; +NPairStyle(half/bin/newton/ghost/kk/host, + NPairKokkosHalfBinNewtonGhostHost, + NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTON | NP_GHOST | NP_ORTHO | NP_TRI); -typedef NPairKokkos NPairKokkosHalfSizeBinDeviceTri; -NPairStyle(half/size/bin/kk/device, - NPairKokkosHalfSizeBinDeviceTri, - NP_HALF | NP_SIZE | NP_BIN | NP_KOKKOS_DEVICE | NP_NEWTON | NP_NEWTOFF | NP_TRI); +typedef NPairKokkos NPairKokkosHalfBinNewtoffGhostHost; +NPairStyle(half/bin/newtoff/ghost/kk/host, + NPairKokkosHalfBinNewtoffGhostHost, + NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTOFF | NP_GHOST | NP_ORTHO | NP_TRI); + +typedef NPairKokkos 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 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 NPairKokkosHalfBinNewtonSizeHost; +NPairStyle(half/bin/newton/size/kk/host, + NPairKokkosHalfBinNewtonSizeHost, + NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTON | NP_SIZE | NP_ORTHO); + +typedef NPairKokkos NPairKokkosHalfBinNewtoffSizeHost; +NPairStyle(half/bin/newtoff/size/kk/host, + NPairKokkosHalfBinNewtoffSizeHost, + NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTOFF | NP_SIZE | NP_ORTHO); + +typedef NPairKokkos NPairKokkosHalfBinNewtonSizeDevice; +NPairStyle(half/bin/newton/size/kk/device, + NPairKokkosHalfBinNewtonSizeDevice, + NP_KOKKOS_DEVICE | NP_HALF | NP_BIN | NP_NEWTON | NP_SIZE | NP_ORTHO); + +typedef NPairKokkos NPairKokkosHalfBinNewtoffSizeDevice; +NPairStyle(half/bin/newtoff/size/kk/device, + NPairKokkosHalfBinNewtoffSizeDevice, + NP_KOKKOS_DEVICE | NP_HALF | NP_BIN | NP_NEWTOFF | NP_SIZE | NP_ORTHO); + +typedef NPairKokkos NPairKokkosHalfBinNewtonSizeTriHost; +NPairStyle(half/bin/newton/size/kk/host, + NPairKokkosHalfBinNewtonSizeTriHost, + NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTON | NP_SIZE | NP_TRI); + +typedef NPairKokkos NPairKokkosHalfBinNewtoffSizeTriHost; +NPairStyle(half/bin/newtoff/size/kk/host, + NPairKokkosHalfBinNewtoffSizeTriHost, + NP_BIN | NP_KOKKOS_HOST | NP_HALF | NP_NEWTOFF | NP_SIZE | NP_TRI); + +typedef NPairKokkos NPairKokkosHalfBinNewtonSizeTriDevice; +NPairStyle(half/bin/newton/size/kk/device, + NPairKokkosHalfBinNewtonSizeTriDevice, + NP_KOKKOS_DEVICE | NP_HALF | NP_BIN | NP_NEWTON | NP_SIZE | NP_TRI); + +typedef NPairKokkos 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 #else @@ -94,7 +144,7 @@ NPairStyle(half/size/bin/kk/device, namespace LAMMPS_NS { -template +template class NPairKokkos : public NPair { typedef ArrayTypes AT; @@ -379,7 +429,7 @@ class NeighborKokkosExecute }; -template +template struct NPairKokkosBuildFunctor { typedef DeviceType device_type; @@ -392,19 +442,19 @@ struct NPairKokkosBuildFunctor { KOKKOS_INLINE_FUNCTION void operator() (const int & i) const { - c.template build_Item(i); + c.template build_Item(i); } #ifdef LMP_KOKKOS_GPU LAMMPS_DEVICE_FUNCTION inline void operator() (typename Kokkos::TeamPolicy::member_type dev) const { - c.template build_ItemGPU(dev, sharedsize); + c.template build_ItemGPU(dev, sharedsize); } size_t team_shmem_size(const int team_size) const { (void) team_size; return sharedsize; } #endif }; -template -struct NPairKokkosBuildFunctor { +template +struct NPairKokkosBuildFunctor { typedef LMPHostType device_type; const NeighborKokkosExecute c; @@ -416,7 +466,7 @@ struct NPairKokkosBuildFunctor { KOKKOS_INLINE_FUNCTION void operator() (const int & i) const { - c.template build_Item(i); + c.template build_Item(i); } void operator() (typename Kokkos::TeamPolicy::member_type /*dev*/) const {} // Should error out @@ -466,7 +516,7 @@ struct NPairKokkosBuildFunctorGhost { void operator() (typename Kokkos::TeamPolicy::member_type /*dev*/) const {} // Should error out }; -template +template struct NPairKokkosBuildFunctorSize { typedef DeviceType device_type; @@ -478,20 +528,20 @@ struct NPairKokkosBuildFunctorSize { KOKKOS_INLINE_FUNCTION void operator() (const int & i) const { - c.template build_ItemSize(i); + c.template build_ItemSize(i); } #ifdef LMP_KOKKOS_GPU LAMMPS_DEVICE_FUNCTION inline void operator() (typename Kokkos::TeamPolicy::member_type dev) const { - c.template build_ItemSizeGPU(dev, sharedsize); + c.template build_ItemSizeGPU(dev, sharedsize); } size_t team_shmem_size(const int team_size) const { (void) team_size; return sharedsize; } #endif }; -template -struct NPairKokkosBuildFunctorSize { +template +struct NPairKokkosBuildFunctorSize { typedef LMPHostType device_type; const NeighborKokkosExecute c; @@ -502,7 +552,7 @@ struct NPairKokkosBuildFunctorSize { KOKKOS_INLINE_FUNCTION void operator() (const int & i) const { - c.template build_ItemSize(i); + c.template build_ItemSize(i); } void operator() (typename Kokkos::TeamPolicy::member_type /*dev*/) const {} // Should error out diff --git a/src/KOKKOS/pair_lj_cut_kokkos.cpp b/src/KOKKOS/pair_lj_cut_kokkos.cpp index c6353cc083..5cff54a440 100644 --- a/src/KOKKOS/pair_lj_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_kokkos.cpp @@ -130,6 +130,7 @@ void PairLJCutKokkos::compute(int eflag_in, int vflag_in) if (vflag_fdotr) pair_virial_fdotr_compute(this); + copymode = 0; } template diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index 0bfcef90cf..273430fd63 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -95,6 +95,8 @@ PairReaxFFKokkos::~PairReaxFFKokkos() { if (copymode) return; + DeAllocate_System(api->system); + memoryKK->destroy_kokkos(k_eatom,eatom); memoryKK->destroy_kokkos(k_vatom,vatom); @@ -184,6 +186,8 @@ void PairReaxFFKokkos::init_style() if (neighflag == FULL) error->all(FLERR,"Must use half neighbor list with pair style reaxff/kk"); + need_dup = lmp->kokkos->need_dup(); + allocate(); setup(); init_md(); @@ -577,17 +581,17 @@ void PairReaxFFKokkos::Deallocate_Lookup_Tables() for (j = i; j <= ntypes; ++j) { if (map[i] == -1) continue; if (LR[i][j].n) { - sfree(api->control->error_ptr, LR[i][j].y, "LR[i,j].y"); - sfree(api->control->error_ptr, LR[i][j].H, "LR[i,j].H"); - sfree(api->control->error_ptr, LR[i][j].vdW, "LR[i,j].vdW"); - sfree(api->control->error_ptr, LR[i][j].CEvd, "LR[i,j].CEvd"); - sfree(api->control->error_ptr, LR[i][j].ele, "LR[i,j].ele"); - sfree(api->control->error_ptr, LR[i][j].CEclmb, "LR[i,j].CEclmb"); + sfree(LR[i][j].y); + sfree(LR[i][j].H); + sfree(LR[i][j].vdW); + sfree(LR[i][j].CEvd); + sfree(LR[i][j].ele); + 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::compute(int eflag_in, int vflag_in) } } - need_dup = lmp->kokkos->need_dup(); - // allocate duplicated memory if (need_dup) { dup_f = Kokkos::Experimental::create_scatter_view(f); diff --git a/src/KOKKOS/pair_sw_kokkos.cpp b/src/KOKKOS/pair_sw_kokkos.cpp index 679d022437..db7320623d 100644 --- a/src/KOKKOS/pair_sw_kokkos.cpp +++ b/src/KOKKOS/pair_sw_kokkos.cpp @@ -47,7 +47,6 @@ PairSWKokkos::PairSWKokkos(LAMMPS *lmp) : PairSW(lmp) { respa_enable = 0; - kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; @@ -138,6 +137,7 @@ void PairSWKokkos::compute(int eflag_in, int vflag_in) } if ((int)d_numneigh_short.extent(0) < ignum) d_numneigh_short = Kokkos::View("SW::numneighs_short",ignum*1.2); + Kokkos::parallel_for(Kokkos::RangePolicy(0,inum), *this); // loop over neighbor list of my atoms diff --git a/src/KOKKOS/pair_vashishta_kokkos.cpp b/src/KOKKOS/pair_vashishta_kokkos.cpp index aa8cb550c7..0bb2b49ece 100644 --- a/src/KOKKOS/pair_vashishta_kokkos.cpp +++ b/src/KOKKOS/pair_vashishta_kokkos.cpp @@ -117,24 +117,23 @@ void PairVashishtaKokkos::compute(int eflag_in, int vflag_in) EV_FLOAT ev; EV_FLOAT ev_all; + // build short neighbor list + int max_neighs = d_neighbors.extent(1); - if (((int)d_neighbors_short_2body.extent(1) != max_neighs) || - ((int)d_neighbors_short_2body.extent(0) != ignum)) { - d_neighbors_short_2body = Kokkos::View("Vashishta::neighbors_short_2body",ignum,max_neighs); - } - if ((int)d_numneigh_short_2body.extent(0)!=ignum) { - d_numneigh_short_2body = Kokkos::View("Vashishta::numneighs_short_2body",ignum); + if (((int)d_neighbors_short_2body.extent(1) < max_neighs) || + ((int)d_neighbors_short_2body.extent(0) < ignum)) { + d_neighbors_short_2body = Kokkos::View("Vashishta::neighbors_short_2body",ignum*1.2,max_neighs); } + if ((int)d_numneigh_short_2body.extent(0) < ignum) + d_numneigh_short_2body = Kokkos::View("Vashishta::numneighs_short_2body",ignum*1.2); - if (((int)d_neighbors_short_3body.extent(1) != max_neighs) || - ((int)d_neighbors_short_3body.extent(0) != ignum)) { - d_neighbors_short_3body = Kokkos::View("Vashishta::neighbors_short_3body",ignum,max_neighs); - } - - if ((int)d_numneigh_short_3body.extent(0)!=ignum) { - d_numneigh_short_3body = Kokkos::View("Vashishta::numneighs_short_3body",ignum); + if (((int)d_neighbors_short_3body.extent(1) < max_neighs) || + ((int)d_neighbors_short_3body.extent(0) < ignum)) { + d_neighbors_short_3body = Kokkos::View("Vashishta::neighbors_short_3body",ignum*1.2,max_neighs); } + if ((int)d_numneigh_short_3body.extent(0) < ignum) + d_numneigh_short_3body = Kokkos::View("Vashishta::numneighs_short_3body",ignum*1.2); Kokkos::parallel_for(Kokkos::RangePolicy(0,neighflag==FULL?ignum:inum), *this); @@ -217,17 +216,17 @@ void PairVashishtaKokkos::operator()(TagPairVashishtaComputeShortNei const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; if (rsq < d_params[ijparam].cutsq) { - d_neighbors_short_2body(i,inside_2body) = j; + d_neighbors_short_2body(ii,inside_2body) = j; inside_2body++; } if (rsq < d_params[ijparam].cutsq2) { - d_neighbors_short_3body(i,inside_3body) = j; + d_neighbors_short_3body(ii,inside_3body) = j; inside_3body++; } } - d_numneigh_short_2body(i) = inside_2body; - d_numneigh_short_3body(i) = inside_3body; + d_numneigh_short_2body(ii) = inside_2body; + d_numneigh_short_3body(ii) = inside_3body; } template @@ -252,14 +251,14 @@ void PairVashishtaKokkos::operator()(TagPairVashishtaComputeHalf::operator()(TagPairVashishtaComputeHalf::operator()(TagPairVashishtaComputeHalf::operator()(TagPairVashishtaComputeFullA::operator()(TagPairVashishtaComputeFullA::operator()(TagPairVashishtaComputeFullA::operator()(TagPairVashishtaComputeFullB= nlocal) continue; const int jtype = d_map[type[j]]; @@ -502,10 +501,10 @@ void PairVashishtaKokkos::operator()(TagPairVashishtaComputeFullBlists+BONDS; for (int i=0; inum_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); } diff --git a/src/OPENMP/reaxff_bonds_omp.cpp b/src/OPENMP/reaxff_bonds_omp.cpp index 41fb7a822a..234b17303f 100644 --- a/src/OPENMP/reaxff_bonds_omp.cpp +++ b/src/OPENMP/reaxff_bonds_omp.cpp @@ -99,6 +99,7 @@ namespace ReaxFF { /* set the pointers */ type_i = system->my_atoms[i].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_j = &(system->reax_param.sbp[type_j]); twbp = &(system->reax_param.tbp[type_i][type_j]); diff --git a/src/OPENMP/reaxff_forces_omp.cpp b/src/OPENMP/reaxff_forces_omp.cpp index 3cb938213f..50157da594 100644 --- a/src/OPENMP/reaxff_forces_omp.cpp +++ b/src/OPENMP/reaxff_forces_omp.cpp @@ -265,6 +265,7 @@ namespace ReaxFF { for (int i = 0; i < system->N; ++i) { atom_i = &(system->my_atoms[i]); type_i = atom_i->type; + if (type_i < 0) continue; sbp_i = &(system->reax_param.sbp[type_i]); start_i = Start_Index(i, far_nbrs); @@ -276,6 +277,7 @@ namespace ReaxFF { int j = nbr_pj->nbr; atom_j = &(system->my_atoms[j]); type_j = atom_j->type; + if (type_j < 0) continue; sbp_j = &(system->reax_param.sbp[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) { atom_i = &(system->my_atoms[i]); type_i = atom_i->type; + if (type_i < 0) continue; sbp_i = &(system->reax_param.sbp[type_i]); ihb = sbp_i->p_hbond; diff --git a/src/OPENMP/reaxff_hydrogen_bonds_omp.cpp b/src/OPENMP/reaxff_hydrogen_bonds_omp.cpp index 6e1db5ffe7..94b1bb60e6 100644 --- a/src/OPENMP/reaxff_hydrogen_bonds_omp.cpp +++ b/src/OPENMP/reaxff_hydrogen_bonds_omp.cpp @@ -98,14 +98,14 @@ namespace ReaxFF { // for (j = 0; j < system->n; ++j) for (j = ifrom; j < ito; ++j) { /* 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 */ - type_j = system->my_atoms[j].type; start_j = Start_Index(j, bonds); end_j = End_Index(j, bonds); hb_start_j = Start_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; for (pi = start_j; pi < end_j; ++pi) { diff --git a/src/REAXFF/pair_reaxff.cpp b/src/REAXFF/pair_reaxff.cpp index d0713308c0..1867aec81b 100644 --- a/src/REAXFF/pair_reaxff.cpp +++ b/src/REAXFF/pair_reaxff.cpp @@ -110,9 +110,7 @@ PairReaxFF::PairReaxFF(LAMMPS *lmp) : Pair(lmp) setup_flag = 0; fixspecies_flag = 0; - nmax = 0; - list_blocking_flag = 0; } @@ -130,13 +128,13 @@ PairReaxFF::~PairReaxFF() // deallocate reax data-structures if (api->control->tabulate) Deallocate_Lookup_Tables(api->system); - if (api->control->hbond_cut > 0) Delete_List(api->lists+HBONDS); + Delete_List(api->lists+BONDS); Delete_List(api->lists+THREE_BODIES); Delete_List(api->lists+FAR_NBRS); - DeAllocate_Workspace(api->control, api->workspace); + DeAllocate_Workspace(api->workspace); DeAllocate_System(api->system); } @@ -153,17 +151,16 @@ PairReaxFF::~PairReaxFF() memory->destroy(cutsq); memory->destroy(cutghost); - delete [] chi; - delete [] eta; - delete [] gamma; - delete [] bcut_acks2; + delete[] chi; + delete[] eta; + delete[] gamma; + delete[] bcut_acks2; } memory->destroy(tmpid); memory->destroy(tmpbo); - delete [] pvector; - + delete[] pvector; } /* ---------------------------------------------------------------------- */ @@ -282,11 +279,6 @@ void PairReaxFF::coeff(int nargs, char **args) if (nargs != 3 + atom->ntypes) 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_Force_Field(args[2], &(api->system->reax_param), api->control, world); @@ -536,7 +528,6 @@ void PairReaxFF::compute(int eflag, int vflag) } FindBond(); } - } /* ---------------------------------------------------------------------- */ @@ -654,7 +645,7 @@ int PairReaxFF::write_reax_lists() jlist = firstneigh[i]; Set_Start_Index(i, num_nbrs, far_nbrs); - if (i < inum) + if (itr_i < inum) cutoff_sqr = SQR(api->control->nonb_cut); else cutoff_sqr = SQR(api->control->bond_cut); diff --git a/src/REAXFF/reaxff_allocate.cpp b/src/REAXFF/reaxff_allocate.cpp index 16b71d041c..5b0a4e513c 100644 --- a/src/REAXFF/reaxff_allocate.cpp +++ b/src/REAXFF/reaxff_allocate.cpp @@ -62,11 +62,10 @@ namespace ReaxFF { void DeAllocate_System(reax_system *system) { - auto error = system->error_ptr; auto memory = system->mem_ptr; // deallocate the atom list - sfree(error, system->my_atoms, "system->my_atoms"); + sfree(system->my_atoms); // deallocate the ffield parameters storage memory->destroy(system->reax_param.gp.l); @@ -78,45 +77,44 @@ namespace ReaxFF { } /************* workspace *************/ - void DeAllocate_Workspace(control_params *control, storage *workspace) + void DeAllocate_Workspace(storage *workspace) { if (!workspace->allocated) return; workspace->allocated = 0; - auto error = control->error_ptr; /* bond order storage */ - sfree(error, workspace->total_bond_order, "total_bo"); - sfree(error, workspace->Deltap, "Deltap"); - sfree(error, workspace->Deltap_boc, "Deltap_boc"); - sfree(error, workspace->dDeltap_self, "dDeltap_self"); - sfree(error, workspace->Delta, "Delta"); - sfree(error, workspace->Delta_lp, "Delta_lp"); - sfree(error, workspace->Delta_lp_temp, "Delta_lp_temp"); - sfree(error, workspace->dDelta_lp, "dDelta_lp"); - sfree(error, workspace->dDelta_lp_temp, "dDelta_lp_temp"); - sfree(error, workspace->Delta_e, "Delta_e"); - sfree(error, workspace->Delta_boc, "Delta_boc"); - sfree(error, workspace->Delta_val, "Delta_val"); - sfree(error, workspace->nlp, "nlp"); - sfree(error, workspace->nlp_temp, "nlp_temp"); - sfree(error, workspace->Clp, "Clp"); - sfree(error, workspace->vlpex, "vlpex"); - sfree(error, workspace->bond_mark, "bond_mark"); + sfree(workspace->total_bond_order); + sfree(workspace->Deltap); + sfree(workspace->Deltap_boc); + sfree(workspace->dDeltap_self); + sfree(workspace->Delta); + sfree(workspace->Delta_lp); + sfree(workspace->Delta_lp_temp); + sfree(workspace->dDelta_lp); + sfree(workspace->dDelta_lp_temp); + sfree(workspace->Delta_e); + sfree(workspace->Delta_boc); + sfree(workspace->Delta_val); + sfree(workspace->nlp); + sfree(workspace->nlp_temp); + sfree(workspace->Clp); + sfree(workspace->vlpex); + sfree(workspace->bond_mark); /* force related storage */ - sfree(error, workspace->f, "f"); - sfree(error, workspace->CdDelta, "CdDelta"); + sfree(workspace->f); + sfree(workspace->CdDelta); /* reductions */ if (workspace->CdDeltaReduction) - sfree(error, workspace->CdDeltaReduction, "cddelta_reduce"); + sfree(workspace->CdDeltaReduction); if (workspace->forceReduction) - sfree(error, workspace->forceReduction, "f_reduce"); + sfree(workspace->forceReduction); 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) @@ -206,7 +204,7 @@ namespace ReaxFF { if (system->omp_active) 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); 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->total_cap*sizeof(reax_atom)); /* workspace */ - DeAllocate_Workspace(control, workspace); + DeAllocate_Workspace(workspace); Allocate_Workspace(control, workspace, system->total_cap); } @@ -292,8 +290,7 @@ namespace ReaxFF { reax_list *bonds = (*lists)+BONDS; 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); bonds->select.bond_list[i].bo_data.CdboReduction = (double*) smalloc(error, sizeof(double)*nthreads, "CdboReduction"); diff --git a/src/REAXFF/reaxff_api.h b/src/REAXFF/reaxff_api.h index d6a0410622..44c0adb9b0 100644 --- a/src/REAXFF/reaxff_api.h +++ b/src/REAXFF/reaxff_api.h @@ -41,7 +41,7 @@ struct API { extern void Allocate_Workspace(control_params *, storage *, int); 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 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 *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 diff --git a/src/REAXFF/reaxff_bonds.cpp b/src/REAXFF/reaxff_bonds.cpp index cb28aaa1ca..c3e4b787c7 100644 --- a/src/REAXFF/reaxff_bonds.cpp +++ b/src/REAXFF/reaxff_bonds.cpp @@ -75,6 +75,7 @@ namespace ReaxFF { /* set the pointers */ type_i = system->my_atoms[i].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_j = &(system->reax_param.sbp[type_j]); twbp = &(system->reax_param.tbp[type_i][type_j]); diff --git a/src/REAXFF/reaxff_hydrogen_bonds.cpp b/src/REAXFF/reaxff_hydrogen_bonds.cpp index 6f5c663da0..6a56675f19 100644 --- a/src/REAXFF/reaxff_hydrogen_bonds.cpp +++ b/src/REAXFF/reaxff_hydrogen_bonds.cpp @@ -59,14 +59,14 @@ namespace ReaxFF { hbonds = (*lists) + HBONDS; hbond_list = hbonds->select.hbond_list; - 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; + for (j = 0; j < system->n; ++j) { + 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); end_j = End_Index(j, bonds); hb_start_j = Start_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; for (pi = start_j; pi < end_j; ++pi) { @@ -154,5 +154,6 @@ namespace ReaxFF { } } } + } } } diff --git a/src/REAXFF/reaxff_init_md.cpp b/src/REAXFF/reaxff_init_md.cpp index 268af75358..2d0459691f 100644 --- a/src/REAXFF/reaxff_init_md.cpp +++ b/src/REAXFF/reaxff_init_md.cpp @@ -56,7 +56,8 @@ namespace ReaxFF { if (control->hbond_cut > 0) for (i = 0; i < system->n; ++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++; else atom->Hindex = -1; } diff --git a/src/REAXFF/reaxff_list.cpp b/src/REAXFF/reaxff_list.cpp index 79d96bb9d9..0ff0852a04 100644 --- a/src/REAXFF/reaxff_list.cpp +++ b/src/REAXFF/reaxff_list.cpp @@ -39,8 +39,8 @@ namespace ReaxFF { l->n = n; l->num_intrs = num_intrs; - if (l->index) sfree(l->error_ptr, l->index, "list:index"); - if (l->end_index) sfree(l->error_ptr, l->end_index, "list:end_index"); + if (l->index) sfree(l->index); + if (l->end_index) sfree(l->end_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"); @@ -48,26 +48,26 @@ namespace ReaxFF { switch(l->type) { 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*) smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(three_body_interaction_data), "list:three_bodies"); break; 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*) smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(bond_data), "list:bonds"); break; 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*) smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(far_neighbor_data), "list:far_nbrs"); break; 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*) smalloc(l->error_ptr, (rc_bigint) num_intrs * sizeof(hbond_data), "list:hbonds"); break; @@ -83,26 +83,26 @@ namespace ReaxFF { return; l->allocated = 0; - sfree(l->error_ptr, l->index, "list:index"); - sfree(l->error_ptr, l->end_index, "list:end_index"); + sfree(l->index); + sfree(l->end_index); l->index = nullptr; l->end_index = nullptr; switch(l->type) { case TYP_HBOND: - sfree(l->error_ptr, l->select.hbond_list, "list:hbonds"); + sfree(l->select.hbond_list); l->select.hbond_list = nullptr; break; 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; break; case TYP_BOND: - sfree(l->error_ptr, l->select.bond_list, "list:bonds"); + sfree(l->select.bond_list); l->select.bond_list = nullptr; break; 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; break; diff --git a/src/REAXFF/reaxff_lookup.cpp b/src/REAXFF/reaxff_lookup.cpp index 6471f1e6e2..c0e7bf2c54 100644 --- a/src/REAXFF/reaxff_lookup.cpp +++ b/src/REAXFF/reaxff_lookup.cpp @@ -90,11 +90,11 @@ namespace ReaxFF { coef[i-1].a = f[i]; } - sfree(error_ptr, a, "cubic_spline:a"); - sfree(error_ptr, b, "cubic_spline:b"); - sfree(error_ptr, c, "cubic_spline:c"); - sfree(error_ptr, d, "cubic_spline:d"); - sfree(error_ptr, v, "cubic_spline:v"); + sfree(a); + sfree(b); + sfree(c); + sfree(d); + sfree(v); } void Complete_Cubic_Spline(LAMMPS_NS::Error* error_ptr, const double *h, @@ -138,11 +138,11 @@ namespace ReaxFF { coef[i-1].a = f[i]; } - sfree(error_ptr, a, "cubic_spline:a"); - sfree(error_ptr, b, "cubic_spline:b"); - sfree(error_ptr, c, "cubic_spline:c"); - sfree(error_ptr, d, "cubic_spline:d"); - sfree(error_ptr, v, "cubic_spline:v"); + sfree(a); + sfree(b); + sfree(c); + sfree(d); + sfree(v); } void Init_Lookup_Tables(reax_system *system, control_params *control, @@ -276,16 +276,16 @@ namespace ReaxFF { for (i = 0; i < ntypes; ++i) { for (j = i; j < ntypes; ++j) if (LR[i][j].n) { - sfree(system->error_ptr, LR[i][j].y, "LR[i,j].y"); - sfree(system->error_ptr, LR[i][j].H, "LR[i,j].H"); - sfree(system->error_ptr, LR[i][j].vdW, "LR[i,j].vdW"); - sfree(system->error_ptr, LR[i][j].CEvd, "LR[i,j].CEvd"); - sfree(system->error_ptr, LR[i][j].ele, "LR[i,j].ele"); - sfree(system->error_ptr, LR[i][j].CEclmb, "LR[i,j].CEclmb"); + sfree(LR[i][j].y); + sfree(LR[i][j].H); + sfree(LR[i][j].vdW); + sfree(LR[i][j].CEvd); + sfree(LR[i][j].ele); + sfree(LR[i][j].CEclmb); } - sfree(system->error_ptr, LR[i], "LR[i]"); + sfree(LR[i]); } - sfree(system->error_ptr, LR, "LR"); + sfree(LR); } } diff --git a/src/REAXFF/reaxff_nonbonded.cpp b/src/REAXFF/reaxff_nonbonded.cpp index 7acab9915a..75cbd79b29 100644 --- a/src/REAXFF/reaxff_nonbonded.cpp +++ b/src/REAXFF/reaxff_nonbonded.cpp @@ -233,8 +233,8 @@ namespace ReaxFF { flag = 0; /* kinetic energy terms */ - 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 ); + 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); if(nbr_pj->d <= xcut) { if (j < natoms) flag = 1; @@ -409,8 +409,8 @@ namespace ReaxFF { flag = 0; /* kinetic energy terms */ - 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 ); + 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); if(nbr_pj->d <= xcut) { if (j < natoms) flag = 1; diff --git a/src/REAXFF/reaxff_tool_box.cpp b/src/REAXFF/reaxff_tool_box.cpp index 5ebed0360e..22ef299b41 100644 --- a/src/REAXFF/reaxff_tool_box.cpp +++ b/src/REAXFF/reaxff_tool_box.cpp @@ -96,16 +96,9 @@ void *scalloc(LAMMPS_NS::Error *error_ptr, rc_bigint n, rc_bigint size, const st } /* safe free */ -void sfree(LAMMPS_NS::Error *error_ptr, void *ptr, const std::string &name) +void sfree(void *ptr) { - if (ptr == nullptr) { - 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; - } + if (ptr == nullptr) return; free(ptr); ptr = nullptr; diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp index efc22dbf4e..f05a201e33 100644 --- a/src/pair_hybrid.cpp +++ b/src/pair_hybrid.cpp @@ -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 styles = new Pair *[narg]; - cutmax_style = new double[narg]; - memset(cutmax_style, 0.0, narg*sizeof(double)); keywords = new char *[narg]; multiple = new int[narg]; @@ -347,6 +345,10 @@ void PairHybrid::settings(int narg, char **arg) 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 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; + memset(cutmax_style, 0, nstyles*sizeof(double)); + // error if a sub-style is not used int ntypes = atom->ntypes; @@ -750,7 +754,7 @@ double PairHybrid::init_one(int i, int j) cutmax_style[istyle] = cut; 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]); break; } @@ -819,8 +823,9 @@ void PairHybrid::read_restart(FILE *fp) delete[] compute_tally; styles = new Pair*[nstyles]; + delete[] cutmax_style; cutmax_style = new double[nstyles]; - memset(cutmax_style, 0.0, nstyles*sizeof(double)); + memset(cutmax_style, 0, nstyles*sizeof(double)); keywords = new char*[nstyles]; multiple = new int[nstyles];