mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
add mpi serialization for tuples
This commit is contained in:
parent
a2ac61f592
commit
d2dd2c51be
@ -158,6 +158,26 @@ std::size_t packSize(const std::vector<bool,A>& data, Dune::MPIHelper::MPICommun
|
||||
return packSize(data.size(), comm) + data.size()*packSize(entry,comm);
|
||||
}
|
||||
|
||||
template<std::size_t I = 0, typename Tuple>
|
||||
typename std::enable_if<I == std::tuple_size<Tuple>::value, std::size_t>::type
|
||||
pack_size_tuple_entry(const Tuple&, Dune::MPIHelper::MPICommunicator)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<std::size_t I = 0, typename Tuple>
|
||||
typename std::enable_if<I != std::tuple_size<Tuple>::value, std::size_t>::type
|
||||
pack_size_tuple_entry(const Tuple& tuple, Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
return packSize(std::get<I>(tuple), comm) + pack_size_tuple_entry<I+1>(tuple, comm);
|
||||
}
|
||||
|
||||
template<class... Ts>
|
||||
std::size_t packSize(const std::tuple<Ts...>& data, Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
return pack_size_tuple_entry(data, comm);
|
||||
}
|
||||
|
||||
template<class Key, class Value>
|
||||
std::size_t packSize(const OrderedMap<Key,Value>& data, Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
@ -697,6 +717,29 @@ void pack(const std::vector<bool,A>& data, std::vector<char>& buffer, int& posit
|
||||
}
|
||||
}
|
||||
|
||||
template<std::size_t I = 0, typename Tuple>
|
||||
typename std::enable_if<I == std::tuple_size<Tuple>::value, void>::type
|
||||
pack_tuple_entry(const Tuple&, std::vector<char>&, int&,
|
||||
Dune::MPIHelper::MPICommunicator)
|
||||
{
|
||||
}
|
||||
|
||||
template<std::size_t I = 0, typename Tuple>
|
||||
typename std::enable_if<I != std::tuple_size<Tuple>::value, void>::type
|
||||
pack_tuple_entry(const Tuple& tuple, std::vector<char>& buffer,
|
||||
int& position, Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(std::get<I>(tuple), buffer, position, comm);
|
||||
pack_tuple_entry<I+1>(tuple, buffer, position, comm);
|
||||
}
|
||||
|
||||
template<class... Ts>
|
||||
void pack(const std::tuple<Ts...>& data, std::vector<char>& buffer,
|
||||
int& position, Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack_tuple_entry(data, buffer, position, comm);
|
||||
}
|
||||
|
||||
template<class Key, class Value>
|
||||
void pack(const OrderedMap<Key, Value>& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
@ -1281,6 +1324,29 @@ void unpack(std::vector<bool,A>& data, std::vector<char>& buffer, int& position,
|
||||
}
|
||||
}
|
||||
|
||||
template<std::size_t I = 0, typename Tuple>
|
||||
typename std::enable_if<I == std::tuple_size<Tuple>::value, void>::type
|
||||
unpack_tuple_entry(Tuple&, std::vector<char>&, int&,
|
||||
Dune::MPIHelper::MPICommunicator)
|
||||
{
|
||||
}
|
||||
|
||||
template<std::size_t I = 0, typename Tuple>
|
||||
typename std::enable_if<I != std::tuple_size<Tuple>::value, void>::type
|
||||
unpack_tuple_entry(Tuple& tuple, std::vector<char>& buffer,
|
||||
int& position, Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
unpack(std::get<I>(tuple), buffer, position, comm);
|
||||
unpack_tuple_entry<I+1>(tuple, buffer, position, comm);
|
||||
}
|
||||
|
||||
template<class... Ts>
|
||||
void unpack(std::tuple<Ts...>& data, std::vector<char>& buffer,
|
||||
int& position, Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
unpack_tuple_entry(data, buffer, position, comm);
|
||||
}
|
||||
|
||||
template<class Key, class Value>
|
||||
void unpack(OrderedMap<Key,Value>& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
#include <dune/common/parallel/mpihelper.hh>
|
||||
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
@ -128,6 +129,9 @@ std::size_t packSize(const std::vector<T,A>& data, Dune::MPIHelper::MPICommunica
|
||||
template<class A>
|
||||
std::size_t packSize(const std::vector<bool,A>& data, Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class... Ts>
|
||||
std::size_t packSize(const std::tuple<Ts...>& data, Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
std::size_t packSize(const char* str, Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
std::size_t packSize(const std::string& str, Dune::MPIHelper::MPICommunicator comm);
|
||||
@ -195,6 +199,10 @@ template<class A>
|
||||
void pack(const std::vector<bool,A>& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class... Ts>
|
||||
void pack(const std::tuple<Ts...>& data, std::vector<char>& buffer,
|
||||
int& position, Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class T1, class T2, class C, class A>
|
||||
void pack(const std::map<T1,T2,C,A>& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
@ -269,6 +277,10 @@ template<class A>
|
||||
void unpack(std::vector<bool,A>& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class... Ts>
|
||||
void unpack(std::tuple<Ts...>& data, std::vector<char>& buffer,
|
||||
int& position, Dune::MPIHelper::MPICommunicator comm);
|
||||
|
||||
template<class T1, class T2, class C, class A>
|
||||
void unpack(std::map<T1,T2,C,A>& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm);
|
||||
|
Loading…
Reference in New Issue
Block a user