#include "MyMPI.hpp" #include #include using namespace MF; using std::cout; using std::endl; int main(int argc, char* argv[]) { const MyMPI* mpi = MyMPI::instance(); const int master = 0; if (mpi->rank() == master) //master { std::vector vec; const int tag = 0; for (int dest=1; destsize(); ++dest) { vec.push_back(dest); mpi->world().Send(&vec[0], static_cast(vec.size()), MPI::INT, dest, tag); } } else { MPI::Status status; unsigned int counter = 0; for(;;) { if(mpi->world().Iprobe(MPI::ANY_SOURCE, MPI::ANY_TAG, status)) { std::vector vec; const int msglen = status.Get_count(MPI::INT); vec.resize(msglen); mpi->world().Recv(&vec[0], msglen, MPI::INT, status.Get_source(), status.Get_tag()); cout << *MyMPI::instance() << " received: "; std::vector::const_iterator it = vec.begin(); for(; it!=vec.end(); ++it) cout << *it << " "; break; } // some things to do... ++counter; } cout << " Counter: " << counter << endl; } return 0; }