git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@10230 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2013-07-08 20:10:50 +00:00
parent 0b8e46c7e3
commit 60d49a7aad
29 changed files with 934 additions and 1528 deletions

View File

@ -31,6 +31,7 @@
#include "neighbor.h" #include "neighbor.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "neigh_request.h" #include "neigh_request.h"
#include "my_page.h"
#include "math_const.h" #include "math_const.h"
#include "math_special.h" #include "math_special.h"
#include "memory.h" #include "memory.h"
@ -55,8 +56,9 @@ PairAIREBO::PairAIREBO(LAMMPS *lmp) : Pair(lmp)
maxlocal = 0; maxlocal = 0;
REBO_numneigh = NULL; REBO_numneigh = NULL;
REBO_firstneigh = NULL; REBO_firstneigh = NULL;
maxpage = 0; ipage = NULL;
pages = NULL; pgsize = oneatom = 0;
nC = nH = NULL; nC = nH = NULL;
manybody_flag = 1; manybody_flag = 1;
} }
@ -69,8 +71,7 @@ PairAIREBO::~PairAIREBO()
{ {
memory->destroy(REBO_numneigh); memory->destroy(REBO_numneigh);
memory->sfree(REBO_firstneigh); memory->sfree(REBO_firstneigh);
for (int i = 0; i < maxpage; i++) memory->destroy(pages[i]); delete [] ipage;
memory->sfree(pages);
memory->destroy(nC); memory->destroy(nC);
memory->destroy(nH); memory->destroy(nH);
@ -221,11 +222,24 @@ void PairAIREBO::init_style()
neighbor->requests[irequest]->full = 1; neighbor->requests[irequest]->full = 1;
neighbor->requests[irequest]->ghost = 1; neighbor->requests[irequest]->ghost = 1;
// local REBO neighbor list memory // local REBO neighbor list
// create pages if first time or if neighbor pgsize/oneatom has changed
pgsize = neighbor->pgsize; int create = 0;
oneatom = neighbor->oneatom; if (ipage == NULL) create = 1;
if (maxpage == 0) add_pages(); if (pgsize != neighbor->pgsize) create = 1;
if (oneatom != neighbor->oneatom) create = 1;
if (create) {
delete [] ipage;
pgsize = neighbor->pgsize;
oneatom = neighbor->oneatom;
int nmypage= comm->nthreads;
ipage = new MyPage<int>[nmypage];
for (int i = 0; i < nmypage; i++)
ipage[i].init(oneatom,pgsize,PGDELTA);
}
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -329,19 +343,13 @@ void PairAIREBO::REBO_neigh()
// store all REBO neighs of owned and ghost atoms // store all REBO neighs of owned and ghost atoms
// scan full neighbor list of I // scan full neighbor list of I
int npage = 0; ipage->reset();
int npnt = 0;
for (ii = 0; ii < allnum; ii++) { for (ii = 0; ii < allnum; ii++) {
i = ilist[ii]; i = ilist[ii];
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == maxpage) add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
xtmp = x[i][0]; xtmp = x[i][0];
ytmp = x[i][1]; ytmp = x[i][1];
@ -371,10 +379,9 @@ void PairAIREBO::REBO_neigh()
REBO_firstneigh[i] = neighptr; REBO_firstneigh[i] = neighptr;
REBO_numneigh[i] = n; REBO_numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (npnt >= pgsize) if (ipage->status())
error->one(FLERR, error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
"Neighbor list overflow, boost neigh_modify one or page");
} }
} }
@ -3285,21 +3292,6 @@ double PairAIREBO::TijSpline(double Nij, double Nji,
return Tijf; return Tijf;
} }
/* ----------------------------------------------------------------------
add pages to REBO neighbor list
------------------------------------------------------------------------- */
void PairAIREBO::add_pages(int howmany)
{
int toppage = maxpage;
maxpage += howmany*PGDELTA;
pages = (int **)
memory->srealloc(pages,maxpage*sizeof(int *),"AIREBO:pages");
for (int i = toppage; i < maxpage; i++)
memory->create(pages[i],pgsize,"AIREBO:pages[i]");
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
read AIREBO potential file read AIREBO potential file
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
@ -4199,7 +4191,10 @@ double PairAIREBO::memory_usage()
double bytes = 0.0; double bytes = 0.0;
bytes += maxlocal * sizeof(int); bytes += maxlocal * sizeof(int);
bytes += maxlocal * sizeof(int *); bytes += maxlocal * sizeof(int *);
bytes += maxpage * neighbor->pgsize * sizeof(int);
bytes += 3 * maxlocal * sizeof(double); for (int i = 0; i < comm->nthreads; i++)
bytes += ipage[i].size();
bytes += 2*maxlocal * sizeof(double);
return bytes; return bytes;
} }

View File

