I got slightly mixed up regarding the concept of synchronous - asynchronous in the context of blocking & non blocking operations (in OpenMPI) from here:
link 1
: MPI_Isend
is not necessarily asynchronous ( so it can synchronous ?)
link 2
:The MPI_Isend()
and MPI_Irecv()
are the ASYNCHRONOUS communication primitives of MPI.
I have already gone through the previous sync - async - blocking - non blocking questions on stackoverflow (asynchronous vs non-blocking), but were of no help to me. As far as i know :
MPI_Isend
): method returns & executes next line -> nonblockingMPI_Send
) : for large messages it blocks until transfer completesso how & why MPI_ISEND
may be blocking (link 1) as well as non blocking (link 2) ?
i.e.what is meant by asynchronous & synchronous MPI_Isend
here ?
Similar confusion arises regarding MPI_Ssend
& MPI_Issend
, since the S in MPI_SSEND means synchronous(or blocking) and:-
also the Immediate is non-blocking, So, how can MPI_ISSEND be Synchronous & return Immediately ?
I guess more clarity is needed in asynchronous & synchronous in context of blocking & non blocking OpenMPI communication . A practical example or analogy in this regard will be very useful.
The key difference between synchronous and asynchronous communication is synchronous communications are scheduled, real-time interactions by phone, video, or in-person. Asynchronous communication happens on your own time and doesn't need scheduling.
Synchronous communication can be in-person or virtual, scheduled or impromptu. Some synchronous communication examples can include phone calls, video conferencing, in-person meetings, water-cooler conversations, and instant messaging (IM).
MPI is a complicated protocol and has many different flavors of functions to send and receive data both synchronously, and asynchronously, but this tutorial just shows you the basic functions that are most often used.
A nonblocking send will return as soon as possible, whereas a blocking send will return after the data has been copied out of the sender memory. The use of nonblocking sends is advantageous in these cases only if data copying can be concurrent with computation.
There is a distinction between when MPI function calls return (blocking vs. non-blocking) and when the corresponding operation completes (standard, synchronous, buffered, ready-mode).
Non-blocking calls MPI_I...
return immediately, no matter if the operation has completed or not. The operation continues in the background, or asynchronously. Blocking calls do not return unless the operation has completed. Non-blocking operations are represented by their handle which could be used to perform a blocking wait (MPI_WAIT
) or non-blocking test (MPI_TEST
) for completion.
Completion of an operation means that the supplied data buffer is no longer being accessed by MPI and it could therefore be reused. Send buffers become free for reuse either after the message has been put in its entirety on the network (including the case where part of the message might still be buffered by the network equipment and/or the driver), or has been buffered somewhere by the MPI implementation. The buffered case does not require that the receiver has posted a matching receive operation and hence is not synchronising - the receive could be posted at a much later time. The blocking synchronous send MPI_SSEND
does not return unless the receiver has posted a receive operation, thus it synchronises both ranks. The non-blocking synchronous send MPI_ISSEND
returns immediately but the asynchronous (background) operation won't complete unless the receiver has posted a matching receive.
A blocking operation is equivalent to a non-blocking one immediately followed by a wait. For example:
MPI_Ssend(buf, len, MPI_TYPE, dest, tag, MPI_COMM_WORLD);
is equivalent to:
MPI_Request req;
MPI_Status status;
MPI_Issend(buf, len, MPI_TYPE, dest, tag, MPI_COMM_WORLD, &req);
MPI_Wait(&req, &status);
The standard send (MPI_SEND
/ MPI_ISEND
) completes once the message has been constructed and the data buffer provided as its first argument might be reused. There is no synchronisation guarantee - the message might get buffered locally or remotely. With most implementations, there is usually some size threshold: messages up to that size get buffered while longer messages are sent synchronously. The threshold is implementation-dependent.
Buffered sends always buffer the messages into a user-supplied intermediate buffer, essentially performing a more complex memory copy operation. The difference between the blocking (MPI_BSEND
) and the non-blocking version (MPI_IBSEND
) is that the former does not return before all the message data has been buffered.
The ready send is a very special kind of operation. It only completes successfully if the destination rank has already posted the receive operation by the time when the sender makes the send call. It might reduce the communication latency by eliminating the need to performing some kind of a handshake.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With