Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dbokal opened this issue Jul 12, 2022 · 3 comments
Open

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

dbokal opened this issue Jul 12, 2022 · 3 comments

Comments

@dbokal
Copy link

dbokal commented Jul 12, 2022

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
Copy link
Collaborator

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
Copy link
Author

dbokal commented Jul 12, 2022 via email

@rmjarvis
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants