My Project
Loading...
Searching...
No Matches
rocsparseBILU0.hpp
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
23#include <opm/simulators/linalg/bda/BlockedMatrix.hpp>
24
25#include <opm/simulators/linalg/bda/rocm/rocsparsePreconditioner.hpp>
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
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
74 bool analyze_matrix(BlockedMatrix<Scalar> *mat) override;
75
80 BlockedMatrix<Scalar> *jacMat) override;
81
85
90 BlockedMatrix<Scalar> *jacMat) override;
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
This struct resembles a blocked csr matrix, like Dune::BCRSMatrix.
Definition BlockedMatrix.hpp:29
This class implements a Blocked ILU0 preconditioner The decomposition is done on GPU,...
Definition rocsparseBILU0.hpp:39
void apply(Scalar &y, Scalar &x) override
Apply preconditioner, x = prec(y) via Lz = y and Ux = z.
Definition rocsparseBILU0.cpp:329
bool create_preconditioner(BlockedMatrix< Scalar > *mat) override
ILU decomposition.
Definition rocsparseBILU0.cpp:222
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...
Definition rocsparseBILU0.cpp:300
bool initialize(std::shared_ptr< BlockedMatrix< Scalar > > matrix, std::shared_ptr< BlockedMatrix< Scalar > > jacMatrix, rocsparse_int *d_Arows, rocsparse_int *d_Acols) override
Initialize GPU and allocate memory.
Definition rocsparseBILU0.cpp:55
bool analyze_matrix(BlockedMatrix< Scalar > *mat) override
Analysis, extract parallelism if specified.
Definition rocsparseBILU0.cpp:89
void copy_system_to_gpu(Scalar *mVals) override
Copy matrix A values to GPU.
Definition rocsparseBILU0.cpp:268
Definition rocsparsePreconditioner.hpp:33
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242