Reference documentation for deal.II version 9.2.0
\(\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 - 2019 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_COMPILER_CUDA_AWARE
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 
63  template <typename Number>
65  {
66  public:
70  using size_type = int;
71 
77  {
84 
93  };
94 
99 
103  PreconditionIC(const PreconditionIC<Number> &) = delete;
104 
109  operator=(const PreconditionIC<Number> &) = delete;
110 
114  ~PreconditionIC();
115 
125  void
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 
330 
340  void
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 
523 
524 #endif // DEAL_II_WITH_CUDA
525 
526 #endif // dealii_cuda_precondition_h
CUDAWrappers::PreconditionILU::descr_M
cusparseMatDescr_t descr_M
Definition: cuda_precondition.h:387
Utilities::CUDA::Handle
Definition: cuda.h:43
CUDAWrappers::PreconditionIC::AdditionalData::use_level_analysis
bool use_level_analysis
Definition: cuda_precondition.h:92
CUDAWrappers::PreconditionILU::descr_L
cusparseMatDescr_t descr_L
Definition: cuda_precondition.h:392
LinearAlgebraDealII::Vector
Vector< double > Vector
Definition: generic_linear_algebra.h:43
CUDAWrappers::PreconditionIC::policy_Lt
cusparseSolvePolicy_t policy_Lt
Definition: cuda_precondition.h:242
CUDAWrappers::SparseMatrix
Definition: cuda_precondition.h:46
cuda.h
CUDAWrappers::PreconditionILU
Definition: cuda_precondition.h:279
CUDAWrappers::PreconditionILU::n_nonzero_elements
int n_nonzero_elements
Definition: cuda_precondition.h:479
CUDAWrappers::PreconditionILU::PreconditionILU
PreconditionILU(const Utilities::CUDA::Handle &handle)
CUDAWrappers::PreconditionILU::Tvmult
void Tvmult(LinearAlgebra::CUDAWrappers::Vector< Number > &dst, const LinearAlgebra::CUDAWrappers::Vector< Number > &src) const
LinearAlgebra
Definition: communication_pattern_base.h:30
CUDAWrappers::PreconditionIC::n
size_type n() const
CUDAWrappers::PreconditionILU::info_L
csrsv2Info_t info_L
Definition: cuda_precondition.h:407
CUDAWrappers::PreconditionIC::AdditionalData::AdditionalData
AdditionalData(bool use_level_analysis=true)
CUDAWrappers::PreconditionILU::descr_U
cusparseMatDescr_t descr_U
Definition: cuda_precondition.h:397
CUDAWrappers::PreconditionILU::buffer_dev
std::unique_ptr< void, void(*)(void *)> buffer_dev
Definition: cuda_precondition.h:447
CUDAWrappers::PreconditionIC::m
size_type m() const
CUDAWrappers::PreconditionILU::policy_M
cusparseSolvePolicy_t policy_M
Definition: cuda_precondition.h:467
CUDAWrappers::PreconditionIC::P_val_dev
std::unique_ptr< Number[], void(*)(Number *)> P_val_dev
Definition: cuda_precondition.h:204
CUDAWrappers::PreconditionIC::policy_L
cusparseSolvePolicy_t policy_L
Definition: cuda_precondition.h:235
CUDAWrappers::PreconditionILU::~PreconditionILU
~PreconditionILU()
CUDAWrappers::PreconditionIC::~PreconditionIC
~PreconditionIC()
CUDAWrappers::PreconditionIC::initialize
void initialize(const SparseMatrix< Number > &matrix, const AdditionalData &additional_data=AdditionalData())
CUDAWrappers::PreconditionILU::AdditionalData::AdditionalData
AdditionalData(bool use_level_analysis=true)
CUDAWrappers::PreconditionILU::n_rows
int n_rows
Definition: cuda_precondition.h:473
CUDAWrappers::PreconditionILU::m
size_type m() const
LinearAlgebra::CUDAWrappers::Vector
Definition: cuda_vector.h:56
CUDAWrappers::PreconditionILU::P_column_index_dev
const int * P_column_index_dev
Definition: cuda_precondition.h:435
CUDAWrappers::PreconditionILU::operator=
PreconditionILU & operator=(const PreconditionILU< Number > &)=delete
CUDAWrappers::PreconditionIC::AdditionalData
Definition: cuda_precondition.h:76
CUDAWrappers::PreconditionILU::P_val_dev
std::unique_ptr< Number[], void(*)(Number *)> P_val_dev
Definition: cuda_precondition.h:423
CUDAWrappers::PreconditionIC::PreconditionIC
PreconditionIC(const Utilities::CUDA::Handle &handle)
CUDAWrappers::PreconditionIC::n_rows
int n_rows
Definition: cuda_precondition.h:254
CUDAWrappers::PreconditionIC::cusparse_handle
cusparseHandle_t cusparse_handle
Definition: cuda_precondition.h:168
CUDAWrappers
Definition: cuda_size.h:23
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
CUDAWrappers::PreconditionIC::n_nonzero_elements
int n_nonzero_elements
Definition: cuda_precondition.h:260
CUDAWrappers::PreconditionIC::info_Lt
csrsv2Info_t info_Lt
Definition: cuda_precondition.h:193
LAPACKSupport::matrix
@ matrix
Contents is actually a matrix.
Definition: lapack_support.h:60
CUDAWrappers::PreconditionILU::size_type
int size_type
Definition: cuda_precondition.h:285
smartpointer.h
CUDAWrappers::PreconditionILU::tmp_dev
std::unique_ptr< Number[], void(*)(Number *)> tmp_dev
Definition: cuda_precondition.h:441
CUDAWrappers::PreconditionIC::policy_M
cusparseSolvePolicy_t policy_M
Definition: cuda_precondition.h:248
CUDAWrappers::PreconditionIC
Definition: cuda_precondition.h:64
CUDAWrappers::PreconditionILU::initialize
void initialize(const SparseMatrix< Number > &matrix, const AdditionalData &additional_data=AdditionalData())
CUDAWrappers::PreconditionIC::descr_M
cusparseMatDescr_t descr_M
Definition: cuda_precondition.h:173
CUDAWrappers::PreconditionIC::vmult
void vmult(LinearAlgebra::CUDAWrappers::Vector< Number > &dst, const LinearAlgebra::CUDAWrappers::Vector< Number > &src) const
SmartPointer
Definition: smartpointer.h:68
CUDAWrappers::PreconditionILU::n
size_type n() const
CUDAWrappers::PreconditionIC::Tvmult
void Tvmult(LinearAlgebra::CUDAWrappers::Vector< Number > &dst, const LinearAlgebra::CUDAWrappers::Vector< Number > &src) const
CUDAWrappers::PreconditionILU::matrix_pointer
SmartPointer< const SparseMatrix< Number > > matrix_pointer
Definition: cuda_precondition.h:417
CUDAWrappers::PreconditionILU::info_M
csrilu02Info_t info_M
Definition: cuda_precondition.h:402
CUDAWrappers::PreconditionILU::P_row_ptr_dev
const int * P_row_ptr_dev
Definition: cuda_precondition.h:429
CUDAWrappers::PreconditionIC::P_row_ptr_dev
const int * P_row_ptr_dev
Definition: cuda_precondition.h:210
CUDAWrappers::PreconditionIC::operator=
PreconditionIC & operator=(const PreconditionIC< Number > &)=delete
CUDAWrappers::PreconditionILU::policy_U
cusparseSolvePolicy_t policy_U
Definition: cuda_precondition.h:461
CUDAWrappers::PreconditionILU::policy_L
cusparseSolvePolicy_t policy_L
Definition: cuda_precondition.h:454
CUDAWrappers::PreconditionILU::AdditionalData::use_level_analysis
bool use_level_analysis
Definition: cuda_precondition.h:307
CUDAWrappers::PreconditionILU::vmult
void vmult(LinearAlgebra::CUDAWrappers::Vector< Number > &dst, const LinearAlgebra::CUDAWrappers::Vector< Number > &src) const
CUDAWrappers::PreconditionIC::buffer_dev
std::unique_ptr< void, void(*)(void *)> buffer_dev
Definition: cuda_precondition.h:228
config.h
CUDAWrappers::PreconditionIC::info_M
csric02Info_t info_M
Definition: cuda_precondition.h:183
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
CUDAWrappers::PreconditionILU::info_U
csrsv2Info_t info_U
Definition: cuda_precondition.h:412
CUDAWrappers::PreconditionIC::tmp_dev
std::unique_ptr< Number[], void(*)(Number *)> tmp_dev
Definition: cuda_precondition.h:222
CUDAWrappers::PreconditionILU::cusparse_handle
cusparseHandle_t cusparse_handle
Definition: cuda_precondition.h:382
CUDAWrappers::PreconditionILU::AdditionalData
Definition: cuda_precondition.h:291
CUDAWrappers::PreconditionIC::P_column_index_dev
const int * P_column_index_dev
Definition: cuda_precondition.h:216
CUDAWrappers::PreconditionIC::size_type
int size_type
Definition: cuda_precondition.h:70
CUDAWrappers::PreconditionIC::info_L
csrsv2Info_t info_L
Definition: cuda_precondition.h:188
CUDAWrappers::PreconditionIC::matrix_pointer
SmartPointer< const SparseMatrix< Number > > matrix_pointer
Definition: cuda_precondition.h:198
CUDAWrappers::PreconditionIC::descr_L
cusparseMatDescr_t descr_L
Definition: cuda_precondition.h:178
int