Apparently a stupid question, but I can't find a definitive answer anyway.
Key questions: do I need MPI :: Irecv for MPI :: Isend?
That is, despite the fact that sending a message is not blocked, if I wait for the completion of sending before reusing the send buffers, do I need to use non-blocking reception and wait for the received buffers to be received?
I want to say that I want to use non-blocking messages to “do other things” while the message is being sent, but the recipient process will use the buffers immediately, so I want them to lock until the buffer is actually received.
It seems that I should receive messages from MPI :: Recv, even if they were sent from MPI :: Isend, but I wonder if I am missing something?
A bit of simple pseudo code
if( rank == 0 ){ int r; for ( int i = 0; i < n; i++ ){ // DO SOME STUFF HERE... request.Wait(status); request2.Wait(status); request3.Wait(status); r = i; memcpy( key, fromKey(i), ...); memcpy( trace, fromTrace(i), ...); request = MPI::COMM_WORLD.Isend( &r, 1, MPI::INT, node, tag ); request2 = MPI::COMM_WORLD.Isend( key, 10, MPI::INT, node, tag ); request3 = MPI::COMM_WORLD.Isend( trace, nBytesTotal, MPI::BYTE, node, tag ); // DO SOME MORE STUFF HERE. } r = -1; request = MPI::COMM_WORLD.Isend( &r, 1, MPI::INT, node, tag ); // Carry on ... } else { int r = -1; MPI::COMM_WORLD.Recv( &r, 1, MPI::INT, 0, tag, status ); while( r >= 0 ){ MPI::COMM_WORLD.Recv( &key, 10, MPI::INT, 0, tag, status ); memcpy( saveKey, key, ...); MPI::COMM_WORLD.Recv( &trace, nBytesTotal, MPI::BYTE, 0, tag, status ); memcpy( saveTrace, trace, ...); MPI::COMM_WORLD.Recv( &r, 1, MPI::INT, 0, tag, status ); }