I believe there is a bug in CommBrick::exchange_variable()
[1] (the method follows the algorithm from [2, Fig. 8]) If the conditional statement in the middle of the function is true, it will result in the loss of intermediate results in buf_recv
:
comm_brick.cpp:1493: if (nrecv > maxrecv) grow_recv(nrecv);
I think the following modification should fix it:
modified src/comm_brick.cpp
@@ -1490,7 +1490,10 @@ int CommBrick::exchange_variable(int n, double *inbuf, double *&outbuf)
nrecv += nrecv2;
} else nrecv2 = 0;
- if (nrecv > maxrecv) grow_recv(nrecv);
+ if (nrecv > maxrecv) {
+ maxrecv = static_cast<int> (BUFFACTOR * nrecv);
+ memory->grow(buf_recv, maxrecv + bufextra,"comm:buf_recv");
+ }
MPI_Irecv(&buf_recv[nsend],nrecv1,MPI_DOUBLE,procneigh[dim][1],0,world,&request);
MPI_Send(buf_recv,nsend,MPI_DOUBLE,procneigh[dim][0],0,world);
[1] lammps/comm_brick.cpp at 15116a04567ce7ea2c5a00635d0f421d64f31894 · lammps/lammps · GitHub
[2] Fast Parallel Algorithms for Short-Range Molecular Dynamics,
S. Plimpton, J Comp Phys, 117, 1-19 (1995)