more changes to robustify comm buf_send length
This commit is contained in:
@ -95,6 +95,7 @@ void AtomVecHybrid::process_args(int narg, char **arg)
|
||||
size_data_atom = 5;
|
||||
size_data_vel = 4;
|
||||
xcol_data = 3;
|
||||
maxexchange = 0;
|
||||
|
||||
for (int k = 0; k < nstyles; k++) {
|
||||
if ((styles[k]->molecular == 1 && molecular == 2) ||
|
||||
@ -120,6 +121,8 @@ void AtomVecHybrid::process_args(int narg, char **arg)
|
||||
size_border += styles[k]->size_border - 6;
|
||||
size_data_atom += styles[k]->size_data_atom - 5;
|
||||
size_data_vel += styles[k]->size_data_vel - 4;
|
||||
|
||||
maxexchange += styles[k]->maxexchange;
|
||||
}
|
||||
|
||||
size_velocity = 3;
|
||||
|
||||
@ -134,7 +134,7 @@ class Comm : protected Pointers {
|
||||
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 bufextra; // augment send buf size for an exchange atom
|
||||
|
||||
|
||||
int gridflag; // option for creating 3d grid
|
||||
|
||||
@ -109,9 +109,9 @@ void CommBrick::init_buffers()
|
||||
multilo = multihi = NULL;
|
||||
cutghostmulti = NULL;
|
||||
|
||||
maxsend = BUFMIN;
|
||||
memory->create(buf_send,maxsend+bufextra,"comm:buf_send");
|
||||
maxrecv = BUFMIN;
|
||||
buf_send = buf_recv = NULL;
|
||||
maxsend = maxrecv = BUFMIN;
|
||||
grow_send(maxsend,2);
|
||||
memory->create(buf_recv,maxrecv,"comm:buf_recv");
|
||||
|
||||
nswap = 0;
|
||||
@ -134,7 +134,7 @@ void CommBrick::init()
|
||||
|
||||
int bufextra_old = bufextra;
|
||||
init_exchange();
|
||||
if (bufextra > bufextra_old) grow_send(maxsend+bufextra,0);
|
||||
if (bufextra > bufextra_old) grow_send(maxsend+bufextra,2);
|
||||
|
||||
// memory for multi-style communication
|
||||
|
||||
@ -604,7 +604,7 @@ void CommBrick::exchange()
|
||||
if (maxexchange_fix_dynamic) {
|
||||
int bufextra_old = bufextra;
|
||||
init_exchange();
|
||||
if (bufextra > bufextra_old) grow_send(maxsend+bufextra,0);
|
||||
if (bufextra > bufextra_old) grow_send(maxsend+bufextra,2);
|
||||
}
|
||||
|
||||
// subbox bounds for orthogonal or triclinic
|
||||
@ -1346,18 +1346,23 @@ int CommBrick::exchange_variable(int n, double *inbuf, double *&outbuf)
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
realloc the size of the send buffer as needed with BUFFACTOR and bufextra
|
||||
if flag = 1, realloc
|
||||
if flag = 0, don't need to realloc with copy, just free/malloc
|
||||
flag = 0, don't need to realloc with copy, just free/malloc w/ BUFFACTOR
|
||||
flag = 1, realloc with BUFFACTOR
|
||||
flag = 2, free/malloc w/out BUFFACTOR
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void CommBrick::grow_send(int n, int flag)
|
||||
{
|
||||
maxsend = static_cast<int> (BUFFACTOR * n);
|
||||
if (flag)
|
||||
memory->grow(buf_send,maxsend+bufextra,"comm:buf_send");
|
||||
else {
|
||||
if (flag == 0) {
|
||||
maxsend = static_cast<int> (BUFFACTOR * n);
|
||||
memory->destroy(buf_send);
|
||||
memory->create(buf_send,maxsend+bufextra,"comm:buf_send");
|
||||
} else if (flag == 1) {
|
||||
maxsend = static_cast<int> (BUFFACTOR * n);
|
||||
memory->grow(buf_send,maxsend+bufextra,"comm:buf_send");
|
||||
} else {
|
||||
memory->destroy(buf_send);
|
||||
memory->grow(buf_send,maxsend+bufextra,"comm:buf_send");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -79,9 +79,9 @@ CommTiled::~CommTiled()
|
||||
|
||||
void CommTiled::init_buffers()
|
||||
{
|
||||
maxsend = BUFMIN;
|
||||
memory->create(buf_send,maxsend+bufextra,"comm:buf_send");
|
||||
maxrecv = BUFMIN;
|
||||
buf_send = buf_recv = NULL;
|
||||
maxsend = maxrecv = BUFMIN;
|
||||
grow_send(maxsend,2);
|
||||
memory->create(buf_recv,maxrecv,"comm:buf_recv");
|
||||
|
||||
maxoverlap = 0;
|
||||
@ -1804,18 +1804,23 @@ int CommTiled::coord2proc(double *x, int &igx, int &igy, int &igz)
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
realloc the size of the send buffer as needed with BUFFACTOR and bufextra
|
||||
if flag = 1, realloc
|
||||
if flag = 0, don't need to realloc with copy, just free/malloc
|
||||
flag = 0, don't need to realloc with copy, just free/malloc w/ BUFFACTOR
|
||||
flag = 1, realloc with BUFFACTOR
|
||||
flag = 2, free/malloc w/out BUFFACTOR
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void CommTiled::grow_send(int n, int flag)
|
||||
{
|
||||
maxsend = static_cast<int> (BUFFACTOR * n);
|
||||
if (flag)
|
||||
memory->grow(buf_send,maxsend+bufextra,"comm:buf_send");
|
||||
else {
|
||||
if (flag == 0) {
|
||||
maxsend = static_cast<int> (BUFFACTOR * n);
|
||||
memory->destroy(buf_send);
|
||||
memory->create(buf_send,maxsend+bufextra,"comm:buf_send");
|
||||
} else if (flag == 1) {
|
||||
maxsend = static_cast<int> (BUFFACTOR * n);
|
||||
memory->grow(buf_send,maxsend+bufextra,"comm:buf_send");
|
||||
} else {
|
||||
memory->destroy(buf_send);
|
||||
memory->grow(buf_send,maxsend+bufextra,"comm:buf_send");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -19,6 +19,8 @@
|
||||
#include "atom_vec.h"
|
||||
#include "domain.h"
|
||||
#include "comm.h"
|
||||
#include "modify.h"
|
||||
#include "fix.h"
|
||||
#include "memory.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
@ -35,8 +37,8 @@ static int compare_standalone(const int, const int, void *);
|
||||
#endif
|
||||
|
||||
#define BUFFACTOR 1.5
|
||||
#define BUFMIN 1000
|
||||
#define BUFEXTRA 1000
|
||||
#define BUFMIN 1024
|
||||
#define BUFEXTRA 1024
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -69,9 +71,10 @@ Irregular::Irregular(LAMMPS *lmp) : Pointers(lmp)
|
||||
// initialize buffers for migrate atoms, not used for datum comm
|
||||
// these can persist for multiple irregular operations
|
||||
|
||||
maxsend = BUFMIN;
|
||||
memory->create(buf_send,maxsend+BUFEXTRA,"comm:buf_send");
|
||||
maxrecv = BUFMIN;
|
||||
buf_send = buf_recv = NULL;
|
||||
maxsend = maxrecv = BUFMIN;
|
||||
bufextra = BUFEXTRA;
|
||||
grow_send(maxsend,2);
|
||||
memory->create(buf_recv,maxrecv,"comm:buf_recv");
|
||||
}
|
||||
|
||||
@ -103,6 +106,13 @@ Irregular::~Irregular()
|
||||
|
||||
void Irregular::migrate_atoms(int sortflag, int preassign, int *procassign)
|
||||
{
|
||||
// check if buf_send needs to be extended due to atom style or per-atom fixes
|
||||
// same as in Comm::exchange()
|
||||
|
||||
int bufextra_old = bufextra;
|
||||
init_exchange();
|
||||
if (bufextra > bufextra_old) grow_send(maxsend+bufextra,2);
|
||||
|
||||
// clear global->local map since atoms move to new procs
|
||||
// clear old ghosts so map_set() at end will operate only on local atoms
|
||||
// exchange() doesn't need to clear ghosts b/c borders()
|
||||
@ -983,24 +993,52 @@ void Irregular::destroy_data()
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
realloc the size of the send buffer as needed with BUFFACTOR & BUFEXTRA
|
||||
if flag = 1, realloc
|
||||
if flag = 0, don't need to realloc with copy, just free/malloc
|
||||
set bufextra based on AtomVec and fixes
|
||||
similar to Comm::init_exchange()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Irregular::init_exchange()
|
||||
{
|
||||
int nfix = modify->nfix;
|
||||
Fix **fix = modify->fix;
|
||||
|
||||
int onefix;
|
||||
int maxexchange_fix = 0;
|
||||
for (int i = 0; i < nfix; i++) {
|
||||
onefix = fix[i]->maxexchange;
|
||||
maxexchange_fix = MAX(maxexchange_fix,onefix);
|
||||
}
|
||||
|
||||
int maxexchange = atom->avec->maxexchange + maxexchange_fix;
|
||||
bufextra = maxexchange + BUFEXTRA;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
realloc the size of the send buffer as needed with BUFFACTOR and bufextra
|
||||
flag = 0, don't need to realloc with copy, just free/malloc w/ BUFFACTOR
|
||||
flag = 1, realloc with BUFFACTOR
|
||||
flag = 2, free/malloc w/out BUFFACTOR
|
||||
same as Comm::grow_send()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Irregular::grow_send(int n, int flag)
|
||||
{
|
||||
maxsend = static_cast<int> (BUFFACTOR * n);
|
||||
if (flag)
|
||||
memory->grow(buf_send,maxsend+BUFEXTRA,"comm:buf_send");
|
||||
else {
|
||||
if (flag == 0) {
|
||||
maxsend = static_cast<int> (BUFFACTOR * n);
|
||||
memory->destroy(buf_send);
|
||||
memory->create(buf_send,maxsend+BUFEXTRA,"comm:buf_send");
|
||||
memory->create(buf_send,maxsend+bufextra,"comm:buf_send");
|
||||
} else if (flag == 1) {
|
||||
maxsend = static_cast<int> (BUFFACTOR * n);
|
||||
memory->grow(buf_send,maxsend+bufextra,"comm:buf_send");
|
||||
} else {
|
||||
memory->destroy(buf_send);
|
||||
memory->grow(buf_send,maxsend+bufextra,"comm:buf_send");
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
free/malloc the size of the recv buffer as needed with BUFFACTOR
|
||||
same as Comm::grow_recv()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Irregular::grow_recv(int n)
|
||||
|
||||
@ -43,6 +43,7 @@ class Irregular : protected Pointers {
|
||||
int triclinic;
|
||||
int map_style;
|
||||
|
||||
int bufextra; // augment send buf size for a migrating atom
|
||||
int maxsend,maxrecv; // size of buf send/recv in # of doubles
|
||||
double *buf_send,*buf_recv; // bufs used in migrate_atoms
|
||||
int maxdbuf; // size of double buf in bytes
|
||||
@ -91,6 +92,7 @@ class Irregular : protected Pointers {
|
||||
|
||||
int binary(double, int, double *);
|
||||
|
||||
void init_exchange(); // reset bufxtra
|
||||
void grow_send(int,int); // reallocate send buffer
|
||||
void grow_recv(int); // free/allocate recv buffer
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user