#include #include #include #include #include static const size_t N = 2; // succeeds with 1, fails when > 1 int main() { boost::mpi::environment env; boost::mpi::communicator world; #if 1 // Serialized types fail. typedef std::string DataType; #define SEND_VALUE "how now brown cow" #else // Native MPI types succeed. typedef int DataType; #define SEND_VALUE 42 #endif // N asynchronous sends of std::string. DataType out(SEND_VALUE); std::vector sends; for (size_t i = 0; i < N; ++i) sends.push_back(world.isend(0, 0, out)); // N asynchronous receives of std::string. std::vector in(sends.size()); std::vector recvs; for (size_t i = 0; i < in.size(); ++i) recvs.push_back(world.irecv(0, 0, in[i])); // Wait a second for messages to go through. usleep(1000000); // Complete the receives -- fails with multiple serialized types. for (size_t i = 0; i < recvs.size(); ++i) { boost::optional status = recvs[i].test(); std::cout << i << ' ' << (status ? "complete" : "incomplete") << '\n'; } return 0; }