LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2004-11-13 15:28:05


On Nov 11, 2004, at 2:39 PM, David Cox wrote:

> I have a question regarding message ordering and and
> collective communication in MPI (and LAM-MPI
> specifically). It is my understanding that messages
> are delivered in order. Essentially I want to know
> whether:
>
> (a) A collective routine such as Allreduce "flushes"
> other previously sent messages, and

Collective and point-to-point communication are unrelated, in terms of
ordering. So an allreduce may or may not flush other previously sent
[p2p] messages. More specifically, you shouldn't depend on one
behavior or another.

> (b) Whether a loop of MPI_Test operations will get all
> messages that are waiting in LAM's buffer but have not
> yet had a Irecv posted.
>
> With some simple pseudo-code:
>
> Process 1:
> // zero or more MPI_Send
> MPI_Allreduce
>
> Process 2:
> MPI_Allreduce
> while( MPI_Test( request ) ) {
> // handle received message
> request = MPI_Irecv
> }
>
> Will all of the messages sent in Process 1 be received
> by process 2? Any input is greatly appreciated.

Maybe, maybe not. You also cannot assume whether MPI_Send blocks or
not. You'd have much better luck if you used Isend in process 1; that
way you can guarantee that they won't block and you'll definitely reach
the Allreduce. As the code stands right now, you can't guarantee that
this code will complete because it's possible that any one of the
MPI_Send's in process 1 will block until a matching receive is posted
in process 2.

Also, I realize that you're showing pseudocode, but be double sure to
check the real code in process 2 -- you don't want to keep posting the
*same* MPI_Request in MPI_Irecv until you're sure that it has completed
(i.e., MPI_Test may not complete it -- you may have to invoke MPI_Test
multiple times for the request to finish; you may wish to use some
flavor of MPI_Wait...?).

Hope this helps.

-- 
{+} Jeff Squyres
{+} jsquyres_at_[hidden]
{+} http://www.lam-mpi.org/