简体   繁体   中英

What happens for standard and non-blocking sends when the receiver does not post a receive

What if i send using either MPI_Send or MPI_Isend and the receiving process either not receiving dead or too busy to reply?

How would i know that i should stop sending to the process since it is not receiving/dead or busy

I tried 1:

MPI_Send (&destNode, strlen(destNode)+1, MPI_CHAR, nameServer, TAG_NAME_RESOLUTION, MPI_COMM_WORLD, &req);

However when the nameServer is not receiving mode the send is blocking

I tried 2 using MPI_Isend and testing if msg is sent:

    //Ask nameServer (process 1) to resolve destNode 
    MPI_Isend (&destNode, strlen(destNode)+1, MPI_CHAR, nameServer, TAG_NAME_RESOLUTION, MPI_COMM_WORLD, &req);

    int flag = 0;
    MPI_Test(&req, &flag,  &stat);

However i keep getting flag = 1 even when i know for the fact that MPI_Send hangs because the process is not receiving.

Whether or not an MPI_Send returns or an MPI_Isend request completes ( flag==true ) does not necessarily depend on a matching receive being posted. In both cases, it only means that the send buffer can be reused.

While the conditions are similar, your MPI implementation may just decide to buffer in the one case and not buffer in the other. Or it may buffer when the during full moon on Wednesdays. You cannot assume anything about that.

If you for some reason need the function return or the operation completion to indicate that the message was actually received, you need to use synchronous mode calls, ie MPI_Ssend or MPI_Issend .

To quote the standard for MPI_Send (3.4)

The send call described in Section 3.2.1 uses the standard communication mode. In this mode, it is up to MPI to decide whether outgoing messages will be buffered. MPI may buffer outgoing messages. In such a case, the send call may complete before a matching receive is invoked. On the other hand, buffer space may be unavailable, or MPI may choose not to buffer outgoing messages, for performance reasons. In this case, the send call will not complete until a matching receive has been posted, and the data has been moved to the receiver.

If you instead want to ensure that your program can continue despite the message not being received, you keep using MPI_Isend and make sure the buffer and request is not touched until completion is indicated by MPI_Test .

For MPI_Isend / MPI_Test (3.7.3)

The completion of a send operation indicates that the sender is now free to update the locations in the send buffer (the send operation itself leaves the content of the send buffer unchanged). It does not indicate that the message has been received, rather, it may have been buffered by the communication subsystem.

PS If your receiver rank is dead , then your MPI program is most probably incorrect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM