Python Mpi Sendrecv() To Pass A Python Object
I am trying to use mpi4py's sendrecv() to pass a dictionary obj. from mpi4py import MPI comm=MPI_COMM_WORLD rnk=comm.Get_rank() size=comm.Get_size() idxdict={1:2} buffer=None com
Solution 1:
I believe the documentation is misleading here; sendrecv returns the received buffer, and doesn't use the receive object argument at all that I can see (at least in older versions, 1.2.x). So your above code doesn't work (although the receive does in fact happen), but the below does:
from mpi4py import MPI
comm=MPI.COMM_WORLD
rnk=comm.Get_rank()
size=comm.Get_size()
idxdict={1:2}
buffer = comm.sendrecv(sendobj=idxdict,dest=(rnk+1)%size,source=(rnk-1+size)%size)
print "idxdict = ", idxdict
print "buffer = ", buffer
Post a Comment for "Python Mpi Sendrecv() To Pass A Python Object"