opm-simulators
openclPreconditioner.hpp
1 /*
2  Copyright 2021 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_OPENCLPRECONDITIONER_HEADER_INCLUDED
21 #define OPM_OPENCLPRECONDITIONER_HEADER_INCLUDED
22 
23 #include <opm/simulators/linalg/gpubridge/opencl/opencl.hpp>
24 #include <opm/simulators/linalg/gpubridge/Preconditioner.hpp>
25 
26 namespace Opm::Accelerator {
27 
28 template<class Scalar> class BlockedMatrix;
29 
30 template <class Scalar, unsigned int block_size>
31 class openclPreconditioner : public Preconditioner<Scalar, block_size, cl::Buffer>
32 {
33 
34 protected:
35  std::shared_ptr<cl::Context> context;
36  std::shared_ptr<cl::CommandQueue> queue;
37  std::vector<cl::Event> events;
38  cl_int err;
39 
40  openclPreconditioner(int verbosity_)
42  {}
43 
44 public:
45  virtual ~openclPreconditioner() = default;
46 
47  static std::unique_ptr<openclPreconditioner<Scalar, block_size>> create(PreconditionerType type,
48  int verbosity,
49  bool opencl_ilu_parallel);
50 
51  // nested Preconditioners might need to override this
52  virtual void setOpencl(std::shared_ptr<cl::Context>& context,
53  std::shared_ptr<cl::CommandQueue>& queue);
54 };
55 } //namespace Opm
56 
57 #endif
Definition: openclPreconditioner.hpp:31
Definition: amgclSolverBackend.cpp:49
Definition: Preconditioner.hpp:42