forked from lijiext/lammps
more robust version of atom exchange size
This commit is contained in:
parent
691fc357a4
commit
2fd327d057
|
@ -44,6 +44,7 @@ BodyNparticle::BodyNparticle(LAMMPS *lmp, int narg, char **arg) :
|
|||
|
||||
icp = new MyPoolChunk<int>(1,1);
|
||||
dcp = new MyPoolChunk<double>(3*nmin,3*nmax);
|
||||
maxexchange = 1 + 3*nmax; // icp max + dcp max
|
||||
|
||||
memory->create(imflag,nmax,"body/nparticle:imflag");
|
||||
memory->create(imdata,nmax,4,"body/nparticle:imdata");
|
||||
|
|
|
@ -61,6 +61,7 @@ BodyRoundedPolygon::BodyRoundedPolygon(LAMMPS *lmp, int narg, char **arg) :
|
|||
|
||||
icp = new MyPoolChunk<int>(1,1);
|
||||
dcp = new MyPoolChunk<double>(3*nmin+2*nmin+1+1,3*nmax+2*nmax+1+1);
|
||||
maxexchange = 1 + 3*nmax+2*nmax+1+1; // icp max + dcp max
|
||||
|
||||
memory->create(imflag,nmax,"body/rounded/polygon:imflag");
|
||||
memory->create(imdata,nmax,7,"body/nparticle:imdata");
|
||||
|
|
|
@ -61,6 +61,7 @@ BodyRoundedPolyhedron::BodyRoundedPolyhedron(LAMMPS *lmp, int narg, char **arg)
|
|||
icp = new MyPoolChunk<int>(1,3);
|
||||
dcp = new MyPoolChunk<double>(3*nmin+2+1+1,
|
||||
3*nmax+2*nmax+MAX_FACE_SIZE*nmax+1+1);
|
||||
maxexchange = 3 + 3*nmax+2*nmax+MAX_FACE_SIZE*nmax+1+1; // icp max + dcp max
|
||||
|
||||
memory->create(imflag,2*nmax,"body/rounded/polyhedron:imflag");
|
||||
memory->create(imdata,2*nmax,7,"body/polyhedron:imdata");
|
||||
|
|
|
@ -34,6 +34,8 @@ AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp)
|
|||
mass_type = dipole_type = 0;
|
||||
forceclearflag = 0;
|
||||
size_data_bonus = 0;
|
||||
maxexchange = 0;
|
||||
|
||||
kokkosable = 0;
|
||||
|
||||
nargcopy = 0;
|
||||
|
|
|
@ -39,6 +39,8 @@ class AtomVec : protected Pointers {
|
|||
int size_data_vel; // number of values in Velocity line
|
||||
int size_data_bonus; // number of values in Bonus line
|
||||
int xcol_data; // column (1-N) where x is in Atom line
|
||||
int maxexchange; // max size of exchanged atom
|
||||
// only needs to be set if size > BUFEXTRA
|
||||
|
||||
class Molecule **onemols; // list of molecules for style template
|
||||
int nset; // # of molecules in list
|
||||
|
|
|
@ -28,6 +28,8 @@ class Body : protected Pointers {
|
|||
char *style;
|
||||
int size_forward; // max extra values packed for comm
|
||||
int size_border; // max extra values packed for border comm
|
||||
int maxexchange; // max size of exchanged atom
|
||||
|
||||
AtomVecBody *avec; // ptr to class that stores body bonus info
|
||||
|
||||
Body(class LAMMPS *, int, char **);
|
||||
|
|
40
src/comm.cpp
40
src/comm.cpp
|
@ -39,7 +39,7 @@
|
|||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define BUFMIN 1000 // also in comm styles
|
||||
#define BUFEXTRA 1024
|
||||
|
||||
enum{ONELEVEL,TWOLEVEL,NUMA,CUSTOM};
|
||||
enum{CART,CARTREORDER,XYZ};
|
||||
|
@ -65,7 +65,10 @@ Comm::Comm(LAMMPS *lmp) : Pointers(lmp)
|
|||
outfile = NULL;
|
||||
recv_from_partition = send_to_partition = -1;
|
||||
otherflag = 0;
|
||||
maxexchange_atom = maxexchange_fix = 0;
|
||||
|
||||
maxexchange = maxexchange_atom = maxexchange_fix = 0;
|
||||
maxexchange_fix_dynamic = 0;
|
||||
bufextra = BUFEXTRA;
|
||||
|
||||
grid2proc = NULL;
|
||||
xsplit = ysplit = zsplit = NULL;
|
||||
|
@ -225,6 +228,39 @@ void Comm::init()
|
|||
|
||||
if (force->newton == 0) maxreverse = 0;
|
||||
if (force->pair) maxreverse = MAX(maxreverse,force->pair->comm_reverse_off);
|
||||
|
||||
// maxexchange_atom = size of an exchanged atom, set by AtomVec
|
||||
// only needs to be set if size > BUFEXTRA
|
||||
// maxexchange_fix_dynamic = 1 if any fix sets its maxexchange dynamically
|
||||
|
||||
maxexchange_atom = atom->avec->maxexchange;
|
||||
|
||||
int nfix = modify->nfix;
|
||||
Fix **fix = modify->fix;
|
||||
|
||||
maxexchange_fix_dynamic = 0;
|
||||
for (int i = 0; i < nfix; i++)
|
||||
if (fix[i]->maxexchange_dynamic) maxexchange_fix_dynamic = 1;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
set maxexchange based on AtomVec and fixes
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Comm::init_exchange()
|
||||
{
|
||||
int nfix = modify->nfix;
|
||||
Fix **fix = modify->fix;
|
||||
|
||||
int onefix;
|
||||
maxexchange_fix = 0;
|
||||
for (int i = 0; i < nfix; i++) {
|
||||
onefix = fix[i]->maxexchange;
|
||||
maxexchange_fix = MAX(maxexchange_fix,onefix);
|
||||
}
|
||||
|
||||
maxexchange = maxexchange_atom + maxexchange_fix;
|
||||
bufextra = maxexchange + BUFEXTRA;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
|
15
src/comm.h
15
src/comm.h
|
@ -38,9 +38,8 @@ class Comm : protected Pointers {
|
|||
// -1 if no recv or send
|
||||
int other_partition_style; // 0 = recv layout dims must be multiple of
|
||||
// my layout dims
|
||||
int maxexchange_atom; // max contribution to exchange from AtomVec
|
||||
int maxexchange_fix; // max contribution to exchange from Fixes
|
||||
int nthreads; // OpenMP threads per MPI process
|
||||
|
||||
int nthreads; // OpenMP threads per MPI process
|
||||
|
||||
// public settings specific to layout = UNIFORM, NONUNIFORM
|
||||
|
||||
|
@ -130,8 +129,13 @@ class Comm : protected Pointers {
|
|||
int size_reverse; // # of datums in reverse comm
|
||||
int size_border; // # of datums in forward border comm
|
||||
|
||||
int maxforward,maxreverse; // max # of datums in forward/reverse comm
|
||||
int maxexchange; // max # of datums/atom in exchange comm
|
||||
int maxforward,maxreverse; // max # of datums in forward/reverse comm
|
||||
int maxexchange; // max size of one exchanged atom
|
||||
int maxexchange_atom; // contribution to maxexchange from AtomVec
|
||||
int maxexchange_fix; // static contribution to maxexchange from Fixes
|
||||
int maxexchange_fix_dynamic; // 1 if a fix has a dynamic contribution
|
||||
int bufextra; // augment size of send buf for an exchange atom
|
||||
|
||||
|
||||
int gridflag; // option for creating 3d grid
|
||||
int mapflag; // option for mapping procs to 3d grid
|
||||
|
@ -147,6 +151,7 @@ class Comm : protected Pointers {
|
|||
int coregrid[3]; // 3d grid of cores within a node
|
||||
int user_coregrid[3]; // user request for cores in each dim
|
||||
|
||||
void init_exchange();
|
||||
int rendezvous_irregular(int, char *, int, int, int *,
|
||||
int (*)(int, char *, int &, int *&, char *&, void *),
|
||||
int, char *&, int, void *, int);
|
||||
|
|
|
@ -42,8 +42,7 @@
|
|||
using namespace LAMMPS_NS;
|
||||
|
||||
#define BUFFACTOR 1.5
|
||||
#define BUFMIN 1000
|
||||
#define BUFEXTRA 1000
|
||||
#define BUFMIN 1024
|
||||
#define BIG 1.0e20
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
@ -110,14 +109,6 @@ void CommBrick::init_buffers()
|
|||
multilo = multihi = NULL;
|
||||
cutghostmulti = NULL;
|
||||
|
||||
// bufextra = max size of one exchanged atom
|
||||
// = allowed overflow of sendbuf in exchange()
|
||||
// atomvec, fix reset these 2 maxexchange values if needed
|
||||
// only necessary if their size > BUFEXTRA
|
||||
|
||||
maxexchange = maxexchange_atom + maxexchange_fix;
|
||||
bufextra = maxexchange + BUFEXTRA;
|
||||
|
||||
maxsend = BUFMIN;
|
||||
memory->create(buf_send,maxsend+bufextra,"comm:buf_send");
|
||||
maxrecv = BUFMIN;
|
||||
|
@ -141,6 +132,10 @@ void CommBrick::init()
|
|||
{
|
||||
Comm::init();
|
||||
|
||||
int bufextra_old = bufextra;
|
||||
init_exchange();
|
||||
if (bufextra > bufextra_old) grow_send(maxsend+bufextra,0);
|
||||
|
||||
// memory for multi-style communication
|
||||
|
||||
if (mode == Comm::MULTI && multilo == NULL) {
|
||||
|
@ -603,15 +598,14 @@ void CommBrick::exchange()
|
|||
atom->nghost = 0;
|
||||
atom->avec->clear_bonus();
|
||||
|
||||
// insure send buf is large enough for single atom
|
||||
// bufextra = max size of one atom = allowed overflow of sendbuf
|
||||
// fixes can change per-atom size requirement on-the-fly
|
||||
// insure send buf has extra space for a single atom
|
||||
// only need to reset if a fix can dynamically add to size of single atom
|
||||
|
||||
int bufextra_old = bufextra;
|
||||
maxexchange = maxexchange_atom + maxexchange_fix;
|
||||
bufextra = maxexchange + BUFEXTRA;
|
||||
if (bufextra > bufextra_old)
|
||||
grow_send(maxsend+bufextra,1);
|
||||
if (maxexchange_fix_dynamic) {
|
||||
int bufextra_old = bufextra;
|
||||
init_exchange();
|
||||
if (bufextra > bufextra_old) grow_send(maxsend+bufextra,0);
|
||||
}
|
||||
|
||||
// subbox bounds for orthogonal or triclinic
|
||||
|
||||
|
|
|
@ -74,7 +74,6 @@ class CommBrick : public Comm {
|
|||
double *buf_send; // send buffer for all comm
|
||||
double *buf_recv; // recv buffer for all comm
|
||||
int maxsend,maxrecv; // current size of send/recv buffer
|
||||
int bufextra; // extra space beyond maxsend in send buffer
|
||||
int smax,rmax; // max size in atoms of single borders send/recv
|
||||
|
||||
// NOTE: init_buffers is called from a constructor and must not be made virtual
|
||||
|
|
|
@ -32,8 +32,7 @@ using namespace LAMMPS_NS;
|
|||
|
||||
#define BUFFACTOR 1.5
|
||||
#define BUFFACTOR 1.5
|
||||
#define BUFMIN 1000
|
||||
#define BUFEXTRA 1000
|
||||
#define BUFMIN 1024
|
||||
#define EPSILON 1.0e-6
|
||||
|
||||
#define DELTA_PROCS 16
|
||||
|
@ -80,14 +79,6 @@ CommTiled::~CommTiled()
|
|||
|
||||
void CommTiled::init_buffers()
|
||||
{
|
||||
// bufextra = max size of one exchanged atom
|
||||
// = allowed overflow of sendbuf in exchange()
|
||||
// atomvec, fix reset these 2 maxexchange values if needed
|
||||
// only necessary if their size > BUFEXTRA
|
||||
|
||||
maxexchange = maxexchange_atom + maxexchange_fix;
|
||||
bufextra = maxexchange + BUFEXTRA;
|
||||
|
||||
maxsend = BUFMIN;
|
||||
memory->create(buf_send,maxsend+bufextra,"comm:buf_send");
|
||||
maxrecv = BUFMIN;
|
||||
|
@ -108,6 +99,10 @@ void CommTiled::init()
|
|||
{
|
||||
Comm::init();
|
||||
|
||||
int bufextra_old = bufextra;
|
||||
init_exchange();
|
||||
if (bufextra > bufextra_old) grow_send(maxsend+bufextra,0);
|
||||
|
||||
// temporary restrictions
|
||||
|
||||
if (triclinic)
|
||||
|
@ -644,15 +639,14 @@ void CommTiled::exchange()
|
|||
atom->nghost = 0;
|
||||
atom->avec->clear_bonus();
|
||||
|
||||
// insure send buf is large enough for single atom
|
||||
// bufextra = max size of one atom = allowed overflow of sendbuf
|
||||
// fixes can change per-atom size requirement on-the-fly
|
||||
// insure send buf has extra space for a single atom
|
||||
// only need to reset if a fix can dynamically add to size of single atom
|
||||
|
||||
int bufextra_old = bufextra;
|
||||
maxexchange = maxexchange_atom + maxexchange_fix;
|
||||
bufextra = maxexchange + BUFEXTRA;
|
||||
if (bufextra > bufextra_old)
|
||||
memory->grow(buf_send,maxsend+bufextra,"comm:buf_send");
|
||||
if (maxexchange_fix_dynamic) {
|
||||
int bufextra_old = bufextra;
|
||||
init_exchange();
|
||||
if (bufextra > bufextra_old) grow_send(maxsend+bufextra,1);
|
||||
}
|
||||
|
||||
// domain properties used in exchange method and methods it calls
|
||||
// subbox bounds for orthogonal or triclinic
|
||||
|
|
|
@ -87,7 +87,6 @@ class CommTiled : public Comm {
|
|||
double *buf_send; // send buffer for all comm
|
||||
double *buf_recv; // recv buffer for all comm
|
||||
int maxsend,maxrecv; // current size of send/recv buffer
|
||||
int bufextra; // extra space beyond maxsend in send buffer
|
||||
int smaxone,rmaxone; // max size in atoms of single borders send/recv
|
||||
int smaxall,rmaxall; // max size in atoms of any borders send/recv
|
||||
// for comm to all procs in one swap
|
||||
|
|
|
@ -78,6 +78,8 @@ Fix::Fix(LAMMPS *lmp, int /*narg*/, char **arg) :
|
|||
enforce2d_flag = 0;
|
||||
respa_level_support = 0;
|
||||
respa_level = -1;
|
||||
maxexchange = 0;
|
||||
maxexchange_dynamic = 0;
|
||||
|
||||
scalar_flag = vector_flag = array_flag = 0;
|
||||
peratom_flag = local_flag = 0;
|
||||
|
|
|
@ -56,6 +56,8 @@ class Fix : protected Pointers {
|
|||
int enforce2d_flag; // 1 if has enforce2d method
|
||||
int respa_level_support; // 1 if fix supports fix_modify respa
|
||||
int respa_level; // which respa level to apply fix (1-Nrespa)
|
||||
int maxexchange; // max # of per-atom values for Comm::exchange()
|
||||
int maxexchange_dynamic; // 1 if fix sets maxexchange dynamically
|
||||
|
||||
int scalar_flag; // 0/1 if compute_scalar() function exists
|
||||
int vector_flag; // 0/1 if compute_vector() function exists
|
||||
|
|
|
@ -42,6 +42,7 @@ FixNeighHistory::FixNeighHistory(LAMMPS *lmp, int narg, char **arg) :
|
|||
|
||||
restart_peratom = 1;
|
||||
create_attribute = 1;
|
||||
maxexchange_dynamic = 1;
|
||||
|
||||
newton_pair = force->newton_pair;
|
||||
|
||||
|
@ -296,11 +297,11 @@ void FixNeighHistory::pre_exchange_onesided()
|
|||
}
|
||||
|
||||
// set maxpartner = max # of partners of any owned atom
|
||||
// bump up comm->maxexchange_fix if necessary
|
||||
// maxexchange = max # of values for any Comm::exchange() atom
|
||||
|
||||
maxpartner = 0;
|
||||
for (i = 0; i < nlocal_neigh; i++) maxpartner = MAX(maxpartner,npartner[i]);
|
||||
comm->maxexchange_fix = MAX(comm->maxexchange_fix,(dnum+1)*maxpartner+1);
|
||||
maxexchange = (dnum+1)*maxpartner + 1;
|
||||
|
||||
// zero npartner values from previous nlocal_neigh to current nlocal
|
||||
|
||||
|
@ -424,11 +425,11 @@ void FixNeighHistory::pre_exchange_newton()
|
|||
comm->reverse_comm_fix_variable(this);
|
||||
|
||||
// set maxpartner = max # of partners of any owned atom
|
||||
// bump up comm->maxexchange_fix if necessary
|
||||
// maxexchange = max # of values for any Comm::exchange() atom
|
||||
|
||||
maxpartner = 0;
|
||||
for (i = 0; i < nlocal_neigh; i++) maxpartner = MAX(maxpartner,npartner[i]);
|
||||
comm->maxexchange_fix = MAX(comm->maxexchange_fix,(dnum+1)*maxpartner+1);
|
||||
maxexchange = (dnum+1)*maxpartner + 1;
|
||||
|
||||
// zero npartner values from previous nlocal_neigh to current nlocal
|
||||
|
||||
|
@ -531,11 +532,11 @@ void FixNeighHistory::pre_exchange_no_newton()
|
|||
}
|
||||
|
||||
// set maxpartner = max # of partners of any owned atom
|
||||
// bump up comm->maxexchange_fix if necessary
|
||||
// maxexchange = max # of values for any Comm::exchange() atom
|
||||
|
||||
maxpartner = 0;
|
||||
for (i = 0; i < nlocal_neigh; i++) maxpartner = MAX(maxpartner,npartner[i]);
|
||||
comm->maxexchange_fix = MAX(comm->maxexchange_fix,(dnum+1)*maxpartner+1);
|
||||
maxexchange = (dnum+1)*maxpartner + 1;
|
||||
|
||||
// zero npartner values from previous nlocal_neigh to current nlocal
|
||||
|
||||
|
@ -796,9 +797,6 @@ void FixNeighHistory::unpack_reverse_comm(int n, int *list, double *buf)
|
|||
|
||||
int FixNeighHistory::pack_exchange(int i, double *buf)
|
||||
{
|
||||
// NOTE: how do I know comm buf is big enough if extreme # of touching neighs
|
||||
// Comm::BUFEXTRA may need to be increased
|
||||
|
||||
int m = 0;
|
||||
buf[m++] = npartner[i];
|
||||
for (int n = 0; n < npartner[i]; n++) {
|
||||
|
|
|
@ -106,6 +106,7 @@ vstore(NULL), astore(NULL), rbuf(NULL)
|
|||
for (int i = 0; i < nlocal; i++)
|
||||
for (int j = 0; j < nvalues; j++)
|
||||
astore[i][j] = 0.0;
|
||||
maxexchange = nvalues;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue