| 1 | #include <iostream>
|
|---|
| 2 | #include <boost/mpi.hpp>
|
|---|
| 3 |
|
|---|
| 4 | struct custom_type {
|
|---|
| 5 | template<class Archive>
|
|---|
| 6 | void serialize(Archive& ar, const unsigned int version) {}
|
|---|
| 7 | };
|
|---|
| 8 |
|
|---|
| 9 | int main() {
|
|---|
| 10 | boost::mpi::environment env;
|
|---|
| 11 | boost::mpi::communicator comm;
|
|---|
| 12 |
|
|---|
| 13 | if (comm.rank() == 0) {
|
|---|
| 14 | comm.send(1,0,42);
|
|---|
| 15 | comm.send(1,0,custom_type());
|
|---|
| 16 | }
|
|---|
| 17 | else {
|
|---|
| 18 | {
|
|---|
| 19 | int i;
|
|---|
| 20 | auto req = comm.irecv(0,0,i);
|
|---|
| 21 | req.wait();
|
|---|
| 22 | std::cout << "Did we receive the built in type message: " << bool(req.test()) << std::endl;
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | {
|
|---|
| 26 | custom_type c;
|
|---|
| 27 | auto req = comm.irecv(0,0,c);
|
|---|
| 28 | req.wait();
|
|---|
| 29 | std::cout << "Did we receive the custom type message: " << bool(req.test()) << std::endl;
|
|---|
| 30 | }
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | return 0;
|
|---|
| 34 | }
|
|---|