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> 40 template <
class X,
class Y,
class CudaPreconditionerType,
class CPUMatrixType>
52 template <
typename... Args>
56 , m_underlyingPreconditioner(m_gpuMatrix, std::forward<Args>(args)...)
64 void pre([[maybe_unused]] X& x, [[maybe_unused]] Y& b)
override 66 static_assert(!detail::shouldCallPreconditionerPre<CudaPreconditionerType>(),
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 85 static_assert(!detail::shouldCallPreconditionerPost<CudaPreconditionerType>(),
86 "We currently do not support Preconditioner::post().");
91 Dune::SolverCategory::Category
category()
const override 93 return m_underlyingPreconditioner.category();
101 m_underlyingPreconditioner.update();
104 static constexpr
bool shouldCallPre()
106 return detail::shouldCallPreconditionerPost<CudaPreconditionerType>();
108 static constexpr
bool shouldCallPost()
110 return detail::shouldCallPreconditionerPre<CudaPreconditionerType>();
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;
127 #endif // OPM_PRECONDITIONERCPUMATRIXTOGPUMATRIX_HPP The GpuSparseMatrixWrapper Checks CUDA/HIP version and dispatches a version either using the old or t...
Definition: gpu_type_detection.hpp:32
X domain_type
The domain type of the preconditioner.
Definition: PreconditionerCPUMatrixToGPUMatrix.hpp:45
Convert a CPU matrix to a GPU matrix and use a CUDA preconditioner on the GPU.
Definition: PreconditionerCPUMatrixToGPUMatrix.hpp:41
void pre([[maybe_unused]] X &x, [[maybe_unused]] Y &b) override
Prepare the preconditioner.
Definition: PreconditionerCPUMatrixToGPUMatrix.hpp:64
Interface class adding the update() method to the preconditioner interface.
Definition: PreconditionerWithUpdate.hpp:33
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
void apply(X &v, const Y &d) override
Apply the preconditoner.
Definition: PreconditionerCPUMatrixToGPUMatrix.hpp:74
void post([[maybe_unused]] X &x) override
Clean up.
Definition: PreconditionerCPUMatrixToGPUMatrix.hpp:83
typename X::field_type field_type
The field type of the preconditioner.
Definition: PreconditionerCPUMatrixToGPUMatrix.hpp:49
A small, fixed‑dimension MiniVector class backed by std::array that can be used in both host and CUD...
Definition: AmgxInterface.hpp:37
void updateNonzeroValues(const MatrixType &matrix, bool copyNonZeroElementsDirectly=false)
updateNonzeroValues updates the non-zero values by using the non-zero values of the supplied matrix ...
Definition: GpuSparseMatrixWrapper.hpp:378
Dune::SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category)
Definition: PreconditionerCPUMatrixToGPUMatrix.hpp:91