Check for "handshake" in MPI?
<p>Is there a way to check whether a non-blocking receive is posted (for a given source and tag), before initiating a <code>MPI_Send</code>? I've got a situation where senders and receivers both don't know who they would like to send to / receive from. My idea was to first post an open <code>Irecv</code> on all the chosen receivers. Senders would then check whether a certain rank has posted a receive, and only send if true (continue otherwise). After all sends were successful, receivers would cancel outstanding <code>Irecv</code>s.</p>

<ul>
<li><p>This currently works with a collective (on <code>MPI_COMM_WORLD</code>) array broadcast; I'm wondering if there is a different way</p></li>
<li><p>I imagine I could do this in reverse, with an <code>MPI_Isend</code> and <code>MPI_Probe</code>. In this case though I'm worried about what happens to the unreceived send buffers (and have heard that <code>MPI_Cancel</code> is bad news for sends)</p></li>
</ul>

<p>Thanks for any suggestions.</p>