rocsparseBILU0.hpp
Go to the documentation of this file.
1/*
2 Copyright 2024 Equinor ASA
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef OPM_ROCSPARSEBILU0_HPP
21#define OPM_ROCSPARSEBILU0_HPP
22
24
26
27#include <rocblas/rocblas.h>
28#include <rocsparse/rocsparse.h>
29
30#include <hip/hip_version.h>
31
32namespace Opm::Accelerator {
33
37template <class Scalar, unsigned int block_size>
38class rocsparseBILU0 : public rocsparsePreconditioner<Scalar, block_size>
39{
41
42 using Base::N;
43 using Base::Nb;
44 using Base::nnz;
45 using Base::nnzb;
46 using Base::verbosity;
47
48private:
49
50 rocsparse_mat_descr descr_M, descr_L, descr_U;
51 rocsparse_mat_info ilu_info;
52#if HIP_VERSION >= 50400000
53 rocsparse_mat_info spmv_info;
54#endif
55
56 rocsparse_int *d_Mrows, *d_Mcols;
57 Scalar *d_Mvals, *d_t;
58 void *d_buffer; // buffer space, used by rocsparse ilu0 analysis
59
60public:
61
62 rocsparseBILU0(int verbosity_);
63
67 bool initialize(std::shared_ptr<BlockedMatrix<Scalar>> matrix,
68 std::shared_ptr<BlockedMatrix<Scalar>> jacMatrix,
69 rocsparse_int *d_Arows,
70 rocsparse_int *d_Acols) override;
71
75
81
85
91
97 void apply(Scalar& y,
98 Scalar& x) override;
99
100#if HAVE_OPENCL
101 // apply preconditioner, x = prec(y)
102 void apply(const cl::Buffer&, cl::Buffer&) override {}
103#endif
104
107 void copy_system_to_gpu(Scalar *mVals) override;
108
110// /// \param[in] vals New values
111// /// \param[in] b New b vector
112// void update_system(Scalar *vals, Scalar *b);
113
116 void update_system_on_gpu(Scalar *b) override;
117};
118} // namespace Opm
119
120#endif
121
Definition: BlockedMatrix.hpp:29
int nnz
Definition: Preconditioner.hpp:45
int Nb
Definition: Preconditioner.hpp:44
int verbosity
Definition: Preconditioner.hpp:47
int nnzb
Definition: Preconditioner.hpp:46
int N
Definition: Preconditioner.hpp:43
Definition: rocsparseBILU0.hpp:39
bool analyze_matrix(BlockedMatrix< Scalar > *mat, BlockedMatrix< Scalar > *jacMat) override
void apply(Scalar &y, Scalar &x) override
bool create_preconditioner(BlockedMatrix< Scalar > *mat) override
bool create_preconditioner(BlockedMatrix< Scalar > *mat, BlockedMatrix< Scalar > *jacMat) override
void update_system_on_gpu(Scalar *b) override
Reassign pointers, in case the addresses of the Dune variables have changed --> TODO: check when/if w...
bool initialize(std::shared_ptr< BlockedMatrix< Scalar > > matrix, std::shared_ptr< BlockedMatrix< Scalar > > jacMatrix, rocsparse_int *d_Arows, rocsparse_int *d_Acols) override
bool analyze_matrix(BlockedMatrix< Scalar > *mat) override
void copy_system_to_gpu(Scalar *mVals) override
Definition: rocsparsePreconditioner.hpp:33
std::shared_ptr< BlockedMatrix< Scalar > > jacMat
Definition: rocsparsePreconditioner.hpp:51
Definition: amgclSolverBackend.hpp:44