Reference documentation for deal.II version Git 7026f387cc 2019-10-15 14:19:01 -0400
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
cuda_precondition.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2018 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_cuda_precondition_h
17 #define dealii_cuda_precondition_h
18 
19 #include <deal.II/base/config.h>
20 
21 #include <deal.II/base/cuda.h>
22 #include <deal.II/base/smartpointer.h>
23 
24 #include <memory>
25 
26 #ifdef DEAL_II_COMPILER_CUDA_AWARE
27 
28 DEAL_II_NAMESPACE_OPEN
29 
30 // forward-definition
31 # ifndef DOXYGEN
32 namespace LinearAlgebra
33 {
34  namespace CUDAWrappers
35  {
36  template <typename Number>
37  class Vector;
38  }
39 } // namespace LinearAlgebra
40 # endif
41 
42 namespace CUDAWrappers
43 {
44  // forward definition
45  template <typename Number>
46  class SparseMatrix;
47 
63  template <typename Number>
65  {
66  public:
70  using size_type = int;
71 
77  {
83  AdditionalData(bool use_level_analysis = true);
84 
93  };
94 
99 
103  PreconditionIC(const PreconditionIC<Number> &) = delete;
104 
109  operator=(const PreconditionIC<Number> &) = delete;
110 
114  ~PreconditionIC();
115 
125  void
126  initialize(const SparseMatrix<Number> &matrix,
127  const AdditionalData & additional_data = AdditionalData());
128 
132  void
135 
140  void
143 
151  size_type
152  m() const;
153 
161  size_type
162  n() const;
163 
164  private:
168  cusparseHandle_t cusparse_handle;
169 
173  cusparseMatDescr_t descr_M;
174 
178  cusparseMatDescr_t descr_L;
179 
183  csric02Info_t info_M;
184 
188  csrsv2Info_t info_L;
189 
193  csrsv2Info_t info_Lt;
194 
199 
204  std::unique_ptr<Number[], void (*)(Number *)> P_val_dev;
205 
210  const int *P_row_ptr_dev;
211 
216  const int *P_column_index_dev;
217 
222  std::unique_ptr<Number[], void (*)(Number *)> tmp_dev;
223 
228  std::unique_ptr<void, void (*)(void *)> buffer_dev;
229 
235  cusparseSolvePolicy_t policy_L;
236 
242  cusparseSolvePolicy_t policy_Lt;
243 
248  cusparseSolvePolicy_t policy_M;
249 
254  int n_rows;
255 
261  };
262 
278  template <typename Number>
280  {
281  public:
285  using size_type = int;
286 
292  {
298  AdditionalData(bool use_level_analysis = true);
299 
308  };
309 
314 
318  PreconditionILU(const PreconditionILU<Number> &) = delete;
319 
324  operator=(const PreconditionILU<Number> &) = delete;
325 
329  ~PreconditionILU();
330 
340  void
341  initialize(const SparseMatrix<Number> &matrix,
342  const AdditionalData & additional_data = AdditionalData());
343 
347  void
350 
354  void
357 
365  size_type
366  m() const;
367 
375  size_type
376  n() const;
377 
378  private:
382  cusparseHandle_t cusparse_handle;
383 
387  cusparseMatDescr_t descr_M;
388 
392  cusparseMatDescr_t descr_L;
393 
397  cusparseMatDescr_t descr_U;
398 
402  csrilu02Info_t info_M;
403 
407  csrsv2Info_t info_L;
408 
412  csrsv2Info_t info_U;
413 
418 
423  std::unique_ptr<Number[], void (*)(Number *)> P_val_dev;
424 
429  const int *P_row_ptr_dev;
430 
435  const int *P_column_index_dev;
436 
441  std::unique_ptr<Number[], void (*)(Number *)> tmp_dev;
442 
447  std::unique_ptr<void, void (*)(void *)> buffer_dev;
448 
454  cusparseSolvePolicy_t policy_L;
455 
461  cusparseSolvePolicy_t policy_U;
462 
467  cusparseSolvePolicy_t policy_M;
468 
473  int n_rows;
474 
480  };
481 
482  /*--------------------------- inline functions ----------------------------*/
483 
484 # ifndef DOXYGEN
485  template <typename Number>
486  inline typename PreconditionIC<Number>::size_type
488  {
489  return n_rows;
490  }
491 
492 
493 
494  template <typename Number>
495  inline typename PreconditionIC<Number>::size_type
497  {
498  return n_rows;
499  }
500 
501 
502 
503  template <typename Number>
504  inline typename PreconditionILU<Number>::size_type
506  {
507  return n_rows;
508  }
509 
510 
511 
512  template <typename Number>
513  inline typename PreconditionILU<Number>::size_type
515  {
516  return n_rows;
517  }
518 # endif // DOXYGEN
519 
520 } // namespace CUDAWrappers
521 
522 DEAL_II_NAMESPACE_CLOSE
523 
524 #endif // DEAL_II_WITH_CUDA
525 
526 #endif // dealii_cuda_precondition_h
std::unique_ptr< void, void(*)(void *)> buffer_dev
cusparseSolvePolicy_t policy_L
cusparseSolvePolicy_t policy_L
LinearAlgebra::distributed::Vector< Number > Vector
SmartPointer< const SparseMatrix< Number > > matrix_pointer
cusparseSolvePolicy_t policy_M
cusparseSolvePolicy_t policy_Lt
SmartPointer< const SparseMatrix< Number > > matrix_pointer
cusparseSolvePolicy_t policy_M
std::unique_ptr< Number[], void(*)(Number *)> P_val_dev
std::unique_ptr< Number[], void(*)(Number *)> tmp_dev
std::unique_ptr< Number[], void(*)(Number *)> P_val_dev
cusparseSolvePolicy_t policy_U
std::unique_ptr< void, void(*)(void *)> buffer_dev
std::unique_ptr< Number[], void(*)(Number *)> tmp_dev