broadcast_sc.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. void
  13. broadcast(const communicator& comm, const skeleton_proxy<T>& proxy, int root)
  14. {
  15. if (comm.rank() == root) {
  16. packed_skeleton_oarchive oa(comm);
  17. oa << proxy.object;
  18. broadcast(comm, oa, root);
  19. } else {
  20. packed_skeleton_iarchive ia(comm);
  21. broadcast(comm, ia, root);
  22. ia >> proxy.object;
  23. }
  24. }
  25. template<typename T>
  26. inline void
  27. broadcast(const communicator& comm, skeleton_proxy<T>& proxy, int root)
  28. {
  29. const skeleton_proxy<T>& const_proxy(proxy);
  30. broadcast(comm, const_proxy, root);
  31. }
  32. } } // end namespace boost::mpi
  33. #endif // BOOST_MPI_BROADCAST_SC_HPP