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
25
27
28#include <rocblas/rocblas.h>
29#include <rocsparse/rocsparse.h>
30
31#include <hip/hip_version.h>
32
33namespace Opm::Accelerator {
34
38template <class Scalar, unsigned int block_size>
39class rocsparseBILU0 : public rocsparsePreconditioner<Scalar, block_size>
40{
42
43 using Base::N;
44 using Base::Nb;
45 using Base::nnz;
46 using Base::nnzb;
47 using Base::verbosity;
48
49private:
50
51 rocsparse_mat_descr descr_M, descr_L, descr_U;
52 rocsparse_mat_info ilu_info;
53#if HIP_VERSION >= 50400000
54 rocsparse_mat_info spmv_info;
55#endif
56
57 rocsparse_int *d_Mrows, *d_Mcols;
58 Scalar *d_Mvals, *d_t;
59 void *d_buffer; // buffer space, used by rocsparse ilu0 analysis
60
61 std::size_t d_bufferSize_M=0, d_bufferSize_L=0, d_bufferSize_U=0, d_bufferSize=0;
62
63public:
64
65 rocsparseBILU0(int verbosity_);
67
73 bool initialize(std::shared_ptr<BlockedMatrix<Scalar>> matrix,
74 std::shared_ptr<BlockedMatrix<Scalar>> jacMatrix,
75 rocsparse_int *d_Arows,
76 rocsparse_int *d_Acols) override;
77
80
84
90
94
100
107 void apply(const Scalar& y,
108 Scalar& x,
109 WellContributions<Scalar>& wellContribs) override;
110
113 void copy_system_to_gpu(Scalar *mVals) override;
114
120 void copy_values_to_gpu(Scalar *mVals, int *mRows, int *mCols, bool reuse);
121
124 void update_system_on_gpu(Scalar*, Scalar* b) override;
125
126};
127} // namespace Opm
128
129#endif
130
Definition: BlockedMatrix.hpp:29
int nnzb
Definition: Preconditioner.hpp:48
int Nb
Definition: Preconditioner.hpp:46
int N
Definition: Preconditioner.hpp:45
int nnz
Definition: Preconditioner.hpp:47
int verbosity
Definition: Preconditioner.hpp:49
Definition: rocsparseBILU0.hpp:40
bool analyze_matrix(BlockedMatrix< Scalar > *mat, BlockedMatrix< Scalar > *jacMat) override
bool create_preconditioner(BlockedMatrix< Scalar > *mat) override
void apply(const Scalar &y, Scalar &x, WellContributions< Scalar > &wellContribs) override
bool create_preconditioner(BlockedMatrix< Scalar > *mat, BlockedMatrix< Scalar > *jacMat) override
void copy_values_to_gpu(Scalar *mVals, int *mRows, int *mCols, bool reuse)
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
bool analyze_matrix()
Analysis, extract parallelism if specified.
void copy_system_to_gpu(Scalar *mVals) override
void update_system_on_gpu(Scalar *, Scalar *b) override
Definition: rocsparsePreconditioner.hpp:34
std::shared_ptr< BlockedMatrix< Scalar > > jacMat
Definition: rocsparsePreconditioner.hpp:53
Definition: WellContributions.hpp:51
Definition: amgclSolverBackend.hpp:44