opm-simulators
Toggle main menu visibility
Loading...
Searching...
No Matches
OpenclMatrix.hpp
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
25
#include <opm/simulators/linalg/gpubridge/opencl/opencl.hpp>
26
27
namespace
Opm
28
{
29
namespace
Accelerator
30
{
31
32
template
<
class
Scalar>
class
Matrix
;
33
template
<
class
Scalar>
class
BlockedMatrix
;
34
37
template
<
class
Scalar>
38
class
OpenclMatrix
39
{
40
public
:
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
Opm::Accelerator::BlockedMatrix
This struct resembles a blocked csr matrix, like Dune::BCRSMatrix.
Definition
BlockedMatrix.hpp:29
Opm::Accelerator::Matrix
This struct resembles a csr matrix, only doubles are supported The data is stored in contiguous memor...
Definition
Matrix.hpp:34
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition
blackoilbioeffectsmodules.hh:43
opm
simulators
linalg
gpubridge
opencl
OpenclMatrix.hpp
Generated by
1.17.0