我是使用Python的MPI中的新手,我在这里遇到一些问题。这是我的代码:来自mpi4py程序的意外输出
from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
if rank == 0:
a = 1
comm.bcast(a, root=0)
s = comm.reduce(a, op=MPI.SUM)
print 'From process 0, sum =', s
elif rank == 1:
b = 2
comm.bcast(b, root=1)
x = comm.reduce(b, op=MPI.SUM)
print 'From process 1, sum =', x
我想打印:From process PROCESS_NUMBER, sum = 3
进程0打印正确,但过程1打印无。
我不明白为什么。任何人都可以帮我吗?