USER-DPD: change nstencil_ssa[] to eliminate a corner case

Saves a conditional inside an NPairHalfBinNewtonSSA::build() inner loop
This commit is contained in:
Tim Mattox
2017-02-17 21:54:41 -05:00
parent 5289ec0b39
commit c2ee3285fc
4 changed files with 21 additions and 19 deletions

View File

@ -207,8 +207,7 @@ void NPairHalfBinNewtonSSA::build(NeighList *list)
}
// loop over all local atoms in other bins in "subphase" of stencil
k = (subphase > 0) ? nstencil_ssa[subphase - 1] : 0;
for (; k < nstencil_ssa[subphase]; k++) {
for (k = nstencil_ssa[subphase]; k < nstencil_ssa[subphase+1]; k++) {
for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) {
jtype = type[j];
if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue;

View File

@ -42,6 +42,7 @@ NStencilHalfBin2dNewtonSSA::NStencilHalfBin2dNewtonSSA(LAMMPS *lmp) :
void NStencilHalfBin2dNewtonSSA::create()
{
int i,j,pos = 0;
nstencil_ssa[0] = 0; // redundant info, but saves a conditional
// Subphase 0: upper right front bins (red)
for (j = 0; j <= sy; j++)
for (i = 0; i <= sx; i++)
@ -52,8 +53,8 @@ void NStencilHalfBin2dNewtonSSA::create()
stencilxyz[pos][2] = 0;
stencil[pos++] = j*mbinx + i;
}
nstencil_ssa[0] = pos;
nstencil_ssa[1] = pos;
// Subphase 1: upper left front bins (light blue)
for (j = 1; j <= sy; j++)
for (i = -sx; i < 0; i++)
@ -63,21 +64,21 @@ void NStencilHalfBin2dNewtonSSA::create()
stencilxyz[pos][2] = 0;
stencil[pos++] = j*mbinx + i;
}
nstencil_ssa[1] = pos;
// Subphase 2: lower right front bins (yellow)
nstencil_ssa[2] = pos;
// Subphase 2: lower right front bins (yellow)
// Subphase 3: lower left front bins (blue)
nstencil_ssa[3] = pos;
// Subphase 3: lower left front bins (blue)
nstencil_ssa[4] = pos; // record end of half stencil
// Now include additional bins for AIR ghosts, and impure-to-pure locals
// Subphase 4: upper right back bins (pink)
nstencil_ssa[4] = pos;
// nstencil_ssa[5] = pos;
// Subphase 5: upper left back bins (light green)
nstencil_ssa[5] = pos;
// nstencil_ssa[6] = pos;
// Subphase 6: lower right back bins (white)
for (j = -sy; j < 0; j++)
for (i = 0; i <= sx; i++)
@ -87,8 +88,8 @@ void NStencilHalfBin2dNewtonSSA::create()
stencilxyz[pos][2] = 0;
stencil[pos++] = j*mbinx + i;
}
nstencil_ssa[6] = pos;
// nstencil_ssa[7] = pos;
// Subphase 7: lower left back bins (purple)
for (j = -sy; j <= 0; j++)
for (i = -sx; i < 0; i++)
@ -98,7 +99,7 @@ void NStencilHalfBin2dNewtonSSA::create()
stencilxyz[pos][2] = 0;
stencil[pos++] = j*mbinx + i;
}
nstencil_ssa[7] = pos;
// nstencil_ssa[8] = pos;
// Also, include the centroid for the AIR ghosts.
stencilxyz[pos][0] = 0;

View File

