OpenclMatrix.hpp
Go to the documentation of this file.
1/*
2 Copyright 2021 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_OPENCLMATRIX_HEADER_INCLUDED
21#define OPM_OPENCLMATRIX_HEADER_INCLUDED
22
23#include <vector>
24
26
27namespace Opm
28{
29namespace Accelerator
30{
31
32template<class Scalar> class Matrix;
33template<class Scalar> class BlockedMatrix;
34
37template<class Scalar>
39{
40public:
41 OpenclMatrix(cl::Context *context, int Nb_, int Mb_, int nnzbs_, unsigned int block_size_)
42 : Nb(Nb_),
43 Mb(Mb_),
44 nnzbs(nnzbs_),
45 block_size(block_size_)
46 {
47 nnzValues = cl::Buffer(*context, CL_MEM_READ_WRITE,
48 sizeof(Scalar) * block_size * block_size * nnzbs);
49 colIndices = cl::Buffer(*context, CL_MEM_READ_WRITE, sizeof(int) * nnzbs);
50 rowPointers = cl::Buffer(*context, CL_MEM_READ_WRITE, sizeof(int) * (Nb + 1));
51 }
52
53 void upload(cl::CommandQueue* queue, Scalar* vals, int* cols, int* rows);
54 void upload(cl::CommandQueue* queue, Matrix<Scalar>* matrix);
55 void upload(cl::CommandQueue* queue, BlockedMatrix<Scalar>* matrix);
56
57 cl::Buffer nnzValues;
58 cl::Buffer colIndices;
59 cl::Buffer rowPointers;
60 int Nb, Mb;
61 int nnzbs;
62 unsigned int block_size;
63};
64
65} // namespace Accelerator
66} // namespace Opm
67
68#endif // OPM_OPENCLMATRIX_HEADER_INCLUDED
Definition: BlockedMatrix.hpp:29
Definition: Matrix.hpp:34
Definition: OpenclMatrix.hpp:39
int nnzbs
Definition: OpenclMatrix.hpp:61
int Mb
Definition: OpenclMatrix.hpp:60
OpenclMatrix(cl::Context *context, int Nb_, int Mb_, int nnzbs_, unsigned int block_size_)
Definition: OpenclMatrix.hpp:41
cl::Buffer nnzValues
Definition: OpenclMatrix.hpp:57
cl::Buffer rowPointers
Definition: OpenclMatrix.hpp:59
unsigned int block_size
Definition: OpenclMatrix.hpp:62
void upload(cl::CommandQueue *queue, Scalar *vals, int *cols, int *rows)
cl::Buffer colIndices
Definition: OpenclMatrix.hpp:58
void upload(cl::CommandQueue *queue, BlockedMatrix< Scalar > *matrix)
int Nb
Definition: OpenclMatrix.hpp:60
void upload(cl::CommandQueue *queue, Matrix< Scalar > *matrix)
Definition: blackoilboundaryratevector.hh:37