19#ifndef OPM_PRECONDITIONERCPUMATRIXTOGPUMATRIX_HPP
20#define OPM_PRECONDITIONERCPUMATRIXTOGPUMATRIX_HPP
21#include "opm/simulators/linalg/gpuistl/GpuSparseMatrixWrapper.hpp"
22#include <dune/istl/preconditioner.hh>
23#include <opm/simulators/linalg/PreconditionerWithUpdate.hpp>
24#include <opm/simulators/linalg/gpuistl/GpuVector.hpp>
25#include <opm/simulators/linalg/gpuistl/PreconditionerHolder.hpp>
26#include <opm/simulators/linalg/gpuistl/detail/preconditioner_should_call_post_pre.hpp>
40template <
class X,
class Y,
class CudaPreconditionerType,
class CPUMatrixType>
52 template <
typename... Args>
53 explicit PreconditionerCPUMatrixToGPUMatrix(
const CPUMatrixType& A, Args&&... args)
56 , m_underlyingPreconditioner(m_gpuMatrix, std::forward<Args>(args)...)
64 void pre([[maybe_unused]] X& x, [[maybe_unused]] Y& b)
override
67 "We currently do not support Preconditioner::pre().");
74 void apply(X& v,
const Y& d)
override
76 m_underlyingPreconditioner.apply(v, d);
83 void post([[maybe_unused]] X& x)
override
86 "We currently do not support Preconditioner::post().");
91 Dune::SolverCategory::Category
category()
const override
93 return m_underlyingPreconditioner.category();
100 m_gpuMatrix.updateNonzeroValues(m_cpuMatrix,
true);
101 m_underlyingPreconditioner.update();
104 static constexpr bool shouldCallPre()
108 static constexpr bool shouldCallPost()
113 virtual bool hasPerfectUpdate()
const override
115 return m_underlyingPreconditioner.hasPerfectUpdate();
119 const CPUMatrixType& m_cpuMatrix;
120 GpuSparseMatrixWrapper<field_type> m_gpuMatrix;
123 CudaPreconditionerType m_underlyingPreconditioner;
Interface class adding the update() method to the preconditioner interface.
Definition PreconditionerWithUpdate.hpp:34
The GpuSparseMatrixWrapper Checks CUDA/HIP version and dispatches a version either using the old or t...
Definition GpuSparseMatrixWrapper.hpp:62
void pre(X &x, Y &b) override
Prepare the preconditioner.
Definition PreconditionerCPUMatrixToGPUMatrix.hpp:64
void apply(X &v, const Y &d) override
Apply the preconditoner.
Definition PreconditionerCPUMatrixToGPUMatrix.hpp:74
void post(X &x) override
Clean up.
Definition PreconditionerCPUMatrixToGPUMatrix.hpp:83
Dune::SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category).
Definition PreconditionerCPUMatrixToGPUMatrix.hpp:91
void update() override
Copies the CPU matrix to the GPU matrix then calls the GPU preconditioner update function.
Definition PreconditionerCPUMatrixToGPUMatrix.hpp:98
Y range_type
The range type of the preconditioner.
Definition PreconditionerCPUMatrixToGPUMatrix.hpp:47
X domain_type
The domain type of the preconditioner.
Definition PreconditionerCPUMatrixToGPUMatrix.hpp:45
typename X::field_type field_type
The field type of the preconditioner.
Definition PreconditionerCPUMatrixToGPUMatrix.hpp:49
constexpr bool shouldCallPreconditionerPost()
Tests (compile time) if the preconditioner type needs to call post() after a call to apply(....
Definition preconditioner_should_call_post_pre.hpp:52
constexpr bool shouldCallPreconditionerPre()
Tests (compile time) if the preconditioner type needs to call pre() before a call to apply().
Definition preconditioner_should_call_post_pre.hpp:34
A small, fixed‑dimension MiniVector class backed by std::array that can be used in both host and CUDA...
Definition AmgxInterface.hpp:38