Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send a message without a specific destination in MPI?

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.

like image 633
maxwong Avatar asked Mar 15 '12 11:03

maxwong


People also ask

How do you avoid deadlock in MPI?

To avoid deadlocks when using FFTW's MPI routines, it is important to know which functions are collective: that is, which functions must always be called in the same order from every process in a given communicator. (For example, MPI_Barrier is the canonical example of a collective function in the MPI standard.)

What is MPI_Send and MPI_Recv?

• MPI_SEND – send a message to another process• MPI_RECV – send a message to another process.

What is the purpose of a message tag in MPI?

MPI. The message tag is used to differentiate messages, in case rank A has sent multiple pieces of data to rank B. When rank B requests for a message with the correct tag, the data buffer will be overwritten by that message. The communicator is something we have seen before.

What is the difference between MPI_Send and Mpi_ssend?

The difference between this and MPI_SSEND is that the latter will always wait until the receive has been posted on the receiving end. Even if the message is small and can be buffered internally, it will still wait until the message has started to be received on the other side.


2 Answers

What I would do is have the worker processes signal to the master that they're ready to receive. The master would keep track of which ranks are ready, pick one (lowest rank first, random, round robin, however you like), send to it, and clear its "ready" flag.

like image 169
suszterpatt Avatar answered Sep 28 '22 08:09

suszterpatt


Do you just want to send a message it to a random rank?

 MPI_Comm_size(MPI_COMM_WORLD, &size);
 sendto = rand() % size;
 MPI_Send(buffer, count, MPI_CHAR, sendto, 0, MPI_COMM_WORLD);
like image 33
eduffy Avatar answered Sep 28 '22 07:09

eduffy