process_group_serialization.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (C) 2006 The Trustees of Indiana University.
  2. // Use, modification and distribution is subject to the Boost Software
  3. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // Authors: Douglas Gregor
  6. // Andrew Lumsdaine
  7. // FIXME: Including because of a missing header in the serialization library.
  8. // Patch sent to list...
  9. #include <cassert>
  10. #include <boost/graph/use_mpi.hpp>
  11. #include <boost/config.hpp>
  12. #include <boost/throw_exception.hpp>
  13. #include <boost/serialization/list.hpp>
  14. #include <boost/graph/distributed/mpi_process_group.hpp>
  15. #include <boost/test/minimal.hpp>
  16. #ifdef BOOST_NO_EXCEPTIONS
  17. void
  18. boost::throw_exception(std::exception const& ex)
  19. {
  20. std::cout << ex.what() << std::endl;
  21. abort();
  22. }
  23. #endif
  24. using boost::graph::distributed::mpi_process_group;
  25. int test_main(int argc, char** argv)
  26. {
  27. boost::mpi::environment env(argc, argv);
  28. mpi_process_group pg;
  29. int seventeen = 17;
  30. std::list<int> seventeens(17, 17);
  31. if (process_id(pg) == 0) {
  32. send(pg, 1, 0, seventeen);
  33. send(pg, 1, 1, seventeens);
  34. }
  35. synchronize(pg);
  36. if (process_id(pg) == 1) {
  37. int value;
  38. receive(pg, 0, 0, value);
  39. BOOST_CHECK(seventeen == value);
  40. std::list<int> values;
  41. receive(pg, 0, 1, values);
  42. BOOST_CHECK(seventeens == values);
  43. }
  44. return 0;
  45. }