difference between MPI_Send() and MPI_Ssend()?
Asked Answered
D

1

24

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() ?

Dubose answered 10/7, 2013 at 23:57 Comment(0)
S
50

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).

Sadyesaechao answered 11/7, 2013 at 12:41 Comment(3)
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() . my code works fine with MPI_Send() but waiting indefinitely with MPI_Ssend() .Can you think of any possible reasons ?Dubose
It would entirely depend on your code. If for some reason your code doesn't reach the matching call to MPI_RECV without progression from the MPI_SEND for some reason, that could cause the deadlock, but there's no way to tell without seeing the code.Sadyesaechao
#17820945 can you please answer that ?Dubose

© 2022 - 2024 — McMap. All rights reserved.