Reputation: 131
I'm doing a project using Python with MPI. Every node of my project needs to know if there is any incoming message for it before continuing the execution of other tasks.
I'm working on a system where multiple nodes executes some operations. Some nodes may need the outputs of another nodes and therefore needs to know if this output is available.
For illustration purposes, let's consider two nodes, A and B. A needs the output of B to execute it's task, but if the output is not available A needs to do some other tasks and then verify if B has send it's output again, in a loop. What I want to do is this verification of availability of output from B in A.
I made some research and found something about a method called probe, but don't understood neither found a usefull documentation about what it does or how to use. So, I don't know if it solves my problem.
The idea of what I want is ver simple: I just need to check if there is data to be received when I use the method "recv" of mpi4py. If there is something the code do some tasks, if there ins't the code do some other taks.
Upvotes: 0
Views: 631
Reputation: 22670
(elaborating on Gilles Gouaillardet's comment)
If you know you will eventually receive a message, but want to be able to run some computations while it is being prepared and sent, you want to use non-blocking receives, not probe
.
Basically use MPI_Irecv
to setup a receive request as soon as possible. If you want to know whether the message is ready yet, use MPI_Test
to check the request.
This is much better than using probes, because you ensure that a receive buffer is ready as early as possible and the sender is not blocked, waiting for the receiver to see that there is a message and post the receive.
For the specific implementation you will have to consult the manual of the Python MPI wrapper you use. You might also find helpful information in the MPI standard itself.
Upvotes: 1