@ -21,6 +21,7 @@ PairStyle(airebo,PairAIREBO)
#define LMP_PAIR_AIREBO_H #define LMP_PAIR_AIREBO_H
#include "pair.h" #include "pair.h"
#include "my_page.h"
#include "math.h" #include "math.h"
#include "math_const.h" #include "math_const.h"
@ -38,15 +39,10 @@ class PairAIREBO : public Pair {
double memory_usage(); double memory_usage();
protected: protected:
int **pages; // neighbor list pages
int *map; // 0 (C), 1 (H), or -1 (NULL) for each type int *map; // 0 (C), 1 (H), or -1 (NULL) for each type
int me; int me;
int ljflag,torflag; // 0/1 if LJ,torsion terms included int ljflag,torflag; // 0/1 if LJ,torsion terms included
int maxlocal; // size of numneigh, firstneigh arrays
int maxpage; // # of pages currently allocated
int pgsize; // size of neighbor page
int oneatom; // max # of neighbors for one atom
double cutlj; // user-specified LJ cutoff double cutlj; // user-specified LJ cutoff
double cutljrebosq; // cut for when to compute double cutljrebosq; // cut for when to compute
@ -56,8 +52,13 @@ class PairAIREBO : public Pair {
double **lj1,**lj2,**lj3,**lj4; // pre-computed LJ coeffs for C,H types double **lj1,**lj2,**lj3,**lj4; // pre-computed LJ coeffs for C,H types
double cut3rebo; // maximum distance for 3rd REBO neigh double cut3rebo; // maximum distance for 3rd REBO neigh
int maxlocal; // size of numneigh, firstneigh arrays
int pgsize; // size of neighbor page
int oneatom; // max # of neighbors for one atom
MyPage<int> *ipage; // neighbor list pages
int *REBO_numneigh; // # of pair neighbors for each atom int *REBO_numneigh; // # of pair neighbors for each atom
int **REBO_firstneigh; // ptr to 1st neighbor of each atom int **REBO_firstneigh; // ptr to 1st neighbor of each atom
double *closestdistsq; // closest owned atom dist to each ghost double *closestdistsq; // closest owned atom dist to each ghost
double *nC,*nH; // sum of weighting fns with REBO neighs double *nC,*nH; // sum of weighting fns with REBO neighs
@ -101,7 +102,6 @@ class PairAIREBO : public Pair {
double piRCSpline(double, double, double, int, int, double *); double piRCSpline(double, double, double, int, int, double *);
double TijSpline(double, double, double, double *); double TijSpline(double, double, double, double *);
void add_pages(int howmany = 1);
void read_file(char *); void read_file(char *);
double Sp5th(double, double *, double *); double Sp5th(double, double *, double *);

View File

@ -31,6 +31,7 @@
#include "neigh_request.h" #include "neigh_request.h"
#include "group.h" #include "group.h"
#include "update.h" #include "update.h"
#include "my_page.h"
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
@ -73,8 +74,9 @@ PairComb::PairComb(LAMMPS *lmp) : Pair(lmp)
sht_num = NULL; sht_num = NULL;
sht_first = NULL; sht_first = NULL;
maxpage = 0;
pages = NULL; ipage = NULL;
pgsize = oneatom = 0;
// set comm size needed by this Pair // set comm size needed by this Pair
@ -108,6 +110,8 @@ PairComb::~PairComb()
memory->destroy(sht_num); memory->destroy(sht_num);
memory->destroy(sht_first); memory->destroy(sht_first);
delete [] ipage;
if (allocated) { if (allocated) {
memory->destroy(setflag); memory->destroy(setflag);
memory->destroy(cutsq); memory->destroy(cutsq);
@ -541,9 +545,24 @@ void PairComb::init_style()
neighbor->requests[irequest]->half = 0; neighbor->requests[irequest]->half = 0;
neighbor->requests[irequest]->full = 1; neighbor->requests[irequest]->full = 1;
pgsize = neighbor->pgsize; // local Comb neighbor list
oneatom = neighbor->oneatom; // create pages if first time or if neighbor pgsize/oneatom has changed
if (maxpage == 0) add_pages();
int create = 0;
if (ipage == NULL) create = 1;
if (pgsize != neighbor->pgsize) create = 1;
if (oneatom != neighbor->oneatom) create = 1;
if (create) {
delete [] ipage;
pgsize = neighbor->pgsize;
oneatom = neighbor->oneatom;
int nmypage = comm->nthreads;
ipage = new MyPage<int>[nmypage];
for (int i = 0; i < nmypage; i++)
ipage[i].init(oneatom,pgsize);
}
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -1364,8 +1383,7 @@ void PairComb::sm_table()
memory->create(NCo,nmax,"pair:NCo"); memory->create(NCo,nmax,"pair:NCo");
memory->create(bbij,nmax,MAXNEIGH,"pair:bbij"); memory->create(bbij,nmax,MAXNEIGH,"pair:bbij");
memory->create(sht_num,nmax,"pair:sht_num"); memory->create(sht_num,nmax,"pair:sht_num");
sht_first = (int **) memory->smalloc(nmax*sizeof(int *), sht_first = (int **) memory->smalloc(nmax*sizeof(int *),"pair:sht_first");
"pair:sht_first");
// set interaction number: 0-0=0, 1-1=1, 0-1=1-0=2 // set interaction number: 0-0=0, 1-1=1, 0-1=1-0=2
@ -2023,18 +2041,6 @@ void PairComb::unpack_reverse_comm(int n, int *list, double *buf)
} }
} }
/* ----------------------------------------------------------------------
memory usage of local atom-based arrays
------------------------------------------------------------------------- */
double PairComb::memory_usage()
{
double bytes = maxeatom * sizeof(double);
bytes += maxvatom*6 * sizeof(double);
bytes += nmax * sizeof(int);
bytes += MAXNEIGH * nmax * sizeof(int);
return bytes;
}
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void PairComb::Short_neigh() void PairComb::Short_neigh()
@ -2064,21 +2070,17 @@ void PairComb::Short_neigh()
ilist = list->ilist; ilist = list->ilist;
numneigh = list->numneigh; numneigh = list->numneigh;
firstneigh = list->firstneigh; firstneigh = list->firstneigh;
int npntj = 0;
int npage = 0; // create Comb neighbor list
ipage->reset();
for (ii = 0; ii < inum; ii++) { for (ii = 0; ii < inum; ii++) {
i = ilist[ii]; i = ilist[ii];
itype = type[i]; itype = type[i];
if (pgsize - npntj < oneatom) {
npntj = 0;
npage++;
if (npage == maxpage) add_pages();
}
nj = 0; nj = 0;
neighptrj = &pages[npage][npntj]; neighptrj = ipage->vget();
xtmp = x[i][0]; xtmp = x[i][0];
ytmp = x[i][1]; ytmp = x[i][1];
@ -2103,19 +2105,27 @@ void PairComb::Short_neigh()
sht_first[i] = neighptrj; sht_first[i] = neighptrj;
sht_num[i] = nj; sht_num[i] = nj;
npntj += nj; ipage->vgot(nj);
if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
} }
/* ---------------------------------------------------------------------- */ /* ----------------------------------------------------------------------
memory usage of local atom-based arrays
------------------------------------------------------------------------- */
void PairComb::add_pages(int howmany) double PairComb::memory_usage()
{ {
int toppage = maxpage; double bytes = maxeatom * sizeof(double);
maxpage += howmany*PGDELTA; bytes += maxvatom*6 * sizeof(double);
bytes += nmax * sizeof(int);
bytes += nmax * sizeof(int *);
pages = (int **) for (int i = 0; i < comm->nthreads; i++)
memory->srealloc(pages,maxpage*sizeof(int *),"pair:pages"); bytes += ipage[i].size();
for (int i = toppage; i < maxpage; i++)
memory->create(pages[i],pgsize,"pair:pages[i]"); bytes += nmax * sizeof(int);
bytes += MAXNEIGH*nmax * sizeof(double);
return bytes;
} }

View File

@ -21,6 +21,7 @@ PairStyle(comb,PairComb)
#define LMP_PAIR_COMB_H #define LMP_PAIR_COMB_H
#include "pair.h" #include "pair.h"
#include "my_page.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -77,6 +78,12 @@ class PairComb : public Pair {
int *NCo, cor_flag, cuo_flag, cuo_flag1, cuo_flag2; int *NCo, cor_flag, cuo_flag, cuo_flag1, cuo_flag2;
double **bbij; double **bbij;
int pgsize; // size of neighbor page
int oneatom; // max # of neighbors for one atom
int *sht_num,**sht_first; // short-range neighbor list
MyPage<int> *ipage; // neighbor list pages
double cutmin;
void allocate(); void allocate();
virtual void read_file(char *); virtual void read_file(char *);
void setup(); void setup();
@ -145,13 +152,7 @@ class PairComb : public Pair {
int pack_comm(int , int *, double *, int, int *); int pack_comm(int , int *, double *, int, int *);
void unpack_comm(int , int , double *); void unpack_comm(int , int , double *);
// short range neighbor list
void add_pages(int howmany = 1);
void Short_neigh(); void Short_neigh();
int maxpage, pgsize, oneatom, **pages;
int *sht_num, **sht_first; // short-range neighbor list
double cutmin;
// vector functions, inline for efficiency // vector functions, inline for efficiency

View File

@ -30,6 +30,7 @@
#include "neighbor.h" #include "neighbor.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "neigh_request.h" #include "neigh_request.h"
#include "my_page.h"
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
@ -52,8 +53,9 @@ PairLCBOP::PairLCBOP(LAMMPS *lmp) : Pair(lmp) {
maxlocal = 0; maxlocal = 0;
SR_numneigh = NULL; SR_numneigh = NULL;
SR_firstneigh = NULL; SR_firstneigh = NULL;
maxpage = 0; ipage = NULL;
pages = NULL; pgsize = oneatom = 0;
N = NULL; N = NULL;
M = NULL; M = NULL;
} }
@ -62,11 +64,11 @@ PairLCBOP::PairLCBOP(LAMMPS *lmp) : Pair(lmp) {
check if allocated, since class can be destructed when incomplete check if allocated, since class can be destructed when incomplete
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
PairLCBOP::~PairLCBOP() { PairLCBOP::~PairLCBOP()
{
memory->destroy(SR_numneigh); memory->destroy(SR_numneigh);
memory->sfree(SR_firstneigh); memory->sfree(SR_firstneigh);
for (int i = 0; i < maxpage; i++) memory->destroy(pages[i]); delete [] ipage;
memory->sfree(pages);
memory->destroy(N); memory->destroy(N);
memory->destroy(M); memory->destroy(M);
@ -191,11 +193,24 @@ void PairLCBOP::init_style()
neighbor->requests[irequest]->full = 1; neighbor->requests[irequest]->full = 1;
neighbor->requests[irequest]->ghost = 1; neighbor->requests[irequest]->ghost = 1;
// local SR neighbor list memory // local SR neighbor list
// create pages if first time or if neighbor pgsize/oneatom has changed
pgsize = neighbor->pgsize; int create = 0;
oneatom = neighbor->oneatom; if (ipage == NULL) create = 1;
if (maxpage == 0) add_pages(); if (pgsize != neighbor->pgsize) create = 1;
if (oneatom != neighbor->oneatom) create = 1;
if (create) {
delete [] ipage;
pgsize = neighbor->pgsize;
oneatom = neighbor->oneatom;
int nmypage = comm->nthreads;
ipage = new MyPage<int>[nmypage];
for (int i = 0; i < nmypage; i++)
ipage[i].init(oneatom,pgsize,PGDELTA);
}
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -238,9 +253,7 @@ double PairLCBOP::init_one(int i, int j)
void PairLCBOP::SR_neigh() void PairLCBOP::SR_neigh()
{ {
int i,j,ii,jj,n, int i,j,ii,jj,n,allnum,jnum;
allnum, // number of atoms(both local and ghost) neighbors are stored for
jnum;
double xtmp,ytmp,ztmp,delx,dely,delz,rsq,dS; double xtmp,ytmp,ztmp,delx,dely,delz,rsq,dS;
int *ilist,*jlist,*numneigh,**firstneigh; int *ilist,*jlist,*numneigh,**firstneigh;
int *neighptr; int *neighptr;
@ -270,19 +283,13 @@ void PairLCBOP::SR_neigh()
// store all SR neighs of owned and ghost atoms // store all SR neighs of owned and ghost atoms
// scan full neighbor list of I // scan full neighbor list of I
int npage = 0; ipage->reset();
int npnt = 0; // position in current page
for (ii = 0; ii < allnum; ii++) { for (ii = 0; ii < allnum; ii++) {
i = ilist[ii]; i = ilist[ii];
if (pgsize - npnt < oneatom) { // ensure at least oneatom space free at current page
npnt = 0;
npage++;
if (npage == maxpage) add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
xtmp = x[i][0]; xtmp = x[i][0];
ytmp = x[i][1]; ytmp = x[i][1];
@ -307,14 +314,13 @@ void PairLCBOP::SR_neigh()
SR_firstneigh[i] = neighptr; SR_firstneigh[i] = neighptr;
SR_numneigh[i] = n; SR_numneigh[i] = n;
npnt += n; ipage->vgot(n);
if( npnt >= pgsize ) if (ipage->status())
error->one(FLERR, error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
"Neighbor list overflow, boost neigh_modify one or page");
} }
// calculate M_i // calculate M_i
for (ii = 0; ii < allnum; ii++) { for (ii = 0; ii < allnum; ii++) {
i = ilist[ii]; i = ilist[ii];
@ -861,21 +867,6 @@ double PairLCBOP::b(int i, int j, double rij[3],
return bij; return bij;
} }
/* ----------------------------------------------------------------------
add pages to SR neighbor list
------------------------------------------------------------------------- */
void PairLCBOP::add_pages(int howmany)
{
int toppage = maxpage;
maxpage += howmany*PGDELTA;
pages = (int **)
memory->srealloc(pages,maxpage*sizeof(int *),"LCBOP:pages");
for (int i = toppage; i < maxpage; i++)
memory->create(pages[i],pgsize,"LCBOP:pages[i]");
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
spline interpolation for G spline interpolation for G
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
@ -1287,11 +1278,15 @@ void PairLCBOP::spline_init() {
memory usage of local atom-based arrays memory usage of local atom-based arrays
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
double PairLCBOP::memory_usage() { double PairLCBOP::memory_usage()
{
double bytes = 0.0; double bytes = 0.0;
bytes += maxlocal * sizeof(int); bytes += maxlocal * sizeof(int);
bytes += maxlocal * sizeof(int *); bytes += maxlocal * sizeof(int *);
bytes += maxpage * neighbor->pgsize * sizeof(int);
bytes += 3 * maxlocal * sizeof(double); for (int i = 0; i < comm->nthreads; i++)
bytes += ipage[i].size();
bytes += 3*maxlocal * sizeof(double);
return bytes; return bytes;
} }

View File

@ -21,6 +21,7 @@ PairStyle(lcbop,PairLCBOP)
#define LMP_PAIR_LCBOP_H #define LMP_PAIR_LCBOP_H
#include "pair.h" #include "pair.h"
#include "my_page.h"
#include "math.h" #include "math.h"
#include "math_const.h" #include "math_const.h"
@ -42,18 +43,20 @@ class PairLCBOP : public Pair {
int *map; // 0 (C) or -1 (NULL) for each type int *map; // 0 (C) or -1 (NULL) for each type
int me; int me;
int maxlocal; // size of numneigh, firstneigh arrays
int maxpage; // # of pages currently allocated
int pgsize; // size of neighbor page
int oneatom; // max # of neighbors for one atom
double cutLR; // LR cutoff double cutLR; // LR cutoff
double cutLRsq; // LR cutoff squared double cutLRsq; // LR cutoff squared
double cut3rebo; // maximum distance for 3rd SR neigh double cut3rebo; // maximum distance for 3rd SR neigh
int maxlocal; // size of numneigh, firstneigh arrays
int maxpage; // # of pages currently allocated
int pgsize; // size of neighbor page
int oneatom; // max # of neighbors for one atom
MyPage<int> *ipage; // neighbor list pages
int *SR_numneigh; // # of pair neighbors for each atom int *SR_numneigh; // # of pair neighbors for each atom
int **SR_firstneigh; // ptr to 1st neighbor of each atom int **SR_firstneigh; // ptr to 1st neighbor of each atom
double *N; // sum of cutoff fns ( f_C ) with SR neighs double *N; // sum of cutoff fns ( f_C ) with SR neighs
double *M; // sum_j f_C_ij*F(N_j - f_C_ij) double *M; // sum_j f_C_ij*F(N_j - f_C_ij)
@ -80,6 +83,7 @@ class PairLCBOP : public Pair {
f_y_10, f_y_10,
f_y_11; f_y_11;
} F_conj_field[3][3][2]; } F_conj_field[3][3][2];
double F_conj_data[4][4][2][3]; // temporary data from file double F_conj_data[4][4][2][3]; // temporary data from file
double gX[6]; // x coordinates for described points[# of points]; double gX[6]; // x coordinates for described points[# of points];
double gC[5+1][6-1]; // coefficients for each period between described points [degree of polynomial+1][# of points-1] double gC[5+1][6-1]; // coefficients for each period between described points [degree of polynomial+1][# of points-1]
@ -98,7 +102,6 @@ class PairLCBOP : public Pair {
void g_decompose_x( double, size_t*, double* ); void g_decompose_x( double, size_t*, double* );
double F_conj( double, double, double, double*, double*, double* ); double F_conj( double, double, double, double*, double*, double* );
void add_pages(int howmany = 1);
void read_file( char * ); void read_file( char * );
void spline_init(); void spline_init();

View File

@ -31,8 +31,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
#define MAXTOUCH 15
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
copy shear partner info from neighbor lists to atom arrays copy shear partner info from neighbor lists to atom arrays
so can be exchanged with atoms so can be exchanged with atoms
@ -45,10 +43,10 @@ void FixShearHistoryOMP::pre_exchange()
const int nghost = atom->nghost; const int nghost = atom->nghost;
const int nall = nlocal + nghost; const int nall = nlocal + nghost;
const int nthreads = comm->nthreads; const int nthreads = comm->nthreads;
maxtouch = 0;
int flag = 0;
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel default(none) shared(flag) #pragma omp parallel default(none)
#endif #endif
{ {
@ -64,22 +62,23 @@ void FixShearHistoryOMP::pre_exchange()
const int lmax = lfrom +ldelta; const int lmax = lfrom +ldelta;
const int lto = (lmax > nlocal) ? nlocal : lmax; const int lto = (lmax > nlocal) ? nlocal : lmax;
const int gdelta = 1 + nghost/nthreads; int i,j,ii,jj,m,n,inum,jnum;
const int gfrom = nlocal + tid*gdelta;
const int gmax = gfrom + gdelta;
const int gto = (gmax > nall) ? nall : gmax;
int i,j,ii,jj,m,inum,jnum;
int *ilist,*jlist,*numneigh,**firstneigh; int *ilist,*jlist,*numneigh,**firstneigh;
int *touch,**firsttouch; int *touch,**firsttouch;
double *shear,*allshear,**firstshear; double *shear,*allshear,**firstshear;
// zero npartners for all current atoms // zero npartners for all current atoms and
// clear page data structures for this thread
for (i = lfrom; i < lto; i++) npartner[i] = 0; for (i = lfrom; i < lto; i++) npartner[i] = 0;
// copy shear info from neighbor list atoms to atom arrays MyPage <int> &ipg = ipage[tid];
MyPage <double[3]> &dpg = dpage[tid];
ipg.reset();
dpg.reset();
// 1st loop over neighbor list
// calculate nparter for each owned atom
int *tag = atom->tag; int *tag = atom->tag;
@ -91,6 +90,42 @@ void FixShearHistoryOMP::pre_exchange()
firsttouch = list->listgranhistory->firstneigh; firsttouch = list->listgranhistory->firstneigh;
firstshear = list->listgranhistory->firstdouble; firstshear = list->listgranhistory->firstdouble;
for (ii = 0; ii < inum; ii++) {
i = ilist[ii];
jlist = firstneigh[i];
jnum = numneigh[i];
touch = firsttouch[i];
for (jj = 0; jj < jnum; jj++) {
if (touch[jj]) {
if ((i >= lfrom) && (i < lto))
npartner[i]++;
j = jlist[jj];
j &= NEIGHMASK;
if ((j >= lfrom) && (j < lto))
npartner[j]++;
}
}
}
// get page chunks to store atom IDs and shear history for my atoms
for (ii = lfrom; ii < lto; ii++) {
i = ilist[ii];
n = npartner[i];
partner[i] = ipg.get(n);
shearpartner[i] = dpg.get(n);
if (partner[i] == NULL || shearpartner[i] == NULL)
error->one(FLERR,"Shear history overflow, boost neigh_modify one");
}
// 2nd loop over neighbor list
// store atom IDs and shear history for my atoms
// re-zero npartner to use as counter for all my atoms
for (i = lfrom; i < lto; i++) npartner[i] = 0;
for (ii = 0; ii < inum; ii++) { for (ii = 0; ii < inum; ii++) {
i = ilist[ii]; i = ilist[ii];
jlist = firstneigh[i]; jlist = firstneigh[i];
@ -100,53 +135,39 @@ void FixShearHistoryOMP::pre_exchange()
for (jj = 0; jj < jnum; jj++) { for (jj = 0; jj < jnum; jj++) {
if (touch[jj]) { if (touch[jj]) {
shear = &allshear[3*jj];
j = jlist[jj]; j = jlist[jj];
j &= NEIGHMASK; j &= NEIGHMASK;
shear = &allshear[3*jj];
if ((i >= lfrom) && (i < lto)) { if ((i >= lfrom) && (i < lto)) {
if (npartner[i] < MAXTOUCH) { m = npartner[i];
m = npartner[i]; partner[i][m] = tag[j];
partner[i][m] = tag[j]; shearpartner[i][m][0] = shear[0];
shearpartner[i][m][0] = shear[0]; shearpartner[i][m][1] = shear[1];
shearpartner[i][m][1] = shear[1]; shearpartner[i][m][2] = shear[2];
shearpartner[i][m][2] = shear[2];
}
npartner[i]++; npartner[i]++;
} }
if ((j >= lfrom) && (j < lto)) { if ((j >= lfrom) && (j < lto)) {
if (npartner[j] < MAXTOUCH) { m = npartner[j];
m = npartner[j]; partner[j][m] = tag[i];
partner[j][m] = tag[i]; shearpartner[j][m][0] = -shear[0];
shearpartner[j][m][0] = -shear[0]; shearpartner[j][m][1] = -shear[1];
shearpartner[j][m][1] = -shear[1]; shearpartner[j][m][2] = -shear[2];
shearpartner[j][m][2] = -shear[2];
}
npartner[j]++;
}
if ((j >= gfrom) && (j < gto)) {
npartner[j]++; npartner[j]++;
} }
} }
} }
} }
// test for too many touching neighbors // set maxtouch = max # of partners of any owned atom
int myflag = 0; m = 0;
for (i = lfrom; i < lto; i++) for (i = lfrom; i < lto; i++)
if (npartner[i] >= MAXTOUCH) myflag = 1; m = MAX(m,npartner[i]);
if (myflag)
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp atomic #pragma omp critical
#endif #endif
++flag; maxtouch = MAX(m,maxtouch);
} }
int flag_all;
MPI_Allreduce(&flag,&flag_all,1,MPI_INT,MPI_SUM,world);
if (flag_all)
error->all(FLERR,"Too many touching neighbors - boost MAXTOUCH");
} }

View File

@ -16,6 +16,7 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "atom.h" #include "atom.h"
#include "comm.h" #include "comm.h"
#include "my_page.h"
#include "error.h" #include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -48,27 +49,16 @@ void Neighbor::half_from_full_no_newton_omp(NeighList *list)
int *numneigh_full = list->listfull->numneigh; int *numneigh_full = list->listfull->numneigh;
int **firstneigh_full = list->listfull->firstneigh; int **firstneigh_full = list->listfull->firstneigh;
// each thread works on its own page // each thread has its own page allocator
int npage = tid; MyPage<int> &ipage = list->ipage[tid];
int npnt = 0; ipage.reset();
// loop over atoms in full list // loop over atoms in full list
for (ii = ifrom; ii < ito; ii++) { for (ii = ifrom; ii < ito; ii++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
// only one thread at a time may check whether we
// need new neighbor list pages and then add to them.
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0; n = 0;
neighptr = ipage.vget();
// loop over parent full list // loop over parent full list
@ -85,8 +75,8 @@ void Neighbor::half_from_full_no_newton_omp(NeighList *list)
ilist[ii] = i; ilist[ii] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;
@ -124,27 +114,16 @@ void Neighbor::half_from_full_newton_omp(NeighList *list)
int *numneigh_full = list->listfull->numneigh; int *numneigh_full = list->listfull->numneigh;
int **firstneigh_full = list->listfull->firstneigh; int **firstneigh_full = list->listfull->firstneigh;
// each thread works on its own page // each thread has its own page allocator
int npage = tid; MyPage<int> &ipage = list->ipage[tid];
int npnt = 0; ipage.reset();
// loop over parent full list // loop over parent full list
for (ii = ifrom; ii < ito; ii++) { for (ii = ifrom; ii < ito; ii++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
// only one thread at a time may check whether we
// need new neighbor list pages and then add to them.
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0; n = 0;
neighptr = ipage.vget();
i = ilist_full[ii]; i = ilist_full[ii];
xtmp = x[i][0]; xtmp = x[i][0];
@ -174,8 +153,8 @@ void Neighbor::half_from_full_newton_omp(NeighList *list)
ilist[ii] = i; ilist[ii] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;

View File

@ -18,6 +18,7 @@
#include "comm.h" #include "comm.h"
#include "domain.h" #include "domain.h"
#include "group.h" #include "group.h"
#include "my_page.h"
#include "error.h" #include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -57,24 +58,16 @@ void Neighbor::full_nsq_omp(NeighList *list)
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int npage = tid; // each thread has its own page allocator
int npnt = 0; MyPage<int> &ipage = list->ipage[tid];
ipage.reset();
// loop over owned atoms, storing neighbors // loop over owned atoms, storing neighbors
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0; n = 0;
neighptr = ipage.vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -108,8 +101,8 @@ void Neighbor::full_nsq_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;
@ -152,24 +145,16 @@ void Neighbor::full_nsq_ghost_omp(NeighList *list)
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int npage = tid; // each thread has its own page allocator
int npnt = 0; MyPage<int> &ipage = list->ipage[tid];
ipage.reset();
// loop over owned & ghost atoms, storing neighbors // loop over owned & ghost atoms, storing neighbors
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0; n = 0;
neighptr = ipage.vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -218,8 +203,8 @@ void Neighbor::full_nsq_ghost_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;
@ -266,24 +251,16 @@ void Neighbor::full_bin_omp(NeighList *list)
int nstencil = list->nstencil; int nstencil = list->nstencil;
int *stencil = list->stencil; int *stencil = list->stencil;
int npage = tid; // each thread has its own page allocator
int npnt = 0; MyPage<int> &ipage = list->ipage[tid];
ipage.reset();
// loop over owned atoms, storing neighbors // loop over owned atoms, storing neighbors
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0; n = 0;
neighptr = ipage.vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -322,8 +299,8 @@ void Neighbor::full_bin_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;
@ -374,24 +351,16 @@ void Neighbor::full_bin_ghost_omp(NeighList *list)
int *stencil = list->stencil; int *stencil = list->stencil;
int **stencilxyz = list->stencilxyz; int **stencilxyz = list->stencilxyz;
int npage = tid; // each thread has its own page allocator
int npnt = 0; MyPage<int> &ipage = list->ipage[tid];
ipage.reset();
// loop over owned & ghost atoms, storing neighbors // loop over owned & ghost atoms, storing neighbors
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0; n = 0;
neighptr = ipage.vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -457,8 +426,8 @@ void Neighbor::full_bin_ghost_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;
@ -510,22 +479,14 @@ void Neighbor::full_multi_omp(NeighList *list)
int **stencil_multi = list->stencil_multi; int **stencil_multi = list->stencil_multi;
double **distsq_multi = list->distsq_multi; double **distsq_multi = list->distsq_multi;
int npage = tid; // each thread has its own page allocator
int npnt = 0; MyPage<int> &ipage = list->ipage[tid];
ipage.reset();
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0; n = 0;
neighptr = ipage.vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -569,8 +530,8 @@ void Neighbor::full_multi_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;

View File

@ -40,10 +40,6 @@ void Neighbor::granular_nsq_no_newton_omp(NeighList *list)
NEIGH_OMP_INIT; NEIGH_OMP_INIT;
if (fix_history)
if (nthreads > listgranhistory->maxpage)
listgranhistory->add_pages(nthreads - listgranhistory->maxpage);
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel default(none) shared(list,listgranhistory) #pragma omp parallel default(none) shared(list,listgranhistory)
#endif #endif
@ -59,6 +55,8 @@ void Neighbor::granular_nsq_no_newton_omp(NeighList *list)
double (**shearpartner)[3]; double (**shearpartner)[3];
int **firsttouch; int **firsttouch;
double **firstshear; double **firstshear;
MyPage<int> *ipage_touch;
MyPage<double> *dpage_shear;
double **x = atom->x; double **x = atom->x;
double *radius = atom->radius; double *radius = atom->radius;
@ -72,41 +70,32 @@ void Neighbor::granular_nsq_no_newton_omp(NeighList *list)
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
// each thread has its own page allocator
MyPage<int> &ipage = list->ipage[tid];
ipage.reset();
if (fix_history) { if (fix_history) {
npartner = fix_history->npartner; npartner = fix_history->npartner;
partner = fix_history->partner; partner = fix_history->partner;
shearpartner = fix_history->shearpartner; shearpartner = fix_history->shearpartner;
firsttouch = listgranhistory->firstneigh; firsttouch = listgranhistory->firstneigh;
firstshear = listgranhistory->firstdouble; firstshear = listgranhistory->firstdouble;
ipage_touch = listgranhistory->ipage+tid;
dpage_shear = listgranhistory->dpage+tid;
ipage_touch->reset();
dpage_shear->reset();
} }
int npage = tid;
int npnt = 0;
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP) n = 0;
#pragma omp critical neighptr = ipage.vget();
#endif if (fix_history) {
{ nn = 0;
if (pgsize - npnt < oneatom) { touchptr = ipage_touch->vget();
npnt = 0; shearptr = dpage_shear->vget();
npage += nthreads;
if (npage >= list->maxpage) {
list->add_pages(nthreads);
if (fix_history)
listgranhistory->add_pages(nthreads);
}
}
n = nn = 0;
neighptr = &(list->pages[npage][npnt]);
if (fix_history) {
touchptr = &(listgranhistory->pages[npage][npnt]);
shearptr = &(listgranhistory->dpages[npage][3*npnt]);
}
} }
xtmp = x[i][0]; xtmp = x[i][0];
ytmp = x[i][1]; ytmp = x[i][1];
ztmp = x[i][2]; ztmp = x[i][2];
@ -158,13 +147,16 @@ void Neighbor::granular_nsq_no_newton_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
ipage.vgot(n);
if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
if (fix_history) { if (fix_history) {
firsttouch[i] = touchptr; firsttouch[i] = touchptr;
firstshear[i] = shearptr; firstshear[i] = shearptr;
ipage_touch->vgot(n);
dpage_shear->vgot(nn);
} }
npnt += n;
if (n > oneatom)
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;
list->inum = nlocal; list->inum = nlocal;
@ -207,22 +199,14 @@ void Neighbor::granular_nsq_newton_omp(NeighList *list)
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int npage = tid; // each thread has its own page allocator
int npnt = 0; MyPage<int> &ipage = list->ipage[tid];
ipage.reset();
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0; n = 0;
neighptr = ipage.vget();
itag = tag[i]; itag = tag[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -265,8 +249,8 @@ void Neighbor::granular_nsq_newton_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;
@ -295,10 +279,6 @@ void Neighbor::granular_bin_no_newton_omp(NeighList *list)
NEIGH_OMP_INIT; NEIGH_OMP_INIT;
if (fix_history)
if (nthreads > listgranhistory->maxpage)
listgranhistory->add_pages(nthreads - listgranhistory->maxpage);
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel default(none) shared(list,listgranhistory) #pragma omp parallel default(none) shared(list,listgranhistory)
#endif #endif
@ -309,6 +289,8 @@ void Neighbor::granular_bin_no_newton_omp(NeighList *list)
double radi,radsum,cutsq; double radi,radsum,cutsq;
int *neighptr,*touchptr; int *neighptr,*touchptr;
double *shearptr; double *shearptr;
MyPage<int> *ipage_touch;
MyPage<double> *dpage_shear;
int *npartner,**partner; int *npartner,**partner;
double (**shearpartner)[3]; double (**shearpartner)[3];
@ -330,39 +312,30 @@ void Neighbor::granular_bin_no_newton_omp(NeighList *list)
int nstencil = list->nstencil; int nstencil = list->nstencil;
int *stencil = list->stencil; int *stencil = list->stencil;
// each thread has its own page allocator
MyPage<int> &ipage = list->ipage[tid];
ipage.reset();
if (fix_history) { if (fix_history) {
npartner = fix_history->npartner; npartner = fix_history->npartner;
partner = fix_history->partner; partner = fix_history->partner;
shearpartner = fix_history->shearpartner; shearpartner = fix_history->shearpartner;
firsttouch = listgranhistory->firstneigh; firsttouch = listgranhistory->firstneigh;
firstshear = listgranhistory->firstdouble; firstshear = listgranhistory->firstdouble;
ipage_touch = listgranhistory->ipage+tid;
dpage_shear = listgranhistory->dpage+tid;
ipage_touch->reset();
dpage_shear->reset();
} }
int npage = tid;
int npnt = 0;
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP) n = 0;
#pragma omp critical neighptr = ipage.vget();
#endif if (fix_history) {
{ nn = 0;
if (pgsize - npnt < oneatom) { touchptr = ipage_touch->vget();
npnt = 0; shearptr = dpage_shear->vget();
npage += nthreads;
if (npage >= list->maxpage) {
list->add_pages(nthreads);
if (fix_history)
listgranhistory->add_pages(nthreads);
}
}
n = nn = 0;
neighptr = &(list->pages[npage][npnt]);
if (fix_history) {
touchptr = &(listgranhistory->pages[npage][npnt]);
shearptr = &(listgranhistory->dpages[npage][3*npnt]);
}
} }
xtmp = x[i][0]; xtmp = x[i][0];
@ -422,13 +395,16 @@ void Neighbor::granular_bin_no_newton_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
ipage.vgot(n);
if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
if (fix_history) { if (fix_history) {
firsttouch[i] = touchptr; firsttouch[i] = touchptr;
firstshear[i] = shearptr; firstshear[i] = shearptr;
ipage_touch->vgot(n);
dpage_shear->vgot(nn);
} }
npnt += n;
if (n > oneatom)
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;
list->inum = nlocal; list->inum = nlocal;
@ -475,22 +451,14 @@ void Neighbor::granular_bin_newton_omp(NeighList *list)
int nstencil = list->nstencil; int nstencil = list->nstencil;
int *stencil = list->stencil; int *stencil = list->stencil;
int npage = tid; // each thread has its own page allocator
int npnt = 0; MyPage<int> &ipage = list->ipage[tid];
ipage.reset();
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
n = 0; n = 0;
neighptr = &(list->pages[npage][npnt]); neighptr = ipage.vget();
xtmp = x[i][0]; xtmp = x[i][0];
ytmp = x[i][1]; ytmp = x[i][1];
@ -543,8 +511,8 @@ void Neighbor::granular_bin_newton_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;
@ -592,22 +560,14 @@ void Neighbor::granular_bin_newton_tri_omp(NeighList *list)
int nstencil = list->nstencil; int nstencil = list->nstencil;
int *stencil = list->stencil; int *stencil = list->stencil;
int npage = tid; // each thread has its own page allocator
int npnt = 0; MyPage<int> &ipage = list->ipage[tid];
ipage.reset();
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
n = 0; n = 0;
neighptr = &(list->pages[npage][npnt]); neighptr = ipage.vget();
xtmp = x[i][0]; xtmp = x[i][0];
ytmp = x[i][1]; ytmp = x[i][1];
@ -648,8 +608,8 @@ void Neighbor::granular_bin_newton_tri_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;

View File

@ -17,6 +17,7 @@
#include "atom.h" #include "atom.h"
#include "comm.h" #include "comm.h"
#include "domain.h" #include "domain.h"
#include "my_page.h"
#include "error.h" #include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -64,23 +65,14 @@ void Neighbor::half_bin_no_newton_omp(NeighList *list)
int nstencil = list->nstencil; int nstencil = list->nstencil;
int *stencil = list->stencil; int *stencil = list->stencil;
// each thread works on its own page // each thread has its own page allocator
int npage = tid; MyPage<int> &ipage = list->ipage[tid];
int npnt = 0; ipage.reset();
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0; n = 0;
neighptr = ipage.vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -121,8 +113,8 @@ void Neighbor::half_bin_no_newton_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;
@ -177,23 +169,14 @@ void Neighbor::half_bin_no_newton_ghost_omp(NeighList *list)
int *stencil = list->stencil; int *stencil = list->stencil;
int **stencilxyz = list->stencilxyz; int **stencilxyz = list->stencilxyz;
// each thread works on its own page // each thread has its own page allocator
int npage = tid; MyPage<int> &ipage = list->ipage[tid];
int npnt = 0; ipage.reset();
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0; n = 0;
neighptr = ipage.vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -263,8 +246,8 @@ void Neighbor::half_bin_no_newton_ghost_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;
@ -314,23 +297,14 @@ void Neighbor::half_bin_newton_omp(NeighList *list)
int nstencil = list->nstencil; int nstencil = list->nstencil;
int *stencil = list->stencil; int *stencil = list->stencil;
// each thread works on its own page // each thread has its own page allocator
int npage = tid; MyPage<int> &ipage = list->ipage[tid];
int npnt = 0; ipage.reset();
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0; n = 0;
neighptr = ipage.vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -399,8 +373,8 @@ void Neighbor::half_bin_newton_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;
@ -449,23 +423,14 @@ void Neighbor::half_bin_newton_tri_omp(NeighList *list)
int nstencil = list->nstencil; int nstencil = list->nstencil;
int *stencil = list->stencil; int *stencil = list->stencil;
// each thread works on its own page // each thread has its own page allocator
int npage = tid; MyPage<int> &ipage = list->ipage[tid];
int npnt = 0; ipage.reset();
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0; n = 0;
neighptr = ipage.vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -513,8 +478,8 @@ void Neighbor::half_bin_newton_tri_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;

View File

@ -17,6 +17,7 @@
#include "atom.h" #include "atom.h"
#include "comm.h" #include "comm.h"
#include "domain.h" #include "domain.h"
#include "my_page.h"
#include "error.h" #include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -67,23 +68,14 @@ void Neighbor::half_multi_no_newton_omp(NeighList *list)
int **stencil_multi = list->stencil_multi; int **stencil_multi = list->stencil_multi;
double **distsq_multi = list->distsq_multi; double **distsq_multi = list->distsq_multi;
// each thread works on its own page // each thread has its own page allocator
int npage = tid; MyPage<int> &ipage = list->ipage[tid];
int npnt = 0; ipage.reset();
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0; n = 0;
neighptr = ipage.vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -129,8 +121,8 @@ void Neighbor::half_multi_no_newton_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;
@ -182,23 +174,14 @@ void Neighbor::half_multi_newton_omp(NeighList *list)
int **stencil_multi = list->stencil_multi; int **stencil_multi = list->stencil_multi;
double **distsq_multi = list->distsq_multi; double **distsq_multi = list->distsq_multi;
// each thread works on its own page // each thread has its own page allocator
int npage = tid; MyPage<int> &ipage = list->ipage[tid];
int npnt = 0; ipage.reset();
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0; n = 0;
neighptr = ipage.vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -272,8 +255,8 @@ void Neighbor::half_multi_newton_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;
@ -325,23 +308,14 @@ void Neighbor::half_multi_newton_tri_omp(NeighList *list)
int **stencil_multi = list->stencil_multi; int **stencil_multi = list->stencil_multi;
double **distsq_multi = list->distsq_multi; double **distsq_multi = list->distsq_multi;
// each thread works on its own page // each thread has its own page allocator
int npage = tid; MyPage<int> &ipage = list->ipage[tid];
int npnt = 0; ipage.reset();
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0; n = 0;
neighptr = ipage.vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -396,8 +370,8 @@ void Neighbor::half_multi_newton_tri_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;

View File

@ -18,6 +18,7 @@
#include "comm.h" #include "comm.h"
#include "domain.h" #include "domain.h"
#include "group.h" #include "group.h"
#include "my_page.h"
#include "error.h" #include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -58,25 +59,16 @@ void Neighbor::half_nsq_no_newton_omp(NeighList *list)
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
// each thread works on its own page // each thread has its own page allocator
int npage = tid; MyPage<int> &ipage = list->ipage[tid];
int npnt = 0; ipage.reset();
// loop over owned atoms, storing neighbors // loop over owned atoms, storing neighbors
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0; n = 0;
neighptr = ipage.vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -110,8 +102,8 @@ void Neighbor::half_nsq_no_newton_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;
@ -156,25 +148,16 @@ void Neighbor::half_nsq_no_newton_ghost_omp(NeighList *list)
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
// each thread works on its own page // each thread has its own page allocator
int npage = tid; MyPage<int> &ipage = list->ipage[tid];
int npnt = 0; ipage.reset();
// loop over owned & ghost atoms, storing neighbors // loop over owned & ghost atoms, storing neighbors
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0; n = 0;
neighptr = ipage.vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -228,8 +211,8 @@ void Neighbor::half_nsq_no_newton_ghost_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;
@ -275,22 +258,14 @@ void Neighbor::half_nsq_newton_omp(NeighList *list)
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int npage = tid; // each thread has its own page allocator
int npnt = 0; MyPage<int> &ipage = list->ipage[tid];
ipage.reset();
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0; n = 0;
neighptr = ipage.vget();
itag = tag[i]; itag = tag[i];
itype = type[i]; itype = type[i];
@ -341,8 +316,8 @@ void Neighbor::half_nsq_newton_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
NEIGH_OMP_CLOSE; NEIGH_OMP_CLOSE;

View File

@ -18,6 +18,7 @@
#include "comm.h" #include "comm.h"
#include "domain.h" #include "domain.h"
#include "group.h" #include "group.h"
#include "my_page.h"
#include "error.h" #include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -37,16 +38,8 @@ void Neighbor::respa_nsq_no_newton_omp(NeighList *list)
NEIGH_OMP_INIT; NEIGH_OMP_INIT;
NeighList *listinner = list->listinner; NeighList *listinner = list->listinner;
if (nthreads > listinner->maxpage) NeighList *listmiddle = list->listmiddle;
listinner->add_pages(nthreads - listinner->maxpage);
NeighList *listmiddle;
const int respamiddle = list->respamiddle; const int respamiddle = list->respamiddle;
if (respamiddle) {
listmiddle = list->listmiddle;
if (nthreads > listmiddle->maxpage)
listmiddle->add_pages(nthreads - listmiddle->maxpage);
}
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel default(none) shared(list,listinner,listmiddle) #pragma omp parallel default(none) shared(list,listinner,listmiddle)
@ -85,48 +78,30 @@ void Neighbor::respa_nsq_no_newton_omp(NeighList *list)
firstneigh_middle = listmiddle->firstneigh; firstneigh_middle = listmiddle->firstneigh;
} }
int npage = tid; // each thread has its own page allocator
int npnt = 0; MyPage<int> &ipage = list->ipage[tid];
int npage_inner = tid; MyPage<int> &ipage_inner = listinner->ipage[tid];
int npnt_inner = 0; ipage.reset();
int npage_middle = tid; ipage_inner.reset();
int npnt_middle = 0;
MyPage<int> *ipage_middle;
if (respamiddle) {
ipage_middle = listmiddle->ipage + tid;
ipage_middle->reset();
}
int which = 0; int which = 0;
int minchange = 0; int minchange = 0;
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP) n = n_inner = 0;
#pragma omp critical neighptr = ipage.vget();
#endif neighptr_inner = ipage_inner.vget();
{
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0;
if (pgsize - npnt_inner < oneatom) {
npnt_inner = 0;
npage_inner += nthreads;
if (npage_inner >= listinner->maxpage) listinner->add_pages(nthreads);
}
neighptr_inner = &(listinner->pages[npage_inner][npnt_inner]);
n_inner = 0;
if (respamiddle) { if (respamiddle) {
if (pgsize - npnt_middle < oneatom) {
npnt_middle = 0;
npage_middle += nthreads;
if (npage_middle >= listmiddle->maxpage) listmiddle->add_pages(nthreads);
}
neighptr_middle = &(listmiddle->pages[npage_middle][npnt_middle]);
n_middle = 0; n_middle = 0;
neighptr_middle = ipage_middle->vget();
} }
}
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -172,23 +147,23 @@ void Neighbor::respa_nsq_no_newton_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
ilist_inner[i] = i; ilist_inner[i] = i;
firstneigh_inner[i] = neighptr_inner; firstneigh_inner[i] = neighptr_inner;
numneigh_inner[i] = n_inner; numneigh_inner[i] = n_inner;
npnt_inner += n_inner; ipage.vgot(n_inner);
if (n_inner > oneatom) if (ipage_inner.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
if (respamiddle) { if (respamiddle) {
ilist_middle[i] = i; ilist_middle[i] = i;
firstneigh_middle[i] = neighptr_middle; firstneigh_middle[i] = neighptr_middle;
numneigh_middle[i] = n_middle; numneigh_middle[i] = n_middle;
npnt_middle += n_middle; ipage_middle->vgot(n_middle);
if (n_middle > oneatom) if (ipage_middle->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
} }
@ -214,16 +189,8 @@ void Neighbor::respa_nsq_newton_omp(NeighList *list)
NEIGH_OMP_INIT; NEIGH_OMP_INIT;
NeighList *listinner = list->listinner; NeighList *listinner = list->listinner;
if (nthreads > listinner->maxpage) NeighList *listmiddle = list->listmiddle;
listinner->add_pages(nthreads - listinner->maxpage);
NeighList *listmiddle;
const int respamiddle = list->respamiddle; const int respamiddle = list->respamiddle;
if (respamiddle) {
listmiddle = list->listmiddle;
if (nthreads > listmiddle->maxpage)
listmiddle->add_pages(nthreads - listmiddle->maxpage);
}
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel default(none) shared(list,listinner,listmiddle) #pragma omp parallel default(none) shared(list,listinner,listmiddle)
@ -262,48 +229,30 @@ void Neighbor::respa_nsq_newton_omp(NeighList *list)
firstneigh_middle = listmiddle->firstneigh; firstneigh_middle = listmiddle->firstneigh;
} }
int npage = tid; // each thread has its own page allocator
int npnt = 0; MyPage<int> &ipage = list->ipage[tid];
int npage_inner = tid; MyPage<int> &ipage_inner = listinner->ipage[tid];
int npnt_inner = 0; ipage.reset();
int npage_middle = tid; ipage_inner.reset();
int npnt_middle = 0;
MyPage<int> *ipage_middle;
if (respamiddle) {
ipage_middle = listmiddle->ipage + tid;
ipage_middle->reset();
}
int which = 0; int which = 0;
int minchange = 0; int minchange = 0;
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP) n = n_inner = 0;
#pragma omp critical neighptr = ipage.vget();
#endif neighptr_inner = ipage_inner.vget();
{
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0;
if (pgsize - npnt_inner < oneatom) {
npnt_inner = 0;
npage_inner += nthreads;
if (npage_inner >= listinner->maxpage) listinner->add_pages(nthreads);
}
neighptr_inner = &(listinner->pages[npage_inner][npnt_inner]);
n_inner = 0;
if (respamiddle) { if (respamiddle) {
if (pgsize - npnt_middle < oneatom) {
npnt_middle = 0;
npage_middle += nthreads;
if (npage_middle >= listmiddle->maxpage) listmiddle->add_pages(nthreads);
}
neighptr_middle = &(listmiddle->pages[npage_middle][npnt_middle]);
n_middle = 0; n_middle = 0;
neighptr_middle = ipage_middle->vget();
} }
}
itag = tag[i]; itag = tag[i];
itype = type[i]; itype = type[i];
@ -367,23 +316,23 @@ void Neighbor::respa_nsq_newton_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
ilist_inner[i] = i; ilist_inner[i] = i;
firstneigh_inner[i] = neighptr_inner; firstneigh_inner[i] = neighptr_inner;
numneigh_inner[i] = n_inner; numneigh_inner[i] = n_inner;
npnt_inner += n_inner; ipage.vgot(n_inner);
if (n_inner > oneatom) if (ipage_inner.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
if (respamiddle) { if (respamiddle) {
ilist_middle[i] = i; ilist_middle[i] = i;
firstneigh_middle[i] = neighptr_middle; firstneigh_middle[i] = neighptr_middle;
numneigh_middle[i] = n_middle; numneigh_middle[i] = n_middle;
npnt_middle += n_middle; ipage_middle->vgot(n_middle);
if (n_middle > oneatom) if (ipage_middle->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
} }
@ -412,16 +361,8 @@ void Neighbor::respa_bin_no_newton_omp(NeighList *list)
NEIGH_OMP_INIT; NEIGH_OMP_INIT;
NeighList *listinner = list->listinner; NeighList *listinner = list->listinner;
if (nthreads > listinner->maxpage) NeighList *listmiddle = list->listmiddle;
listinner->add_pages(nthreads - listinner->maxpage);
NeighList *listmiddle;
const int respamiddle = list->respamiddle; const int respamiddle = list->respamiddle;
if (respamiddle) {
listmiddle = list->listmiddle;
if (nthreads > listmiddle->maxpage)
listmiddle->add_pages(nthreads - listmiddle->maxpage);
}
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel default(none) shared(list,listinner,listmiddle) #pragma omp parallel default(none) shared(list,listinner,listmiddle)
@ -461,48 +402,30 @@ void Neighbor::respa_bin_no_newton_omp(NeighList *list)
firstneigh_middle = listmiddle->firstneigh; firstneigh_middle = listmiddle->firstneigh;
} }
int npage = tid; // each thread has its own page allocator
int npnt = 0; MyPage<int> &ipage = list->ipage[tid];
int npage_inner = tid; MyPage<int> &ipage_inner = listinner->ipage[tid];
int npnt_inner = 0; ipage.reset();
int npage_middle = tid; ipage_inner.reset();
int npnt_middle = 0;
MyPage<int> *ipage_middle;
if (respamiddle) {
ipage_middle = listmiddle->ipage + tid;
ipage_middle->reset();
}
int which = 0; int which = 0;
int minchange = 0; int minchange = 0;
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP) n = n_inner = 0;
#pragma omp critical neighptr = ipage.vget();
#endif neighptr_inner = ipage_inner.vget();
{
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0;
if (pgsize - npnt_inner < oneatom) {
npnt_inner = 0;
npage_inner += nthreads;
if (npage_inner >= listinner->maxpage) listinner->add_pages(nthreads);
}
neighptr_inner = &(listinner->pages[npage_inner][npnt_inner]);
n_inner = 0;
if (respamiddle) { if (respamiddle) {
if (pgsize - npnt_middle < oneatom) {
npnt_middle = 0;
npage_middle += nthreads;
if (npage_middle >= listmiddle->maxpage) listmiddle->add_pages(nthreads);
}
neighptr_middle = &(listmiddle->pages[npage_middle][npnt_middle]);
n_middle = 0; n_middle = 0;
neighptr_middle = ipage_middle->vget();
} }
}
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -557,23 +480,23 @@ void Neighbor::respa_bin_no_newton_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
ilist_inner[i] = i; ilist_inner[i] = i;
firstneigh_inner[i] = neighptr_inner; firstneigh_inner[i] = neighptr_inner;
numneigh_inner[i] = n_inner; numneigh_inner[i] = n_inner;
npnt_inner += n_inner; ipage.vgot(n_inner);
if (n_inner > oneatom) if (ipage_inner.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
if (respamiddle) { if (respamiddle) {
ilist_middle[i] = i; ilist_middle[i] = i;
firstneigh_middle[i] = neighptr_middle; firstneigh_middle[i] = neighptr_middle;
numneigh_middle[i] = n_middle; numneigh_middle[i] = n_middle;
npnt_middle += n_middle; ipage_middle->vgot(n_middle);
if (n_middle > oneatom) if (ipage_middle->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
} }
@ -601,16 +524,8 @@ void Neighbor::respa_bin_newton_omp(NeighList *list)
NEIGH_OMP_INIT; NEIGH_OMP_INIT;
NeighList *listinner = list->listinner; NeighList *listinner = list->listinner;
if (nthreads > listinner->maxpage) NeighList *listmiddle = list->listmiddle;
listinner->add_pages(nthreads - listinner->maxpage);
NeighList *listmiddle;
const int respamiddle = list->respamiddle; const int respamiddle = list->respamiddle;
if (respamiddle) {
listmiddle = list->listmiddle;
if (nthreads > listmiddle->maxpage)
listmiddle->add_pages(nthreads - listmiddle->maxpage);
}
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel default(none) shared(list,listinner,listmiddle) #pragma omp parallel default(none) shared(list,listinner,listmiddle)
@ -650,48 +565,30 @@ void Neighbor::respa_bin_newton_omp(NeighList *list)
firstneigh_middle = listmiddle->firstneigh; firstneigh_middle = listmiddle->firstneigh;
} }
int npage = tid; // each thread has its own page allocator
int npnt = 0; MyPage<int> &ipage = list->ipage[tid];
int npage_inner = tid; MyPage<int> &ipage_inner = listinner->ipage[tid];
int npnt_inner = 0; ipage.reset();
int npage_middle = tid; ipage_inner.reset();
int npnt_middle = 0;
MyPage<int> *ipage_middle;
if (respamiddle) {
ipage_middle = listmiddle->ipage + tid;
ipage_middle->reset();
}
int which = 0; int which = 0;
int minchange = 0; int minchange = 0;
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP) n = n_inner = 0;
#pragma omp critical neighptr = ipage.vget();
#endif neighptr_inner = ipage_inner.vget();
{
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0;
if (pgsize - npnt_inner < oneatom) {
npnt_inner = 0;
npage_inner += nthreads;
if (npage_inner >= listinner->maxpage) listinner->add_pages(nthreads);
}
neighptr_inner = &(listinner->pages[npage_inner][npnt_inner]);
n_inner = 0;
if (respamiddle) { if (respamiddle) {
if (pgsize - npnt_middle < oneatom) {
npnt_middle = 0;
npage_middle += nthreads;
if (npage_middle >= listmiddle->maxpage) listmiddle->add_pages(nthreads);
}
neighptr_middle = &(listmiddle->pages[npage_middle][npnt_middle]);
n_middle = 0; n_middle = 0;
neighptr_middle = ipage_middle->vget();
} }
}
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -787,23 +684,23 @@ void Neighbor::respa_bin_newton_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
ilist_inner[i] = i; ilist_inner[i] = i;
firstneigh_inner[i] = neighptr_inner; firstneigh_inner[i] = neighptr_inner;
numneigh_inner[i] = n_inner; numneigh_inner[i] = n_inner;
npnt_inner += n_inner; ipage.vgot(n_inner);
if (n_inner > oneatom) if (ipage_inner.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
if (respamiddle) { if (respamiddle) {
ilist_middle[i] = i; ilist_middle[i] = i;
firstneigh_middle[i] = neighptr_middle; firstneigh_middle[i] = neighptr_middle;
numneigh_middle[i] = n_middle; numneigh_middle[i] = n_middle;
npnt_middle += n_middle; ipage_middle->vgot(n_middle);
if (n_middle > oneatom) if (ipage_middle->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
} }
@ -831,16 +728,8 @@ void Neighbor::respa_bin_newton_tri_omp(NeighList *list)
NEIGH_OMP_INIT; NEIGH_OMP_INIT;
NeighList *listinner = list->listinner; NeighList *listinner = list->listinner;
if (nthreads > listinner->maxpage) NeighList *listmiddle = list->listmiddle;
listinner->add_pages(nthreads - listinner->maxpage);
NeighList *listmiddle;
const int respamiddle = list->respamiddle; const int respamiddle = list->respamiddle;
if (respamiddle) {
listmiddle = list->listmiddle;
if (nthreads > listmiddle->maxpage)
listmiddle->add_pages(nthreads - listmiddle->maxpage);
}
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel default(none) shared(list,listinner,listmiddle) #pragma omp parallel default(none) shared(list,listinner,listmiddle)
@ -880,48 +769,30 @@ void Neighbor::respa_bin_newton_tri_omp(NeighList *list)
firstneigh_middle = listmiddle->firstneigh; firstneigh_middle = listmiddle->firstneigh;
} }
int npage = tid; // each thread has its own page allocator
int npnt = 0; MyPage<int> &ipage = list->ipage[tid];
int npage_inner = tid; MyPage<int> &ipage_inner = listinner->ipage[tid];
int npnt_inner = 0; ipage.reset();
int npage_middle = tid; ipage_inner.reset();
int npnt_middle = 0;
MyPage<int> *ipage_middle;
if (respamiddle) {
ipage_middle = listmiddle->ipage + tid;
ipage_middle->reset();
}
int which = 0; int which = 0;
int minchange = 0; int minchange = 0;
for (i = ifrom; i < ito; i++) { for (i = ifrom; i < ito; i++) {
#if defined(_OPENMP) n = n_inner = 0;
#pragma omp critical neighptr = ipage.vget();
#endif neighptr_inner = ipage_inner.vget();
{
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= list->maxpage) list->add_pages(nthreads);
}
neighptr = &(list->pages[npage][npnt]);
n = 0;
if (pgsize - npnt_inner < oneatom) {
npnt_inner = 0;
npage_inner += nthreads;
if (npage_inner >= listinner->maxpage) listinner->add_pages(nthreads);
}
neighptr_inner = &(listinner->pages[npage_inner][npnt_inner]);
n_inner = 0;
if (respamiddle) { if (respamiddle) {
if (pgsize - npnt_middle < oneatom) {
npnt_middle = 0;
npage_middle += nthreads;
if (npage_middle >= listmiddle->maxpage) listmiddle->add_pages(nthreads);
}
neighptr_middle = &(listmiddle->pages[npage_middle][npnt_middle]);
n_middle = 0; n_middle = 0;
neighptr_middle = ipage_middle->vget();
} }
}
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -984,23 +855,23 @@ void Neighbor::respa_bin_newton_tri_omp(NeighList *list)
ilist[i] = i; ilist[i] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage.vgot(n);
if (n > oneatom) if (ipage.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
ilist_inner[i] = i; ilist_inner[i] = i;
firstneigh_inner[i] = neighptr_inner; firstneigh_inner[i] = neighptr_inner;
numneigh_inner[i] = n_inner; numneigh_inner[i] = n_inner;
npnt_inner += n_inner; ipage.vgot(n_inner);
if (n_inner > oneatom) if (ipage_inner.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
if (respamiddle) { if (respamiddle) {
ilist_middle[i] = i; ilist_middle[i] = i;
firstneigh_middle[i] = neighptr_middle; firstneigh_middle[i] = neighptr_middle;
numneigh_middle[i] = n_middle; numneigh_middle[i] = n_middle;
npnt_middle += n_middle; ipage_middle->vgot(n_middle);
if (n_middle > oneatom) if (ipage_middle->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
} }

View File

@ -25,9 +25,7 @@ namespace LAMMPS_NS {
// make sure we have at least one page for each thread // make sure we have at least one page for each thread
#define NEIGH_OMP_INIT \ #define NEIGH_OMP_INIT \
const int nthreads = comm->nthreads; \ const int nthreads = comm->nthreads;
if (nthreads > list->maxpage) \
list->add_pages(nthreads - list->maxpage)
// get thread id and then assign each thread a fixed chunk of atoms // get thread id and then assign each thread a fixed chunk of atoms
#define NEIGH_OMP_SETUP(num) \ #define NEIGH_OMP_SETUP(num) \

View File

@ -19,6 +19,7 @@
#include "error.h" #include "error.h"
#include "force.h" #include "force.h"
#include "memory.h" #include "memory.h"
#include "my_page.h"
#include "math_special.h" #include "math_special.h"
#include "neighbor.h" #include "neighbor.h"
#include "neigh_list.h" #include "neigh_list.h"
@ -2671,9 +2672,6 @@ void PairAIREBOOMP::REBO_neigh_thr()
memory->create(nH,maxlocal,"AIREBO:nH"); memory->create(nH,maxlocal,"AIREBO:nH");
} }
if (nthreads > maxpage)
add_pages(nthreads - maxpage);
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel default(none) #pragma omp parallel default(none)
#endif #endif
@ -2704,22 +2702,15 @@ void PairAIREBOOMP::REBO_neigh_thr()
// store all REBO neighs of owned and ghost atoms // store all REBO neighs of owned and ghost atoms
// scan full neighbor list of I // scan full neighbor list of I
int npage = tid; // each thread has its own page allocator
int npnt = 0; MyPage<int> &ipg = ipage[tid];
ipg.reset();
for (ii = iifrom; ii < iito; ii++) { for (ii = iifrom; ii < iito; ii++) {
i = ilist[ii]; i = ilist[ii];
#if defined(_OPENMP)
#pragma omp critical
#endif
if (pgsize - npnt < oneatom) {
npnt = 0;
npage += nthreads;
if (npage >= maxpage) add_pages(nthreads);
}
neighptr = &(pages[npage][npnt]);
n = 0; n = 0;
neighptr = ipg.vget();
xtmp = x[i][0]; xtmp = x[i][0];
ytmp = x[i][1]; ytmp = x[i][1];
@ -2749,10 +2740,9 @@ void PairAIREBOOMP::REBO_neigh_thr()
REBO_firstneigh[i] = neighptr; REBO_firstneigh[i] = neighptr;
REBO_numneigh[i] = n; REBO_numneigh[i] = n;
npnt += n; ipg.vgot(n);
if (ipg.status())
if (npnt >= pgsize) error->one(FLERR,"REBO list overflow, boost neigh_modify one");
error->one(FLERR,"REBO list overflow, boost neigh_modify one or page");
} }
} }
} }

View File

@ -19,6 +19,7 @@
#include "group.h" #include "group.h"
#include "force.h" #include "force.h"
#include "memory.h" #include "memory.h"
#include "my_page.h"
#include "neighbor.h" #include "neighbor.h"
#include "neigh_list.h" #include "neigh_list.h"
@ -553,15 +554,13 @@ void PairCombOMP::Short_neigh_thr()
nmax = atom->nmax; nmax = atom->nmax;
memory->sfree(sht_first); memory->sfree(sht_first);
sht_first = (int **) memory->smalloc(nmax*sizeof(int *), sht_first = (int **) memory->smalloc(nmax*sizeof(int *),
"pair:sht_first"); "pair:sht_first");
memory->grow(sht_num,nmax,"pair:sht_num"); memory->grow(sht_num,nmax,"pair:sht_num");
memory->grow(NCo,nmax,"pair:NCo"); memory->grow(NCo,nmax,"pair:NCo");
memory->grow(bbij,nmax,nmax,"pair:bbij"); memory->grow(bbij,nmax,MAXNEIGH,"pair:bbij");
} }
const int nthreads = comm->nthreads; const int nthreads = comm->nthreads;
if (nthreads > maxpage)
add_pages(nthreads - maxpage);
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel default(none) #pragma omp parallel default(none)
@ -588,51 +587,44 @@ void PairCombOMP::Short_neigh_thr()
const int iidelta = 1 + inum/nthreads; const int iidelta = 1 + inum/nthreads;
const int iifrom = tid*iidelta; const int iifrom = tid*iidelta;
int iito = iifrom + iidelta; const int iito = ((iifrom + iidelta) > inum) ? inum : (iifrom+iidelta);
if (iito > inum) iito = inum;
int npage = tid; // each thread has its own page allocator
npntj = 0; MyPage<int> &ipg = ipage[tid];
ipg.reset();
if (iifrom < inum) { // create Comb neighbor list
for (ii = iifrom; ii < iito; ii++) {
i = ilist[ii];
#if defined(_OPENMP) for (ii = iifrom; ii < iito; ii++) {
#pragma omp critical i = ilist[ii];
#endif
if(pgsize - npntj < oneatom) {
npntj = 0;
npage += nthreads;
if (npage >= maxpage) add_pages(nthreads);
}
neighptrj = &pages[npage][npntj]; nj = 0;
nj = 0; neighptrj = ipg.vget();
xtmp = x[i][0]; xtmp = x[i][0];
ytmp = x[i][1]; ytmp = x[i][1];
ztmp = x[i][2]; ztmp = x[i][2];
jlist = firstneigh[i]; jlist = firstneigh[i];
jnum = numneigh[i]; jnum = numneigh[i];
for (jj = 0; jj < jnum; jj++) { for (jj = 0; jj < jnum; jj++) {
j = jlist[jj]; j = jlist[jj];
j &= NEIGHMASK; j &= NEIGHMASK;
delrj[0] = xtmp - x[j][0]; delrj[0] = xtmp - x[j][0];
delrj[1] = ytmp - x[j][1]; delrj[1] = ytmp - x[j][1];
delrj[2] = ztmp - x[j][2]; delrj[2] = ztmp - x[j][2];
rsq = vec3_dot(delrj,delrj); rsq = vec3_dot(delrj,delrj);
if (rsq > cutmin) continue; if (rsq > cutmin) continue;
neighptrj[nj++] = j; neighptrj[nj++] = j;
}
sht_first[i] = neighptrj;
sht_num[i] = nj;
npntj += nj;
} }
sht_first[i] = neighptrj;
sht_num[i] = nj;
ipg.vgot(nj);
if (ipg.status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
} }
} }

