I want to send a message to one of the ranks receiving a message with a specific tag. If there is any rank received the message and the message is consumed. In MPI_Recv() we can receive a message using MPI_ANY_SOURCE/MPI_ANY_TAG but the MPI_Send() can't do this. How can I send an message with unknown destination? The MPI_Bcast() can't do it because after receiving, I have to reply to the source process. Thanks.
6
votes
3 Answers
6
votes
1
votes
1
votes
The short answer is: You cannot do this in MPI.
The slightly longer answer is: You probably do not want to do this. I am guessing that you are trying to set up some sort of work-stealing. As suszterpatt suggested, you could use one-sided communication to 'grab' the work from the sending process, but you will need to use locks, and this will not scale well to many processes unless there is some idea of a local process group (i.e., you cannot have 1,000 processes all work-stealing from one process, you will need to decompose things).
MPI_Get
. – Greg Inozemtsev