diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index b304e3051..66a83c401 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -255,33 +255,6 @@ std::size_t packSize(const T* data, std::size_t l, Dune::MPIHelper::MPICommunica return packSize(data, l, comm, typename std::is_pod::type()); } -template -std::size_t packSize(const T&, Dune::MPIHelper::MPICommunicator, - std::integral_constant) -{ - OPM_THROW(std::logic_error, "Packing not (yet) supported for this non-pod type."); -} - -template -std::size_t packSize(const T&, Dune::MPIHelper::MPICommunicator comm, - std::integral_constant) -{ -#if HAVE_MPI - int size{}; - MPI_Pack_size(1, Dune::MPITraits::getType(), comm, &size); - return size; -#else - (void) comm; - return 0; -#endif -} - -template -std::size_t packSize(const T& data, Dune::MPIHelper::MPICommunicator comm) -{ - return packSize(data, comm, typename std::is_pod::type()); -} - template std::size_t packSize(const std::pair& data, Dune::MPIHelper::MPICommunicator comm) { @@ -1862,35 +1835,6 @@ void pack(const T* data, std::size_t l, std::vector& buffer, int& position pack(data, l, buffer, position, comm, typename std::is_pod::type()); } -template -void pack(const T&, std::vector&, int&, - Dune::MPIHelper::MPICommunicator, std::integral_constant) -{ - OPM_THROW(std::logic_error, "Packing not (yet) supported for this non-pod type."); -} - -template -void pack(const T& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm, std::integral_constant) -{ -#if HAVE_MPI - MPI_Pack(&data, 1, Dune::MPITraits::getType(), buffer.data(), - buffer.size(), &position, comm); -#else - (void) data; - (void) comm; - (void) buffer; - (void) position; -#endif -} - -template -void pack(const T& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - pack(data, buffer, position, comm, typename std::is_pod::type()); -} - template void pack(const std::pair& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) @@ -3555,35 +3499,6 @@ void unpack(T* data, const std::size_t& l, std::vector& buffer, int& posit unpack(data, l, buffer, position, comm, typename std::is_pod::type()); } -template -void unpack(T&, std::vector&, int&, - Dune::MPIHelper::MPICommunicator, std::integral_constant) -{ - OPM_THROW(std::logic_error, "Packing not (yet) supported for this non-pod type."); -} - -template -void unpack(T& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm, std::integral_constant) -{ -#if HAVE_MPI - MPI_Unpack(buffer.data(), buffer.size(), &position, &data, 1, - Dune::MPITraits::getType(), comm); -#else - (void) data; - (void) comm; - (void) buffer; - (void) position; -#endif -} - -template -void unpack(T& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - unpack(data, buffer, position, comm, typename std::is_pod::type()); -} - template void unpack(std::pair& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index 22a459bb2..2e13fe793 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -193,14 +193,30 @@ std::size_t packSize(const T* data, std::size_t l, Dune::MPIHelper::MPICommunica template std::size_t packSize(const T&, Dune::MPIHelper::MPICommunicator, - std::integral_constant); + std::integral_constant) +{ + OPM_THROW(std::logic_error, "Packing not (yet) supported for this non-pod type."); +} template std::size_t packSize(const T&, Dune::MPIHelper::MPICommunicator comm, - std::integral_constant); + std::integral_constant) +{ +#if HAVE_MPI + int size{}; + MPI_Pack_size(1, Dune::MPITraits::getType(), comm, &size); + return size; +#else + (void) comm; + return 0; +#endif +} template -std::size_t packSize(const T& data, Dune::MPIHelper::MPICommunicator comm); +std::size_t packSize(const T& data, Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data, comm, typename std::is_pod::type()); +} template std::size_t packSize(const std::pair& data, Dune::MPIHelper::MPICommunicator comm); @@ -271,16 +287,32 @@ void pack(const T* data, std::size_t l, std::vector& buffer, int& position template void pack(const T&, std::vector&, int&, - Dune::MPIHelper::MPICommunicator, std::integral_constant); + Dune::MPIHelper::MPICommunicator, std::integral_constant) +{ + OPM_THROW(std::logic_error, "Packing not (yet) supported for this non-pod type."); +} template void pack(const T& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm, std::integral_constant); - + Dune::MPIHelper::MPICommunicator comm, std::integral_constant) +{ +#if HAVE_MPI + MPI_Pack(&data, 1, Dune::MPITraits::getType(), buffer.data(), + buffer.size(), &position, comm); +#else + (void) data; + (void) comm; + (void) buffer; + (void) position; +#endif +} template void pack(const T& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data, buffer, position, comm, typename std::is_pod::type()); +} template void pack(const std::pair& data, std::vector& buffer, int& position, @@ -364,15 +396,32 @@ void unpack(T* data, const std::size_t& l, std::vector& buffer, int& posit template void unpack(T&, std::vector&, int&, - Dune::MPIHelper::MPICommunicator, std::integral_constant); + Dune::MPIHelper::MPICommunicator, std::integral_constant) +{ + OPM_THROW(std::logic_error, "Packing not (yet) supported for this non-pod type."); +} template void unpack(T& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm, std::integral_constant); + Dune::MPIHelper::MPICommunicator comm, std::integral_constant) +{ +#if HAVE_MPI + MPI_Unpack(buffer.data(), buffer.size(), &position, &data, 1, + Dune::MPITraits::getType(), comm); +#else + (void) data; + (void) comm; + (void) buffer; + (void) position; +#endif +} template void unpack(T& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); + Dune::MPIHelper::MPICommunicator comm) +{ + unpack(data, buffer, position, comm, typename std::is_pod::type()); +} template void unpack(std::pair& data, std::vector& buffer, int& position,