Refer to the following gather code:
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
How can I use the comm.barrier() function to ensure the “After” step always comes after all the “Before” steps?
If I put comm.barrier() before if condition, the results would just be in any order.
I've tried flush and it doesn't work.
Should I specify the send buffer and receive buffer using Gather?
Or, should I try gather everything to one process, then scatter, then gather again?
Any advice is more than welcome and appreciated.