From cd63cc83c2c88560d25d245195f1b4a70a0e3296 Mon Sep 17 00:00:00 2001 From: Razvan Nane Date: Thu, 26 Oct 2023 06:40:06 +0200 Subject: [PATCH] Remove redundant cpu decomposition when using gpu --- opm/simulators/linalg/ISTLSolverEbos.hpp | 21 ++++++++++++++------- opm/simulators/linalg/ISTLSolverEbosBda.hpp | 10 +++++++++- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/opm/simulators/linalg/ISTLSolverEbos.hpp b/opm/simulators/linalg/ISTLSolverEbos.hpp index 59fdb3871..de72f0431 100644 --- a/opm/simulators/linalg/ISTLSolverEbos.hpp +++ b/opm/simulators/linalg/ISTLSolverEbos.hpp @@ -306,14 +306,8 @@ std::unique_ptr blockJacobiAdjacency(const Grid& grid, return flexibleSolver_.size(); } - void prepare(const SparseMatrixAdapter& M, Vector& b) + void initPrepare(const Matrix& M, Vector& b) { - prepare(M.istlMatrix(), b); - } - - void prepare(const Matrix& M, Vector& b) - { - OPM_TIMEBLOCK(istlSolverEbosPrepare); const bool firstcall = (matrix_ == nullptr); #if HAVE_MPI if (firstcall && isParallel()) { @@ -344,6 +338,19 @@ std::unique_ptr blockJacobiAdjacency(const Grid& grid, if (isParallel() && prm_[activeSolverNum_].template get("preconditioner.type") != "ParOverILU0") { detail::makeOverlapRowsInvalid(getMatrix(), overlapRows_); } + } + + void prepare(const SparseMatrixAdapter& M, Vector& b) + { + prepare(M.istlMatrix(), b); + } + + void prepare(const Matrix& M, Vector& b) + { + OPM_TIMEBLOCK(istlSolverEbosPrepare); + + initPrepare(M,b); + prepareFlexibleSolver(); } diff --git a/opm/simulators/linalg/ISTLSolverEbosBda.hpp b/opm/simulators/linalg/ISTLSolverEbosBda.hpp index 6eaff0218..1f086eb7a 100644 --- a/opm/simulators/linalg/ISTLSolverEbosBda.hpp +++ b/opm/simulators/linalg/ISTLSolverEbosBda.hpp @@ -182,7 +182,15 @@ public: { OPM_TIMEBLOCK(prepare); [[maybe_unused]] const bool firstcall = (this->matrix_ == nullptr); - ParentType::prepare(M,b); + + // Avoid performing the decomposition on CPU when we also do it on GPU, but we do + // need to initialize the pointers. + if(bdaBridge_){ + ParentType::initPrepare(M,b); + } + else { + ParentType::prepare(M,b); + } #if HAVE_OPENCL // update matrix entries for solvers.