Loading...
Searching...
No Matches
hipKernels.hpp
/*
Copyright 2024 Equinor ASA
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_HIPKERNELS_HPP
#define OPM_HIPKERNELS_HPP
#include <string>
#include <memory>
#include <cstddef>
#include <hip/hip_runtime_api.h>
#include <hip/hip_version.h>
namespace Opm {
template<class Scalar>
class HipKernels
{
private:
static int verbosity;
static bool initialized;
HipKernels();
public:
static void init(int verbosity);
static void full_to_pressure_restriction(const Scalar* fine_y,
Scalar* weights,
Scalar* coarse_y,
int Nb,
hipStream_t stream);
static void add_coarse_pressure_correction(Scalar* coarse_x,
Scalar* fine_x,
int pressure_idx,
int Nb,
hipStream_t stream);
static void vmul(const Scalar alpha,
Scalar* in1,
Scalar* in2,
Scalar* out,
int N,
hipStream_t stream);
static void prolongate_vector(const Scalar* in,
Scalar* out,
const int* cols,
int N,
hipStream_t stream);
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);
static void spmv(Scalar* vals,
int* cols,
int* rows,
Scalar* x,
Scalar* y,
int Nb,
unsigned int block_size,
hipStream_t stream);
};
} // namespace Opm
#endif
Opm::HipKernels::residual
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
Opm::HipKernels::vmul
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
Opm::HipKernels::prolongate_vector
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
Opm::HipKernels::spmv
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
Opm::HipKernels::add_coarse_pressure_correction
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
Opm::HipKernels::full_to_pressure_restriction
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
Opm::HipKernels::init
static void init(int verbosity)
Initialize verbosity level for the HIP kernels.
Definition hipKernels.cpp:293
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43