]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/mpi/collectives/broadcast.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / mpi / collectives / broadcast.hpp
index d5160cff7fbf1b897c96a39e0e994e2519434de5..f8b27f0b4f46a882d75f40468ff4317cb42db402 100644 (file)
@@ -100,22 +100,35 @@ namespace detail {
   }
 
   // We're sending a type that does not have an associated MPI
-  // datatype, so we'll need to serialize it. Unfortunately, this
-  // means that we cannot use MPI_Bcast, so we'll just send from the
-  // root to everyone else.
+  // datatype, so we'll need to serialize it.
   template<typename T>
   void
   broadcast_impl(const communicator& comm, T* values, int n, int root, 
-                 mpl::false_)
+                 mpl::false_ non_mpi_datatype)
   {
+    // Implementation proposed by Lorenz Hübschle-Schneider
     if (comm.rank() == root) {
       packed_oarchive oa(comm);
-      for (int i = 0; i < n; ++i)
+      for (int i = 0; i < n; ++i) {
         oa << values[i];
-      broadcast(comm, oa, root);
+      }
+      std::size_t asize = oa.size();
+      broadcast(comm, asize, root);
+      void const* aptr = oa.address();
+      BOOST_MPI_CHECK_RESULT(MPI_Bcast,
+                             (const_cast<void*>(aptr), asize,
+                              MPI_BYTE,
+                              root, MPI_Comm(comm)));
     } else {
       packed_iarchive ia(comm);
-      broadcast(comm, ia, root);
+      std::size_t asize;
+      broadcast(comm, asize, root);
+      ia.resize(asize);
+      void* aptr = ia.address();
+      BOOST_MPI_CHECK_RESULT(MPI_Bcast,
+                             (aptr, asize,
+                              MPI_BYTE,
+                              root, MPI_Comm(comm)));
       for (int i = 0; i < n; ++i)
         ia >> values[i];
     }