opm-simulators
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 
25 namespace Opm::Accelerator {
26 
27 template<class Scalar> class Matrix;
28 template<class Scalar> class BlockedMatrix;
29 
31 template<class Scalar>
32 class RocmMatrix {
33 public:
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 
57 template <typename Scalar>
58 class RocmVector {
59 public:
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
Definition: rocsparseMatrix.hpp:58
Definition: amgclSolverBackend.cpp:49
This struct resembles a csr matrix.
Definition: rocsparseMatrix.hpp:32
This struct resembles a blocked csr matrix, like Dune::BCRSMatrix.
Definition: BlockedMatrix.hpp:28
This struct resembles a csr matrix, only doubles are supported The data is stored in contiguous memor...
Definition: Matrix.hpp:33