Reference documentation for deal.II version GIT c00406db16 2023-09-28 18:00:02+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
cuda_precondition.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2018 - 2023 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>
23 
24 #include <memory>
25 
26 #ifdef DEAL_II_WITH_CUDA
27 
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 
61  template <typename Number>
63  {
64  public:
68  using size_type = int;
69 
75  {
82 
91  };
92 
97 
102 
108 
112  ~PreconditionIC();
113 
123  void
125  const AdditionalData &additional_data = AdditionalData());
126 
130  void
133 
138  void
141 
149  size_type
150  m() const;
151 
159  size_type
160  n() const;
161 
162  private:
166  cusparseHandle_t cusparse_handle;
167 
171  cusparseMatDescr_t descr_M;
172 
176  cusparseMatDescr_t descr_L;
177 
181  csric02Info_t info_M;
182 
186  csrsv2Info_t info_L;
187 
191  csrsv2Info_t info_Lt;
192 
197 
202  std::unique_ptr<Number[], void (*)(Number *)> P_val_dev;
203 
208  const int *P_row_ptr_dev;
209 
214  const int *P_column_index_dev;
215 
220  std::unique_ptr<Number[], void (*)(Number *)> tmp_dev;
221 
226  std::unique_ptr<void, void (*)(void *)> buffer_dev;
227 
233  cusparseSolvePolicy_t policy_L;
234 
240  cusparseSolvePolicy_t policy_Lt;
241 
246  cusparseSolvePolicy_t policy_M;
247 
252  int n_rows;
253 
259  };
260 
274  template <typename Number>
276  {
277  public:
281  using size_type = int;
282 
288  {
294  AdditionalData(bool use_level_analysis = true);
295 
304  };
305 
310 
315 
321 
326 
336  void
338  const AdditionalData &additional_data = AdditionalData());
339 
343  void
346 
350  void
353 
361  size_type
362  m() const;
363 
371  size_type
372  n() const;
373 
374  private:
378  cusparseHandle_t cusparse_handle;
379 
383  cusparseMatDescr_t descr_M;
384 
388  cusparseMatDescr_t descr_L;
389 
393  cusparseMatDescr_t descr_U;
394 
398  csrilu02Info_t info_M;
399 
403  csrsv2Info_t info_L;
404 
408  csrsv2Info_t info_U;
409 
414 
419  std::unique_ptr<Number[], void (*)(Number *)> P_val_dev;
420 
425  const int *P_row_ptr_dev;
426 
431  const int *P_column_index_dev;
432 
437  std::unique_ptr<Number[], void (*)(Number *)> tmp_dev;
438 
443  std::unique_ptr<void, void (*)(void *)> buffer_dev;
444 
450  cusparseSolvePolicy_t policy_L;
451 
457  cusparseSolvePolicy_t policy_U;
458 
463  cusparseSolvePolicy_t policy_M;
464 
469  int n_rows;
470 
476  };
477 
478  /*--------------------------- inline functions ----------------------------*/
479 
480 # ifndef DOXYGEN
481  template <typename Number>
482  inline typename PreconditionIC<Number>::size_type
484  {
485  return n_rows;
486  }
487 
488 
489 
490  template <typename Number>
491  inline typename PreconditionIC<Number>::size_type
493  {
494  return n_rows;
495  }
496 
497 
498 
499  template <typename Number>
500  inline typename PreconditionILU<Number>::size_type
502  {
503  return n_rows;
504  }
505 
506 
507 
508  template <typename Number>
509  inline typename PreconditionILU<Number>::size_type
511  {
512  return n_rows;
513  }
514 # endif // DOXYGEN
515 
516 } // namespace CUDAWrappers
517 
519 
520 #endif // DEAL_II_WITH_CUDA
521 
522 #endif // dealii_cuda_precondition_h
cusparseSolvePolicy_t policy_M
std::unique_ptr< Number[], void(*)(Number *)> P_val_dev
void Tvmult(LinearAlgebra::CUDAWrappers::Vector< Number > &dst, const LinearAlgebra::CUDAWrappers::Vector< Number > &src) const
std::unique_ptr< Number[], void(*)(Number *)> tmp_dev
PreconditionIC & operator=(const PreconditionIC< Number > &)=delete
void initialize(const SparseMatrix< Number > &matrix, const AdditionalData &additional_data=AdditionalData())
cusparseSolvePolicy_t policy_Lt
cusparseSolvePolicy_t policy_L
void vmult(LinearAlgebra::CUDAWrappers::Vector< Number > &dst, const LinearAlgebra::CUDAWrappers::Vector< Number > &src) const
PreconditionIC(const Utilities::CUDA::Handle &handle)
SmartPointer< const SparseMatrix< Number > > matrix_pointer
std::unique_ptr< void, void(*)(void *)> buffer_dev
PreconditionIC(const PreconditionIC< Number > &)=delete
cusparseSolvePolicy_t policy_M
void vmult(LinearAlgebra::CUDAWrappers::Vector< Number > &dst, const LinearAlgebra::CUDAWrappers::Vector< Number > &src) const
PreconditionILU(const PreconditionILU< Number > &)=delete
std::unique_ptr< void, void(*)(void *)> buffer_dev
void initialize(const SparseMatrix< Number > &matrix, const AdditionalData &additional_data=AdditionalData())
cusparseSolvePolicy_t policy_U
PreconditionILU & operator=(const PreconditionILU< Number > &)=delete
SmartPointer< const SparseMatrix< Number > > matrix_pointer
PreconditionILU(const Utilities::CUDA::Handle &handle)
std::unique_ptr< Number[], void(*)(Number *)> P_val_dev
std::unique_ptr< Number[], void(*)(Number *)> tmp_dev
void Tvmult(LinearAlgebra::CUDAWrappers::Vector< Number > &dst, const LinearAlgebra::CUDAWrappers::Vector< Number > &src) const
cusparseSolvePolicy_t policy_L
Definition: vector.h:110
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:477
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:478
@ matrix
Contents is actually a matrix.