View File

@ -16,6 +16,7 @@
#include "stdio.h" #include "stdio.h"
#include "fix_shear_history.h" #include "fix_shear_history.h"
#include "atom.h" #include "atom.h"
#include "comm.h"
#include "neighbor.h" #include "neighbor.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "force.h" #include "force.h"
@ -71,8 +72,8 @@ FixShearHistory::~FixShearHistory()
memory->destroy(npartner); memory->destroy(npartner);
memory->sfree(partner); memory->sfree(partner);
memory->sfree(shearpartner); memory->sfree(shearpartner);
delete ipage; delete [] ipage;
delete dpage; delete [] dpage;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -105,10 +106,18 @@ void FixShearHistory::init()
if (oneatom != neighbor->oneatom) create = 1; if (oneatom != neighbor->oneatom) create = 1;
if (create) { if (create) {
delete [] ipage;
delete [] dpage;
pgsize = neighbor->pgsize; pgsize = neighbor->pgsize;
oneatom = neighbor->oneatom; oneatom = neighbor->oneatom;
ipage = new MyPage<int>(oneatom,pgsize); int nmypage = comm->nthreads;
dpage = new MyPage<double[3]>(oneatom,pgsize); ipage = new MyPage<int>[nmypage];
dpage = new MyPage<double[3]>[nmypage];
for (int i = 0; i < nmypage; i++) {
ipage[i].init(oneatom,pgsize);
dpage[i].init(oneatom,pgsize);
}
} }
} }
@ -260,8 +269,13 @@ double FixShearHistory::memory_usage()
double bytes = nmax * sizeof(int); double bytes = nmax * sizeof(int);
bytes = nmax * sizeof(int *); bytes = nmax * sizeof(int *);
bytes = nmax * sizeof(double *); bytes = nmax * sizeof(double *);
bytes += ipage->ndatum * sizeof(int);
bytes += dpage->ndatum * sizeof(double[3]); int nmypage = comm->nthreads;
for (int i = 0; i < nmypage; i++) {
bytes += ipage[i].size();
bytes += dpage[i].size();
}
return bytes; return bytes;
} }

