communicator_sc.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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.preserve(archive);
  45. return result;
  46. }
  47. } } // end namespace boost::mpi
  48. #endif // BOOST_MPI_COMMUNICATOR_SC_HPP