Merge branch 'master' into multi-comm-tiled
Conflicts resolved:
src/comm_tiled.cpp
This commit is contained in:
@ -15,19 +15,17 @@
|
||||
Contributing author (multi) : Adrian Diaz (University of Florida)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cstring>
|
||||
#include "comm_tiled.h"
|
||||
#include "comm_brick.h"
|
||||
#include <mpi.h>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include "atom.h"
|
||||
#include "atom_vec.h"
|
||||
#include "domain.h"
|
||||
#include "force.h"
|
||||
#include "pair.h"
|
||||
#include "neighbor.h"
|
||||
#include "modify.h"
|
||||
#include "fix.h"
|
||||
#include "compute.h"
|
||||
#include "output.h"
|
||||
#include "dump.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
@ -36,8 +34,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
|
||||
@ -89,17 +86,9 @@ void CommTiled::init_buffers()
|
||||
{
|
||||
sendbox_multi = 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;
|
||||
buf_send = buf_recv = NULL;
|
||||
maxsend = maxrecv = BUFMIN;
|
||||
grow_send(maxsend,2);
|
||||
memory->create(buf_recv,maxrecv,"comm:buf_recv");
|
||||
|
||||
maxoverlap = 0;
|
||||
@ -118,7 +107,6 @@ void CommTiled::init()
|
||||
Comm::init();
|
||||
|
||||
// memory for multi-style communication
|
||||
int maxswap = 6;
|
||||
if (mode == Comm::MULTI) {
|
||||
memory->create(cutghostmulti,atom->ntypes+1,3,"comm:cutghostmulti");
|
||||
}
|
||||
@ -126,6 +114,10 @@ void CommTiled::init()
|
||||
memory->destroy(cutghostmulti);
|
||||
}
|
||||
|
||||
int bufextra_old = bufextra;
|
||||
init_exchange();
|
||||
if (bufextra > bufextra_old) grow_send(maxsend+bufextra,2);
|
||||
|
||||
// temporary restrictions
|
||||
|
||||
if (triclinic)
|
||||
@ -174,19 +166,23 @@ void CommTiled::setup()
|
||||
// set cutoff for comm forward and comm reverse
|
||||
// check that cutoff < any periodic box length
|
||||
|
||||
double cut;
|
||||
|
||||
if (mode == Comm::MULTI) {
|
||||
double *cuttype = neighbor->cuttype;
|
||||
for (i = 1; i <= ntypes; i++) {
|
||||
cut = 0.0;
|
||||
if (cutusermulti) cut = cutusermulti[i];
|
||||
cutghostmulti[i][0] = MAX(cut,cuttype[i]);
|
||||
cutghostmulti[i][1] = MAX(cut,cuttype[i]);
|
||||
cutghostmulti[i][2] = MAX(cut,cuttype[i]);
|
||||
}
|
||||
if (mode == Comm::MULTI) {
|
||||
double *cuttype = neighbor->cuttype;
|
||||
double cut;
|
||||
for (i = 1; i <= ntypes; i++) {
|
||||
cut = 0.0;
|
||||
if (cutusermulti) cut = cutusermulti[i];
|
||||
cutghostmulti[i][0] = MAX(cut,cuttype[i]);
|
||||
cutghostmulti[i][1] = MAX(cut,cuttype[i]);
|
||||
cutghostmulti[i][2] = MAX(cut,cuttype[i]);
|
||||
}
|
||||
cut = MAX(neighbor->cutneighmax,cutghostuser);
|
||||
}
|
||||
|
||||
double cut = get_comm_cutoff();
|
||||
if ((cut == 0.0) && (me == 0))
|
||||
error->warning(FLERR,"Communication cutoff is 0.0. No ghost atoms "
|
||||
"will be generated. Atoms may get lost.");
|
||||
|
||||
cutghost[0] = cutghost[1] = cutghost[2] = cut;
|
||||
|
||||
|
||||
@ -601,7 +597,7 @@ void CommTiled::forward_comm(int /*dummy*/)
|
||||
MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]);
|
||||
}
|
||||
if (sendother[iswap]) {
|
||||
for (i = 0; i < nsendproc[iswap]; i++) {
|
||||
for (i = 0; i < nsend; i++) {
|
||||
n = avec->pack_comm(sendnum[iswap][i],sendlist[iswap][i],
|
||||
buf_send,pbc_flag[iswap][i],pbc[iswap][i]);
|
||||
MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap][i],0,world);
|
||||
@ -733,15 +729,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,2);
|
||||
}
|
||||
|
||||
// domain properties used in exchange method and methods it calls
|
||||
// subbox bounds for orthogonal or triclinic
|
||||
@ -1953,18 +1948,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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user