Is it enough to check only one request object from two matching non-blocking send and recv operations.
This would be great as this would reduce the effort to handle the request objects in my program.
Here a small example with boost mpi:
#include <boost/mpi.hpp>
int main(int argc, char* argv[]) {
// initialize mpi
mpi::environment env(argc, argv);
boost::mpi::communicator world;
boost::mpi::request req0, req1;
double blub;
if(world.rank()==1)
req1 = world.irecv(0, 23, blub);
if(world.rank()==0)
req0 = world.isend(0, 23, blub);
//now I want to synchronize the processors is this enough?
req0.wait();
//or do I also need this line
req1.wait();
}
Rank 1 doesn't have a valid
req0
, and rank 0 doesn't have a validreq1
; they are requests which are only valid on the tasks that actually performed the nonblocking operation (and returned a handle to a request).So no, neither rank here needs to (or even could) call wait on both requests; each calls a wait on the request that it has, eg
or, better (I assume that the isend for rank 0 should go to rank 1, not 0):
Note that when you do need to wait for the multiple operations corresponding to multiple requests, you can have a list of the requests and call wait_all.