Say I have a simple program, foo.py
:
from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
# Some stuff happens here
print "Done"
and run it using mpiexec -n 4 python foo.py
, it prints "Done" 4 times.
How do I get it to print "Done" only once, at the end?
I tried
if rank == 3:
print "Done"
but this is not guaranteed to be last. The documentation regarding I/O for mpi4py is not complete.