MPI 中非阻塞发送和阻塞接收的用法?

发布于 2024-10-12 22:49:57 字数 427 浏览 11 评论 0原文

我正在尝试实施主工计划。

我的主人有工人要做的工作。每当工人完成一项工作时,他都会向主人请求新的工作,然后主人将其发送给他。工人们正在计算最小路径。当一个worker发现一个最小值比他得到的全局最小值更好时,他会将其发送给包括master在内的所有人。

我计划让工人和主人使用MPI_ISEND发送数据。另外,我认为接收应该是阻塞的。当没有人要求工作或更新最佳结果时,主人无事可做,因此他应该阻塞等待接收。此外,每个工人在完成工作后都应该等待接收以获取新的工作。

尽管如此,我不确定使用非阻塞异步发送和阻塞同步接收的影响

我认为的另一种选择是使用MPI_IPROBE,但我不确定这会给我带来任何优化。

请帮助我了解我所做的是否正确。这是正确的解决方案吗?

I am trying to implement master-worker program.

My master has jobs that the workers are going to do. Every time a worker completes a job, he asks for a new job from the master, and the master sends it to him. The workers are calculating minimal paths. When a worker finds a minimum that is better than the global minimum he got, he sends it to everyone including the master.

I plan for the workers and masters to send data using MPI_ISEND. Also, I think that the receive should be blocking. The master has nothing to do when no one has asked for work or has updated the best result, so he should block waiting for a receive. Also, each worker should, after he has done his work, wait on a receive to get a new one.

Nevertheless, I'm not sure of the impact of using non-blocking asynchronous send, and blocking synchronous receive.

An alternative I think is using MPI_IPROBE, but I'm not sure that this will give me any optimization.

Please help me understand whether what I'm doing is right. Is this the right solution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别闹i 2024-10-19 22:49:57

您可以将阻塞发送与非阻塞接收相匹配,反之亦然,这不会导致任何问题。然而,如果当工人工作时,主人确实无事可做,并且工人在完成他们的工作单元后应该阻塞,那么就没有理由在这方面进行非阻塞通信。主站可以使用 MPI_ANY_SOURCE 发布阻塞接收,而工作线程可以仅使用阻塞发送来回发其结果,因为主站处的匹配接收已经发布。

因此,我将使用 Send-Recv 来在主服务器和工作线程之间交换工作单元,并使用 Isend-Irecv 来广播新的全局最小值。

You can match blocking sends with nonblocking receives and vice versa, that won't cause any problems. However, if the master really has nothing to do while the workers work, and the workers should block after completing their work unit, then there's no reason for non-blocking communication on that front. The master can post a blocking receive with MPI_ANY_SOURCE, and the workers can just use a blocking send to post back their results, since the matching receive at the master will already have been posted.

So, I'd have Send-Recv for exchanging work units between master and worker, and Isend-Irecv for broadcasting the new global minima.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文