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
comm.sendrecv(idxdict,dest=(rnk+1)%size,sendtag=rnk,recvobj=buffer,source=(rnk-1+size)%size,recvtag=(rnk-1+size)%size)
idxdict=buffer
If I print idxidct
at the last step, I will get a bunch of "None"s, so the dictionary idxdict
is not passed between cores. If I use a dictionary as buffer: buffer={}
, then there is typeerror:TypeError: expected a writeable buffer object
.
What did I do wrong? Many thanks for your help.