opm-simulators
Loading...
Searching...
No Matches
rocsparseMatrix.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_ROCMMATRIX_HEADER_INCLUDED
21#define OPM_ROCMMATRIX_HEADER_INCLUDED
22
23#include <hip/hip_runtime_api.h>
24
25namespace Opm::Accelerator {
26
27template<class Scalar> class Matrix;
28template<class Scalar> class BlockedMatrix;
29
31template<class Scalar>
32class RocmMatrix {
33public:
34
35 RocmMatrix(int Nb_, int Mb_, int nnzbs_, unsigned int block_size_);
36 ~RocmMatrix();
37
38 void upload(Scalar *vals,
39 int *cols,
40 int *rows,
41 hipStream_t stream);
42
43 void upload(Matrix<Scalar> *matrix,
44 hipStream_t stream);
45
46 void upload(BlockedMatrix<Scalar> *matrix,
47 hipStream_t stream);
48
49 Scalar* nnzValues;
50 int* colIndices;
51 int* rowPointers;
52 int Nb, Mb;
53 int nnzbs;
54 unsigned int block_size;
55};
56
57template <typename Scalar>
58class RocmVector {
59public:
60
61 RocmVector(int N);
62 ~RocmVector();
63
64 void upload(Scalar *vals,
65 hipStream_t stream);
66
67 void upload(Matrix<Scalar> *matrix,
68 hipStream_t stream);
69
70 Scalar* nnzValues;
71 int size;
72};
73} // namespace Opm
74
75#endif
This struct resembles a blocked csr matrix, like Dune::BCRSMatrix.
Definition BlockedMatrix.hpp:29
This struct resembles a csr matrix, only doubles are supported The data is stored in contiguous memor...
Definition Matrix.hpp:34