mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-20 11:48:25 -06:00
added: pack array/vector of pod in one op
This commit is contained in:
parent
b1092c1a12
commit
9cbb0aa05e
@ -121,7 +121,7 @@ public:
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
void vector(std::vector<T>& data)
|
void vector(std::vector<T>& data)
|
||||||
{
|
{
|
||||||
auto handle = [&](auto& d)
|
[[maybe_unused]] auto handle = [&](auto& d)
|
||||||
{
|
{
|
||||||
for (auto& it : d) {
|
for (auto& it : d) {
|
||||||
if constexpr (is_pair_or_tuple<T>::value)
|
if constexpr (is_pair_or_tuple<T>::value)
|
||||||
@ -139,15 +139,24 @@ public:
|
|||||||
|
|
||||||
if (m_op == Operation::PACKSIZE) {
|
if (m_op == Operation::PACKSIZE) {
|
||||||
m_packSize += Mpi::Packer::packSize(data.size(), m_comm);
|
m_packSize += Mpi::Packer::packSize(data.size(), m_comm);
|
||||||
handle(data);
|
if constexpr (std::is_pod_v<T>)
|
||||||
|
m_packSize += Mpi::Packer::packSize(data.data(), data.size(), m_comm);
|
||||||
|
else
|
||||||
|
handle(data);
|
||||||
} else if (m_op == Operation::PACK) {
|
} else if (m_op == Operation::PACK) {
|
||||||
Mpi::packer::pack(data.size(), m_buffer, m_position, m_comm);
|
Mpi::Packer::pack(data.size(), m_buffer, m_position, m_comm);
|
||||||
handle(data);
|
if constexpr (std::is_pod_v<T>)
|
||||||
|
Mpi::Packer::pack(data.data(), data.size(), m_buffer, m_position, m_comm);
|
||||||
|
else
|
||||||
|
handle(data);
|
||||||
} else if (m_op == Operation::UNPACK) {
|
} else if (m_op == Operation::UNPACK) {
|
||||||
size_t size;
|
size_t size;
|
||||||
Mpi::Packer::unpack(size, m_buffer, m_position, m_comm);
|
Mpi::Packer::unpack(size, m_buffer, m_position, m_comm);
|
||||||
data.resize(size);
|
data.resize(size);
|
||||||
handle(data);
|
if constexpr (std::is_pod_v<T>)
|
||||||
|
Mpi::Packer::unpack(data.data(), size, m_buffer, m_position, m_comm);
|
||||||
|
else
|
||||||
|
handle(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +193,7 @@ public:
|
|||||||
{
|
{
|
||||||
using T = typename Array::value_type;
|
using T = typename Array::value_type;
|
||||||
|
|
||||||
auto handle = [&](auto& d) {
|
[[maybe_unused]] auto handle = [&](auto& d) {
|
||||||
for (auto& it : d) {
|
for (auto& it : d) {
|
||||||
if constexpr (is_pair_or_tuple<T>::value)
|
if constexpr (is_pair_or_tuple<T>::value)
|
||||||
tuple(it);
|
tuple(it);
|
||||||
@ -198,15 +207,20 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (m_op == Operation::PACKSIZE) {
|
if (m_op == Operation::PACKSIZE) {
|
||||||
m_packSize += Mpi::Packer::packSize(data.size(), m_comm);
|
if constexpr (std::is_pod_v<T>)
|
||||||
handle(data);
|
m_packSize += Mpi::Packer::packSize(data.data(), data.size(), m_comm);
|
||||||
|
else
|
||||||
|
handle(data);
|
||||||
} else if (m_op == Operation::PACK) {
|
} else if (m_op == Operation::PACK) {
|
||||||
Mpi::Packer::pack(data.size(), m_buffer, m_position, m_comm);
|
if constexpr (std::is_pod_v<T>)
|
||||||
handle(data);
|
Mpi::Packer::pack(data.data(), data.size(), m_buffer, m_position, m_comm);
|
||||||
|
else
|
||||||
|
handle(data);
|
||||||
} else if (m_op == Operation::UNPACK) {
|
} else if (m_op == Operation::UNPACK) {
|
||||||
size_t size;
|
if constexpr (std::is_pod_v<T>)
|
||||||
Mpi::Packer::unpack(size, m_buffer, m_position, m_comm);
|
Mpi::Packer::unpack(data.data(), data.size(), m_buffer, m_position, m_comm);
|
||||||
handle(data);
|
else
|
||||||
|
handle(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user