@ -42,6 +42,7 @@ NStencilHalfBin3dNewtonSSA::NStencilHalfBin3dNewtonSSA(LAMMPS *lmp) :
void NStencilHalfBin3dNewtonSSA::create()
{
int i,j,k,pos = 0;
nstencil_ssa[0] = 0; // redundant info, but saves a conditional
// Subphase 0: upper right front bins (red)
for (k = 0; k <= sz; k++)
for (j = 0; j <= sy; j++)
@ -53,8 +54,8 @@ void NStencilHalfBin3dNewtonSSA::create()
stencilxyz[pos][2] = k;
stencil[pos++] = k*mbiny*mbinx + j*mbinx + i;
}
nstencil_ssa[0] = pos;
nstencil_ssa[1] = pos;
// Subphase 1: upper left front bins (light blue)
for (k = 0; k <= sz; k++)
for (j = 1; j <= sy; j++)
@ -65,8 +66,8 @@ void NStencilHalfBin3dNewtonSSA::create()
stencilxyz[pos][2] = k;
stencil[pos++] = k*mbiny*mbinx + j*mbinx + i;
}
nstencil_ssa[1] = pos;
nstencil_ssa[2] = pos;
// Subphase 2: lower right front bins (yellow)
for (k = 1; k <= sz; k++)
for (j = -sy; j < 0; j++)
@ -77,8 +78,8 @@ void NStencilHalfBin3dNewtonSSA::create()
stencilxyz[pos][2] = k;
stencil[pos++] = k*mbiny*mbinx + j*mbinx + i;
}
nstencil_ssa[2] = pos;
nstencil_ssa[3] = pos;
// Subphase 3: lower left front bins (blue)
for (k = 1; k <= sz; k++)
for (j = -sy; j <= 0; j++)
@ -89,8 +90,8 @@ void NStencilHalfBin3dNewtonSSA::create()
stencilxyz[pos][2] = k;
stencil[pos++] = k*mbiny*mbinx + j*mbinx + i;
}
nstencil_ssa[3] = pos;
nstencil_ssa[4] = pos; // record end of half stencil
// Now include additional bins for AIR ghosts, and impure-to-pure locals
// Subphase 4: upper right back bins (pink)
for (k = -sz; k < 0; k++)
@ -102,8 +103,8 @@ void NStencilHalfBin3dNewtonSSA::create()
stencilxyz[pos][2] = k;
stencil[pos++] = k*mbiny*mbinx + j*mbinx + i;
}
nstencil_ssa[4] = pos;
// nstencil_ssa[5] = pos;
// Subphase 5: upper left back bins (light green)
for (k = -sz; k < 0; k++)
for (j = 1; j <= sy; j++)
@ -114,8 +115,8 @@ void NStencilHalfBin3dNewtonSSA::create()
stencilxyz[pos][2] = k;
stencil[pos++] = k*mbiny*mbinx + j*mbinx + i;
}
nstencil_ssa[5] = pos;
// nstencil_ssa[6] = pos;
// Subphase 6: lower right back bins (white)
for (k = -sz; k <= 0; k++)
for (j = -sy; j < 0; j++)
@ -126,8 +127,8 @@ void NStencilHalfBin3dNewtonSSA::create()
stencilxyz[pos][2] = k;
stencil[pos++] = k*mbiny*mbinx + j*mbinx + i;
}
nstencil_ssa[6] = pos;
// nstencil_ssa[7] = pos;
// Subphase 7: lower left back bins (purple)
for (k = -sz; k <= 0; k++)
for (j = -sy; j <= 0; j++)
@ -138,7 +139,7 @@ void NStencilHalfBin3dNewtonSSA::create()
stencilxyz[pos][2] = k;
stencil[pos++] = k*mbiny*mbinx + j*mbinx + i;
}
nstencil_ssa[7] = pos;
//nstencil_ssa[8] = pos;
// Also, include the centroid for the AIR ghosts.
stencilxyz[pos][0] = 0;

View File

@ -24,7 +24,8 @@ class NStencilSSA : public NStencil {
~NStencilSSA() {}
virtual void create() = 0;
int nstencil_ssa[8]; // last stencil index for each subphase
// first stencil index for each subphase, with last index at end
int nstencil_ssa[5];
};
}