MPI_Send()和MPI_Ssend()之间的区别? [英] difference between MPI_Send() and MPI_Ssend()?

查看:704
本文介绍了MPI_Send()和MPI_Ssend()之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道MPI_Send()是一个阻塞调用,它等待直到可以安全地修改应用程序缓冲区以供重用.为了使发送呼叫同步(应该与接收者握手),我们需要使用MPI_Ssend(). 我想知道两者之间的区别.假设我需要在进程之间发送固定数量的字节,这应该花费更长的时间?
对于我来说,代码可以很好地调用MPI_Send(),但是可以无限期地等待MPI_Ssend(). 可能是什么原因?

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 ?

最重要的是,我很确定使用MPI_Send()时在接收过程中正在接收数据,因此使用MPI_Ssend()时,这种推断不会导致等待握手的任何好处.

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

或者我可以得出一个结论:使用MPI_Send()您可以将数据发送到自身进程,但不能使用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 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.

此内容与MPI_SSEND之间的区别在于,后者总是一直等到收货已张贴到接收端.即使该消息很小并且可以在内部进行缓冲,它仍将等待直到另一端开始接收该消息.

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是一种确保两个进程都在执行中达到特定点的一种方式,例如无需执行MPI_BARRIER.如果您的应用程序在同一级别上来回发送,则执行MPI_SENDMPI_SSEND都不安全,因为一个可以无限期阻塞.相反,应该使用MPI_ISENDMPI_IRECV,以便调用将立即返回,并且可以同时进行实际的发送/接收(在对MPI_WAITALL的调用中).

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

这篇关于MPI_Send()和MPI_Ssend()之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