Reputation: 2071
Suppose I have one server that processes several kinds of requests identified by different kinds of MPI tags.
while(!stop)
{
MPI_Iprobe(MPI_ANY_SOURCE,MPI_ANY_TAG,MPI_COMM_WORLD,&ready,&status);
if(ready)
{
src = status.MPI_SOURCE;
switch(status.MPI_TAG)
{
case MPI_REQ_A:
MPI_Irecv(...);
//do something else useful while waiting
MPI_Wait(...);
break;
case MPI_REQ_B:
MPI_Irecv(...);
//do something else useful while waiting
MPI_Wait(...);
break;
}
}
//do something else before calling MPI_Iprobe() again
}
And there are N clients that send requests to the server. If each client sends messages as in the following code:
for( int i=0; i<k ; i++ )
{
MPI_Send(....,MPI_REQ_A,..);
MPI_Send(....,MPI_REQ_B,..);
}
If MPI_Probe() or MPI_Iprobe() is used with MPI_ANY_SOURCE and MPI_ANY_TAG on the receiving side as in the code above,
Question 1) Is it still guaranteed that the message of type A sent in iteration i is received before the message of the same type sent in iteration i+1 by the same client?
Question 2) Is it still guaranteed that the message of type A sent in iteration i is received before the message of type B sent in the same iteration i by the same client?
Upvotes: 2
Views: 661
Reputation: 8273
According to this:
If a sender sends two messages in succession to the same destination, and both match the same receive, then this operation cannot receive the second message if the first one is still pending.
Now, if you unroll that loop in the client, it basically does this:
MPI_Send(....,MPI_REQ_A,..); // i
MPI_Send(....,MPI_REQ_B,..); // i
MPI_Send(....,MPI_REQ_A,..); // i + 1
MPI_Send(....,MPI_REQ_B,..); // i + 1
MPI_Send(....,MPI_REQ_A,..); // i + 2
MPI_Send(....,MPI_REQ_B,..); // i + 2
...
Since the server's receives match all of those calls, the messages are guaranteed to be received in that exact order for that client. So the answer to both your questions is Yes: on any one client, messages are delivered in the order they are posted.
On a side note, there is no requirement as to the order in which messages from different clients are received. For instance, the following scenario is perfectly legal:
And so forth, the server can alternate between accepting sends from client X and Y only, leaving the others starved.
Upvotes: 3