Reputation: 81
Given a situation where master process A spawns a set of worker processes B, who each spawn their own unique worker process C, how can I open a communicator between C to A?
I'm trying to create a loop, using mpi4py, between several pieces of code that were written separately from one another while minimizing modifications to the codes. So, the general framework of the MPI code is going to be:
I know this will involve opening an intercommunicator between existing processes, possibly using group communication. What would be the best way to accomplish this?
Thank you.
Upvotes: 4
Views: 735
Reputation: 9062
There are two ways you can do this off the top of my head. I wouldn't say one is better or worse than the other, though the first probably matches your use case better.
Use the name publishing system (or some other method) to open a connection using MPI_COMM_CONNECT
and MPI_COMM_ACCEPT
to connect A to whomever needs to communicate with it. This might result in a bunch of communicators for A depending on how many processes you are creating so this may result in some bad things, but this is probably the most direct way to make this work. You'll just have to have A do a bunch of calls to MPI_COMM_ACCEPT
(unfortunately there isn't a non-blocking version of this call).
Continually merge your intercommunicators that you're creating with MPI_COMM_SPAWN
to create one giant communicator containing all of the processes. Then you can just send messages as you usually would (or create new sub-communciators with A and all of the spawnees so you can do collectives among just them).
Upvotes: 2