| 1 | #include <boost/mpi.hpp>
|
|---|
| 2 | #include <chrono>
|
|---|
| 3 | #include <vector>
|
|---|
| 4 | #include <boost/serialization/vector.hpp>
|
|---|
| 5 |
|
|---|
| 6 | namespace mpi = boost::mpi;
|
|---|
| 7 |
|
|---|
| 8 | int main()
|
|---|
| 9 | {
|
|---|
| 10 | mpi::environment env;
|
|---|
| 11 | mpi::communicator world;
|
|---|
| 12 |
|
|---|
| 13 | if (world.rank() == 0) {
|
|---|
| 14 | // make sure message is large enough so it is not transmitted eagerly
|
|---|
| 15 | std::vector<int> msg0(100000);
|
|---|
| 16 | std::vector<int> msg1(1);
|
|---|
| 17 | world.send(1, 0, msg0);
|
|---|
| 18 | world.send(1, 1, msg1);
|
|---|
| 19 | } else {
|
|---|
| 20 | mpi::request req;
|
|---|
| 21 | std::vector<int> msgs[2];
|
|---|
| 22 | req = world.irecv(0, 0, msgs[0]);
|
|---|
| 23 | world.recv(0, 1, msgs[1]);
|
|---|
| 24 | req.wait();
|
|---|
| 25 | }
|
|---|
| 26 | }
|
|---|