diff --git a/flow/flow.cpp b/flow/flow.cpp index 2685f3fd5..eed3e15de 100644 --- a/flow/flow.cpp +++ b/flow/flow.cpp @@ -386,7 +386,6 @@ int main(int argc, char** argv) setupMessageLimiter(schedule->getMessageLimits(), "STDOUT_LOGGER"); summaryConfig.reset( new Opm::SummaryConfig(*deck, *schedule, eclipseState->getTableManager(), parseContext, errorGuard)); #ifdef HAVE_MPI - Opm::Mpi::packAndSend(*summaryConfig, Dune::MPIHelper::getCollectiveCommunication()); Opm::Mpi::packAndSend(*schedule, Dune::MPIHelper::getCollectiveCommunication()); #endif } @@ -395,11 +394,11 @@ int main(int argc, char** argv) summaryConfig.reset(new Opm::SummaryConfig); schedule.reset(new Opm::Schedule); parState = new Opm::ParallelEclipseState; - Opm::Mpi::receiveAndUnpack(*summaryConfig, mpiHelper.getCollectiveCommunication()); Opm::Mpi::receiveAndUnpack(*schedule, mpiHelper.getCollectiveCommunication()); eclipseState.reset(parState); } Opm::EclMpiSerializer ser(mpiHelper.getCollectiveCommunication()); + ser.broadcast(*summaryConfig); ser.broadcast(*parState); #endif diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index f49544695..92e213203 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -1651,14 +1651,6 @@ std::size_t packSize(const SummaryNode& data, packSize(data.isUserDefined(), comm); } -std::size_t packSize(const SummaryConfig& data, - Dune::MPIHelper::MPICommunicator comm) -{ - return packSize(data.getKwds(), comm) + - packSize(data.getShortKwds(), comm) + - packSize(data.getSmryKwds(), comm); -} - std::size_t packSize(const EquilRecord& data, Dune::MPIHelper::MPICommunicator comm) { @@ -3328,15 +3320,6 @@ void pack(const SummaryNode& data, pack(data.isUserDefined(), buffer, position, comm); } -void pack(const SummaryConfig& data, - std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - pack(data.getKwds(), buffer, position, comm); - pack(data.getShortKwds(), buffer, position, comm); - pack(data.getSmryKwds(), buffer, position, comm); -} - void pack(const EquilRecord& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) @@ -5681,19 +5664,6 @@ void unpack(SummaryNode& data, .isUserDefined(isUserDefined); } -void unpack(SummaryConfig& data, - std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - SummaryConfig::keyword_list kwds; - std::set shortKwds, smryKwds; - - unpack(kwds, buffer, position, comm); - unpack(shortKwds, buffer, position, comm); - unpack(smryKwds, buffer, position, comm); - data = SummaryConfig(kwds, shortKwds, smryKwds); -} - void unpack(EquilRecord& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) @@ -6046,8 +6016,24 @@ INSTANTIATE_PACK_VECTOR(bool) INSTANTIATE_PACK_VECTOR(char) INSTANTIATE_PACK_VECTOR(int) INSTANTIATE_PACK_VECTOR(std::array) +INSTANTIATE_PACK_VECTOR(SummaryNode) + #undef INSTANTIATE_PACK_VECTOR +#define INSTANTIATE_PACK_SET(...) \ +template std::size_t packSize(const std::set<__VA_ARGS__>& data, \ + Dune::MPIHelper::MPICommunicator comm); \ +template void pack(const std::set<__VA_ARGS__>& data, \ + std::vector& buffer, int& position, \ + Dune::MPIHelper::MPICommunicator comm); \ +template void unpack(std::set<__VA_ARGS__>& data, \ + std::vector& buffer, int& position, \ + Dune::MPIHelper::MPICommunicator comm); + +INSTANTIATE_PACK_SET(std::string) + +#undef INSTANTIATE_PACK_SET + #define INSTANTIATE_PACK_SHARED_PTR(...) \ template std::size_t packSize(const std::shared_ptr<__VA_ARGS__>& data, \ Dune::MPIHelper::MPICommunicator comm); \ @@ -6078,6 +6064,7 @@ INSTANTIATE_PACK(int) INSTANTIATE_PACK(std::array) INSTANTIATE_PACK(std::array) INSTANTIATE_PACK(unsigned char) +INSTANTIATE_PACK(SummaryNode) #undef INSTANTIATE_PACK } // end namespace Mpi diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index 7ef971769..22a459bb2 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -141,7 +141,6 @@ class SpiralICD; class StandardCond; class Stone1exRecord; class Stone1exTable; -class SummaryConfig; class SummaryNode; class Tabdims; class TableColumn; @@ -564,7 +563,6 @@ ADD_PACK_PROTOTYPES(SpiralICD) ADD_PACK_PROTOTYPES(std::string) ADD_PACK_PROTOTYPES(Stone1exRecord) ADD_PACK_PROTOTYPES(Stone1exTable) -ADD_PACK_PROTOTYPES(SummaryConfig) ADD_PACK_PROTOTYPES(SummaryNode) ADD_PACK_PROTOTYPES(Tabdims) ADD_PACK_PROTOTYPES(TableColumn) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index d51bbac8e..d386c2241 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -110,6 +110,7 @@ #include #include #include +#include namespace { @@ -543,6 +544,20 @@ std::tuple PackUnpack(const T& in) return std::make_tuple(out, pos1, pos2); } +template +std::tuple PackUnpack2(T& in) +{ + auto comm = Dune::MPIHelper::getCollectiveCommunication(); + Opm::EclMpiSerializer ser(comm); + ser.pack(in); + size_t pos1 = ser.position(); + T out; + ser.unpack(out); + size_t pos2 = ser.position(); + + return std::make_tuple(out, pos1, pos2); +} + #define DO_CHECKS(TYPE_NAME) \ BOOST_CHECK_MESSAGE(std::get<1>(val2) == std::get<2>(val2), "Packed size differ from unpack size for " #TYPE_NAME); \ @@ -2189,7 +2204,7 @@ BOOST_AUTO_TEST_CASE(SummaryConfig) .isUserDefined(true); Opm::SummaryConfig val1({node}, {"test1", "test2"}, {"test3", "test4"}); - auto val2 = PackUnpack(val1); + auto val2 = PackUnpack2(val1); DO_CHECKS(SummaryConfig) #endif }