Allow neighbor class to set newton flag in Kokkos neigh list

This commit is contained in:
Stan Gerald Moore
2023-01-30 16:14:39 -07:00
parent b54cdc48e2
commit 0870bc3046
2 changed files with 171 additions and 152 deletions

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