View File

@ -1,4 +1,4 @@
/* ---------------------------------------------------------------------- /* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov Steve Plimpton, sjplimp@sandia.gov
@ -24,22 +24,25 @@ usage:
inputs: inputs:
template T = one datum, e.g. int, double, struct, int[3] template T = one datum, e.g. int, double, struct, int[3]
for int[3], access datum as ivec[i][2] for int[3], access datum as ivec[i][2]
maxchunk = max # of datums in one chunk, default = 1
pagesize = # of datums in one page, default = 1024
should be insure big enough to store multiple chunks
pagedelta = # of pages to allocate at a time, default = 1
methods: methods:
T *get() = return ptr to one datum T *get() = return ptr to one datum
T *get(N) = return ptr to N datums, N < maxchunk required T *get(N) = return ptr to N datums, N < maxchunk required
T *vget() = return ptr to maxchunk datums, use as needed, then call vgot() T *vget() = return ptr to maxchunk datums, use as needed, then call vgot()
all gets return NULL if error encountered all gets return NULL if error encountered
vgot(N) = used N datums of previous vget(), N < maxchunk required vgot(N) = used N datums of previous vget(), N < maxchunk required
void init(maxchunk, pagesize, pagedelta)
define allocation params and allocate first page(s)
call right after constructor
can call again to reset allocation params and free previous pages
maxchunk = max # of datums in one chunk, default = 1
pagesize = # of datums in one page, default = 1024
should be big enough to store multiple chunks
pagedelta = # of pages to allocate at a time, default = 1
return 1 if bad params
void reset() = clear pages w/out freeing void reset() = clear pages w/out freeing
int size() = return total size of allocated pages in bytes int size() = return total size of allocated pages in bytes
public variables: int status() = return error status
ndatum = total # of stored datums 0 = ok, 1 = chunksize > maxchunk, 2 = allocation error
nchunk = total # of stored chunks
errorflag = flag for various error conditions
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#ifndef LAMMPS_MY_PAGE_H #ifndef LAMMPS_MY_PAGE_H
@ -50,24 +53,33 @@ namespace LAMMPS_NS {
template<class T> template<class T>
class MyPage { class MyPage {
public:
int ndatum; // total # of stored datums int ndatum; // total # of stored datums
int nchunk; // total # of stored chunks int nchunk; // total # of stored chunks
int errorflag; // flag > 1 if error has occurred
// 1 = invalid inputs
// 2 = memory allocation error
// 3 = chunk size exceeded maxchunk
MyPage(int user_maxchunk = 1, int user_pagesize = 1024, public:
int user_pagedelta = 1) { MyPage() {
ndatum = nchunk = 0;
pages = NULL;
npage = 0;
errorflag = 0;
}
// (re)initialize allocation params
// also allocate first page(s)
int init(int user_maxchunk = 1, int user_pagesize = 1024,
int user_pagedelta = 1) {
maxchunk = user_maxchunk; maxchunk = user_maxchunk;
pagesize = user_pagesize; pagesize = user_pagesize;
pagedelta = user_pagedelta; pagedelta = user_pagedelta;
errorflag = 0; if (maxchunk <= 0 || pagesize <= 0 || pagedelta <= 0) return 1;
if (maxchunk <= 0 || pagesize <= 0 || pagedelta <= 0) errorflag = 1; if (maxchunk > pagesize) return 1;
if (maxchunk > pagesize) errorflag = 1;
if (errorflag) return; // free any previously allocated pages
for (int i = 0; i < npage; i++) free(pages[i]);
free(pages);
// initial page allocation // initial page allocation
@ -75,12 +87,13 @@ class MyPage {
pages = NULL; pages = NULL;
npage = 0; npage = 0;
allocate(); allocate();
if (errorflag) return; if (errorflag) return 2;
ipage = index = 0; ipage = index = 0;
page = pages[ipage]; page = pages[ipage];
return 0;
} }
// free all pages of allocated memory // free all allocated pages
~MyPage() { ~MyPage() {
for (int i = 0; i < npage; i++) free(pages[i]); for (int i = 0; i < npage; i++) free(pages[i]);
@ -110,7 +123,7 @@ class MyPage {
T *get(int n) { T *get(int n) {
if (n > maxchunk) { if (n > maxchunk) {
errorflag = 3; errorflag = 1;
return NULL; return NULL;
} }
ndatum += n; ndatum += n;
@ -151,14 +164,13 @@ class MyPage {
// error if N > maxchunk // error if N > maxchunk
void vgot(int n) { void vgot(int n) {
if (n > maxchunk) errorflag = 3; if (n > maxchunk) errorflag = 1;
ndatum += n; ndatum += n;
nchunk++; nchunk++;
index += n; index += n;
} }
// reset index to beginning of first page // clear all pages, without freeing any memory
// effectively clears all pages, without freeing any memory
void reset() { void reset() {
ndatum = nchunk = 0; ndatum = nchunk = 0;
@ -166,23 +178,33 @@ class MyPage {
page = pages[ipage]; page = pages[ipage];
} }
// return total size of all allocated pages // return total size of allocated pages
int size() { int size() const {
return npage*pagesize*sizeof(T); return npage*pagesize*sizeof(T);
} }
private: // return error status
int maxchunk; // max # of datums in one requested chunk
int pagesize; // # of datums in one page, default = 1024
int pagedelta; // # of pages to allocate at once, default = 1
int status() const {
return errorflag;
}
private:
T **pages; // list of allocated pages T **pages; // list of allocated pages
T *page; // ptr to current page T *page; // ptr to current page
int npage; // # of allocated pages int npage; // # of allocated pages
int ipage; // index of current page int ipage; // index of current page
int index; // current index on current page int index; // current index on current page
int maxchunk; // max # of datums in one requested chunk
int pagesize; // # of datums in one page, default = 1024
int pagedelta; // # of pages to allocate at once, default = 1
int errorflag; // flag > 0 if error has occurred
// 1 = chunk size exceeded maxchunk
// 2 = memory allocation error
void allocate() { void allocate() {
npage += pagedelta; npage += pagedelta;
pages = (T **) realloc(pages,npage*sizeof(T *)); pages = (T **) realloc(pages,npage*sizeof(T *));
@ -190,9 +212,17 @@ class MyPage {
errorflag = 2; errorflag = 2;
return; return;
} }
void *ptr;
for (int i = npage-pagedelta; i < npage; i++) { for (int i = npage-pagedelta; i < npage; i++) {
#if defined(LAMMPS_MEMALIGN)
if (posix_memalign(&ptr, LAMMPS_MEMALIGN, pagesize*sizeof(T)))
errorflag = 2;
pages[i] = (T *) ptr;
#else
pages[i] = (T *) malloc(pagesize*sizeof(T)); pages[i] = (T *) malloc(pagesize*sizeof(T));
if (!pages[i]) errorflag = 2; if (!pages[i]) errorflag = 2;
#endif
} }
} }
}; };

View File

@ -14,6 +14,7 @@
#include "neighbor.h" #include "neighbor.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "atom.h" #include "atom.h"
#include "my_page.h"
#include "error.h" #include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -33,28 +34,21 @@ void Neighbor::half_from_full_no_newton(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages; MyPage<int> *ipage = list->ipage;
int *ilist_full = list->listfull->ilist; int *ilist_full = list->listfull->ilist;
int *numneigh_full = list->listfull->numneigh; int *numneigh_full = list->listfull->numneigh;
int **firstneigh_full = list->listfull->firstneigh; int **firstneigh_full = list->listfull->firstneigh;
int inum_full = list->listfull->inum; int inum_full = list->listfull->inum;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
// loop over atoms in full list // loop over atoms in full list
for (ii = 0; ii < inum_full; ii++) { for (ii = 0; ii < inum_full; ii++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
// loop over parent full list // loop over parent full list
@ -71,8 +65,8 @@ void Neighbor::half_from_full_no_newton(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -98,28 +92,21 @@ void Neighbor::half_from_full_newton(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages; MyPage<int> *ipage = list->ipage;
int *ilist_full = list->listfull->ilist; int *ilist_full = list->listfull->ilist;
int *numneigh_full = list->listfull->numneigh; int *numneigh_full = list->listfull->numneigh;
int **firstneigh_full = list->listfull->firstneigh; int **firstneigh_full = list->listfull->firstneigh;
int inum_full = list->listfull->inum; int inum_full = list->listfull->inum;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
// loop over parent full list // loop over parent full list
for (ii = 0; ii < inum_full; ii++) { for (ii = 0; ii < inum_full; ii++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
i = ilist_full[ii]; i = ilist_full[ii];
xtmp = x[i][0]; xtmp = x[i][0];
@ -149,8 +136,8 @@ void Neighbor::half_from_full_newton(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -175,7 +162,8 @@ void Neighbor::skip_from(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages; MyPage<int> *ipage = list->ipage;
int *ilist_skip = list->listskip->ilist; int *ilist_skip = list->listskip->ilist;
int *numneigh_skip = list->listskip->numneigh; int *numneigh_skip = list->listskip->numneigh;
int **firstneigh_skip = list->listskip->firstneigh; int **firstneigh_skip = list->listskip->firstneigh;
@ -186,8 +174,7 @@ void Neighbor::skip_from(NeighList *list)
int **ijskip = list->ijskip; int **ijskip = list->ijskip;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
// loop over atoms in other list // loop over atoms in other list
// skip I atom entirely if iskip is set for type[I] // skip I atom entirely if iskip is set for type[I]
@ -198,14 +185,8 @@ void Neighbor::skip_from(NeighList *list)
itype = type[i]; itype = type[i];
if (iskip[itype]) continue; if (iskip[itype]) continue;
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
// loop over parent non-skip list // loop over parent non-skip list
@ -222,8 +203,8 @@ void Neighbor::skip_from(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -255,7 +236,8 @@ void Neighbor::skip_from_granular(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages; MyPage<int> *ipage = list->ipage;
int *ilist_skip = list->listskip->ilist; int *ilist_skip = list->listskip->ilist;
int *numneigh_skip = list->listskip->numneigh; int *numneigh_skip = list->listskip->numneigh;
int **firstneigh_skip = list->listskip->firstneigh; int **firstneigh_skip = list->listskip->firstneigh;
@ -269,12 +251,13 @@ void Neighbor::skip_from_granular(NeighList *list)
NeighList *listgranhistory = list->listgranhistory; NeighList *listgranhistory = list->listgranhistory;
int **firsttouch = listgranhistory->firstneigh; int **firsttouch = listgranhistory->firstneigh;
double **firstshear = listgranhistory->firstdouble; double **firstshear = listgranhistory->firstdouble;
int **pages_touch = listgranhistory->pages; MyPage<int> *ipage_touch = listgranhistory->ipage;
double **pages_shear = listgranhistory->dpages; MyPage<double> *dpage_shear = listgranhistory->dpage;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0; ipage_touch->reset();
dpage_shear->reset();
// loop over atoms in other list // loop over atoms in other list
// skip I atom entirely if iskip is set for type[I] // skip I atom entirely if iskip is set for type[I]
@ -285,21 +268,10 @@ void Neighbor::skip_from_granular(NeighList *list)
itype = type[i]; itype = type[i];
if (iskip[itype]) continue; if (iskip[itype]) continue;
if (pgsize - npnt < oneatom) { n = nn = 0;
npnt = 0; neighptr = ipage->vget();
npage++; touchptr = ipage_touch->vget();
if (npage == list->maxpage) { shearptr = dpage_shear->vget();
pages = list->add_pages();
pages_touch = listgranhistory->add_pages();
pages_shear = listgranhistory->dpages;
}
}
n = 0;
neighptr = &pages[npage][npnt];
nn = 0;
touchptr = &pages_touch[npage][npnt];
shearptr = &pages_shear[npage][3*npnt];
// loop over parent non-skip granular list and its history info // loop over parent non-skip granular list and its history info
@ -322,11 +294,14 @@ void Neighbor::skip_from_granular(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
ipage->vgot(n);
if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
firsttouch[i] = touchptr; firsttouch[i] = touchptr;
firstshear[i] = shearptr; firstshear[i] = shearptr;
npnt += n; ipage_touch->vgot(n);
if (n > oneatom) dpage_shear->vgot(nn);
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
list->inum = inum; list->inum = inum;
@ -348,7 +323,8 @@ void Neighbor::skip_from_respa(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages; MyPage<int> *ipage = list->ipage;
int *ilist_skip = list->listskip->ilist; int *ilist_skip = list->listskip->ilist;
int *numneigh_skip = list->listskip->numneigh; int *numneigh_skip = list->listskip->numneigh;
int **firstneigh_skip = list->listskip->firstneigh; int **firstneigh_skip = list->listskip->firstneigh;
@ -360,30 +336,29 @@ void Neighbor::skip_from_respa(NeighList *list)
NeighList *listinner = list->listinner; NeighList *listinner = list->listinner;
int *numneigh_inner = listinner->numneigh; int *numneigh_inner = listinner->numneigh;
int **firstneigh_inner = listinner->firstneigh; int **firstneigh_inner = listinner->firstneigh;
int **pages_inner = listinner->pages; MyPage<int> *ipage_inner = listinner->ipage;
int *numneigh_inner_skip = list->listskip->listinner->numneigh; int *numneigh_inner_skip = list->listskip->listinner->numneigh;
int **firstneigh_inner_skip = list->listskip->listinner->firstneigh; int **firstneigh_inner_skip = list->listskip->listinner->firstneigh;
NeighList *listmiddle; NeighList *listmiddle;
int *numneigh_middle,**firstneigh_middle,**pages_middle; int *ilist_middle,*numneigh_middle,**firstneigh_middle;
MyPage<int> *ipage_middle;
int *numneigh_middle_skip,**firstneigh_middle_skip; int *numneigh_middle_skip,**firstneigh_middle_skip;
int respamiddle = list->respamiddle; int respamiddle = list->respamiddle;
if (respamiddle) { if (respamiddle) {
listmiddle = list->listmiddle; listmiddle = list->listmiddle;
numneigh_middle = listmiddle->numneigh; numneigh_middle = listmiddle->numneigh;
firstneigh_middle = listmiddle->firstneigh; firstneigh_middle = listmiddle->firstneigh;
pages_middle = listmiddle->pages; ipage_middle = listmiddle->ipage;
numneigh_middle_skip = list->listskip->listmiddle->numneigh; numneigh_middle_skip = list->listskip->listmiddle->numneigh;
firstneigh_middle_skip = list->listskip->listmiddle->firstneigh; firstneigh_middle_skip = list->listskip->listmiddle->firstneigh;
} }
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0; ipage_inner->reset();
int npage_inner = 0; if (respamiddle) ipage_middle->reset();
int npnt_inner = 0;
int npage_middle = 0;
int npnt_middle = 0;
// loop over atoms in other list // loop over atoms in other list
// skip I atom entirely if iskip is set for type[I] // skip I atom entirely if iskip is set for type[I]
@ -394,32 +369,12 @@ void Neighbor::skip_from_respa(NeighList *list)
itype = type[i]; itype = type[i];
if (iskip[itype]) continue; if (iskip[itype]) continue;
if (pgsize - npnt < oneatom) { n = n_inner = 0;
npnt = 0; neighptr = ipage->vget();
npage++; neighptr_inner = ipage_inner->vget();
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0;
if (pgsize - npnt_inner < oneatom) {
npnt_inner = 0;
npage_inner++;
if (npage_inner == listinner->maxpage)
pages_inner = listinner->add_pages();
}
neighptr_inner = &pages_inner[npage_inner][npnt_inner];
n_inner = 0;
if (respamiddle) { if (respamiddle) {
if (pgsize - npnt_middle < oneatom) {
npnt_middle = 0;
npage_middle++;
if (npage_middle == listmiddle->maxpage)
pages_middle = listmiddle->add_pages();
}
neighptr_middle = &pages_middle[npage_middle][npnt_middle];
n_middle = 0; n_middle = 0;
neighptr_middle = ipage_middle->vget();
} }
// loop over parent outer rRESPA list // loop over parent outer rRESPA list
@ -460,24 +415,24 @@ void Neighbor::skip_from_respa(NeighList *list)
} }
} }
ilist[inum++] = i; ilist[inum] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
firstneigh_inner[i] = neighptr_inner; firstneigh_inner[i] = neighptr_inner;
numneigh_inner[i] = n_inner; numneigh_inner[i] = n_inner;
npnt_inner += n_inner; ipage_inner->vgot(n);
if (n_inner > oneatom) if (ipage_inner->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
if (respamiddle) { if (respamiddle) {
firstneigh_middle[i] = neighptr_middle; firstneigh_middle[i] = neighptr_middle;
numneigh_middle[i] = n_middle; numneigh_middle[i] = n_middle;
npnt_middle += n_middle; ipage_middle->vgot(n);
if (n_middle > oneatom) if (ipage_middle->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
} }
@ -499,6 +454,6 @@ void Neighbor::copy_from(NeighList *list)
list->numneigh = listcopy->numneigh; list->numneigh = listcopy->numneigh;
list->firstneigh = listcopy->firstneigh; list->firstneigh = listcopy->firstneigh;
list->firstdouble = listcopy->firstdouble; list->firstdouble = listcopy->firstdouble;
list->pages = listcopy->pages; list->ipage = listcopy->ipage;
list->dpages = listcopy->dpages; list->dpage = listcopy->dpage;
} }

View File

@ -15,6 +15,7 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "atom.h" #include "atom.h"
#include "domain.h" #include "domain.h"
#include "my_page.h"
#include "group.h" #include "group.h"
#include "error.h" #include "error.h"
@ -50,24 +51,16 @@ void Neighbor::full_nsq(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages; MyPage<int> *ipage = list->ipage;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
// loop over owned atoms, storing neighbors // loop over owned atoms, storing neighbors
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -101,8 +94,8 @@ void Neighbor::full_nsq(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -137,24 +130,16 @@ void Neighbor::full_nsq_ghost(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages; MyPage<int> *ipage = list->ipage;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
// loop over owned & ghost atoms, storing neighbors // loop over owned & ghost atoms, storing neighbors
for (i = 0; i < nall; i++) { for (i = 0; i < nall; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -203,8 +188,8 @@ void Neighbor::full_nsq_ghost(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -242,26 +227,18 @@ void Neighbor::full_bin(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages;
int nstencil = list->nstencil; int nstencil = list->nstencil;
int *stencil = list->stencil; int *stencil = list->stencil;
MyPage<int> *ipage = list->ipage;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
// loop over owned atoms, storing neighbors // loop over owned atoms, storing neighbors
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -300,8 +277,8 @@ void Neighbor::full_bin(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -341,27 +318,19 @@ void Neighbor::full_bin_ghost(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages;
int nstencil = list->nstencil; int nstencil = list->nstencil;
int *stencil = list->stencil; int *stencil = list->stencil;
int **stencilxyz = list->stencilxyz; int **stencilxyz = list->stencilxyz;
MyPage<int> *ipage = list->ipage;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
// loop over owned & ghost atoms, storing neighbors // loop over owned & ghost atoms, storing neighbors
for (i = 0; i < nall; i++) { for (i = 0; i < nall; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -427,8 +396,8 @@ void Neighbor::full_bin_ghost(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -470,25 +439,17 @@ void Neighbor::full_multi(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages;
int *nstencil_multi = list->nstencil_multi; int *nstencil_multi = list->nstencil_multi;
int **stencil_multi = list->stencil_multi; int **stencil_multi = list->stencil_multi;
double **distsq_multi = list->distsq_multi; double **distsq_multi = list->distsq_multi;
MyPage<int> *ipage = list->ipage;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -532,8 +493,8 @@ void Neighbor::full_multi(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }

View File

@ -41,8 +41,8 @@ void Neighbor::granular_nsq_no_newton(NeighList *list)
double (**shearpartner)[3]; double (**shearpartner)[3];
int **firsttouch; int **firsttouch;
double **firstshear; double **firstshear;
int **pages_touch; MyPage<int> *ipage_touch;
double **pages_shear; MyPage<double> *dpage_shear;
double **x = atom->x; double **x = atom->x;
double *radius = atom->radius; double *radius = atom->radius;
@ -60,7 +60,7 @@ void Neighbor::granular_nsq_no_newton(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages; MyPage<int> *ipage = list->ipage;
FixShearHistory *fix_history = list->fix_history; FixShearHistory *fix_history = list->fix_history;
if (fix_history) { if (fix_history) {
@ -70,34 +70,24 @@ void Neighbor::granular_nsq_no_newton(NeighList *list)
listgranhistory = list->listgranhistory; listgranhistory = list->listgranhistory;
firsttouch = listgranhistory->firstneigh; firsttouch = listgranhistory->firstneigh;
firstshear = listgranhistory->firstdouble; firstshear = listgranhistory->firstdouble;
pages_touch = listgranhistory->pages; ipage_touch = listgranhistory->ipage;
pages_shear = listgranhistory->dpages; dpage_shear = listgranhistory->dpage;
} }
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0; if (fix_history) {
ipage_touch->reset();
dpage_shear->reset();
}
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) {
pages = list->add_pages();
if (fix_history) {
pages_touch = listgranhistory->add_pages();
pages_shear = listgranhistory->dpages;
}
}
}
n = 0; n = 0;
neighptr = &pages[npage][npnt]; neighptr = ipage->vget();
if (fix_history) { if (fix_history) {
nn = 0; nn = 0;
touchptr = &pages_touch[npage][npnt]; touchptr = ipage_touch->vget();
shearptr = &pages_shear[npage][3*npnt]; shearptr = dpage_shear->vget();
} }
xtmp = x[i][0]; xtmp = x[i][0];
@ -151,13 +141,16 @@ void Neighbor::granular_nsq_no_newton(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
ipage->vgot(n);
if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
if (fix_history) { if (fix_history) {
firsttouch[i] = touchptr; firsttouch[i] = touchptr;
firstshear[i] = shearptr; firstshear[i] = shearptr;
ipage_touch->vgot(n);
dpage_shear->vgot(nn);
} }
npnt += n;
if (n > oneatom)
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
list->inum = inum; list->inum = inum;
@ -195,22 +188,14 @@ void Neighbor::granular_nsq_newton(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages; MyPage<int> *ipage = list->ipage;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
n = 0; n = 0;
neighptr = &pages[npage][npnt]; neighptr = ipage->vget();
itag = tag[i]; itag = tag[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -253,8 +238,8 @@ void Neighbor::granular_nsq_newton(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -283,8 +268,8 @@ void Neighbor::granular_bin_no_newton(NeighList *list)
double (**shearpartner)[3]; double (**shearpartner)[3];
int **firsttouch; int **firsttouch;
double **firstshear; double **firstshear;
int **pages_touch; MyPage<int> *ipage_touch;
double **pages_shear; MyPage<double> *dpage_shear;
// bin local & ghost atoms // bin local & ghost atoms
@ -304,9 +289,9 @@ void Neighbor::granular_bin_no_newton(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages;
int nstencil = list->nstencil; int nstencil = list->nstencil;
int *stencil = list->stencil; int *stencil = list->stencil;
MyPage<int> *ipage = list->ipage;
FixShearHistory *fix_history = list->fix_history; FixShearHistory *fix_history = list->fix_history;
if (fix_history) { if (fix_history) {
@ -316,34 +301,24 @@ void Neighbor::granular_bin_no_newton(NeighList *list)
listgranhistory = list->listgranhistory; listgranhistory = list->listgranhistory;
firsttouch = listgranhistory->firstneigh; firsttouch = listgranhistory->firstneigh;
firstshear = listgranhistory->firstdouble; firstshear = listgranhistory->firstdouble;
pages_touch = listgranhistory->pages; ipage_touch = listgranhistory->ipage;
pages_shear = listgranhistory->dpages; dpage_shear = listgranhistory->dpage;
} }
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0; if (fix_history) {
ipage_touch->reset();
dpage_shear->reset();
}
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) {
pages = list->add_pages();
if (fix_history) {
pages_touch = listgranhistory->add_pages();
pages_shear = listgranhistory->dpages;
}
}
}
n = 0; n = 0;
neighptr = &pages[npage][npnt]; neighptr = ipage->vget();
if (fix_history) { if (fix_history) {
nn = 0; nn = 0;
touchptr = &pages_touch[npage][npnt]; touchptr = ipage_touch->vget();
shearptr = &pages_shear[npage][3*npnt]; shearptr = dpage_shear->vget();
} }
xtmp = x[i][0]; xtmp = x[i][0];
@ -403,13 +378,16 @@ void Neighbor::granular_bin_no_newton(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
ipage->vgot(n);
if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
if (fix_history) { if (fix_history) {
firsttouch[i] = touchptr; firsttouch[i] = touchptr;
firstshear[i] = shearptr; firstshear[i] = shearptr;
ipage_touch->vgot(n);
dpage_shear->vgot(nn);
} }
npnt += n;
if (n > oneatom)
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
list->inum = inum; list->inum = inum;
@ -447,24 +425,16 @@ void Neighbor::granular_bin_newton(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages;
int nstencil = list->nstencil; int nstencil = list->nstencil;
int *stencil = list->stencil; int *stencil = list->stencil;
MyPage<int> *ipage = list->ipage;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
n = 0; n = 0;
neighptr = &pages[npage][npnt]; neighptr = ipage->vget();
xtmp = x[i][0]; xtmp = x[i][0];
ytmp = x[i][1]; ytmp = x[i][1];
@ -517,8 +487,8 @@ void Neighbor::granular_bin_newton(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -557,24 +527,16 @@ void Neighbor::granular_bin_newton_tri(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages;
int nstencil = list->nstencil; int nstencil = list->nstencil;
int *stencil = list->stencil; int *stencil = list->stencil;
MyPage<int> *ipage = list->ipage;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
n = 0; n = 0;
neighptr = &pages[npage][npnt]; neighptr = ipage->vget();
xtmp = x[i][0]; xtmp = x[i][0];
ytmp = x[i][1]; ytmp = x[i][1];
@ -615,8 +577,8 @@ void Neighbor::granular_bin_newton_tri(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }

View File

@ -15,6 +15,7 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "atom.h" #include "atom.h"
#include "domain.h" #include "domain.h"
#include "my_page.h"
#include "error.h" #include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -53,24 +54,16 @@ void Neighbor::half_bin_no_newton(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages;
int nstencil = list->nstencil; int nstencil = list->nstencil;
int *stencil = list->stencil; int *stencil = list->stencil;
MyPage<int> *ipage = list->ipage;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -111,8 +104,8 @@ void Neighbor::half_bin_no_newton(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -156,25 +149,17 @@ void Neighbor::half_bin_no_newton_ghost(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages;
int nstencil = list->nstencil; int nstencil = list->nstencil;
int *stencil = list->stencil; int *stencil = list->stencil;
int **stencilxyz = list->stencilxyz; int **stencilxyz = list->stencilxyz;
MyPage<int> *ipage = list->ipage;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
for (i = 0; i < nall; i++) { for (i = 0; i < nall; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -244,8 +229,8 @@ void Neighbor::half_bin_no_newton_ghost(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -286,24 +271,16 @@ void Neighbor::half_bin_newton(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages;
int nstencil = list->nstencil; int nstencil = list->nstencil;
int *stencil = list->stencil; int *stencil = list->stencil;
MyPage<int> *ipage = list->ipage;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -372,8 +349,8 @@ void Neighbor::half_bin_newton(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -413,24 +390,16 @@ void Neighbor::half_bin_newton_tri(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages;
int nstencil = list->nstencil; int nstencil = list->nstencil;
int *stencil = list->stencil; int *stencil = list->stencil;
MyPage<int> *ipage = list->ipage;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -478,8 +447,8 @@ void Neighbor::half_bin_newton_tri(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }

View File

@ -15,6 +15,7 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "atom.h" #include "atom.h"
#include "domain.h" #include "domain.h"
#include "my_page.h"
#include "error.h" #include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -55,25 +56,17 @@ void Neighbor::half_multi_no_newton(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages;
int *nstencil_multi = list->nstencil_multi; int *nstencil_multi = list->nstencil_multi;
int **stencil_multi = list->stencil_multi; int **stencil_multi = list->stencil_multi;
double **distsq_multi = list->distsq_multi; double **distsq_multi = list->distsq_multi;
MyPage<int> *ipage = list->ipage;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -119,8 +112,8 @@ void Neighbor::half_multi_no_newton(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -162,25 +155,17 @@ void Neighbor::half_multi_newton(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages;
int *nstencil_multi = list->nstencil_multi; int *nstencil_multi = list->nstencil_multi;
int **stencil_multi = list->stencil_multi; int **stencil_multi = list->stencil_multi;
double **distsq_multi = list->distsq_multi; double **distsq_multi = list->distsq_multi;
MyPage<int> *ipage = list->ipage;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -254,8 +239,8 @@ void Neighbor::half_multi_newton(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -297,25 +282,17 @@ void Neighbor::half_multi_newton_tri(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages;
int *nstencil_multi = list->nstencil_multi; int *nstencil_multi = list->nstencil_multi;
int **stencil_multi = list->stencil_multi; int **stencil_multi = list->stencil_multi;
double **distsq_multi = list->distsq_multi; double **distsq_multi = list->distsq_multi;
MyPage<int> *ipage = list->ipage;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -370,8 +347,8 @@ void Neighbor::half_multi_newton_tri(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }

View File

@ -51,24 +51,16 @@ void Neighbor::half_nsq_no_newton(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages; MyPage<int> *ipage = list->ipage;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
// loop over owned atoms, storing neighbors // loop over owned atoms, storing neighbors
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -102,8 +94,8 @@ void Neighbor::half_nsq_no_newton(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -143,24 +135,16 @@ void Neighbor::half_nsq_no_newton_ghost(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages; MyPage<int> *ipage = list->ipage;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
// loop over owned & ghost atoms, storing neighbors // loop over owned & ghost atoms, storing neighbors
for (i = 0; i < nall; i++) { for (i = 0; i < nall; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
itype = type[i]; itype = type[i];
xtmp = x[i][0]; xtmp = x[i][0];
@ -214,8 +198,8 @@ void Neighbor::half_nsq_no_newton_ghost(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -256,22 +240,14 @@ void Neighbor::half_nsq_newton(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages; MyPage<int> *ipage = list->ipage;
int inum = 0; int inum = 0;
int npage = 0; ipage->reset();
int npnt = 0;
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (pgsize - npnt < oneatom) {
npnt = 0;
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0; n = 0;
neighptr = ipage->vget();
itag = tag[i]; itag = tag[i];
itype = type[i]; itype = type[i];
@ -322,8 +298,8 @@ void Neighbor::half_nsq_newton(NeighList *list)
ilist[inum++] = i; ilist[inum++] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }

View File

@ -17,6 +17,7 @@
#include "update.h" #include "update.h"
#include "neighbor.h" #include "neighbor.h"
#include "neigh_request.h" #include "neigh_request.h"
#include "my_page.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
@ -28,11 +29,10 @@ enum{NSQ,BIN,MULTI}; // also in neighbor.cpp
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
NeighList::NeighList(LAMMPS *lmp, int size, int onesize) : Pointers(lmp) NeighList::NeighList(LAMMPS *lmp) :
Pointers(lmp)
{ {
maxatoms = 0; maxatoms = 0;
pgsize = size;
oneatom = onesize;
inum = gnum = 0; inum = gnum = 0;
ilist = NULL; ilist = NULL;
@ -40,11 +40,6 @@ NeighList::NeighList(LAMMPS *lmp, int size, int onesize) : Pointers(lmp)
firstneigh = NULL; firstneigh = NULL;
firstdouble = NULL; firstdouble = NULL;
maxpage = 0;
pages = NULL;
dpages = NULL;
dnum = 0;
iskip = NULL; iskip = NULL;
ijskip = NULL; ijskip = NULL;
@ -66,6 +61,9 @@ NeighList::NeighList(LAMMPS *lmp, int size, int onesize) : Pointers(lmp)
nstencil_multi = NULL; nstencil_multi = NULL;
stencil_multi = NULL; stencil_multi = NULL;
distsq_multi = NULL; distsq_multi = NULL;
ipage = NULL;
dpage = NULL;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -78,12 +76,8 @@ NeighList::~NeighList()
memory->sfree(firstneigh); memory->sfree(firstneigh);
memory->sfree(firstdouble); memory->sfree(firstdouble);
for (int i = 0; i < maxpage; i++) memory->destroy(pages[i]); delete [] ipage;
memory->sfree(pages); if (dnum) delete [] dpage;
if (dnum) {
for (int i = 0; i < maxpage; i++) memory->destroy(dpages[i]);
memory->sfree(dpages);
}
} }
delete [] iskip; delete [] iskip;
@ -103,6 +97,28 @@ NeighList::~NeighList()
} }
} }
/* ---------------------------------------------------------------------- */
void NeighList::setup_pages(int pgsize_caller, int oneatom_caller,
int dnum_caller)
{
pgsize = pgsize_caller;
oneatom = oneatom_caller;
dnum = dnum_caller;
int nmypage = comm->nthreads;
ipage = new MyPage<int>[nmypage];
for (int i = 0; i < nmypage; i++)
ipage[i].init(oneatom,pgsize,PGDELTA);
if (dnum) {
dpage = new MyPage<double>[nmypage];
for (int i = 0; i < nmypage; i++)
dpage[i].init(dnum*oneatom,dnum*pgsize,PGDELTA);
}
else dpage = NULL;
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom arrays to allow for nmax atoms grow atom arrays to allow for nmax atoms
triggered by more atoms on a processor triggered by more atoms on a processor
@ -177,30 +193,6 @@ void NeighList::stencil_allocate(int smax, int style)
} }
} }
/* ----------------------------------------------------------------------
add PGDELTA pages to neighbor list
------------------------------------------------------------------------- */
int **NeighList::add_pages(int howmany)
{
int toppage = maxpage;
maxpage += howmany*PGDELTA;
pages = (int **)
memory->srealloc(pages,maxpage*sizeof(int *),"neighlist:pages");
for (int i = toppage; i < maxpage; i++)
memory->create(pages[i],pgsize,"neighlist:pages[i]");
if (dnum) {
dpages = (double **)
memory->srealloc(dpages,maxpage*sizeof(double *),"neighlist:dpages");
for (int i = toppage; i < maxpage; i++)
memory->create(dpages[i],dnum*pgsize,"neighlist:dpages[i]");
}
return pages;
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
copy skip info from request rq into list's iskip,ijskip copy skip info from request rq into list's iskip,ijskip
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
@ -272,11 +264,16 @@ bigint NeighList::memory_usage()
bytes += memory->usage(ilist,maxatoms); bytes += memory->usage(ilist,maxatoms);
bytes += memory->usage(numneigh,maxatoms); bytes += memory->usage(numneigh,maxatoms);
bytes += maxatoms * sizeof(int *); bytes += maxatoms * sizeof(int *);
bytes += memory->usage(pages,maxpage,pgsize);
int nmypage = comm->nthreads;
for (int i = 0; i < nmypage; i++)
bytes += ipage[i].size();
if (dnum) { if (dnum) {
bytes += maxatoms * sizeof(double *); for (int i = 0; i < nmypage; i++) {
bytes += memory->usage(dpages,maxpage,dnum*pgsize); bytes += maxatoms * sizeof(double *);
bytes += dpage[i].size();
}
} }
if (maxstencil) bytes += memory->usage(stencil,maxstencil); if (maxstencil) bytes += memory->usage(stencil,maxstencil);

View File

@ -41,12 +41,9 @@ class NeighList : protected Pointers {
int pgsize; // size of each page int pgsize; // size of each page
int oneatom; // max size for one atom int oneatom; // max size for one atom
int maxpage; // # of pages currently allocated int dnum; // # of doubles per neighbor, 0 if none
int **pages; // neighbor list pages for ints MyPage<int> *ipage; // pages of neighbor indices
double **dpages; // neighbor list pages for doubles MyPage<double> *dpage; // pages of neighbor doubles, if dnum > 0
int dnum; // # of doubles for each pair (0 if none)
MyPage<int> *page;
// atom types to skip when building list // atom types to skip when building list
// iskip,ijskip are just ptrs to corresponding request // iskip,ijskip are just ptrs to corresponding request
@ -80,11 +77,11 @@ class NeighList : protected Pointers {
class CudaNeighList *cuda_list; // CUDA neighbor list class CudaNeighList *cuda_list; // CUDA neighbor list
NeighList(class LAMMPS *, int, int); NeighList(class LAMMPS *);
~NeighList(); ~NeighList();
void setup_pages(int, int, int); // setup page data structures
void grow(int); // grow maxlocal void grow(int); // grow maxlocal
void stencil_allocate(int, int); // allocate stencil arrays void stencil_allocate(int, int); // allocate stencil arrays
int **add_pages(int howmany=1); // add pages to neigh list
void copy_skip_info(int *, int **); // copy skip info from a neigh request void copy_skip_info(int *, int **); // copy skip info from a neigh request
void print_attributes(); // debug routine void print_attributes(); // debug routine
int get_maxlocal() {return maxatoms;} int get_maxlocal() {return maxatoms;}

View File

@ -16,6 +16,7 @@
#include "atom.h" #include "atom.h"
#include "domain.h" #include "domain.h"
#include "group.h" #include "group.h"
#include "my_page.h"
#include "error.h" #include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -54,64 +55,40 @@ void Neighbor::respa_nsq_no_newton(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages; MyPage<int> *ipage = list->ipage;
NeighList *listinner = list->listinner; NeighList *listinner = list->listinner;
int *ilist_inner = listinner->ilist; int *ilist_inner = listinner->ilist;
int *numneigh_inner = listinner->numneigh; int *numneigh_inner = listinner->numneigh;
int **firstneigh_inner = listinner->firstneigh; int **firstneigh_inner = listinner->firstneigh;
int **pages_inner = listinner->pages; MyPage<int> *ipage_inner = listinner->ipage;
NeighList *listmiddle; NeighList *listmiddle;
int *ilist_middle,*numneigh_middle,**firstneigh_middle,**pages_middle; int *ilist_middle,*numneigh_middle,**firstneigh_middle;
MyPage<int> *ipage_middle;
int respamiddle = list->respamiddle; int respamiddle = list->respamiddle;
if (respamiddle) { if (respamiddle) {
listmiddle = list->listmiddle; listmiddle = list->listmiddle;
ilist_middle = listmiddle->ilist; ilist_middle = listmiddle->ilist;
numneigh_middle = listmiddle->numneigh; numneigh_middle = listmiddle->numneigh;
firstneigh_middle = listmiddle->firstneigh; firstneigh_middle = listmiddle->firstneigh;
pages_middle = listmiddle->pages; ipage_middle = listmiddle->ipage;
} }
int inum = 0; int inum = 0;
int npage = 0;
int npnt = 0;
int npage_inner = 0;
int npnt_inner = 0;
int npage_middle = 0;
int npnt_middle = 0;
int which = 0; int which = 0;
int minchange = 0; int minchange = 0;
ipage->reset();
ipage_inner->reset();
if (respamiddle) ipage_middle->reset();
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
n = n_inner = 0;
if (pgsize - npnt < oneatom) { neighptr = ipage->vget();
npnt = 0; neighptr_inner = ipage_inner->vget();
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0;
if (pgsize - npnt_inner < oneatom) {
npnt_inner = 0;
npage_inner++;
if (npage_inner == listinner->maxpage)
pages_inner = listinner->add_pages();
}
neighptr_inner = &pages_inner[npage_inner][npnt_inner];
n_inner = 0;
if (respamiddle) { if (respamiddle) {
if (pgsize - npnt_middle < oneatom) {
npnt_middle = 0;
npage_middle++;
if (npage_middle == listmiddle->maxpage)
pages_middle = listmiddle->add_pages();
}
neighptr_middle = &pages_middle[npage_middle][npnt_middle];
n_middle = 0; n_middle = 0;
neighptr_middle = ipage_middle->vget();
} }
itype = type[i]; itype = type[i];
@ -158,23 +135,23 @@ void Neighbor::respa_nsq_no_newton(NeighList *list)
ilist[inum] = i; ilist[inum] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
ilist_inner[inum] = i; ilist_inner[inum] = i;
firstneigh_inner[i] = neighptr_inner; firstneigh_inner[i] = neighptr_inner;
numneigh_inner[i] = n_inner; numneigh_inner[i] = n_inner;
npnt_inner += n_inner; ipage_inner->vgot(n_inner);
if (n_inner > oneatom) if (ipage_inner->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
if (respamiddle) { if (respamiddle) {
ilist_middle[inum] = i; ilist_middle[inum] = i;
firstneigh_middle[i] = neighptr_middle; firstneigh_middle[i] = neighptr_middle;
numneigh_middle[i] = n_middle; numneigh_middle[i] = n_middle;
npnt_middle += n_middle; ipage_middle->vgot(n_middle);
if (n_middle > oneatom) if (ipage_middle->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -221,64 +198,40 @@ void Neighbor::respa_nsq_newton(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages; MyPage<int> *ipage = list->ipage;
NeighList *listinner = list->listinner; NeighList *listinner = list->listinner;
int *ilist_inner = listinner->ilist; int *ilist_inner = listinner->ilist;
int *numneigh_inner = listinner->numneigh; int *numneigh_inner = listinner->numneigh;
int **firstneigh_inner = listinner->firstneigh; int **firstneigh_inner = listinner->firstneigh;
int **pages_inner = listinner->pages; MyPage<int> *ipage_inner = listinner->ipage;
NeighList *listmiddle; NeighList *listmiddle;
int *ilist_middle,*numneigh_middle,**firstneigh_middle,**pages_middle; int *ilist_middle,*numneigh_middle,**firstneigh_middle;
MyPage<int> *ipage_middle;
int respamiddle = list->respamiddle; int respamiddle = list->respamiddle;
if (respamiddle) { if (respamiddle) {
listmiddle = list->listmiddle; listmiddle = list->listmiddle;
ilist_middle = listmiddle->ilist; ilist_middle = listmiddle->ilist;
numneigh_middle = listmiddle->numneigh; numneigh_middle = listmiddle->numneigh;
firstneigh_middle = listmiddle->firstneigh; firstneigh_middle = listmiddle->firstneigh;
pages_middle = listmiddle->pages; ipage_middle = listmiddle->ipage;
} }
int inum = 0; int inum = 0;
int npage = 0;
int npnt = 0;
int npage_inner = 0;
int npnt_inner = 0;
int npage_middle = 0;
int npnt_middle = 0;
int which = 0; int which = 0;
int minchange = 0; int minchange = 0;
ipage->reset();
ipage_inner->reset();
if (respamiddle) ipage_middle->reset();
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
n = n_inner = 0;
if (pgsize - npnt < oneatom) { neighptr = ipage->vget();
npnt = 0; neighptr_inner = ipage_inner->vget();
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0;
if (pgsize - npnt_inner < oneatom) {
npnt_inner = 0;
npage_inner++;
if (npage_inner == listinner->maxpage)
pages_inner = listinner->add_pages();
}
neighptr_inner = &pages_inner[npage_inner][npnt_inner];
n_inner = 0;
if (respamiddle) { if (respamiddle) {
if (pgsize - npnt_middle < oneatom) {
npnt_middle = 0;
npage_middle++;
if (npage_middle == listmiddle->maxpage)
pages_middle = listmiddle->add_pages();
}
neighptr_middle = &pages_middle[npage_middle][npnt_middle];
n_middle = 0; n_middle = 0;
neighptr_middle = ipage_middle->vget();
} }
itag = tag[i]; itag = tag[i];
@ -343,23 +296,23 @@ void Neighbor::respa_nsq_newton(NeighList *list)
ilist[inum] = i; ilist[inum] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
ilist_inner[inum] = i; ilist_inner[inum] = i;
firstneigh_inner[i] = neighptr_inner; firstneigh_inner[i] = neighptr_inner;
numneigh_inner[i] = n_inner; numneigh_inner[i] = n_inner;
npnt_inner += n_inner; ipage_inner->vgot(n_inner);
if (n_inner > oneatom) if (ipage_inner->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
if (respamiddle) { if (respamiddle) {
ilist_middle[inum] = i; ilist_middle[inum] = i;
firstneigh_middle[i] = neighptr_middle; firstneigh_middle[i] = neighptr_middle;
numneigh_middle[i] = n_middle; numneigh_middle[i] = n_middle;
npnt_middle += n_middle; ipage_middle->vgot(n_middle);
if (n_middle > oneatom) if (ipage_middle->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -406,66 +359,42 @@ void Neighbor::respa_bin_no_newton(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages;
int nstencil = list->nstencil; int nstencil = list->nstencil;
int *stencil = list->stencil; int *stencil = list->stencil;
MyPage<int> *ipage = list->ipage;
NeighList *listinner = list->listinner; NeighList *listinner = list->listinner;
int *ilist_inner = listinner->ilist; int *ilist_inner = listinner->ilist;
int *numneigh_inner = listinner->numneigh; int *numneigh_inner = listinner->numneigh;
int **firstneigh_inner = listinner->firstneigh; int **firstneigh_inner = listinner->firstneigh;
int **pages_inner = listinner->pages; MyPage<int> *ipage_inner = listinner->ipage;
NeighList *listmiddle; NeighList *listmiddle;
int *ilist_middle,*numneigh_middle,**firstneigh_middle,**pages_middle; int *ilist_middle,*numneigh_middle,**firstneigh_middle;
MyPage<int> *ipage_middle;
int respamiddle = list->respamiddle; int respamiddle = list->respamiddle;
if (respamiddle) { if (respamiddle) {
listmiddle = list->listmiddle; listmiddle = list->listmiddle;
ilist_middle = listmiddle->ilist; ilist_middle = listmiddle->ilist;
numneigh_middle = listmiddle->numneigh; numneigh_middle = listmiddle->numneigh;
firstneigh_middle = listmiddle->firstneigh; firstneigh_middle = listmiddle->firstneigh;
pages_middle = listmiddle->pages; ipage_middle = listmiddle->ipage;
} }
int inum = 0; int inum = 0;
int npage = 0;
int npnt = 0;
int npage_inner = 0;
int npnt_inner = 0;
int npage_middle = 0;
int npnt_middle = 0;
int which = 0; int which = 0;
int minchange = 0; int minchange = 0;
ipage->reset();
ipage_inner->reset();
if (respamiddle) ipage_middle->reset();
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
n = n_inner = 0;
if (pgsize - npnt < oneatom) { neighptr = ipage->vget();
npnt = 0; neighptr_inner = ipage_inner->vget();
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0;
if (pgsize - npnt_inner < oneatom) {
npnt_inner = 0;
npage_inner++;
if (npage_inner == listinner->maxpage)
pages_inner = listinner->add_pages();
}
neighptr_inner = &pages_inner[npage_inner][npnt_inner];
n_inner = 0;
if (respamiddle) { if (respamiddle) {
if (pgsize - npnt_middle < oneatom) {
npnt_middle = 0;
npage_middle++;
if (npage_middle == listmiddle->maxpage)
pages_middle = listmiddle->add_pages();
}
neighptr_middle = &pages_middle[npage_middle][npnt_middle];
n_middle = 0; n_middle = 0;
neighptr_middle = ipage_middle->vget();
} }
itype = type[i]; itype = type[i];
@ -521,23 +450,23 @@ void Neighbor::respa_bin_no_newton(NeighList *list)
ilist[inum] = i; ilist[inum] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
ilist_inner[inum] = i; ilist_inner[inum] = i;
firstneigh_inner[i] = neighptr_inner; firstneigh_inner[i] = neighptr_inner;
numneigh_inner[i] = n_inner; numneigh_inner[i] = n_inner;
npnt_inner += n_inner; ipage_inner->vgot(n_inner);
if (n_inner > oneatom) if (ipage_inner->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
if (respamiddle) { if (respamiddle) {
ilist_middle[inum] = i; ilist_middle[inum] = i;
firstneigh_middle[i] = neighptr_middle; firstneigh_middle[i] = neighptr_middle;
numneigh_middle[i] = n_middle; numneigh_middle[i] = n_middle;
npnt_middle += n_middle; ipage_middle->vgot(n_middle);
if (n_middle > oneatom) if (ipage_middle->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -583,66 +512,42 @@ void Neighbor::respa_bin_newton(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages;
int nstencil = list->nstencil; int nstencil = list->nstencil;
int *stencil = list->stencil; int *stencil = list->stencil;
MyPage<int> *ipage = list->ipage;
NeighList *listinner = list->listinner; NeighList *listinner = list->listinner;
int *ilist_inner = listinner->ilist; int *ilist_inner = listinner->ilist;
int *numneigh_inner = listinner->numneigh; int *numneigh_inner = listinner->numneigh;
int **firstneigh_inner = listinner->firstneigh; int **firstneigh_inner = listinner->firstneigh;
int **pages_inner = listinner->pages; MyPage<int> *ipage_inner = listinner->ipage;
NeighList *listmiddle; NeighList *listmiddle;
int *ilist_middle,*numneigh_middle,**firstneigh_middle,**pages_middle; int *ilist_middle,*numneigh_middle,**firstneigh_middle;
MyPage<int> *ipage_middle;
int respamiddle = list->respamiddle; int respamiddle = list->respamiddle;
if (respamiddle) { if (respamiddle) {
listmiddle = list->listmiddle; listmiddle = list->listmiddle;
ilist_middle = listmiddle->ilist; ilist_middle = listmiddle->ilist;
numneigh_middle = listmiddle->numneigh; numneigh_middle = listmiddle->numneigh;
firstneigh_middle = listmiddle->firstneigh; firstneigh_middle = listmiddle->firstneigh;
pages_middle = listmiddle->pages; ipage_middle = listmiddle->ipage;
} }
int inum = 0; int inum = 0;
int npage = 0;
int npnt = 0;
int npage_inner = 0;
int npnt_inner = 0;
int npage_middle = 0;
int npnt_middle = 0;
int which = 0; int which = 0;
int minchange = 0; int minchange = 0;
ipage->reset();
ipage_inner->reset();
if (respamiddle) ipage_middle->reset();
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
n = n_inner = 0;
if (pgsize - npnt < oneatom) { neighptr = ipage->vget();
npnt = 0; neighptr_inner = ipage_inner->vget();
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0;
if (pgsize - npnt_inner < oneatom) {
npnt_inner = 0;
npage_inner++;
if (npage_inner == listinner->maxpage)
pages_inner = listinner->add_pages();
}
neighptr_inner = &pages_inner[npage_inner][npnt_inner];
n_inner = 0;
if (respamiddle) { if (respamiddle) {
if (pgsize - npnt_middle < oneatom) {
npnt_middle = 0;
npage_middle++;
if (npage_middle == listmiddle->maxpage)
pages_middle = listmiddle->add_pages();
}
neighptr_middle = &pages_middle[npage_middle][npnt_middle];
n_middle = 0; n_middle = 0;
neighptr_middle = ipage_middle->vget();
} }
itype = type[i]; itype = type[i];
@ -739,23 +644,23 @@ void Neighbor::respa_bin_newton(NeighList *list)
ilist[inum] = i; ilist[inum] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
ilist_inner[inum] = i; ilist_inner[inum] = i;
firstneigh_inner[i] = neighptr_inner; firstneigh_inner[i] = neighptr_inner;
numneigh_inner[i] = n_inner; numneigh_inner[i] = n_inner;
npnt_inner += n_inner; ipage_inner->vgot(n_inner);
if (n_inner > oneatom) if (ipage_inner->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
if (respamiddle) { if (respamiddle) {
ilist_middle[inum] = i; ilist_middle[inum] = i;
firstneigh_middle[i] = neighptr_middle; firstneigh_middle[i] = neighptr_middle;
numneigh_middle[i] = n_middle; numneigh_middle[i] = n_middle;
npnt_middle += n_middle; ipage_middle->vgot(n_middle);
if (n_middle > oneatom) if (ipage_middle->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }
@ -801,66 +706,42 @@ void Neighbor::respa_bin_newton_tri(NeighList *list)
int *ilist = list->ilist; int *ilist = list->ilist;
int *numneigh = list->numneigh; int *numneigh = list->numneigh;
int **firstneigh = list->firstneigh; int **firstneigh = list->firstneigh;
int **pages = list->pages;
int nstencil = list->nstencil; int nstencil = list->nstencil;
int *stencil = list->stencil; int *stencil = list->stencil;
MyPage<int> *ipage = list->ipage;
NeighList *listinner = list->listinner; NeighList *listinner = list->listinner;
int *ilist_inner = listinner->ilist; int *ilist_inner = listinner->ilist;
int *numneigh_inner = listinner->numneigh; int *numneigh_inner = listinner->numneigh;
int **firstneigh_inner = listinner->firstneigh; int **firstneigh_inner = listinner->firstneigh;
int **pages_inner = listinner->pages; MyPage<int> *ipage_inner = listinner->ipage;
NeighList *listmiddle; NeighList *listmiddle;
int *ilist_middle,*numneigh_middle,**firstneigh_middle,**pages_middle; int *ilist_middle,*numneigh_middle,**firstneigh_middle;
MyPage<int> *ipage_middle;
int respamiddle = list->respamiddle; int respamiddle = list->respamiddle;
if (respamiddle) { if (respamiddle) {
listmiddle = list->listmiddle; listmiddle = list->listmiddle;
ilist_middle = listmiddle->ilist; ilist_middle = listmiddle->ilist;
numneigh_middle = listmiddle->numneigh; numneigh_middle = listmiddle->numneigh;
firstneigh_middle = listmiddle->firstneigh; firstneigh_middle = listmiddle->firstneigh;
pages_middle = listmiddle->pages; ipage_middle = listmiddle->ipage;
} }
int inum = 0; int inum = 0;
int npage = 0;
int npnt = 0;
int npage_inner = 0;
int npnt_inner = 0;
int npage_middle = 0;
int npnt_middle = 0;
int which = 0; int which = 0;
int minchange = 0; int minchange = 0;
ipage->reset();
ipage_inner->reset();
if (respamiddle) ipage_middle->reset();
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
n = n_inner = 0;
if (pgsize - npnt < oneatom) { neighptr = ipage->vget();
npnt = 0; neighptr_inner = ipage_inner->vget();
npage++;
if (npage == list->maxpage) pages = list->add_pages();
}
neighptr = &pages[npage][npnt];
n = 0;
if (pgsize - npnt_inner < oneatom) {
npnt_inner = 0;
npage_inner++;
if (npage_inner == listinner->maxpage)
pages_inner = listinner->add_pages();
}
neighptr_inner = &pages_inner[npage_inner][npnt_inner];
n_inner = 0;
if (respamiddle) { if (respamiddle) {
if (pgsize - npnt_middle < oneatom) {
npnt_middle = 0;
npage_middle++;
if (npage_middle == listmiddle->maxpage)
pages_middle = listmiddle->add_pages();
}
neighptr_middle = &pages_middle[npage_middle][npnt_middle];
n_middle = 0; n_middle = 0;
neighptr_middle = ipage_middle->vget();
} }
itype = type[i]; itype = type[i];
@ -924,23 +805,23 @@ void Neighbor::respa_bin_newton_tri(NeighList *list)
ilist[inum] = i; ilist[inum] = i;
firstneigh[i] = neighptr; firstneigh[i] = neighptr;
numneigh[i] = n; numneigh[i] = n;
npnt += n; ipage->vgot(n);
if (n > oneatom) if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
ilist_inner[inum] = i; ilist_inner[inum] = i;
firstneigh_inner[i] = neighptr_inner; firstneigh_inner[i] = neighptr_inner;
numneigh_inner[i] = n_inner; numneigh_inner[i] = n_inner;
npnt_inner += n_inner; ipage_inner->vgot(n_inner);
if (n_inner > oneatom) if (ipage_inner->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
if (respamiddle) { if (respamiddle) {
ilist_middle[inum] = i; ilist_middle[inum] = i;
firstneigh_middle[i] = neighptr_middle; firstneigh_middle[i] = neighptr_middle;
numneigh_middle[i] = n_middle; numneigh_middle[i] = n_middle;
npnt_middle += n_middle; ipage_middle->vgot(n_middle);
if (n_middle > oneatom) if (ipage_middle->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
} }

View File

@ -456,9 +456,9 @@ void Neighbor::init()
// pass list ptr back to requestor (except for Command class) // pass list ptr back to requestor (except for Command class)
for (i = 0; i < nlist; i++) { for (i = 0; i < nlist; i++) {
lists[i] = new NeighList(lmp,pgsize,oneatom); lists[i] = new NeighList(lmp);
lists[i]->setup_pages(pgsize,oneatom,requests[i]->dnum);
lists[i]->index = i; lists[i]->index = i;
lists[i]->dnum = requests[i]->dnum;
if (requests[i]->pair) { if (requests[i]->pair) {
Pair *pair = (Pair *) requests[i]->requestor; Pair *pair = (Pair *) requests[i]->requestor;
@ -620,14 +620,11 @@ void Neighbor::init()
for (i = 0; i < nlist; i++) lists[i]->print_attributes(); for (i = 0; i < nlist; i++) lists[i]->print_attributes();
#endif #endif
// allocate atom arrays and 1st pages of lists that store them // allocate atom arrays for neighbor lists that store them
maxatom = atom->nmax; maxatom = atom->nmax;
for (i = 0; i < nlist; i++) for (i = 0; i < nlist; i++)
if (lists[i]->growflag) { if (lists[i]->growflag) lists[i]->grow(maxatom);
lists[i]->grow(maxatom);
lists[i]->add_pages();
}
// setup 3 vectors of pairwise neighbor lists // setup 3 vectors of pairwise neighbor lists
// blist = lists whose pair_build() is invoked every reneighbor // blist = lists whose pair_build() is invoked every reneighbor