From ee0d482b326e9f3f414d8bd9fc657b244221cc19 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 6 Sep 2022 15:36:30 +0200 Subject: [PATCH] added: eclmpiserializer::append this broadcasts from the root rank, and then appends the results to existing data on the others --- ebos/eclmpiserializer.hh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ebos/eclmpiserializer.hh b/ebos/eclmpiserializer.hh index c59f89931..37f67c39b 100644 --- a/ebos/eclmpiserializer.hh +++ b/ebos/eclmpiserializer.hh @@ -386,6 +386,25 @@ public: } } + //! \brief Serialize and broadcast on root process, de-serialize and append on + //! others. + //! + //! \tparam T Type of class to broadcast + //! \param data Class to broadcast + template + void append(T& data) + { + if (m_comm.size() == 1) + return; + + T tmp; + T& bcast = m_comm.rank() == 0 ? data : tmp; + broadcast(bcast); + + if (m_comm.rank() != 0) + data.append(tmp); + } + //! \brief Returns current position in buffer. size_t position() const {