mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-16 20:24:48 -06:00
changed: handle all sets in eclmpiserializer
thus we can remove support in MPIPacker
This commit is contained in:
parent
3fc8433cc8
commit
dfa870c313
@ -24,10 +24,15 @@
|
||||
#include <opm/simulators/utils/MPIPacker.hpp>
|
||||
#include <opm/simulators/utils/ParallelCommunication.hpp>
|
||||
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
namespace detail
|
||||
{
|
||||
@ -94,6 +99,8 @@ public:
|
||||
map(const_cast<T&>(data));
|
||||
} else if constexpr (is_array<T>::value) {
|
||||
array(const_cast<T&>(data));
|
||||
} else if constexpr (is_set<T>::value) {
|
||||
set(const_cast<T&>(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<class T>
|
||||
struct is_set {
|
||||
constexpr static bool value = false;
|
||||
};
|
||||
|
||||
template<class Key, class Compare, class Allocator>
|
||||
struct is_set<std::set<Key,Compare,Allocator>> {
|
||||
constexpr static bool value = true;
|
||||
};
|
||||
|
||||
template<class Key, class Hash, class KeyEqual, class Allocator>
|
||||
struct is_set<std::unordered_set<Key,Hash,KeyEqual,Allocator>> {
|
||||
constexpr static bool value = true;
|
||||
};
|
||||
|
||||
//! \brief Predicate for arrays
|
||||
template<class T>
|
||||
struct is_array {
|
||||
|
@ -109,30 +109,6 @@ std::size_t packSize(const std::tuple<Ts...>& data, Opm::Parallel::MPIComm comm)
|
||||
return pack_size_tuple_entry(data, comm);
|
||||
}
|
||||
|
||||
template<class T, class H, class KE, class A>
|
||||
std::size_t packSize(const std::unordered_set<T,H,KE,A>& 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<class K, class C, class A>
|
||||
std::size_t packSize(const std::set<K,C,A>& 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<T, A>& data, std::vector<char>& buffer, int& positio
|
||||
pack(entry, buffer, position, comm);
|
||||
}
|
||||
|
||||
template<class K, class C, class A>
|
||||
void pack(const std::set<K,C,A>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Opm::Parallel::MPIComm comm)
|
||||
{
|
||||
pack(data.size(), buffer, position, comm);
|
||||
|
||||
for (const auto& entry : data)
|
||||
{
|
||||
pack(entry, buffer, position, comm);
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class H, class KE, class A>
|
||||
void pack(const std::unordered_set<T,H,KE,A>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Opm::Parallel::MPIComm comm)
|
||||
{
|
||||
pack(data.size(), buffer, position, comm);
|
||||
|
||||
for (const auto& entry : data)
|
||||
{
|
||||
pack(entry, buffer, position, comm);
|
||||
}
|
||||
}
|
||||
|
||||
template<class A>
|
||||
void pack(const std::vector<bool,A>& data, std::vector<char>& buffer, int& position,
|
||||
Opm::Parallel::MPIComm comm)
|
||||
@ -446,38 +396,6 @@ void unpack(std::tuple<Ts...>& data, std::vector<char>& buffer,
|
||||
unpack_tuple_entry(data, buffer, position, comm);
|
||||
}
|
||||
|
||||
template<class K, class C, class A>
|
||||
void unpack(std::set<K,C,A>& data,
|
||||
std::vector<char>& 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<class T, class H, class KE, class A>
|
||||
void unpack(std::unordered_set<T,H,KE,A>& data,
|
||||
std::vector<char>& 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<char>& 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<double, double>)
|
||||
INSTANTIATE_PACK(std::unordered_set<std::string>)
|
||||
INSTANTIATE_PACK(std::set<std::string>)
|
||||
INSTANTIATE_PACK(std::bitset<4>)
|
||||
|
||||
|
||||
|
@ -26,11 +26,9 @@
|
||||
|
||||
#include <bitset>
|
||||
#include <cstddef>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <typeinfo>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
namespace Opm
|
||||
@ -83,14 +81,6 @@ std::size_t packSize(const std::pair<T1,T2>& data, Opm::Parallel::MPIComm comm);
|
||||
template<class T, class A>
|
||||
std::size_t packSize(const std::vector<T,A>& data, Opm::Parallel::MPIComm comm);
|
||||
|
||||
template<class K, class C, class A>
|
||||
std::size_t packSize(const std::set<K,C,A>& data,
|
||||
Opm::Parallel::MPIComm comm);
|
||||
|
||||
template<class T, class H, class KE, class A>
|
||||
std::size_t packSize(const std::unordered_set<T,H,KE,A>& data,
|
||||
Opm::Parallel::MPIComm comm);
|
||||
|
||||
template<class A>
|
||||
std::size_t packSize(const std::vector<bool,A>& data, Opm::Parallel::MPIComm comm);
|
||||
|
||||
@ -161,16 +151,6 @@ template<class... Ts>
|
||||
void pack(const std::tuple<Ts...>& data, std::vector<char>& buffer,
|
||||
int& position, Opm::Parallel::MPIComm comm);
|
||||
|
||||
template<class K, class C, class A>
|
||||
void pack(const std::set<K,C,A>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Opm::Parallel::MPIComm comm);
|
||||
|
||||
template<class T, class H, class KE, class A>
|
||||
void pack(const std::unordered_set<T,H,KE,A>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Opm::Parallel::MPIComm comm);
|
||||
|
||||
void pack(const char* str, std::vector<char>& buffer, int& position,
|
||||
Opm::Parallel::MPIComm comm);
|
||||
|
||||
@ -238,16 +218,6 @@ template<class... Ts>
|
||||
void unpack(std::tuple<Ts...>& data, std::vector<char>& buffer,
|
||||
int& position, Opm::Parallel::MPIComm comm);
|
||||
|
||||
template<class K, class C, class A>
|
||||
void unpack(std::set<K,C,A>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Opm::Parallel::MPIComm comm);
|
||||
|
||||
template<class T, class H, class KE, class A>
|
||||
void unpack(std::unordered_set<T,H,KE,A>& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Opm::Parallel::MPIComm comm);
|
||||
|
||||
void unpack(char* str, std::size_t length, std::vector<char>& buffer, int& position,
|
||||
Opm::Parallel::MPIComm comm);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user