I know MPI_Send()
is a blocking call ,which waits until it is safe to modify the application buffer for reuse. For making the send call synchronous(there should be a handshake with the receiver) , we need to use MPI_Ssend()
.
I want to know the difference between the two. Suppose i need to send fix amount of Bytes among the processes , which one is supposed to take longer time ?
With me the code works well the MPI_Send() call but waiting indefinitely for MPI_Ssend().
What could be the possible reasons ?
And the most important thing is , i am pretty sure the data is being received at the receiving process when using MPI_Send()
,so this inference leads nothing in favor to wait for the handshake when using MPI_Ssend()
.
Or i can make a conclusion : with MPI_Send()
you can send data to the self process but can't using MPI_Ssend()
?
There is a small but important difference between the two (you can find it in the MPI 3.0 Standard document in Section 3.4). With a regular MPI_SEND
, the implementation will return to the application when the buffer is available for reuse. This could be before the receiving process has actually posted the receive. For instance, it could be when a small message has been copied into an internal buffer and the application buffer is no longer needed. However, for large messages that may not be buffered internally, the call may not return until enough of the message has been sent to the remote process that the buffer is no longer needed.
The difference between this and MPI_SSEND
is that the latter will always wait until the receive has been posted on the receiving end. Even if the message is small and can be buffered internally, it will still wait until the message has started to be received on the other side.
MPI_SSEND
is a way of ensuring that both processes have reached a certain point in their execution without having to do an MPI_BARRIER
, for instance. If your application is sending and receiving to and from the same rank, it's not safe to do either MPI_SEND
OR MPI_SSEND
, as either one could block indefinitely. Instead, you should use MPI_ISEND
and MPI_IRECV
so that the calls will return immediately and the actual send/receive can be done at the same time (in the call to MPI_WAITALL
).