20#ifndef OPM_OPENCLSOLVER_BACKEND_HEADER_INCLUDED
21#define OPM_OPENCLSOLVER_BACKEND_HEADER_INCLUDED
23#include <opm/simulators/linalg/bda/opencl/opencl.hpp>
24#include <opm/simulators/linalg/bda/BdaResult.hpp>
25#include <opm/simulators/linalg/bda/BdaSolver.hpp>
26#include <opm/simulators/linalg/bda/WellContributions.hpp>
28#include <opm/simulators/linalg/bda/opencl/Preconditioner.hpp>
36template <
unsigned int block_size>
45 using Base::verbosity;
46 using Base::platformID;
49 using Base::tolerance;
50 using Base::initialized;
53 double *h_b =
nullptr;
54 std::vector<double> vals_contiguous;
57 cl::Buffer d_Avals, d_Acols, d_Arows;
58 cl::Buffer d_x, d_b, d_rb, d_r, d_rw, d_p;
59 cl::Buffer d_pw, d_s, d_t, d_v;
62 std::vector<cl::Device> devices;
64 bool useJacMatrix =
false;
66 std::unique_ptr<Preconditioner<block_size> > prec;
69 bool analysis_done =
false;
70 std::shared_ptr<BlockedMatrix> mat =
nullptr;
71 std::shared_ptr<BlockedMatrix> jacMat =
nullptr;
72 bool opencl_ilu_parallel;
73 std::vector<cl::Event> events;
84 void initialize(std::shared_ptr<BlockedMatrix> matrix, std::shared_ptr<BlockedMatrix> jacMatrix);
87 void copy_system_to_gpu();
92 void update_system(
double *vals,
double *b);
95 void update_system_on_gpu();
99 bool analyze_matrix();
103 bool create_preconditioner();
112 std::shared_ptr<cl::Context> context;
113 std::shared_ptr<cl::CommandQueue> queue;
124 openclSolverBackend(
int linear_solver_verbosity,
int maxit,
double tolerance,
unsigned int platformID,
unsigned int deviceID,
125 bool opencl_ilu_parallel, std::string linsolver);
128 openclSolverBackend(
int linear_solver_verbosity,
int maxit,
double tolerance,
bool opencl_ilu_parallel);
137 SolverStatus solve_system(std::shared_ptr<BlockedMatrix> matrix,
double *b,
152 void setOpencl(std::shared_ptr<cl::Context>& context, std::shared_ptr<cl::CommandQueue>& queue);
This class is based on InverseOperatorResult struct from dune/istl/solver.hh It is needed to prevent ...
Definition: BdaResult.hpp:31
This class serves to simplify choosing between different backend solvers, such as cusparseSolver and ...
Definition: BdaSolver.hpp:46
This class implements a opencl-based ilu0-bicgstab solver on GPU.
Definition: openclSolverBackend.hpp:38
void get_result(double *x) override
Solve scalar linear system, for example a coarse system of an AMG preconditioner Data is already on t...
Definition: openclSolverBackend.cpp:628
openclSolverBackend(int linear_solver_verbosity, int maxit, double tolerance, unsigned int platformID, unsigned int deviceID, bool opencl_ilu_parallel, std::string linsolver)
Construct a openclSolver.
Definition: openclSolverBackend.cpp:49
void setOpencl(std::shared_ptr< cl::Context > &context, std::shared_ptr< cl::CommandQueue > &queue)
Set OpenCL objects This class either creates them based on platformID and deviceID or receives them t...
Definition: openclSolverBackend.cpp:229
This class serves to eliminate the need to include the WellContributions into the matrix (with –matri...
Definition: WellContributions.hpp:52
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:27