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 {
48 if (m_comm.size() == 1)
51 if (m_comm.rank() ==
root) {
55 broadcast_chunked(
root);
57 m_packSize = std::numeric_limits<size_t>::max();
63 if (
m_packSize == std::numeric_limits<size_t>::max()) {
64 throw std::runtime_error(
"Error detected in parallel serialization");
67 broadcast_chunked(
root);
72 template<
typename...
Args>
75 if (m_comm.size() == 1)
78 if (m_comm.rank() ==
root) {
80 this->pack(std::forward<Args>(args)...);
82 broadcast_chunked(
root);
84 m_packSize = std::numeric_limits<size_t>::max();
90 if (
m_packSize == std::numeric_limits<size_t>::max()) {
91 throw std::runtime_error(
"Error detected in parallel serialization");
94 broadcast_chunked(
root);
95 this->unpack(std::forward<Args>(args)...);
108 if (m_comm.size() == 1)
112 T&
bcast = m_comm.rank() ==
root ? data : tmp;
115 if (m_comm.rank() !=
root)
120 void broadcast_chunked(
int root) {
121 const int maxChunkSize = std::numeric_limits<int>::max();
132 const Mpi::Packer m_packer;
133 Parallel::Communication m_comm;
Class for serializing and broadcasting data using MPI.
Definition MPISerializer.hpp:31
void append(T &data, int root=0)
Serialize and broadcast on root process, de-serialize and append on others.
Definition MPISerializer.hpp:106
void broadcast(T &data, int root=0)
Serialize and broadcast on root process, de-serialize on others.
Definition MPISerializer.hpp:46
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242