20 #ifndef OPM_OPENCLSOLVER_BACKEND_HEADER_INCLUDED 21 #define OPM_OPENCLSOLVER_BACKEND_HEADER_INCLUDED 23 #include <opm/simulators/linalg/gpubridge/opencl/opencl.hpp> 24 #include <opm/simulators/linalg/gpubridge/GpuResult.hpp> 25 #include <opm/simulators/linalg/gpubridge/GpuSolver.hpp> 26 #include <opm/simulators/linalg/gpubridge/WellContributions.hpp> 28 #include <opm/simulators/linalg/gpubridge/opencl/openclPreconditioner.hpp> 33 template<
class Scalar,
unsigned int block_size>
42 using Base::verbosity;
43 using Base::platformID;
46 using Base::tolerance;
47 using Base::initialized;
50 Scalar* h_b =
nullptr;
51 std::vector<Scalar> vals_contiguous;
54 cl::Buffer d_Avals, d_Acols, d_Arows;
55 cl::Buffer d_x, d_b, d_rb, d_r, d_rw, d_p;
56 cl::Buffer d_pw, d_s, d_t, d_v;
59 std::vector<cl::Device> devices;
61 bool useJacMatrix =
false;
63 std::unique_ptr<openclPreconditioner<Scalar,block_size>> prec;
66 bool analysis_done =
false;
67 std::shared_ptr<BlockedMatrix<Scalar>> mat{};
68 std::shared_ptr<BlockedMatrix<Scalar>> jacMat{};
69 bool opencl_ilu_parallel;
70 std::vector<cl::Event> events;
85 void copy_system_to_gpu();
90 void update_system(Scalar* vals, Scalar* b);
93 void update_system_on_gpu();
97 bool analyze_matrix();
101 bool create_preconditioner();
110 std::shared_ptr<cl::Context> context{};
111 std::shared_ptr<cl::CommandQueue> queue{};
123 unsigned int platformID,
unsigned int deviceID,
124 bool opencl_ilu_parallel, std::string linsolver);
128 Scalar tolerance,
bool opencl_ilu_parallel);
155 void setOpencl(std::shared_ptr<cl::Context>& context,
156 std::shared_ptr<cl::CommandQueue>& queue);
Definition: amgclSolverBackend.cpp:49
This class implements a opencl-based ilu0-bicgstab solver on GPU.
Definition: openclSolverBackend.hpp:34
This class is based on InverseOperatorResult struct from dune/istl/solver.hh It is needed to prevent ...
Definition: GpuResult.hpp:30
This class serves to eliminate the need to include the WellContributions into the matrix (with –matr...
Definition: GpuBridge.hpp:30
openclSolverBackend(int linear_solver_verbosity, int maxit, Scalar tolerance, unsigned int platformID, unsigned int deviceID, bool opencl_ilu_parallel, std::string linsolver)
Construct a openclSolver.
Definition: openclSolverBackend.cpp:46
void get_result(Scalar *x) override
Solve scalar linear system, for example a coarse system of an AMG preconditioner Data is already on t...
Definition: openclSolverBackend.cpp:666
This struct resembles a blocked csr matrix, like Dune::BCRSMatrix.
Definition: BlockedMatrix.hpp:28
This class serves to simplify choosing between different backend solvers, such as cusparseSolver and ...
Definition: GpuSolver.hpp:45
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:241