From dfa870c313e87a9ec6a4a1405fb351b9c99fc292 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 7 Sep 2022 12:03:10 +0200 Subject: [PATCH] changed: handle all sets in eclmpiserializer thus we can remove support in MPIPacker --- ebos/eclmpiserializer.hh | 23 ++++++++ opm/simulators/utils/MPIPacker.cpp | 84 ------------------------------ opm/simulators/utils/MPIPacker.hpp | 30 ----------- 3 files changed, 23 insertions(+), 114 deletions(-) diff --git a/ebos/eclmpiserializer.hh b/ebos/eclmpiserializer.hh index 62b2c2958..a61408065 100644 --- a/ebos/eclmpiserializer.hh +++ b/ebos/eclmpiserializer.hh @@ -24,10 +24,15 @@ #include #include +#include #include +#include #include #include +#include +#include #include +#include namespace detail { @@ -94,6 +99,8 @@ public: map(const_cast(data)); } else if constexpr (is_array::value) { array(const_cast(data)); + } else if constexpr (is_set::value) { + set(const_cast(data)); } else { if (m_op == Operation::PACKSIZE) m_packSize += Mpi::packSize(data, m_comm); @@ -505,6 +512,22 @@ protected: constexpr static bool value = true; }; + //! \brief Predicate for sets + template + struct is_set { + constexpr static bool value = false; + }; + + template + struct is_set> { + constexpr static bool value = true; + }; + + template + struct is_set> { + constexpr static bool value = true; + }; + //! \brief Predicate for arrays template struct is_array { diff --git a/opm/simulators/utils/MPIPacker.cpp b/opm/simulators/utils/MPIPacker.cpp index ddbe1e2a7..9972cf5e2 100644 --- a/opm/simulators/utils/MPIPacker.cpp +++ b/opm/simulators/utils/MPIPacker.cpp @@ -109,30 +109,6 @@ std::size_t packSize(const std::tuple& data, Opm::Parallel::MPIComm comm) return pack_size_tuple_entry(data, comm); } -template -std::size_t packSize(const std::unordered_set& data, - Opm::Parallel::MPIComm comm) -{ - std::size_t totalSize = packSize(data.size(), comm); - for (const auto& entry : data) - { - totalSize += packSize(entry, comm); - } - return totalSize; -} - -template -std::size_t packSize(const std::set& data, - Opm::Parallel::MPIComm comm) -{ - std::size_t totalSize = packSize(data.size(), comm); - for (const auto& entry : data) - { - totalSize += packSize(entry, comm); - } - return totalSize; -} - std::size_t packSize(const char* str, Opm::Parallel::MPIComm comm) { #if HAVE_MPI @@ -252,32 +228,6 @@ void pack(const std::vector& data, std::vector& buffer, int& positio pack(entry, buffer, position, comm); } -template -void pack(const std::set& data, - std::vector& buffer, int& position, - Opm::Parallel::MPIComm comm) -{ - pack(data.size(), buffer, position, comm); - - for (const auto& entry : data) - { - pack(entry, buffer, position, comm); - } -} - -template -void pack(const std::unordered_set& data, - std::vector& buffer, int& position, - Opm::Parallel::MPIComm comm) -{ - pack(data.size(), buffer, position, comm); - - for (const auto& entry : data) - { - pack(entry, buffer, position, comm); - } -} - template void pack(const std::vector& data, std::vector& buffer, int& position, Opm::Parallel::MPIComm comm) @@ -446,38 +396,6 @@ void unpack(std::tuple& data, std::vector& buffer, unpack_tuple_entry(data, buffer, position, comm); } -template -void unpack(std::set& data, - std::vector& buffer, int& position, - Opm::Parallel::MPIComm comm) -{ - std::size_t size = 0; - unpack(size, buffer, position, comm); - - for (;size>0; size--) - { - K entry; - unpack(entry, buffer, position, comm); - data.insert(entry); - } -} - -template -void unpack(std::unordered_set& data, - std::vector& buffer, int& position, - Opm::Parallel::MPIComm comm) -{ - std::size_t size=0; - unpack(size, buffer, position, comm); - - for (;size>0; size--) - { - T entry; - unpack(entry, buffer, position, comm); - data.insert(entry); - } -} - void unpack(char* str, std::size_t length, std::vector& buffer, int& position, Opm::Parallel::MPIComm comm) { @@ -571,8 +489,6 @@ INSTANTIATE_PACK(unsigned int) INSTANTIATE_PACK(unsigned long int) INSTANTIATE_PACK(unsigned long long int) INSTANTIATE_PACK(std::pair) -INSTANTIATE_PACK(std::unordered_set) -INSTANTIATE_PACK(std::set) INSTANTIATE_PACK(std::bitset<4>) diff --git a/opm/simulators/utils/MPIPacker.hpp b/opm/simulators/utils/MPIPacker.hpp index abcf8ad25..cf4931958 100644 --- a/opm/simulators/utils/MPIPacker.hpp +++ b/opm/simulators/utils/MPIPacker.hpp @@ -26,11 +26,9 @@ #include #include -#include #include #include #include -#include #include namespace Opm @@ -83,14 +81,6 @@ std::size_t packSize(const std::pair& data, Opm::Parallel::MPIComm comm); template std::size_t packSize(const std::vector& data, Opm::Parallel::MPIComm comm); -template -std::size_t packSize(const std::set& data, - Opm::Parallel::MPIComm comm); - -template -std::size_t packSize(const std::unordered_set& data, - Opm::Parallel::MPIComm comm); - template std::size_t packSize(const std::vector& data, Opm::Parallel::MPIComm comm); @@ -161,16 +151,6 @@ template void pack(const std::tuple& data, std::vector& buffer, int& position, Opm::Parallel::MPIComm comm); -template -void pack(const std::set& data, - std::vector& buffer, int& position, - Opm::Parallel::MPIComm comm); - -template -void pack(const std::unordered_set& data, - std::vector& buffer, int& position, - Opm::Parallel::MPIComm comm); - void pack(const char* str, std::vector& buffer, int& position, Opm::Parallel::MPIComm comm); @@ -238,16 +218,6 @@ template void unpack(std::tuple& data, std::vector& buffer, int& position, Opm::Parallel::MPIComm comm); -template -void unpack(std::set& data, - std::vector& buffer, int& position, - Opm::Parallel::MPIComm comm); - -template -void unpack(std::unordered_set& data, - std::vector& buffer, int& position, - Opm::Parallel::MPIComm comm); - void unpack(char* str, std::size_t length, std::vector& buffer, int& position, Opm::Parallel::MPIComm comm);