broadcast_sc.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright (C) 2005, 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. // Allows broadcast of skeletons via proxy.
  6. // This header may only be included after both the broadcast.hpp and
  7. // and skeleton_and_content.hpp headers have been included.
  8. #ifndef BOOST_MPI_BROADCAST_SC_HPP
  9. #define BOOST_MPI_BROADCAST_SC_HPP
  10. namespace boost { namespace mpi {
  11. template<typename T>
  12. inline void
  13. broadcast(const communicator& comm, skeleton_proxy<T>& proxy, int root)
  14. {
  15. const skeleton_proxy<T>& const_proxy(proxy);
  16. broadcast(comm, const_proxy, root);
  17. }
  18. template<typename T>
  19. void
  20. broadcast(const communicator& comm, const skeleton_proxy<T>& proxy, int root)
  21. {
  22. if (comm.rank() == root) {
  23. packed_skeleton_oarchive oa(comm);
  24. oa << proxy.object;
  25. broadcast(comm, oa, root);
  26. } else {
  27. packed_skeleton_iarchive ia(comm);
  28. broadcast(comm, ia, root);
  29. ia >> proxy.object;
  30. }
  31. }
  32. } } // end namespace boost::mpi
  33. #endif // BOOST_MPI_BROADCAST_SC_HPP