opm-simulators
hipKernels.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_HIPKERNELS_HPP
21 #define OPM_HIPKERNELS_HPP
22 
23 #include <string>
24 #include <memory>
25 #include <cstddef>
26 
27 #include <hip/hip_runtime_api.h>
28 #include <hip/hip_version.h>
29 
30 namespace Opm {
31 
32 template<class Scalar>
34 {
35 private:
36  static int verbosity;
37  static bool initialized;
38 
39  HipKernels();
40 
41 public:
44  static void init(int verbosity);
45 
52  static void full_to_pressure_restriction(const Scalar* fine_y,
53  Scalar* weights,
54  Scalar* coarse_y,
55  int Nb,
56  hipStream_t stream);
57 
64  static void add_coarse_pressure_correction(Scalar* coarse_x,
65  Scalar* fine_x,
66  int pressure_idx,
67  int Nb,
68  hipStream_t stream);
69 
70 
78  static void vmul(const Scalar alpha,
79  Scalar* in1,
80  Scalar* in2,
81  Scalar* out,
82  int N,
83  hipStream_t stream);
84 
91  static void prolongate_vector(const Scalar* in,
92  Scalar* out,
93  const int* cols,
94  int N,
95  hipStream_t stream);
96 
107  static void residual(Scalar* vals,
108  int* cols,
109  int* rows,
110  Scalar* x,
111  const Scalar* rhs,
112  Scalar* out,
113  int Nb,
114  unsigned int block_size,
115  hipStream_t stream);
116 
126  static void spmv(Scalar* vals,
127  int* cols,
128  int* rows,
129  Scalar* x,
130  Scalar* y,
131  int Nb,
132  unsigned int block_size,
133  hipStream_t stream);
134 };
135 
136 } // namespace Opm
137 
138 #endif
static void add_coarse_pressure_correction(Scalar *coarse_x, Scalar *fine_x, int pressure_idx, int Nb, hipStream_t stream)
Add the coarse pressure solution back to the finer, complete solution; every workitem handles one blo...
Definition: hipKernels.cpp:364
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45
static void prolongate_vector(const Scalar *in, Scalar *out, const int *cols, int N, hipStream_t stream)
Function to prolongate vector during amg cycle, every workitem handles one row.
Definition: hipKernels.cpp:392
static void residual(Scalar *vals, int *cols, int *rows, Scalar *x, const Scalar *rhs, Scalar *out, int Nb, unsigned int block_size, hipStream_t stream)
Function to perform res = rhs - mat * x.
Definition: hipKernels.cpp:422
static void vmul(const Scalar alpha, Scalar *in1, Scalar *in2, Scalar *out, int N, hipStream_t stream)
Function to multiply vector with another vector and a scalar, element-wise and add the result to a th...
Definition: hipKernels.cpp:307
static void spmv(Scalar *vals, int *cols, int *rows, Scalar *x, Scalar *y, int Nb, unsigned int block_size, hipStream_t stream)
Function to perform sparse matrix vector multipliation.
Definition: hipKernels.cpp:461
static void init(int verbosity)
Initialize verbosity level for the HIP kernels.
Definition: hipKernels.cpp:293
static void full_to_pressure_restriction(const Scalar *fine_y, Scalar *weights, Scalar *coarse_y, int Nb, hipStream_t stream)
Transform blocked vector to scalar vector using pressure-weights, where every workitem handles one bl...
Definition: hipKernels.cpp:336
Definition: hipKernels.hpp:33