暗示与发送者和接收者的MPI_BCAST同步吗? [英] Implied synchronization with MPI_BCAST for both sender and receivers?

查看:383
本文介绍了暗示与发送者和接收者的MPI_BCAST同步吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调用MPI_BCAST时,是否存在任何隐含的同步?例如,如果发件人进程要在其他人之前可以先到达MPI_BCAST,则它可以执行BCAST,然后在没有任何确认的情况下继续进行?一些最近的测试,其代码如下:

When calling MPI_BCAST, is there any implied synchronization? For example, if the sender process were to get to the MPI_BCAST before others could it do the BCAST and then continue without any acknowledgements? Some recent tests with code like:

program test
include 'mpif.h'

integer ierr, tid, tmp

call MPI_INIT(ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, tid, ierr)

tmp = tid

if(tid.eq.0) then
  call MPI_BCAST(tmp,1,MPI_INTEGER,MPI_ROOT,MPI_COMM_WORLD, ierr)
else

endif

write(*,*) tid,'done'
call MPI_FINALIZE(ierr)

end

显示,尽管只有发送者对MPI_BCAST进行了调用,但通过两个线程它们都可以完成.

shows that with two threads they both reach completion, despite only the sender doing a call to MPI_BCAST.

输出:

1 done           0
0 done           0

这是我正在使用的MPI安装(MPICH)时出现的问题,还是MPI的这种标准行为?

Could this be a problem with the MPI installation I'm working with (MPICH), or is this standard behavior for MPI?

推荐答案

我可以证明MPI_Bcast不会 NOT 阻止,至少对于根(发送)过程而言.如果要确定程序已阻塞,则应在之后立即调用MPI_Barrier.我之所以知道这一点,是因为我最近不小心只为根进程 (而不是集体地)调用了MPI_Bcast,并且程序的执行一直照常进行,直到后来对NEXT的不相关调用MPI_Bcast为止.旧缓冲区被接收到新的不同缓冲区中.缓冲区数据类型/长度的这种不匹配会产生垃圾数据,我花了一段时间才找到该错误.

I can attest that MPI_Bcast does NOT block, at least for the root (sending) process. You should call MPI_Barrier immediately afterward if you want to be certain that your program blocks. I know this because I recently accidentally called MPI_Bcast for the root process only (instead of collectively) and the program execution continued as normal until much later when the NEXT unrelated call to MPI_Bcast, in which the old buffer was received into the new different buffers. This mismatch in buffer data type/length produced garbage data and it took me a while to find that bug.

这篇关于暗示与发送者和接收者的MPI_BCAST同步吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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