Loading...
Searching...
No Matches
rocsparseBILU0.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_ROCSPARSEBILU0_HPP
#define OPM_ROCSPARSEBILU0_HPP
#include <opm/simulators/linalg/gpubridge/BlockedMatrix.hpp>
#include <opm/simulators/linalg/gpubridge/WellContributions.hpp>
#include <opm/simulators/linalg/gpubridge/rocm/rocsparsePreconditioner.hpp>
#include <rocblas/rocblas.h>
#include <rocsparse/rocsparse.h>
#include <hip/hip_version.h>
namespace Opm::Accelerator {
template <class Scalar, unsigned int block_size>
class rocsparseBILU0 : public rocsparsePreconditioner<Scalar, block_size>
{
typedef rocsparsePreconditioner<Scalar, block_size> Base;
using Base::N;
using Base::Nb;
using Base::nnz;
using Base::nnzb;
using Base::verbosity;
private:
rocsparse_mat_descr descr_M, descr_L, descr_U;
rocsparse_mat_info ilu_info;
#if HIP_VERSION >= 50400000
rocsparse_mat_info spmv_info;
#endif
rocsparse_int *d_Mrows, *d_Mcols;
Scalar *d_Mvals, *d_t;
void *d_buffer; // buffer space, used by rocsparse ilu0 analysis
std::size_t d_bufferSize_M=0, d_bufferSize_L=0, d_bufferSize_U=0, d_bufferSize=0;
public:
rocsparseBILU0(int verbosity_);
~rocsparseBILU0();
bool initialize(std::shared_ptr<BlockedMatrix<Scalar>> matrix,
std::shared_ptr<BlockedMatrix<Scalar>> jacMatrix,
rocsparse_int *d_Arows,
rocsparse_int *d_Acols) override;
bool analyze_matrix();
bool analyze_matrix(BlockedMatrix<Scalar> *mat) override;
bool analyze_matrix(BlockedMatrix<Scalar> *mat,
BlockedMatrix<Scalar> *jacMat) override;
bool create_preconditioner(BlockedMatrix<Scalar> *mat) override;
bool create_preconditioner(BlockedMatrix<Scalar> *mat,
BlockedMatrix<Scalar> *jacMat) override;
void apply(const Scalar& y,
Scalar& x,
WellContributions<Scalar>& wellContribs) override;
void copy_system_to_gpu(Scalar *mVals) override;
void copy_values_to_gpu(Scalar *mVals, int *mRows, int *mCols, bool reuse);
void update_system_on_gpu(Scalar*, Scalar* b) override;
};
} // namespace Opm
#endif
Opm::Accelerator::BlockedMatrix
This struct resembles a blocked csr matrix, like Dune::BCRSMatrix.
Definition BlockedMatrix.hpp:29
Opm::Accelerator::rocsparseBILU0::create_preconditioner
bool create_preconditioner(BlockedMatrix< Scalar > *mat) override
ILU decomposition.
Definition rocsparseBILU0.cpp:328
Opm::Accelerator::rocsparseBILU0::apply
void apply(const Scalar &y, Scalar &x, WellContributions< Scalar > &wellContribs) override
Apply preconditioner, x = prec(y) via Lz = y and Ux = z.
Definition rocsparseBILU0.cpp:428
Opm::Accelerator::rocsparseBILU0::copy_values_to_gpu
void copy_values_to_gpu(Scalar *mVals, int *mRows, int *mCols, bool reuse)
Copy matrix A values to GPU.
Definition rocsparseBILU0.cpp:393
Opm::Accelerator::rocsparseBILU0::initialize
bool initialize(std::shared_ptr< BlockedMatrix< Scalar > > matrix, std::shared_ptr< BlockedMatrix< Scalar > > jacMatrix, rocsparse_int *d_Arows, rocsparse_int *d_Acols) override
Initialize GPU and allocate memory.
Definition rocsparseBILU0.cpp:75
Opm::Accelerator::rocsparseBILU0::analyze_matrix
bool analyze_matrix()
Analysis, extract parallelism if specified.
Definition rocsparseBILU0.cpp:124
Opm::Accelerator::rocsparseBILU0::copy_system_to_gpu
void copy_system_to_gpu(Scalar *mVals) override
Copy matrix A values to GPU.
Definition rocsparseBILU0.cpp:369
Opm::Accelerator::rocsparseBILU0::update_system_on_gpu
void update_system_on_gpu(Scalar *, Scalar *b) override
Update GPU values after a new assembly is done.
Definition rocsparseBILU0.cpp:406
Opm::WellContributions
This class serves to eliminate the need to include the WellContributions into the matrix (with –matri...
Definition WellContributions.hpp:51