Newsgroups: comp.parallel.mpi
From: doss@ERC.MsState.Edu (Nathan E. Doss)
Subject: Re: Overlapping send and receive buffers in collective comm
Organization: Mississippi State University
Date: 2 Nov 1994 21:07:08 GMT
Message-ID: <398v1s$fuj@Tut.MsState.Edu>

Rob Neely (neely@crevasse.llnl.gov) wrote:
: Is it legal to do "in place" gathering using the gather/gatherv
: functions?   That is, I want my send buffer to overlap with my receive
: buffer on the root node.

: For example, each processor contains an array "A" which is of the
: complete problem size, but only computes an independent piece of it
: (say, 10 elements). One would like to be able to gather the entire array
: "A" at the root using something like (fortran-style):

: call mpi_gather(A((me+1)*10), 10, type, A, 10, type, 0, MPI_COMM_WORLD, ierr)

: thus avoiding the extra buffers and copying which would be required if
: the send and receive buffers must not overlap on the root.

: Is this allowed?  All of the examples I've seen use separate send and
: receive buffers, but the standard does not explicitly say (at least that
: I can find).  

: Thanks.

: --Rob Neely, LLNL
: --rneely@llnl.gov


From section 2.2 of the standard:

   Unless specified otherwise, an argument of type OUT or type
   INOUT cannot be aliased with any other argument passed to
   an MPI procedure.  An example of argument aliasing in
   C appears below.  If we define a C procedure like this,

     void copyIntBuffer( int *pin, int *pout, int len )
     {   int i;
	 for (i=0; i<len; ++i) *pout++ = *pin++;
     }

   then a call to it in the following code fragment has aliased
   arguments.

     int a[10];
     copyIntBuffer( a, a+3, 7);

--
Nathan Doss          doss@ERC.MsState.Edu

