21#ifndef MPI_SERIALIZER_HPP
22#define MPI_SERIALIZER_HPP
24#include <opm/common/utility/Serializer.hpp>
25#include <opm/simulators/utils/MPIPacker.hpp>
26#include <opm/simulators/utils/ParallelCommunication.hpp>
28namespace Opm::Parallel {
46 template<
typename...
Args>
49 if (m_comm.size() == 1)
53 if (m_comm.rank() ==
root) {
55 this->pack(std::forward<Args>(args)...);
57 broadcast_chunked(
root);
59 m_packSize = std::numeric_limits<size_t>::max();
65 if (
m_packSize == std::numeric_limits<size_t>::max()) {
66 throw std::runtime_error(
"Error detected in parallel serialization");
69 broadcast_chunked(
root);
70 this->unpack(std::forward<Args>(args)...);
84 if (m_comm.size() == 1)
88 T&
bcast = m_comm.rank() ==
root ? data : tmp;
91 if (m_comm.rank() !=
root)
96 void broadcast_chunked(
int root) {
97 const int maxChunkSize = std::numeric_limits<int>::max();
108 const Mpi::Packer m_packer;
109 Parallel::Communication m_comm;
Class for serializing and broadcasting data using MPI.
Definition MPISerializer.hpp:38
void append(T &data, int root=0)
Serialize and broadcast on root process, de-serialize and append on others.
Definition MPISerializer.hpp:82
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:240
Avoid mistakes in calls to broadcast() by wrapping the root argument in an explicit type.
Definition MPISerializer.hpp:33