My Project
ChowPatelIlu.hpp
1 /*
2  Copyright 2020 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 CHOW_PATEL_ILU_HEADER_INCLUDED
21 #define CHOW_PATEL_ILU_HEADER_INCLUDED
22 
23 
24 #include <mutex>
25 
26 #include <opm/simulators/linalg/bda/opencl.hpp>
27 
28 
29 namespace bda
30 {
31 
32  // This class implements a blocked version on GPU of the Fine-Grained Parallel ILU (FGPILU) by Chow and Patel 2015:
33  // FINE-GRAINED PARALLEL INCOMPLETE LU FACTORIZATION, E. Chow and A. Patel, SIAM 2015, https://doi.org/10.1137/140968896
34  // only blocksize == 3 is supported
35  // decomposition() allocates the cl::Buffers on the first call, these are C++ objects that deallocate automatically
37  {
38  private:
39  cl::Buffer d_Ut_vals, d_L_vals, d_LU_vals;
40  cl::Buffer d_Ut_ptrs, d_Ut_idxs;
41  cl::Buffer d_L_rows, d_L_cols;
42  cl::Buffer d_LU_rows, d_LU_cols;
43  cl::Buffer d_Ltmp, d_Utmp;
44 
45  cl::Event event;
46  std::vector<cl::Event> events;
47  cl_int err;
48  std::once_flag initialize_flag;
49 
50  std::unique_ptr<cl::KernelFunctor<cl::Buffer&, cl::Buffer&, cl::Buffer&,
51  cl::Buffer&, cl::Buffer&, cl::Buffer&,
52  cl::Buffer&, cl::Buffer&, cl::Buffer&,
53  cl::Buffer&, cl::Buffer&,
54  const int, cl::LocalSpaceArg, cl::LocalSpaceArg> > chow_patel_ilu_sweep_k;
55 
56  public:
76  void decomposition(
77  cl::CommandQueue *queue, cl::Context *context,
78  int *Ut_ptrs, int *Ut_idxs, double *Ut_vals, int Ut_nnzbs,
79  int *L_rows, int *L_cols, double *L_vals, int L_nnzbs,
80  int *LU_rows, int *LU_cols, double *LU_vals, int LU_nnzbs,
81  int Nb, int num_sweeps, int verbosity);
82 
83  };
84 
85 } // end namespace bda
86 
87 #endif // CHOW_PATEL_ILU_HEADER_INCLUDED
Definition: ChowPatelIlu.hpp:37
void decomposition(cl::CommandQueue *queue, cl::Context *context, int *Ut_ptrs, int *Ut_idxs, double *Ut_vals, int Ut_nnzbs, int *L_rows, int *L_cols, double *L_vals, int L_nnzbs, int *LU_rows, int *LU_cols, double *LU_vals, int LU_nnzbs, int Nb, int num_sweeps, int verbosity)
Executes the ChowPatelIlu sweeps also copies data from CPU to GPU and GPU to CPU.
Definition: ChowPatelIlu.cpp:479