Merge pull request #2450 from akva2/serializer_summaryconfig

use eclmpiserializer for SummaryConfig broadcast
This commit is contained in:
Bård Skaflestad 2020-03-10 20:32:06 -05:00 committed by GitHub
commit c53d8c58f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 35 deletions

View File

@ -386,7 +386,6 @@ int main(int argc, char** argv)
setupMessageLimiter(schedule->getMessageLimits(), "STDOUT_LOGGER");
summaryConfig.reset( new Opm::SummaryConfig(*deck, *schedule, eclipseState->getTableManager(), parseContext, errorGuard));
#ifdef HAVE_MPI
Opm::Mpi::packAndSend(*summaryConfig, Dune::MPIHelper::getCollectiveCommunication());
Opm::Mpi::packAndSend(*schedule, Dune::MPIHelper::getCollectiveCommunication());
#endif
}
@ -395,11 +394,11 @@ int main(int argc, char** argv)
summaryConfig.reset(new Opm::SummaryConfig);
schedule.reset(new Opm::Schedule);
parState = new Opm::ParallelEclipseState;
Opm::Mpi::receiveAndUnpack(*summaryConfig, mpiHelper.getCollectiveCommunication());
Opm::Mpi::receiveAndUnpack(*schedule, mpiHelper.getCollectiveCommunication());
eclipseState.reset(parState);
}
Opm::EclMpiSerializer ser(mpiHelper.getCollectiveCommunication());
ser.broadcast(*summaryConfig);
ser.broadcast(*parState);
#endif

View File

@ -1619,14 +1619,6 @@ std::size_t packSize(const SummaryNode& data,
packSize(data.isUserDefined(), comm);
}
std::size_t packSize(const SummaryConfig& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getKwds(), comm) +
packSize(data.getShortKwds(), comm) +
packSize(data.getSmryKwds(), comm);
}
std::size_t packSize(const EquilRecord& data,
Dune::MPIHelper::MPICommunicator comm)
{
@ -3296,15 +3288,6 @@ void pack(const SummaryNode& data,
pack(data.isUserDefined(), buffer, position, comm);
}
void pack(const SummaryConfig& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.getKwds(), buffer, position, comm);
pack(data.getShortKwds(), buffer, position, comm);
pack(data.getSmryKwds(), buffer, position, comm);
}
void pack(const EquilRecord& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
@ -5647,19 +5630,6 @@ void unpack(SummaryNode& data,
.isUserDefined(isUserDefined);
}
void unpack(SummaryConfig& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
SummaryConfig::keyword_list kwds;
std::set<std::string> shortKwds, smryKwds;
unpack(kwds, buffer, position, comm);
unpack(shortKwds, buffer, position, comm);
unpack(smryKwds, buffer, position, comm);
data = SummaryConfig(kwds, shortKwds, smryKwds);
}
void unpack(EquilRecord& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
@ -6012,8 +5982,24 @@ INSTANTIATE_PACK_VECTOR(bool)
INSTANTIATE_PACK_VECTOR(char)
INSTANTIATE_PACK_VECTOR(int)
INSTANTIATE_PACK_VECTOR(std::array<double, 3>)
INSTANTIATE_PACK_VECTOR(SummaryNode)
#undef INSTANTIATE_PACK_VECTOR
#define INSTANTIATE_PACK_SET(...) \
template std::size_t packSize(const std::set<__VA_ARGS__>& data, \
Dune::MPIHelper::MPICommunicator comm); \
template void pack(const std::set<__VA_ARGS__>& data, \
std::vector<char>& buffer, int& position, \
Dune::MPIHelper::MPICommunicator comm); \
template void unpack(std::set<__VA_ARGS__>& data, \
std::vector<char>& buffer, int& position, \
Dune::MPIHelper::MPICommunicator comm);
INSTANTIATE_PACK_SET(std::string)
#undef INSTANTIATE_PACK_SET
#define INSTANTIATE_PACK_SHARED_PTR(...) \
template std::size_t packSize(const std::shared_ptr<__VA_ARGS__>& data, \
Dune::MPIHelper::MPICommunicator comm); \
@ -6044,6 +6030,7 @@ INSTANTIATE_PACK(int)
INSTANTIATE_PACK(std::array<short,3>)
INSTANTIATE_PACK(std::array<bool,3>)
INSTANTIATE_PACK(unsigned char)
INSTANTIATE_PACK(SummaryNode)
#undef INSTANTIATE_PACK
} // end namespace Mpi

View File

@ -141,7 +141,6 @@ class SpiralICD;
class StandardCond;
class Stone1exRecord;
class Stone1exTable;
class SummaryConfig;
class SummaryNode;
class Tabdims;
class TableColumn;
@ -564,7 +563,6 @@ ADD_PACK_PROTOTYPES(SpiralICD)
ADD_PACK_PROTOTYPES(std::string)
ADD_PACK_PROTOTYPES(Stone1exRecord)
ADD_PACK_PROTOTYPES(Stone1exTable)
ADD_PACK_PROTOTYPES(SummaryConfig)
ADD_PACK_PROTOTYPES(SummaryNode)
ADD_PACK_PROTOTYPES(Tabdims)
ADD_PACK_PROTOTYPES(TableColumn)

View File

@ -110,6 +110,7 @@
#include <opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp>
#include <opm/output/eclipse/RestartValue.hpp>
#include <opm/simulators/utils/ParallelRestart.hpp>
#include <ebos/eclmpiserializer.hh>
namespace {
@ -543,6 +544,20 @@ std::tuple<T,int,int> PackUnpack(const T& in)
return std::make_tuple(out, pos1, pos2);
}
template<class T>
std::tuple<T,int,int> PackUnpack2(T& in)
{
auto comm = Dune::MPIHelper::getCollectiveCommunication();
Opm::EclMpiSerializer ser(comm);
ser.pack(in);
size_t pos1 = ser.position();
T out;
ser.unpack(out);
size_t pos2 = ser.position();
return std::make_tuple(out, pos1, pos2);
}
#define DO_CHECKS(TYPE_NAME) \
BOOST_CHECK_MESSAGE(std::get<1>(val2) == std::get<2>(val2), "Packed size differ from unpack size for " #TYPE_NAME); \
@ -2187,7 +2202,7 @@ BOOST_AUTO_TEST_CASE(SummaryConfig)
.isUserDefined(true);
Opm::SummaryConfig val1({node}, {"test1", "test2"}, {"test3", "test4"});
auto val2 = PackUnpack(val1);
auto val2 = PackUnpack2(val1);
DO_CHECKS(SummaryConfig)
#endif
}