/Src/Dependencies/Boost/boost/mpi/detail/communicator_sc.hpp

http://hadesmem.googlecode.com/ · C++ Header · 96 lines · 72 code · 17 blank · 7 comment · 0 complexity · c5868bdf9531a4a22f60b6d8651bdbfb MD5 · raw file

  1. // Copyright (C) 2006 Douglas Gregor <doug.gregor -at- gmail.com>.
  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. // Skeleton and content support for communicators
  6. // This header should be included only after both communicator.hpp and
  7. // skeleton_and_content.hpp have been included.
  8. #ifndef BOOST_MPI_COMMUNICATOR_SC_HPP
  9. #define BOOST_MPI_COMMUNICATOR_SC_HPP
  10. namespace boost { namespace mpi {
  11. template<typename T>
  12. void
  13. communicator::send(int dest, int tag, const skeleton_proxy<T>& proxy) const
  14. {
  15. packed_skeleton_oarchive ar(*this);
  16. ar << proxy.object;
  17. send(dest, tag, ar);
  18. }
  19. template<typename T>
  20. status
  21. communicator::recv(int source, int tag, const skeleton_proxy<T>& proxy) const
  22. {
  23. packed_skeleton_iarchive ar(*this);
  24. status result = recv(source, tag, ar);
  25. ar >> proxy.object;
  26. return result;
  27. }
  28. template<typename T>
  29. status communicator::recv(int source, int tag, skeleton_proxy<T>& proxy) const
  30. {
  31. packed_skeleton_iarchive ar(*this);
  32. status result = recv(source, tag, ar);
  33. ar >> proxy.object;
  34. return result;
  35. }
  36. template<typename T>
  37. request
  38. communicator::isend(int dest, int tag, const skeleton_proxy<T>& proxy) const
  39. {
  40. shared_ptr<packed_skeleton_oarchive>
  41. archive(new packed_skeleton_oarchive(*this));
  42. *archive << proxy.object;
  43. request result = isend(dest, tag, *archive);
  44. result.m_data = archive;
  45. return result;
  46. }
  47. namespace detail {
  48. template<typename T>
  49. struct serialized_irecv_data<const skeleton_proxy<T> >
  50. {
  51. serialized_irecv_data(const communicator& comm, int source, int tag,
  52. skeleton_proxy<T> proxy)
  53. : comm(comm), source(source), tag(tag), isa(comm),
  54. ia(isa.get_skeleton()), proxy(proxy) { }
  55. void deserialize(status& stat)
  56. {
  57. isa >> proxy.object;
  58. stat.m_count = 1;
  59. }
  60. communicator comm;
  61. int source;
  62. int tag;
  63. std::size_t count;
  64. packed_skeleton_iarchive isa;
  65. packed_iarchive& ia;
  66. skeleton_proxy<T> proxy;
  67. };
  68. template<typename T>
  69. struct serialized_irecv_data<skeleton_proxy<T> >
  70. : public serialized_irecv_data<const skeleton_proxy<T> >
  71. {
  72. typedef serialized_irecv_data<const skeleton_proxy<T> > inherited;
  73. serialized_irecv_data(const communicator& comm, int source, int tag,
  74. const skeleton_proxy<T>& proxy)
  75. : inherited(comm, source, tag, proxy) { }
  76. };
  77. }
  78. } } // end namespace boost::mpi
  79. #endif // BOOST_MPI_COMMUNICATOR_SC_HPP