【发布时间】:2018-03-27 09:04:18
【问题描述】:
参考以下收集代码:
from mpi4py import MPI
comm = MPI.COMM.WORLD
size = comm.Get_size()
rank = comm.Get_rank()
stat = MPI.Status()
message = (rank)**2
print "Before Gather ",rank, message
message = comm.gather(message, root=0)
if rank == 0:
print "After Gather ",rank,message
如何使用 comm.barrier() 函数确保“After”步骤总是在所有“Before”步骤之后?
如果我将 comm.barrier() 放在 if 条件之前,结果将按任意顺序排列。
我试过冲洗,但它不起作用。
我应该使用 Gather 指定发送缓冲区和接收缓冲区吗?
或者,我应该尝试将所有内容收集到一个进程中,然后分散,然后再次收集?
欢迎和赞赏任何建议。
【问题讨论】:
标签: python mpi stdout hpc mpi4py