From aad289841adfa96911aaff4a4442c03f6ad24b42 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 13 Mar 2020 08:26:18 +0100 Subject: [PATCH 1/5] remove old serialization support for MULTREGTScanner --- opm/simulators/utils/ParallelRestart.cpp | 76 ------------------------ opm/simulators/utils/ParallelRestart.hpp | 4 -- tests/test_ParallelRestart.cpp | 4 +- 3 files changed, 2 insertions(+), 82 deletions(-) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 01eb59f68..64d389e62 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -1549,27 +1548,6 @@ std::size_t packSize(const GuideRateConfig::GroupTarget& data, packSize(data.target, comm); } -std::size_t packSize(const MULTREGTRecord& data, - Dune::MPIHelper::MPICommunicator comm) -{ - return packSize(data.src_value, comm) + - packSize(data.target_value, comm) + - packSize(data.trans_mult, comm) + - packSize(data.directions, comm) + - packSize(data.nnc_behaviour, comm) + - packSize(data.region_name, comm); -} - -std::size_t packSize(const MULTREGTScanner& data, - Dune::MPIHelper::MPICommunicator comm) -{ - return packSize(data.getSize(), comm) + - packSize(data.getRecords(), comm) + - packSize(data.getSearchMap(), comm) + - packSize(data.getRegions(), comm) + - packSize(data.getDefaultRegion(), comm); -} - std::size_t packSize(const EclipseConfig& data, Dune::MPIHelper::MPICommunicator comm) { @@ -3099,29 +3077,6 @@ void pack(const GuideRateConfig::GroupTarget& data, pack(data.target, buffer, position, comm); } -void pack(const MULTREGTRecord& data, - std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - pack(data.src_value, buffer, position, comm); - pack(data.target_value, buffer, position, comm); - pack(data.trans_mult, buffer, position, comm); - pack(data.directions, buffer, position, comm); - pack(data.nnc_behaviour, buffer, position, comm); - pack(data.region_name, buffer, position, comm); -} - -void pack(const MULTREGTScanner& data, - std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - pack(data.getSize(), buffer, position, comm); - pack(data.getRecords(), buffer, position, comm); - pack(data.getSearchMap(), buffer, position, comm); - pack(data.getRegions(), buffer, position, comm); - pack(data.getDefaultRegion(), buffer, position, comm); -} - void pack(const EclipseConfig& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) @@ -5275,37 +5230,6 @@ void unpack(GuideRateConfig::GroupTarget& data, unpack(data.target, buffer, position, comm); } -void unpack(MULTREGTRecord& data, - std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - unpack(data.src_value, buffer, position, comm); - unpack(data.target_value, buffer, position, comm); - unpack(data.trans_mult, buffer, position, comm); - unpack(data.directions, buffer, position, comm); - unpack(data.nnc_behaviour, buffer, position, comm); - unpack(data.region_name, buffer, position, comm); -} - -void unpack(MULTREGTScanner& data, - std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - std::array size; - std::vector records; - MULTREGTScanner::ExternalSearchMap searchMap; - std::map> regions; - std::string defaultRegion; - - unpack(size, buffer, position, comm); - unpack(records, buffer, position, comm); - unpack(searchMap, buffer, position, comm); - unpack(regions, buffer, position, comm); - unpack(defaultRegion, buffer, position, comm); - - data = MULTREGTScanner(size, records, searchMap, regions, defaultRegion); -} - void unpack(EclipseConfig& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index 508395707..3751ea312 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -94,8 +94,6 @@ class JFunc; class Location; class MessageLimits; class MLimits; -class MULTREGTRecord; -class MULTREGTScanner; class OilVaporizationProperties; class Phases; class PlymwinjTable; @@ -551,8 +549,6 @@ ADD_PACK_PROTOTYPES(JFunc) ADD_PACK_PROTOTYPES(Location) ADD_PACK_PROTOTYPES(MessageLimits) ADD_PACK_PROTOTYPES(MLimits) -ADD_PACK_PROTOTYPES(MULTREGTRecord) -ADD_PACK_PROTOTYPES(MULTREGTScanner) ADD_PACK_PROTOTYPES(OilVaporizationProperties) ADD_PACK_PROTOTYPES(Phases) ADD_PACK_PROTOTYPES(PlmixparRecord) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index a07993113..ac98e3562 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -2232,7 +2232,7 @@ BOOST_AUTO_TEST_CASE(MULTREGTRecord) { #ifdef HAVE_MPI Opm::MULTREGTRecord val1{1, 2, 3.0, 4, Opm::MULTREGT::ALL, "test"}; - auto val2 = PackUnpack(val1); + auto val2 = PackUnpack2(val1); DO_CHECKS(MULTREGTRecord) #endif } @@ -2251,7 +2251,7 @@ BOOST_AUTO_TEST_CASE(MULTREGTScanner) {{"test3", {7,8}}}, "test4"); - auto val2 = PackUnpack(val1); + auto val2 = PackUnpack2(val1); DO_CHECKS(MULTREGTScanner) #endif } From 0212c5e9be2816a56038b5c07d9365e204495a2b Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 13 Mar 2020 08:26:18 +0100 Subject: [PATCH 2/5] remove old serialization support for TransMult --- opm/simulators/utils/ParallelRestart.cpp | 36 ------------------------ opm/simulators/utils/ParallelRestart.hpp | 2 -- tests/test_ParallelRestart.cpp | 2 +- 3 files changed, 1 insertion(+), 39 deletions(-) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 64d389e62..04ee176b1 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -1555,15 +1554,6 @@ std::size_t packSize(const EclipseConfig& data, packSize(data.io(), comm); } -std::size_t packSize(const TransMult& data, - Dune::MPIHelper::MPICommunicator comm) -{ - return packSize(data.getSize(), comm) + - packSize(data.getTrans(), comm) + - packSize(data.getNames(), comm) + - packSize(data.getScanner(), comm); -} - std::size_t packSize(const FaultFace& data, Dune::MPIHelper::MPICommunicator comm) { @@ -3085,16 +3075,6 @@ void pack(const EclipseConfig& data, pack(data.io(), buffer, position, comm); } -void pack(const TransMult& data, - std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - pack(data.getSize(), buffer, position, comm); - pack(data.getTrans(), buffer, position, comm); - pack(data.getNames(), buffer, position, comm); - pack(data.getScanner(), buffer, position, comm); -} - void pack(const FaultFace& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) @@ -5242,22 +5222,6 @@ void unpack(EclipseConfig& data, data = EclipseConfig(init, io); } -void unpack(TransMult& data, - std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - std::array size; - std::map> trans; - std::map names; - MULTREGTScanner scanner; - - unpack(size, buffer, position, comm); - unpack(trans, buffer, position, comm); - unpack(names, buffer, position, comm); - unpack(scanner, buffer, position, comm); - data = TransMult(size, trans, names, scanner); -} - void unpack(FaultFace& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index 3751ea312..a4c32bc5b 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -139,7 +139,6 @@ class TableSchema; class TimeStampUTC; class TlmixparRecord; class TlmixparTable; -class TransMult; class Tuning; class UDAValue; class UDQASTNode; @@ -597,7 +596,6 @@ ADD_PACK_PROTOTYPES(TimeMap) ADD_PACK_PROTOTYPES(TimeStampUTC) ADD_PACK_PROTOTYPES(TlmixparRecord) ADD_PACK_PROTOTYPES(TlmixparTable) -ADD_PACK_PROTOTYPES(TransMult) ADD_PACK_PROTOTYPES(Tuning) ADD_PACK_PROTOTYPES(UDAValue) ADD_PACK_PROTOTYPES(UDQActive) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index ac98e3562..898d07237 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -2290,7 +2290,7 @@ BOOST_AUTO_TEST_CASE(TransMult) {{Opm::FaceDir::YPlus, {4.0, 5.0}}}, {{Opm::FaceDir::ZPlus, "test1"}}, scanner); - auto val2 = PackUnpack(val1); + auto val2 = PackUnpack2(val1); DO_CHECKS(TransMult) #endif } From d342ef5c5cee848daaddebc8cfc0819f9bc6e340 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 13 Mar 2020 08:53:26 +0100 Subject: [PATCH 3/5] remove old serialization support for Fault, FaultCollection, FaultFace --- opm/simulators/utils/ParallelRestart.cpp | 84 ------------------------ opm/simulators/utils/ParallelRestart.hpp | 6 -- tests/test_ParallelRestart.cpp | 6 +- 3 files changed, 3 insertions(+), 93 deletions(-) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 04ee176b1..dde9e291e 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -25,9 +25,6 @@ #include #include #include -#include -#include -#include #include #include #include @@ -1554,27 +1551,6 @@ std::size_t packSize(const EclipseConfig& data, packSize(data.io(), comm); } -std::size_t packSize(const FaultFace& data, - Dune::MPIHelper::MPICommunicator comm) -{ - return packSize(data.getIndices(), comm) + - packSize(data.getDir(), comm); -} - -std::size_t packSize(const Fault& data, - Dune::MPIHelper::MPICommunicator comm) -{ - return packSize(data.getName(), comm) + - packSize(data.getTransMult(), comm) + - packSize(data.getFaceList(), comm); -} - -std::size_t packSize(const FaultCollection& data, - Dune::MPIHelper::MPICommunicator comm) -{ - return packSize(data.getFaults(), comm); -} - std::size_t packSize(const SolventDensityTable& data, Dune::MPIHelper::MPICommunicator comm) { @@ -3075,30 +3051,6 @@ void pack(const EclipseConfig& data, pack(data.io(), buffer, position, comm); } -void pack(const FaultFace& data, - std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - pack(data.getIndices(), buffer, position, comm); - pack(data.getDir(), buffer, position, comm); -} - -void pack(const Fault& data, - std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - pack(data.getName(), buffer, position, comm); - pack(data.getTransMult(), buffer, position, comm); - pack(data.getFaceList(), buffer, position, comm); -} - -void pack(const FaultCollection& data, - std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - pack(data.getFaults(), buffer, position, comm); -} - void pack(const SolventDensityTable& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) @@ -5222,42 +5174,6 @@ void unpack(EclipseConfig& data, data = EclipseConfig(init, io); } -void unpack(FaultFace& data, - std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - std::vector indices; - FaceDir::DirEnum dir; - - unpack(indices, buffer, position, comm); - unpack(dir, buffer, position, comm); - data = FaultFace(indices, dir); -} - -void unpack(Fault& data, - std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - std::string name; - double transMult; - std::vector faceList; - - unpack(name, buffer, position, comm); - unpack(transMult, buffer, position, comm); - unpack(faceList, buffer, position, comm); - data = Fault(name, transMult, faceList); -} - -void unpack(FaultCollection& data, - std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - OrderedMap faults; - - unpack(faults, buffer, position, comm); - data = FaultCollection(faults); -} - void unpack(SolventDensityTable& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) { diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index a4c32bc5b..884fbd696 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -82,9 +82,6 @@ class EndpointScaling; class Equil; class EquilRecord; class Events; -class Fault; -class FaultCollection; -class FaultFace; class FoamConfig; class FoamData; class InitConfig; @@ -526,9 +523,6 @@ ADD_PACK_PROTOTYPES(Equil) ADD_PACK_PROTOTYPES(Eqldims) ADD_PACK_PROTOTYPES(EquilRecord) ADD_PACK_PROTOTYPES(Events) -ADD_PACK_PROTOTYPES(Fault) -ADD_PACK_PROTOTYPES(FaultCollection) -ADD_PACK_PROTOTYPES(FaultFace) ADD_PACK_PROTOTYPES(FoamConfig) ADD_PACK_PROTOTYPES(FoamData) ADD_PACK_PROTOTYPES(GConSale) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index 898d07237..dd870c120 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -2300,7 +2300,7 @@ BOOST_AUTO_TEST_CASE(FaultFace) { #ifdef HAVE_MPI Opm::FaultFace val1({1,2,3,4,5,6}, Opm::FaceDir::YPlus); - auto val2 = PackUnpack(val1); + auto val2 = PackUnpack2(val1); DO_CHECKS(FaultFace) #endif } @@ -2310,7 +2310,7 @@ BOOST_AUTO_TEST_CASE(Fault) { #ifdef HAVE_MPI Opm::Fault val1("test", 1.0, {{{1,2,3,4,5,6}, Opm::FaceDir::YPlus}}); - auto val2 = PackUnpack(val1); + auto val2 = PackUnpack2(val1); DO_CHECKS(Fault) #endif } @@ -2340,7 +2340,7 @@ BOOST_AUTO_TEST_CASE(FaultCollection) Opm::OrderedMap faults; faults.insert({"test2", fault}); Opm::FaultCollection val1(faults); - auto val2 = PackUnpack(val1); + auto val2 = PackUnpack2(val1); DO_CHECKS(FaultCollection) #endif } From fe2437e67eaf4c82a326eb04fe93643b1e0bfb3c Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Thu, 12 Mar 2020 15:06:45 +0100 Subject: [PATCH 4/5] add pair handling in eclmpiserializer::vector --- ebos/eclmpiserializer.hh | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/ebos/eclmpiserializer.hh b/ebos/eclmpiserializer.hh index a0938e365..1d52cb14a 100644 --- a/ebos/eclmpiserializer.hh +++ b/ebos/eclmpiserializer.hh @@ -54,7 +54,10 @@ public: auto handle = [&](auto& d) { for (auto& it : d) { - it.serializeOp(*this); + if constexpr (is_pair::value) + pair(it); + else + it.serializeOp(*this); } }; @@ -118,6 +121,30 @@ public: } protected: + template + struct is_pair { + constexpr static bool value = false; + }; + + template + struct is_pair> { + constexpr static bool value = true; + }; + + template + void pair(const std::pair& data) + { + if constexpr (std::is_pod::value || std::is_same::value) + (*this)(data.first); + else + data.first.serializeOp(*this); + + if constexpr (std::is_pod::value || std::is_same::value) + (*this)(data.second); + else + const_cast(data.second).serializeOp(*this); + } + Dune::CollectiveCommunication m_comm; Operation m_op = Operation::PACKSIZE; From edca0f7da0b0ef943564b81fd73df004ab3a74f7 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 13 Mar 2020 09:56:57 +0100 Subject: [PATCH 5/5] add necessary explicit template instantations --- opm/simulators/utils/ParallelRestart.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index dde9e291e..6e61d22ec 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -5280,6 +5280,7 @@ INSTANTIATE_PACK_VECTOR(std::vector) INSTANTIATE_PACK_VECTOR(bool) INSTANTIATE_PACK_VECTOR(char) INSTANTIATE_PACK_VECTOR(int) +INSTANTIATE_PACK_VECTOR(size_t) INSTANTIATE_PACK_VECTOR(std::array) INSTANTIATE_PACK_VECTOR(std::pair) INSTANTIATE_PACK_VECTOR(std::shared_ptr)