1 | #include <boost/mpi.hpp>
|
---|
2 | #include <chrono>
|
---|
3 | #include <string>
|
---|
4 |
|
---|
5 | namespace mpi = boost::mpi;
|
---|
6 |
|
---|
7 | int main()
|
---|
8 | {
|
---|
9 | mpi::environment env;
|
---|
10 | mpi::communicator world;
|
---|
11 |
|
---|
12 | if (world.rank() == 0) {
|
---|
13 | std::string msgs[2] = {"Hello", "World"};
|
---|
14 | world.send(1, 0, msgs[0]);
|
---|
15 | world.send(1, 0, msgs[1]);
|
---|
16 | } else {
|
---|
17 | mpi::request reqs[2];
|
---|
18 | std::string msgs[2];
|
---|
19 | reqs[0] = world.irecv(0, 0, msgs[0]);
|
---|
20 | reqs[1] = world.irecv(0, 0, msgs[1]);
|
---|
21 | mpi::wait_all(std::begin(reqs), std::end(reqs));
|
---|
22 | }
|
---|
23 | }
|
---|