| 1 | #include <iostream>
|
|---|
| 2 | #include <boost/mpi/communicator.hpp>
|
|---|
| 3 | #include <boost/mpi/collectives.hpp>
|
|---|
| 4 |
|
|---|
| 5 | using namespace std;
|
|---|
| 6 | using namespace boost::mpi;
|
|---|
| 7 |
|
|---|
| 8 | int main(int argc,char *argv[]) {
|
|---|
| 9 |
|
|---|
| 10 | environment env(argc, argv);
|
|---|
| 11 | communicator world;
|
|---|
| 12 |
|
|---|
| 13 | bool test(true);
|
|---|
| 14 |
|
|---|
| 15 | if (world.rank() == 0) test = false;
|
|---|
| 16 |
|
|---|
| 17 | #ifndef LEAK_WORKAROUND
|
|---|
| 18 | broadcast(world,test,0);
|
|---|
| 19 | #else
|
|---|
| 20 | MPI_Datatype type;
|
|---|
| 21 | BOOST_MPI_CHECK_RESULT(MPI_Type_contiguous,(sizeof(bool),MPI_BYTE,&type));
|
|---|
| 22 | BOOST_MPI_CHECK_RESULT(MPI_Type_commit,(&type));
|
|---|
| 23 | BOOST_MPI_CHECK_RESULT(MPI_Bcast,(reinterpret_cast<void*>(test),1,type,0,world));
|
|---|
| 24 | BOOST_MPI_CHECK_RESULT(MPI_Type_free,(&type));
|
|---|
| 25 | #endif
|
|---|
| 26 |
|
|---|
| 27 | cout << "\nrank " << world.rank() << ": test = " << test << endl;
|
|---|
| 28 |
|
|---|
| 29 | return EXIT_SUCCESS;
|
|---|
| 30 | }
|
|---|