rmjarvis / MockMPI

BSD 2-Clause "Simplified" License
4 stars 1 forks source link

TypeError: recv() takes 2 positional arguments but 4 were given #6

Open dbokal opened 2 years ago

dbokal commented 2 years ago

Dear sirs,

while mocking MPI for our code that uses

comm = MPI.COMM_WORLD .... comm.recv(None, 0, 2),

we have obtained the error in the title. Apparently, the mocked rev function is not receiving the parameters Recv(buf, source=ANY_SOURCE, tag=ANY_TAG, status=None) (see https://mpi4py.readthedocs.io/en/stable/reference/mpi4py.MPI.Comm.html#mpi4py.MPI.Comm.Recvsource and tag. Looking into) your GitHub code, we discovered def recv(self, source) hence the mocked MPI is not fully compliant with the original.

Is there an accessible work-around, or is this currently a prohibitive issue for us to use mockmpi?

We highly appreciate your contributions and any possible hints as to the workaround.

joezuntz commented 2 years ago

I'm afraid we have not implemented the tag arguments in MockMPI; you are right that this is not MPI compliant. I can't see a simple workaround, and adding it to the code would be useful but would take some time to do (we would need to change the current pipe-based approach used for communication with some kind of multiprocessing manager object with a shared dictionary.

So sorry, I'm afraid that in the short term this probably won't work for you.

dbokal commented 2 years ago

Thank you for the quick response! Best, Drago

V tor., 12. jul. 2022 14:54 je oseba joezuntz @.***> napisala:

I'm afraid we have not implemented the tag arguments in MockMPI; you are right that this is not MPI compliant. I can't see a simple workaround, and adding it to the code would be useful but would take some time to do (we would need to change the current pipe-based approach used for communication with some kind of multiprocessing manager object with a shared dictionary.

So sorry, I'm afraid that in the short term this probably won't work for you.

— Reply to this email directly, view it on GitHub https://github.com/rmjarvis/MockMPI/issues/6#issuecomment-1181725551, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHNJTOQLPCCQ5S4WMQ3QH7DVTVTHVANCNFSM53K4YA3A . You are receiving this because you authored the thread.Message ID: @.***>

rmjarvis commented 2 years ago

Right. We don't claim to be fully MPI-compliant. We've mostly added features as needed for our own use, and neither of us use tags, so we never bothered.

But FWIW, I don't think it would be that hard to implement. Rather that just keep a raw mp.Pipe instance as our pipes in the MockComm object, we could wrap it with a buffer that would stick things in an ordered dict with the tags being the keys. Then when there is a request for a tagged recv, it would check if it has that key yet. If so, return it. If not draw from the pipe until you get the right tag, storing other things in the buffer dict.

@dbokal, if this is a blocker for you, and you want to try implementing this and write some appropriate unit tests, we'd happily take a PR with this addition.