On Oct 17, 2004, at 12:01 PM, hye_at_[hidden] wrote:
> Scenario:
> There are 3 processors/parties: A B C involving. Their pseudocodes are
> shown as
> following.
> =================================================
> A psuedocode:
> ...
> //send message M1 to C with Isend
> MPI_Isend(&M1, sizeof(M1), MPI_BYTE, C,
> M1TAG, MPI_COMM_WORLD, &request);
> MPI_Wait(&request, &status);
> ... other computation and communication ....
> //send message M2 to B with Isend
> MPI_Isend(&M2, sizeof(M2), MPI_BYTE, B,
> M2TAG, MPI_COMM_WORLD, &request);
> MPI_Wait(&request, &status);
> ... other computation and communication ....
> =================================================
> B psuedocode:
> ...
> //receve message M2 from A
> MPI_Recv(&M2, sizeof(M2), MPI_BYTE, A,
> M2TAG, MPI_COMM_WORLD, &status);
> //forward M2 to C
> MPI_Isend(&M2, sizeof(M2), MPI_BYTE, C,
> M2TAG, MPI_COMM_WORLD, &request);
> MPI_Wait(&request, &status);
> ... other computation and communication ....
> =================================================
> C psuedocode:
> ...
> MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &rc,
> &status);
> switch(status.MPI_TAG)
> {
> case M1TAG:
> recvM1();break;
> case M2TAG:
> recvM2();break;
> ...cases for other messages....
> }
> ...
> =================================================
> Question 1: is it possible that, in party C, M2 is received before M1?
Yes. Given the structuring of your code, it's unlikely (if all the
messages are short), but it is possible. Your code shows a race
condition -- it's possible that C could receive from either A or B
first (it depends on all kinds of factors -- size of each of the
messages, network congestion, etc.).
> Question 2: After MPI_Isend/MPI_Wait returns, where is the message?
> Is the message in the receiving queue on the receiver side?
Maybe. Recall that MPI doesn't say anything about the location of the
message after sending -- it only says that the user's buffer is
available for re-use. So the message may still be in the sending
process' space, in OS buffering, on the network, or at the receiver.
There's two typical ways for you to know if a receiver has actually
started receiving a message:
1) the receiver sends back an ACK
2) the sender uses a synchronous send (MPI_SSEND or MPI_ISSEND), which
will not complete until the receiver has *started* to receive the
message
> Question 3: How MPI_Iprobe select a message if
> MPI_ANY_SOURCE/MPI_ANY_TAG are
> used?
First: See my previous rants on this list about the use of probe. :-)
It will return the first one available -- i.e., the first one that was
received at C. Also, LAM uses select() and a linear examination of the
resulting bitmap, so there may be an implicit ordering imposed.
--
{+} Jeff Squyres
{+} jsquyres_at_[hidden]
{+} http://www.lam-mpi.org/
|