diff --git a/src/KOKKOS/fix_deform_kokkos.cpp b/src/KOKKOS/fix_deform_kokkos.cpp index cdfbeb1a60..d49e335986 100644 --- a/src/KOKKOS/fix_deform_kokkos.cpp +++ b/src/KOKKOS/fix_deform_kokkos.cpp @@ -315,14 +315,13 @@ void FixDeformKokkos::end_of_step() int nlocal = atom->nlocal; domainKK->x2lamda(nlocal); - //for (i = 0; i < nlocal; i++) - // if (mask[i] & groupbit) - // domain->x2lamda(x[i],x[i]); - if (rfix.size() > 0) - error->all(FLERR,"Cannot (yet) use rigid bodies with fix deform and Kokkos"); - //for (i = 0; i < nrigid; i++) - // modify->fix[rfix[i]]->deform(0); + if (rfix.size() > 0) { + atomKK->sync(Host,ALL_MASK); + for (auto &ifix : rfix) + ifix->deform(0); + atomKK->modified(Host,ALL_MASK); + } } // reset global and local box to new size/shape @@ -355,13 +354,13 @@ void FixDeformKokkos::end_of_step() int nlocal = atom->nlocal; domainKK->lamda2x(nlocal); - //for (i = 0; i < nlocal; i++) - // if (mask[i] & groupbit) - // domain->lamda2x(x[i],x[i]); - //if (nrigid) - // for (i = 0; i < nrigid; i++) - // modify->fix[rfix[i]]->deform(1); + if (rfix.size() > 0) { + atomKK->sync(Host,ALL_MASK); + for (auto &ifix : rfix) + ifix->deform(1); + atomKK->modified(Host,ALL_MASK); + } } // redo KSpace coeffs since box has changed diff --git a/src/KOKKOS/npair_kokkos.cpp b/src/KOKKOS/npair_kokkos.cpp index 3ead5a2e34..ee8da12c52 100644 --- a/src/KOKKOS/npair_kokkos.cpp +++ b/src/KOKKOS/npair_kokkos.cpp @@ -243,6 +243,8 @@ void NPairKokkos::build(NeighList *list_) #endif if (GHOST) { + // assumes newton off + NPairKokkosBuildFunctorGhost f(data,atoms_per_bin * 5 * sizeof(X_FLOAT) * factor); #ifdef LMP_KOKKOS_GPU if (ExecutionSpaceFromDevice::space == Device) { @@ -262,7 +264,7 @@ void NPairKokkos::build(NeighList *list_) #endif } else { if (SIZE) { - NPairKokkosBuildFunctorSize f(data,atoms_per_bin * 6 * sizeof(X_FLOAT) * factor); + 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; @@ -280,7 +282,7 @@ void NPairKokkos::build(NeighList *list_) Kokkos::parallel_for(nall, f); #endif } else { - NPairKokkosBuildFunctor 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; @@ -402,7 +404,6 @@ KOKKOS_FUNCTION void NeighborKokkosExecute:: build_Item(const int &i) const { - /* if necessary, goto next page and add pages */ int n = 0; int which = 0; int moltemplate; @@ -422,24 +423,31 @@ void NeighborKokkosExecute:: const typename ArrayTypes::t_int_1d_const_um stencil = d_stencil; - // loop over all bins in neighborhood (includes ibin) - if (HalfNeigh) + // loop over rest of atoms in i's bin, ghosts are at end of linked list + // if j is owned atom, store it, since j is beyond i in linked list + // if j is ghost, only store if j coords are "above and to the right" of i + + if (HalfNeigh && Newton && !Tri) for (int m = 0; m < c_bincount(ibin); m++) { const int j = c_bins(ibin,m); - const int jtype = type(j); - //for same bin as atom i skip j if i==j and skip atoms "below and to the left" if using HalfNeighborlists - if ((j == i) || (HalfNeigh && !Newton && (j < i)) || - (HalfNeigh && Newton && ((j < i) || ((j >= nlocal) && - ((x(j, 2) < ztmp) || (x(j, 2) == ztmp && x(j, 1) < ytmp) || - (x(j, 2) == ztmp && x(j, 1) == ytmp && x(j, 0) < xtmp))))) - ) continue; + if (j <= i) continue; + if (j >= nlocal) { + if (x(j,2) < ztmp) continue; + if (x(j,2) == ztmp) { + if (x(j,1) < ytmp) continue; + if (x(j,1) == ytmp && x(j,0) < xtmp) continue; + } + } + + const int jtype = type(j); if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j, 0); const X_FLOAT dely = ytmp - x(j, 1); const X_FLOAT delz = ztmp - x(j, 2); const X_FLOAT rsq = delx*delx + dely*dely + delz*delz; + if (rsq <= cutneighsq(itype,jtype)) { if (molecular != Atom::ATOMIC) { if (!moltemplate) @@ -470,17 +478,16 @@ void NeighborKokkosExecute:: for (int k = 0; k < nstencil; k++) { const int jbin = ibin + stencil[k]; + if (HalfNeigh && Newton && !Tri && (ibin == jbin)) continue; // get subview of jbin - if (HalfNeigh && (ibin==jbin)) continue; //const ArrayTypes::t_int_1d_const_um =Kokkos::subview(bins,jbin,ALL); for (int m = 0; m < c_bincount(jbin); m++) { const int j = c_bins(jbin,m); - const int jtype = type(j); - if (HalfNeigh && !Newton && (j < i)) continue; - if (!HalfNeigh && j==i) continue; - if (Tri) { + if (HalfNeigh && !Newton && j <= i) continue; + if (!HalfNeigh && j == i) continue; + if (HalfNeigh && Newton && Tri) { if (x(j,2) < ztmp) continue; if (x(j,2) == ztmp) { if (x(j,1) < ytmp) continue; @@ -490,6 +497,8 @@ void NeighborKokkosExecute:: } } } + + const int jtype = type(j); if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j, 0); @@ -522,7 +531,6 @@ void NeighborKokkosExecute:: else n++; } } - } } @@ -617,31 +625,28 @@ void NeighborKokkosExecute::build_ItemGPU(typename Kokkos::TeamPolic dev.team_barrier(); #endif + // loop over rest of atoms in i's bin, ghosts are at end of linked list + // if j is owned atom, store it, since j is beyond i in linked list + // if j is ghost, only store if j coords are "above and to the right" of i + + if (HalfNeigh && Newton && !Tri) if (i >= 0 && i < nlocal) { #pragma unroll 4 for (int m = 0; m < bincount_current; m++) { int j = other_id[m]; - const int jtype = other_x[m + 3 * atoms_per_bin]; - //for same bin as atom i skip j if i==j and skip atoms "below and to the left" if using halfneighborlists - if ((j == i) || - (HalfNeigh && !Newton && (j < i)) || - (HalfNeigh && Newton && - ((j < i) || - ((j >= nlocal) && ((x(j, 2) < ztmp) || (x(j, 2) == ztmp && x(j, 1) < ytmp) || - (x(j, 2) == ztmp && x(j, 1) == ytmp && x(j, 0) < xtmp))))) - ) continue; - if (Tri) { - if (x(j,2) < ztmp) continue; - if (x(j,2) == ztmp) { - if (x(j,1) < ytmp) continue; - if (x(j,1) == ytmp) { - if (x(j,0) < xtmp) continue; - if (x(j,0) == xtmp && j <= i) continue; - } - } + if (j <= i) continue; + if (j >= nlocal) { + if (x(j,2) < ztmp) continue; + if (x(j,2) == ztmp) { + if (x(j,1) < ytmp) continue; + if (x(j,1) == ytmp && x(j,0) < xtmp) continue; } + } + + const int jtype = other_x[m + 3 * atoms_per_bin]; if (exclude && exclusion(i,j,itype,jtype)) continue; + const X_FLOAT delx = xtmp - other_x[m]; const X_FLOAT dely = ytmp - other_x[m + atoms_per_bin]; const X_FLOAT delz = ztmp - other_x[m + 2 * atoms_per_bin]; @@ -683,7 +688,7 @@ void NeighborKokkosExecute::build_ItemGPU(typename Kokkos::TeamPolic for (int k = 0; k < nstencil; k++) { const int jbin = ibin + stencil[k]; - if (ibin == jbin) continue; + if (HalfNeigh && Newton && !Tri && (ibin == jbin)) continue; bincount_current = c_bincount[jbin]; int j = MY_II < bincount_current ? c_bins(jbin, MY_II) : -1; @@ -703,12 +708,10 @@ void NeighborKokkosExecute::build_ItemGPU(typename Kokkos::TeamPolic #pragma unroll 8 for (int m = 0; m < bincount_current; m++) { const int j = other_id[m]; - const int jtype = other_x[m + 3 * atoms_per_bin]; - //if(HalfNeigh && (j < i)) continue; - if (HalfNeigh && !Newton && (j < i)) continue; - if (!HalfNeigh && j==i) continue; - if (Tri) { + if (HalfNeigh && !Newton && j <= i) continue; + if (!HalfNeigh && j == i) continue; + if (HalfNeigh && Newton && Tri) { if (x(j,2) < ztmp) continue; if (x(j,2) == ztmp) { if (x(j,1) < ytmp) continue; @@ -718,6 +721,8 @@ void NeighborKokkosExecute::build_ItemGPU(typename Kokkos::TeamPolic } } } + + const int jtype = other_x[m + 3 * atoms_per_bin]; if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - other_x[m]; @@ -1091,17 +1096,24 @@ void NeighborKokkosExecute:: const int mask_history = 3 << SBBITS; // loop over all bins in neighborhood (includes ibin) - if (HalfNeigh) + // loop over rest of atoms in i's bin, ghosts are at end of linked list + // if j is owned atom, store it, since j is beyond i in linked list + // if j is ghost, only store if j coords are "above and to the right" of i + + if (HalfNeigh && Newton && !Tri) for (int m = 0; m < c_bincount(ibin); m++) { const int j = c_bins(ibin,m); - const int jtype = type(j); - //for same bin as atom i skip j if i==j and skip atoms "below and to the left" if using HalfNeighborlists - if ((j == i) || (HalfNeigh && !Newton && (j < i)) || - (HalfNeigh && Newton && ((j < i) || ((j >= nlocal) && - ((x(j, 2) < ztmp) || (x(j, 2) == ztmp && x(j, 1) < ytmp) || - (x(j, 2) == ztmp && x(j, 1) == ytmp && x(j, 0) < xtmp))))) - ) continue; + if (j <= i) continue; + if (j >= nlocal) { + if (x(j,2) < ztmp) continue; + if (x(j,2) == ztmp) { + if (x(j,1) < ytmp) continue; + if (x(j,1) == ytmp && x(j,0) < xtmp) continue; + } + } + + const int jtype = type(j); if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j, 0); @@ -1123,17 +1135,16 @@ void NeighborKokkosExecute:: for (int k = 0; k < nstencil; k++) { const int jbin = ibin + stencil[k]; + if (HalfNeigh && Newton && !Tri && (ibin == jbin)) continue; // get subview of jbin - if (HalfNeigh && (ibin==jbin)) continue; //const ArrayTypes::t_int_1d_const_um =Kokkos::subview(bins,jbin,ALL); for (int m = 0; m < c_bincount(jbin); m++) { const int j = c_bins(jbin,m); - const int jtype = type(j); - if (HalfNeigh && !Newton && (j < i)) continue; - if (!HalfNeigh && j==i) continue; - if (Tri) { + if (HalfNeigh && !Newton && j <= i) continue; + if (!HalfNeigh && j == i) continue; + if (HalfNeigh && Newton && Tri) { if (x(j,2) < ztmp) continue; if (x(j,2) == ztmp) { if (x(j,1) < ytmp) continue; @@ -1143,6 +1154,8 @@ void NeighborKokkosExecute:: } } } + + const int jtype = type(j); if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j, 0); @@ -1239,30 +1252,22 @@ void NeighborKokkosExecute::build_ItemSizeGPU(typename Kokkos::TeamP dev.team_barrier(); #endif + if (HalfNeigh && Newton && !Tri) if (i >= 0 && i < nlocal) { #pragma unroll 4 for (int m = 0; m < bincount_current; m++) { int j = other_id[m]; - const int jtype = other_x[m + 3 * atoms_per_bin]; - //for same bin as atom i skip j if i==j and skip atoms "below and to the left" if using halfneighborlists - if ((j == i) || - (HalfNeigh && !Newton && (j < i)) || - (HalfNeigh && Newton && - ((j < i) || - ((j >= nlocal) && ((x(j, 2) < ztmp) || (x(j, 2) == ztmp && x(j, 1) < ytmp) || - (x(j, 2) == ztmp && x(j, 1) == ytmp && x(j, 0) < xtmp))))) - ) continue; - if (Tri) { + if (j <= i) continue; + if (j >= nlocal) { if (x(j,2) < ztmp) continue; if (x(j,2) == ztmp) { if (x(j,1) < ytmp) continue; - if (x(j,1) == ytmp) { - if (x(j,0) < xtmp) continue; - if (x(j,0) == xtmp && j <= i) continue; - } + if (x(j,1) == ytmp && x(j,0) < xtmp) continue; } } + + const int jtype = other_x[m + 3 * atoms_per_bin]; if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - other_x[m]; const X_FLOAT dely = ytmp - other_x[m + atoms_per_bin]; @@ -1288,6 +1293,7 @@ void NeighborKokkosExecute::build_ItemSizeGPU(typename Kokkos::TeamP const int jbin = ibin + stencil[k]; if (ibin == jbin) continue; + if (HalfNeigh && Newton && !Tri && (ibin == jbin)) continue; bincount_current = c_bincount[jbin]; int j = MY_II < bincount_current ? c_bins(jbin, MY_II) : -1; @@ -1308,12 +1314,10 @@ void NeighborKokkosExecute::build_ItemSizeGPU(typename Kokkos::TeamP #pragma unroll 8 for (int m = 0; m < bincount_current; m++) { const int j = other_id[m]; - const int jtype = other_x[m + 3 * atoms_per_bin]; - if (HalfNeigh && (j < i)) continue; - if (HalfNeigh && !Newton && (j < i)) continue; - if (!HalfNeigh && j==i) continue; - if (Tri) { + if (HalfNeigh && !Newton && j <= i) continue; + if (!HalfNeigh && j == i) continue; + if (HalfNeigh && Newton && Tri) { if (x(j,2) < ztmp) continue; if (x(j,2) == ztmp) { if (x(j,1) < ytmp) continue; @@ -1323,6 +1327,8 @@ void NeighborKokkosExecute::build_ItemSizeGPU(typename Kokkos::TeamP } } } + + const int jtype = other_x[m + 3 * atoms_per_bin]; if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - other_x[m]; diff --git a/src/KOKKOS/npair_kokkos.h b/src/KOKKOS/npair_kokkos.h index 78d735f829..5eb32951e7 100644 --- a/src/KOKKOS/npair_kokkos.h +++ b/src/KOKKOS/npair_kokkos.h @@ -73,21 +73,11 @@ NPairStyle(half/bin/newtoff/kk/device, NPairKokkosHalfBinNewtoffTriDevice, NP_KOKKOS_DEVICE | NP_HALF | NP_BIN | 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 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,