Opened 8 years ago
#10065 new Bugs
wait_any return with -1
Reported by: | Owned by: | Matthias Troyer | |
---|---|---|---|
Milestone: | To Be Determined | Component: | mpi |
Version: | Boost 1.55.0 | Severity: | Problem |
Keywords: | Cc: |
Description
I have a small example, where every process send his rank to rank 0. The process with rank 0, should receive with irecv every message and wait for it with wait_any. But the wait_any function returns with -1. I have seen two other tickets, which are marked as fixed/ solved. I think they are not solved. If they are solve the documentation should be changed, because if I make the same example with MPI_Waitany, the result is completely different.
#include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <boost/mpi.hpp> #include <iostream> #include <string> #include <boost/serialization/string.hpp> #define MAXPROC 16 /* Max number of procsses */ int main(int argc, char* argv[]) { int i, np, me, index; const int tag = 42; /* Tag value for communication */ const int root = 0; /* Root process in broadcast */ boost::mpi::status status; /* Status object for non-blocing receive */ boost::mpi::request recv_req[MAXPROC]; /* Request objects for non-blocking receive */ int myname[5]; /* Local host name string */ int hostname[5]; /* Received host names */ int namelen; boost::mpi::environment env; /* Initialize MPI */ boost::mpi::communicator world; /* Initialize MPI */ np = world.size(); /* Get nr of processes */ me = world.rank(); /* Get own identifier */ if (me == 0) { /* Process 0 does this */ std::cout <<"Process " << me << " broadcasting to all processes\n"; boost::mpi::broadcast(world, me, 0); std::cout <<"Process " << me<< " receiving from all other processes\n"; for (i=1; i<np; i++) { recv_req[i] = world.irecv(i,i,hostname[i]); } for (i=1; i<np; i++) { status = wait_any(recv_req,recv_req +5 ).first; std::cout<<"Received a message from process "<< status.source() << " tag " << status.tag() << std::endl; } std::cout <<"Ready\n"; } else { int y; boost::mpi::broadcast(world, y, 0); sleep(me%3+1); MPI_Send (myname, namelen, MPI_CHAR, 0, tag, world); } world.barrier(); ~world; return 0; }
Note:
See TracTickets
for help on using tickets.