from mpi4py import MPI comm = MPI.COMM_WORLD rank = comm.rank if rank == 0: data = {'a':1,'b':2,'c':3} else: data = None data = comm.bcast(data, root=0) print 'rank',rank,data
What's happening is, first, we assign some data to rank 0, the master node. Then, we want to "broadcast" with bcast the data to all of the other nodes. We are then setting all data to None first, so all other nodes have None as their data.
Next, we use comm.bcast() to broadcast the data from rank 0. So, the first parameter is the data, the second, "root," means "from what node." With broadcast, all nodes automatically accept the data, under the data var name.
mpirun.openmpi -np 5 -machinefile /home/pi/mpi_testing/machinefile python ~/Desktop/sct/sct8.py