python - mpi4py: Communicating between spawned processes -
i have 1 process running program called t1.py spawns 3 other processes, of run t2.py. want broadcast value spawned process rank of 0 2 other spawned processes. however, when bcast called, program blocks. idea why happens? , how fix it? t1.py from mpi4py import mpi import sys sub_comm = mpi.comm_self.spawn(sys.executable, args=['t2.py'], maxprocs=3) print 'hi' t2.py from mpi4py import mpi comm = mpi.comm.get_parent() print 'ho ', comm.get_rank() = comm.bcast(comm.get_rank(), root=0) print output hi ho 2 ho 0 ho 1 if want childs talk each other, can use mpi.comm_world : a = mpi.comm_world.bcast(mpi.comm_world.get_rank(), root=0) by printing mpi.comm_world.get_rank(), ' of ',mpi.comm_world.get_size() , can check childs' mpi.comm_world limited childs. now, let's investigate reason why comm.bcast(...) failed if comm obtained comm=mpi.comm.get_parent() . indeed, looking @ size , ranks of communicator, seems simi...