opm-simulators
Toggle main menu visibility
Loading...
Searching...
No Matches
rocsparsePreconditioner.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_ROCSPARSEPRECONDITIONER_HEADER_INCLUDED
21
#define OPM_ROCSPARSEPRECONDITIONER_HEADER_INCLUDED
22
23
#include <opm/simulators/linalg/gpubridge/Preconditioner.hpp>
24
25
#include <rocsparse/rocsparse.h>
26
#include <rocblas/rocblas.h>
27
28
namespace
Opm::Accelerator {
29
30
template
<
class
Scalar>
class
BlockedMatrix
;
31
32
template
<
class
Scalar,
unsigned
int
block_size>
33
class
rocsparsePreconditioner :
public
Preconditioner<Scalar, block_size>
34
{
35
36
protected
:
37
rocsparse_handle handle;
38
rocblas_handle blas_handle;
39
rocsparse_direction dir = rocsparse_direction_row;
40
rocsparse_operation operation = rocsparse_operation_none;
41
rocsparse_mat_descr descr_L, descr_U;
42
43
hipStream_t stream;
44
45
rocsparsePreconditioner(
int
verbosity_) :
46
Preconditioner<Scalar, block_size>(verbosity_)
47
{};
48
49
public
:
50
51
int
nnzbs_prec = 0;
// number of nnz blocks in preconditioner matrix M
52
bool
useJacMatrix =
false
;
53
std::shared_ptr<BlockedMatrix<Scalar>> jacMat{};
// matrix for preconditioner
54
55
virtual
~rocsparsePreconditioner() =
default
;
56
57
static
std::unique_ptr<rocsparsePreconditioner<Scalar, block_size>> create(PreconditionerType type,
58
int
verbosity);
59
60
virtual
bool
initialize(std::shared_ptr<
BlockedMatrix<Scalar>
> matrix,
61
std::shared_ptr<
BlockedMatrix<Scalar>
> jacMatrix,
62
rocsparse_int* d_Arows,
63
rocsparse_int* d_Acols) = 0;
64
65
virtual
void
copy_system_to_gpu(Scalar* b) = 0;
66
70
virtual
void
update_system_on_gpu
(Scalar* vals, Scalar* b)=0;
71
72
void
set_matrix_analysis(rocsparse_mat_descr descr_L,
73
rocsparse_mat_descr descr_U);
74
75
void
set_context(rocsparse_handle handle,
76
rocblas_handle blas_handle,
77
rocsparse_direction dir,
78
rocsparse_operation operation,
79
hipStream_t stream);
80
81
void
setJacMat(
const
BlockedMatrix<Scalar>
& jacMat);
82
};
83
}
//namespace Opm
84
85
#endif
Opm::Accelerator::BlockedMatrix
This struct resembles a blocked csr matrix, like Dune::BCRSMatrix.
Definition
BlockedMatrix.hpp:29
Opm::Accelerator::rocsparsePreconditioner::update_system_on_gpu
virtual void update_system_on_gpu(Scalar *vals, Scalar *b)=0
Update linear system to GPU.
opm
simulators
linalg
gpubridge
rocm
rocsparsePreconditioner.hpp
Generated by
1.17.0