From 0b0bf77f04c39cc81392299fd35e5e79228f2339 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Mon, 11 Feb 2013 20:34:02 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@9447 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/comm.cpp | 13 +++++++++---- src/comm.h | 2 +- src/special.cpp | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/comm.cpp b/src/comm.cpp index 681b54fe97..e2ea0278db 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -1506,12 +1506,15 @@ void Comm::forward_comm_array(int n, double **array) /* ---------------------------------------------------------------------- communicate inbuf around full ring of processors with messtag - nbytes = size of inbuf = n datums, each of size nper bytes - use callback() to allow caller to process each proc's inbuf + nbytes = size of inbuf = n datums * nper bytes + callback() is invoked to allow caller to process/update each proc's inbuf + note that callback() is invoked on final iteration for original inbuf + for non-NULL outbuf, final updated inbuf is copied to it + outbuf = inbuf is OK ------------------------------------------------------------------------- */ void Comm::ring(int n, int nper, void *inbuf, int messtag, - void (*callback)(int, char *)) + void (*callback)(int, char *), void *outbuf) { MPI_Request request; MPI_Status status; @@ -1537,10 +1540,12 @@ void Comm::ring(int n, int nper, void *inbuf, int messtag, MPI_Wait(&request,&status); MPI_Get_count(&status,MPI_CHAR,&nbytes); memcpy(buf,bufcopy,nbytes); - callback(nbytes/nper,buf); } + callback(nbytes/nper,buf); } + if (outbuf) memcpy(outbuf,buf,nbytes); + memory->destroy(buf); memory->destroy(bufcopy); } diff --git a/src/comm.h b/src/comm.h index 17c8b0ac50..fe0ccc2727 100644 --- a/src/comm.h +++ b/src/comm.h @@ -61,7 +61,7 @@ class Comm : protected Pointers { virtual void reverse_comm_dump(class Dump *); // reverse comm from a Dump void forward_comm_array(int, double **); // forward comm of array - void ring(int, int, void *, int, void (*)(int, char *)); // ring comm + void ring(int, int, void *, int, void (*)(int, char *), void *); // ring comm virtual void set(int, char **); // set communication style void set_processors(int, char **); // set 3d processor grid attributes diff --git a/src/special.cpp b/src/special.cpp index 77314cceb5..eb7d8f826f 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -956,7 +956,7 @@ void Special::dihedral_trim() if (next == nprocs) next = 0; if (prev < 0) prev = nprocs - 1; - int messtag = 7; + int messtag = 8; for (int loop = 0; loop < nprocs; loop++) { i = 0; while (i < size) {