1 | #include <iostream>
|
---|
2 | #include <boost/mpi.hpp>
|
---|
3 | #include <boost/serialization/string.hpp>
|
---|
4 | #include <vector>
|
---|
5 |
|
---|
6 | #include <string>
|
---|
7 |
|
---|
8 | namespace mpi = boost::mpi;
|
---|
9 |
|
---|
10 | int main(int argc, char *argv[])
|
---|
11 | {
|
---|
12 | mpi::environment env(argc, argv);
|
---|
13 | mpi::communicator world;
|
---|
14 |
|
---|
15 | std::string str;
|
---|
16 | mpi::content content;
|
---|
17 |
|
---|
18 | if (world.rank () == 0)
|
---|
19 | str = "hello";
|
---|
20 |
|
---|
21 | mpi::broadcast (world, mpi::skeleton<std::string>(str), 0);
|
---|
22 | std::cout << "Process " << world.rank () << " receaved skeleton" << std::endl;
|
---|
23 |
|
---|
24 | content = mpi::get_content (str);
|
---|
25 |
|
---|
26 | mpi::broadcast (world, content, 0);
|
---|
27 | std::cout << "Process " << world.rank () << " receaved content: " << str << std::endl;
|
---|
28 | }
|
---|