#include #include #include #include namespace mpi = boost::mpi; /** * The main program. * @param argc the number of command line arguments. * @param argv[] the command line arguments. * @retval 0 on success. * @retval non-zero on error. */ int main(int argc, char* argv[]) { mpi::environment env(argc, argv); mpi::communicator world; std::vector buff0(world.size() * 2); for (size_t i = 0; i < buff0.size(); ++i) { buff0[i] = i; } size_t i[2]; scatter(world, buff0, i, 2, 0); if (world.rank() > 0) { int j; world.recv(world.rank() - 1, 0, j); } std::cout << "I am process " << world.rank() << " of " << world.size() << ". "; std::cout << "I got " << i[0] << " and " << i[1] << std::endl; if (world.rank() < (world.size() - 1)) { world.send(world.rank() + 1, 0, 1); } return 0; }