From 167e1f413a77b306578b033c67bfddbd18942ba0 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 7 Aug 2024 11:18:42 +0200 Subject: [PATCH 1/2] Bda: add missing override specifiers --- opm/simulators/linalg/bda/Preconditioner.hpp | 2 ++ opm/simulators/linalg/bda/opencl/openclBILU0.hpp | 6 +++--- opm/simulators/linalg/bda/opencl/openclBISAI.hpp | 2 +- opm/simulators/linalg/bda/opencl/openclCPR.hpp | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/opm/simulators/linalg/bda/Preconditioner.hpp b/opm/simulators/linalg/bda/Preconditioner.hpp index 93031dbe7..10901f4b8 100644 --- a/opm/simulators/linalg/bda/Preconditioner.hpp +++ b/opm/simulators/linalg/bda/Preconditioner.hpp @@ -24,6 +24,8 @@ #include #endif +#include + namespace Opm::Accelerator { enum PreconditionerType { diff --git a/opm/simulators/linalg/bda/opencl/openclBILU0.hpp b/opm/simulators/linalg/bda/opencl/openclBILU0.hpp index f52badbad..149212b78 100644 --- a/opm/simulators/linalg/bda/opencl/openclBILU0.hpp +++ b/opm/simulators/linalg/bda/opencl/openclBILU0.hpp @@ -20,14 +20,14 @@ #ifndef OPM_OPENCLBILU0_HPP #define OPM_OPENCLBILU0_HPP -#include - #include #include #include #include +#include +#include namespace Opm::Accelerator { @@ -103,7 +103,7 @@ public: // via Lz = y // and Ux = z void apply(const cl::Buffer& y, cl::Buffer& x) override; - void apply(Scalar&, Scalar&) {} + void apply(Scalar&, Scalar&) override {} std::tuple, std::vector, std::vector> get_preconditioner_structure() diff --git a/opm/simulators/linalg/bda/opencl/openclBISAI.hpp b/opm/simulators/linalg/bda/opencl/openclBISAI.hpp index 5bb524f40..275fabf98 100644 --- a/opm/simulators/linalg/bda/opencl/openclBISAI.hpp +++ b/opm/simulators/linalg/bda/opencl/openclBISAI.hpp @@ -125,7 +125,7 @@ public: // apply preconditioner, x = prec(y) void apply(const cl::Buffer& y, cl::Buffer& x) override; - void apply(Scalar&, Scalar&) {} + void apply(Scalar&, Scalar&) override {} }; /// Similar function to csrPatternToCsc. It gives an offset map from CSR to CSC instead of the full CSR to CSC conversion. diff --git a/opm/simulators/linalg/bda/opencl/openclCPR.hpp b/opm/simulators/linalg/bda/opencl/openclCPR.hpp index bf5a75a13..9fc1fe7cd 100644 --- a/opm/simulators/linalg/bda/opencl/openclCPR.hpp +++ b/opm/simulators/linalg/bda/opencl/openclCPR.hpp @@ -95,7 +95,7 @@ public: // applies blocked ilu0 // also applies amg for pressure component void apply(const cl::Buffer& y, cl::Buffer& x) override; - void apply(Scalar&, Scalar&) {} + void apply(Scalar&, Scalar&) override {} bool create_preconditioner(BlockedMatrix* mat) override; bool create_preconditioner(BlockedMatrix* mat, From f310698fef40991f8df13d10356fae3c6d011488 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 7 Aug 2024 11:19:05 +0200 Subject: [PATCH 2/2] MPIPacker: move function definition to cpp file --- opm/simulators/utils/MPIPacker.cpp | 19 +++++++++++++------ opm/simulators/utils/MPIPacker.hpp | 18 ++++++------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/opm/simulators/utils/MPIPacker.cpp b/opm/simulators/utils/MPIPacker.cpp index 430a10b26..f0c502265 100644 --- a/opm/simulators/utils/MPIPacker.cpp +++ b/opm/simulators/utils/MPIPacker.cpp @@ -25,13 +25,22 @@ #include #include #include +#include #include #include -namespace Opm { -namespace Mpi { -namespace detail { +namespace Opm::Mpi::detail { + +std::size_t mpi_buffer_size(const std::size_t bufsize, const std::size_t position) +{ + if (bufsize < position) { + throw std::invalid_argument("Buffer size should never be less than position!"); + } + + return std::min(bufsize - position, + static_cast(std::numeric_limits::max())); +} template std::size_t Packing>:: @@ -139,6 +148,4 @@ template struct Packing>; constexpr int NumFip = static_cast(FIPConfig::OutputField::NUM_FIP_REPORT); template struct Packing>; -} // end namespace detail -} // end namespace Mpi -} // end namespace Opm +} // end namespace Opm::Mpi::detail diff --git a/opm/simulators/utils/MPIPacker.hpp b/opm/simulators/utils/MPIPacker.hpp index cd4406280..30606a4cd 100644 --- a/opm/simulators/utils/MPIPacker.hpp +++ b/opm/simulators/utils/MPIPacker.hpp @@ -30,17 +30,11 @@ #include -namespace Opm { -namespace Mpi { +namespace Opm::Mpi { + namespace detail { -static std::size_t mpi_buffer_size(const std::size_t bufsize, const std::size_t position) { - if (bufsize < position) - throw std::invalid_argument("Buffer size should never be less than position!"); - - return static_cast(std::min(bufsize-position, - static_cast(std::numeric_limits::max()))); -} +std::size_t mpi_buffer_size(const std::size_t bufsize, const std::size_t position); //! \brief Abstract struct for packing which is (partially) specialized for specific types. template @@ -190,7 +184,8 @@ ADD_PACK_SPECIALIZATION(time_point) } //! \brief Struct handling packing of serialization for MPI communication. -struct Packer { +struct Packer +{ //! \brief Constructor. //! \param comm The communicator to use Packer(Parallel::Communication comm) @@ -279,7 +274,6 @@ private: Parallel::Communication m_comm; //!< Communicator to use }; -} // end namespace Mpi -} // end namespace Opm +} // end namespace Opm::Mpi #endif // MPI_PACKER_HPP