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
32class Matrix;
33class BlockedMatrix;
34
38public:
39
40 OpenclMatrix(cl::Context *context, int Nb_, int Mb_, int nnzbs_, unsigned int block_size_)
41 : Nb(Nb_),
42 Mb(Mb_),
43 nnzbs(nnzbs_),
44 block_size(block_size_)
45 {
46 nnzValues = cl::Buffer(*context, CL_MEM_READ_WRITE, sizeof(double) * block_size * block_size * nnzbs);
47 colIndices = cl::Buffer(*context, CL_MEM_READ_WRITE, sizeof(int) * nnzbs);
48 rowPointers = cl::Buffer(*context, CL_MEM_READ_WRITE, sizeof(int) * (Nb + 1));
49 }
50
51 void upload(cl::CommandQueue *queue, double *vals, int *cols, int *rows);
52 void upload(cl::CommandQueue *queue, Matrix *matrix);
53 void upload(cl::CommandQueue *queue, BlockedMatrix *matrix);
54
55 cl::Buffer nnzValues;
56 cl::Buffer colIndices;
57 cl::Buffer rowPointers;
58 int Nb, Mb;
59 int nnzbs;
60 unsigned int block_size;
61};
62
63} // namespace Accelerator
64} // namespace Opm
65
66#endif // OPM_OPENCLMATRIX_HEADER_INCLUDED
Definition: BlockedMatrix.hpp:31
Definition: Matrix.hpp:32
Definition: OpenclMatrix.hpp:37
void upload(cl::CommandQueue *queue, double *vals, int *cols, int *rows)
cl::Buffer rowPointers
Definition: OpenclMatrix.hpp:57
cl::Buffer colIndices
Definition: OpenclMatrix.hpp:56
int Mb
Definition: OpenclMatrix.hpp:58
void upload(cl::CommandQueue *queue, BlockedMatrix *matrix)
cl::Buffer nnzValues
Definition: OpenclMatrix.hpp:55
unsigned int block_size
Definition: OpenclMatrix.hpp:60
void upload(cl::CommandQueue *queue, Matrix *matrix)
OpenclMatrix(cl::Context *context, int Nb_, int Mb_, int nnzbs_, unsigned int block_size_)
Definition: OpenclMatrix.hpp:40
int Nb
Definition: OpenclMatrix.hpp:58
int nnzbs
Definition: OpenclMatrix.hpp:59
Definition: BlackoilPhases.hpp:27