29 template <
typename Number>
31 cusparseXcsrilu02(cusparseHandle_t ,
34 const cusparseMatDescr_t ,
39 cusparseSolvePolicy_t ,
43 return CUSPARSE_STATUS_INVALID_VALUE;
48 cusparseXcsrilu02<float>(cusparseHandle_t handle,
51 const cusparseMatDescr_t descrA,
53 const int * csrRowPtrA,
54 const int * csrColIndA,
56 cusparseSolvePolicy_t policy,
59 return cusparseScsrilu02(handle,
73 cusparseXcsrilu02<double>(cusparseHandle_t handle,
76 const cusparseMatDescr_t descrA,
77 double * csrValA_valM,
78 const int * csrRowPtrA,
79 const int * csrColIndA,
81 cusparseSolvePolicy_t policy,
84 return cusparseDcsrilu02(handle,
156 template <
typename Number>
158 cusparseXcsrilu02_analysis(cusparseHandle_t ,
161 const cusparseMatDescr_t ,
166 cusparseSolvePolicy_t ,
170 return CUSPARSE_STATUS_INVALID_VALUE;
175 cusparseXcsrilu02_analysis<float>(cusparseHandle_t handle,
178 const cusparseMatDescr_t descrA,
179 const float * csrValA,
180 const int * csrRowPtrA,
181 const int * csrColIndA,
183 cusparseSolvePolicy_t policy,
186 return cusparseScsrilu02_analysis(handle,
200 cusparseXcsrilu02_analysis<double>(cusparseHandle_t handle,
203 const cusparseMatDescr_t descrA,
204 const double * csrValA,
205 const int * csrRowPtrA,
206 const int * csrColIndA,
208 cusparseSolvePolicy_t policy,
211 return cusparseDcsrilu02_analysis(handle,
283 template <
typename Number>
285 cusparseXcsrilu02_bufferSize(cusparseHandle_t ,
288 const cusparseMatDescr_t ,
296 return CUSPARSE_STATUS_INVALID_VALUE;
301 cusparseXcsrilu02_bufferSize<float>(cusparseHandle_t handle,
304 const cusparseMatDescr_t descrA,
306 const int * csrRowPtrA,
307 const int * csrColIndA,
309 int *pBufferSizeInBytes)
311 return cusparseScsrilu02_bufferSize(handle,
324 cusparseXcsrilu02_bufferSize<double>(cusparseHandle_t handle,
327 const cusparseMatDescr_t descrA,
329 const int * csrRowPtrA,
330 const int * csrColIndA,
332 int *pBufferSizeInBytes)
334 return cusparseDcsrilu02_bufferSize(handle,
399 template <
typename Number>
401 cusparseXcsric02(cusparseHandle_t ,
404 const cusparseMatDescr_t ,
409 cusparseSolvePolicy_t ,
413 return CUSPARSE_STATUS_INVALID_VALUE;
418 cusparseXcsric02<float>(cusparseHandle_t handle,
421 const cusparseMatDescr_t descrA,
422 float * csrValA_valM,
423 const int * csrRowPtrA,
424 const int * csrColIndA,
426 cusparseSolvePolicy_t policy,
429 return cusparseScsric02(handle,
443 cusparseXcsric02<double>(cusparseHandle_t handle,
446 const cusparseMatDescr_t descrA,
447 double * csrValA_valM,
448 const int * csrRowPtrA,
449 const int * csrColIndA,
451 cusparseSolvePolicy_t policy,
454 return cusparseDcsric02(handle,
526 template <
typename Number>
528 cusparseXcsrsv2_solve(cusparseHandle_t ,
529 cusparseOperation_t ,
533 const cusparseMatDescr_t ,
540 cusparseSolvePolicy_t ,
544 return CUSPARSE_STATUS_INVALID_VALUE;
549 cusparseXcsrsv2_solve<float>(cusparseHandle_t handle,
550 cusparseOperation_t transA,
554 const cusparseMatDescr_t descra,
555 const float * csrValA,
556 const int * csrRowPtrA,
557 const int * csrColIndA,
561 cusparseSolvePolicy_t policy,
564 return cusparseScsrsv2_solve(handle,
582 cusparseXcsrsv2_solve<double>(cusparseHandle_t handle,
583 cusparseOperation_t transA,
586 const double * alpha,
587 const cusparseMatDescr_t descra,
588 const double * csrValA,
589 const int * csrRowPtrA,
590 const int * csrColIndA,
594 cusparseSolvePolicy_t policy,
597 return cusparseDcsrsv2_solve(handle,
689 template <
typename Number>
691 cusparseXcsrsv2_analysis(cusparseHandle_t ,
692 cusparseOperation_t ,
695 const cusparseMatDescr_t ,
700 cusparseSolvePolicy_t ,
704 return CUSPARSE_STATUS_INVALID_VALUE;
709 cusparseXcsrsv2_analysis<float>(cusparseHandle_t handle,
710 cusparseOperation_t transA,
713 const cusparseMatDescr_t descrA,
714 const float * csrValA,
715 const int * csrRowPtrA,
716 const int * csrColIndA,
718 cusparseSolvePolicy_t policy,
721 return cusparseScsrsv2_analysis(handle,
736 cusparseXcsrsv2_analysis<double>(cusparseHandle_t handle,
737 cusparseOperation_t transA,
740 const cusparseMatDescr_t descrA,
741 const double * csrValA,
742 const int * csrRowPtrA,
743 const int * csrColIndA,
745 cusparseSolvePolicy_t policy,
748 return cusparseDcsrsv2_analysis(handle,
824 template <
typename Number>
826 cusparseXcsric02_analysis(cusparseHandle_t ,
829 const cusparseMatDescr_t ,
834 cusparseSolvePolicy_t ,
838 return CUSPARSE_STATUS_INVALID_VALUE;
843 cusparseXcsric02_analysis<float>(cusparseHandle_t handle,
846 const cusparseMatDescr_t descrA,
847 const float * csrValA,
848 const int * csrRowPtrA,
849 const int * csrColIndA,
851 cusparseSolvePolicy_t policy,
854 return cusparseScsric02_analysis(handle,
868 cusparseXcsric02_analysis<double>(cusparseHandle_t handle,
871 const cusparseMatDescr_t descrA,
872 const double * csrValA,
873 const int * csrRowPtrA,
874 const int * csrColIndA,
876 cusparseSolvePolicy_t policy,
879 return cusparseDcsric02_analysis(handle,
951 template <
typename Number>
953 cusparseXcsrsv2_bufferSize(cusparseHandle_t ,
954 cusparseOperation_t ,
957 const cusparseMatDescr_t ,
965 return CUSPARSE_STATUS_INVALID_VALUE;
970 cusparseXcsrsv2_bufferSize<float>(cusparseHandle_t handle,
971 cusparseOperation_t transA,
974 const cusparseMatDescr_t descrA,
976 const int * csrRowPtrA,
977 const int * csrColIndA,
979 int * pBufferSizeInBytes)
981 return cusparseScsrsv2_bufferSize(handle,
995 cusparseXcsrsv2_bufferSize<double>(cusparseHandle_t handle,
996 cusparseOperation_t transA,
999 const cusparseMatDescr_t descrA,
1001 const int * csrRowPtrA,
1002 const int * csrColIndA,
1004 int *pBufferSizeInBytes)
1006 return cusparseDcsrsv2_bufferSize(handle,
1015 pBufferSizeInBytes);
1078 template <
typename Number>
1080 cusparseXcsric02_bufferSize(cusparseHandle_t ,
1083 const cusparseMatDescr_t ,
1091 return CUSPARSE_STATUS_INVALID_VALUE;
1096 cusparseXcsric02_bufferSize<float>(cusparseHandle_t handle,
1099 const cusparseMatDescr_t descrA,
1101 const int * csrRowPtrA,
1102 const int * csrColIndA,
1104 int *pBufferSizeInBytes)
1106 return cusparseScsric02_bufferSize(handle,
1114 pBufferSizeInBytes);
1119 cusparseXcsric02_bufferSize<double>(cusparseHandle_t handle,
1122 const cusparseMatDescr_t descrA,
1124 const int * csrRowPtrA,
1125 const int * csrColIndA,
1127 int *pBufferSizeInBytes)
1129 return cusparseDcsric02_bufferSize(handle,
1137 pBufferSizeInBytes);
1191 template <
typename Number>
1193 bool use_level_analysis_)
1194 : use_level_analysis(use_level_analysis_)
1199 template <
typename Number>
1207 ,
policy_L(CUSPARSE_SOLVE_POLICY_USE_LEVEL)
1208 ,
policy_Lt(CUSPARSE_SOLVE_POLICY_USE_LEVEL)
1209 ,
policy_M(CUSPARSE_SOLVE_POLICY_USE_LEVEL)
1218 cusparseStatus_t status = cusparseCreateMatDescr(&
descr_M);
1220 status = cusparseSetMatIndexBase(
descr_M, CUSPARSE_INDEX_BASE_ZERO);
1222 status = cusparseSetMatType(
descr_M, CUSPARSE_MATRIX_TYPE_GENERAL);
1225 status = cusparseCreateMatDescr(&
descr_L);
1227 status = cusparseSetMatIndexBase(
descr_L, CUSPARSE_INDEX_BASE_ZERO);
1229 status = cusparseSetMatType(
descr_L, CUSPARSE_MATRIX_TYPE_GENERAL);
1231 status = cusparseSetMatFillMode(
descr_L, CUSPARSE_FILL_MODE_LOWER);
1233 status = cusparseSetMatDiagType(
descr_L, CUSPARSE_DIAG_TYPE_NON_UNIT);
1238 status = cusparseCreateCsric02Info(&
info_M);
1240 status = cusparseCreateCsrsv2Info(&
info_L);
1242 status = cusparseCreateCsrsv2Info(&
info_Lt);
1248 template <
typename Number>
1252 cusparseStatus_t status = cusparseDestroyMatDescr(descr_M);
1255 status = cusparseDestroyMatDescr(descr_L);
1258 status = cusparseDestroyCsric02Info(info_M);
1261 status = cusparseDestroyCsrsv2Info(info_L);
1264 status = cusparseDestroyCsrsv2Info(info_Lt);
1270 template <
typename Number>
1277 policy_L = CUSPARSE_SOLVE_POLICY_USE_LEVEL;
1278 policy_Lt = CUSPARSE_SOLVE_POLICY_USE_LEVEL;
1279 policy_M = CUSPARSE_SOLVE_POLICY_USE_LEVEL;
1283 policy_L = CUSPARSE_SOLVE_POLICY_NO_LEVEL;
1284 policy_Lt = CUSPARSE_SOLVE_POLICY_NO_LEVEL;
1285 policy_M = CUSPARSE_SOLVE_POLICY_NO_LEVEL;
1292 matrix_pointer = &A;
1293 const Number *A_val_dev;
1302 Utilities::CUDA::allocate_device_data<Number>(n_nonzero_elements));
1303 cudaError_t cuda_status = cudaMemcpy(P_val_dev.get(),
1305 n_nonzero_elements *
sizeof(Number),
1306 cudaMemcpyDeviceToDevice);
1310 tmp_dev.reset(Utilities::CUDA::allocate_device_data<Number>(n_rows));
1315 cusparseStatus_t status = cusparseXcsric02_bufferSize(cusparse_handle,
1327 status = cusparseXcsrsv2_bufferSize(cusparse_handle,
1328 CUSPARSE_OPERATION_NON_TRANSPOSE,
1340 status = cusparseXcsrsv2_bufferSize(cusparse_handle,
1341 CUSPARSE_OPERATION_TRANSPOSE,
1352 const int BufferSize =
1356 buffer_dev.reset(
static_cast<void *
>(
1357 Utilities::CUDA::allocate_device_data<char>(BufferSize /
sizeof(
char))));
1365 status = cusparseXcsric02_analysis(cusparse_handle,
1377 int structural_zero;
1379 cusparseXcsric02_zeroPivot(cusparse_handle, info_M, &structural_zero);
1382 status = cusparseXcsrsv2_analysis(cusparse_handle,
1383 CUSPARSE_OPERATION_TRANSPOSE,
1395 status = cusparseXcsrsv2_analysis(cusparse_handle,
1396 CUSPARSE_OPERATION_NON_TRANSPOSE,
1409 status = cusparseXcsric02(cusparse_handle,
1423 cusparseXcsric02_zeroPivot(cusparse_handle, info_M, &numerical_zero);
1429 template <
typename Number>
1442 const Number *
const src_dev = src.
get_values();
1446 cusparseStatus_t status =
1447 cusparseXcsrsv2_solve(cusparse_handle,
1448 CUSPARSE_OPERATION_NON_TRANSPOSE,
1464 status = cusparseXcsrsv2_solve(cusparse_handle,
1465 CUSPARSE_OPERATION_TRANSPOSE,
1483 template <
typename Number>
1495 template <
typename Number>
1497 bool use_level_analysis_)
1498 : use_level_analysis(use_level_analysis_)
1503 template <
typename Number>
1512 ,
policy_L(CUSPARSE_SOLVE_POLICY_USE_LEVEL)
1513 ,
policy_U(CUSPARSE_SOLVE_POLICY_USE_LEVEL)
1514 ,
policy_M(CUSPARSE_SOLVE_POLICY_USE_LEVEL)
1526 cusparseStatus_t status = cusparseCreateMatDescr(&
descr_M);
1528 status = cusparseSetMatIndexBase(
descr_M, CUSPARSE_INDEX_BASE_ZERO);
1530 status = cusparseSetMatType(
descr_M, CUSPARSE_MATRIX_TYPE_GENERAL);
1533 status = cusparseCreateMatDescr(&
descr_L);
1535 status = cusparseSetMatIndexBase(
descr_L, CUSPARSE_INDEX_BASE_ZERO);
1537 status = cusparseSetMatType(
descr_L, CUSPARSE_MATRIX_TYPE_GENERAL);
1539 status = cusparseSetMatFillMode(
descr_L, CUSPARSE_FILL_MODE_LOWER);
1541 status = cusparseSetMatDiagType(
descr_L, CUSPARSE_DIAG_TYPE_UNIT);
1544 status = cusparseCreateMatDescr(&
descr_U);
1546 status = cusparseSetMatIndexBase(
descr_U, CUSPARSE_INDEX_BASE_ZERO);
1548 status = cusparseSetMatType(
descr_U, CUSPARSE_MATRIX_TYPE_GENERAL);
1550 status = cusparseSetMatFillMode(
descr_U, CUSPARSE_FILL_MODE_UPPER);
1552 status = cusparseSetMatDiagType(
descr_U, CUSPARSE_DIAG_TYPE_NON_UNIT);
1557 status = cusparseCreateCsrilu02Info(&
info_M);
1559 status = cusparseCreateCsrsv2Info(&
info_L);
1561 status = cusparseCreateCsrsv2Info(&
info_U);
1567 template <
typename Number>
1571 cusparseStatus_t status = cusparseDestroyMatDescr(descr_M);
1574 status = cusparseDestroyMatDescr(descr_L);
1577 status = cusparseDestroyMatDescr(descr_U);
1580 status = cusparseDestroyCsrilu02Info(info_M);
1583 status = cusparseDestroyCsrsv2Info(info_L);
1586 status = cusparseDestroyCsrsv2Info(info_U);
1592 template <
typename Number>
1599 policy_L = CUSPARSE_SOLVE_POLICY_USE_LEVEL;
1600 policy_U = CUSPARSE_SOLVE_POLICY_USE_LEVEL;
1601 policy_M = CUSPARSE_SOLVE_POLICY_USE_LEVEL;
1605 policy_L = CUSPARSE_SOLVE_POLICY_NO_LEVEL;
1606 policy_U = CUSPARSE_SOLVE_POLICY_NO_LEVEL;
1607 policy_M = CUSPARSE_SOLVE_POLICY_NO_LEVEL;
1610 matrix_pointer = &A;
1615 const Number *A_val_dev;
1624 Utilities::CUDA::allocate_device_data<Number>(n_nonzero_elements));
1625 cudaError_t cuda_status = cudaMemcpy(P_val_dev.get(),
1627 n_nonzero_elements *
sizeof(Number),
1628 cudaMemcpyDeviceToDevice);
1632 tmp_dev.reset(Utilities::CUDA::allocate_device_data<Number>(n_rows));
1637 cusparseStatus_t status = cusparseXcsrilu02_bufferSize(cusparse_handle,
1649 status = cusparseXcsrsv2_bufferSize(cusparse_handle,
1650 CUSPARSE_OPERATION_NON_TRANSPOSE,
1662 status = cusparseXcsrsv2_bufferSize(cusparse_handle,
1663 CUSPARSE_OPERATION_NON_TRANSPOSE,
1674 const int BufferSize =
1678 buffer_dev.reset(
static_cast<void *
>(
1679 Utilities::CUDA::allocate_device_data<char>(BufferSize /
sizeof(
char))));
1687 status = cusparseXcsrilu02_analysis(cusparse_handle,
1699 int structural_zero;
1701 cusparseXcsrilu02_zeroPivot(cusparse_handle, info_M, &structural_zero);
1704 status = cusparseXcsrsv2_analysis(cusparse_handle,
1705 CUSPARSE_OPERATION_NON_TRANSPOSE,
1717 status = cusparseXcsrsv2_analysis(cusparse_handle,
1718 CUSPARSE_OPERATION_NON_TRANSPOSE,
1730 status = cusparseXcsrilu02(cusparse_handle,
1744 cusparseXcsrilu02_zeroPivot(cusparse_handle, info_M, &numerical_zero);
1750 template <
typename Number>
1763 const Number *
const src_dev = src.
get_values();
1768 cusparseStatus_t status =
1769 cusparseXcsrsv2_solve(cusparse_handle,
1770 CUSPARSE_OPERATION_NON_TRANSPOSE,
1786 status = cusparseXcsrsv2_solve(cusparse_handle,
1787 CUSPARSE_OPERATION_NON_TRANSPOSE,
1805 template <
typename Number>
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
const int * P_row_ptr_dev
void initialize(const SparseMatrix< Number > &matrix, const AdditionalData &additional_data=AdditionalData())
cusparseSolvePolicy_t policy_Lt
const int * P_column_index_dev
cusparseSolvePolicy_t policy_L
void vmult(LinearAlgebra::CUDAWrappers::Vector< Number > &dst, const LinearAlgebra::CUDAWrappers::Vector< Number > &src) const
PreconditionIC(const Utilities::CUDA::Handle &handle)
std::unique_ptr< void, void(*)(void *)> buffer_dev
cusparseHandle_t cusparse_handle
cusparseMatDescr_t descr_L
cusparseMatDescr_t descr_M
cusparseMatDescr_t descr_U
const int * P_row_ptr_dev
cusparseSolvePolicy_t policy_M
void vmult(LinearAlgebra::CUDAWrappers::Vector< Number > &dst, const LinearAlgebra::CUDAWrappers::Vector< Number > &src) const
std::unique_ptr< void, void(*)(void *)> buffer_dev
void initialize(const SparseMatrix< Number > &matrix, const AdditionalData &additional_data=AdditionalData())
cusparseMatDescr_t descr_M
cusparseHandle_t cusparse_handle
cusparseSolvePolicy_t policy_U
PreconditionILU(const Utilities::CUDA::Handle &handle)
std::unique_ptr< Number[], void(*)(Number *)> P_val_dev
std::unique_ptr< Number[], void(*)(Number *)> tmp_dev
const int * P_column_index_dev
void Tvmult(LinearAlgebra::CUDAWrappers::Vector< Number > &dst, const LinearAlgebra::CUDAWrappers::Vector< Number > &src) const
cusparseMatDescr_t descr_L
cusparseSolvePolicy_t policy_L
std::tuple< Number *, int *, int *, cusparseMatDescr_t, cusparseSpMatDescr_t > get_cusparse_matrix() const
std::size_t n_nonzero_elements() const
Number * get_values() const
virtual size_type size() const override
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define AssertCusparse(error_code)
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertNothrowCusparse(error_code)
static ::ExceptionBase & ExcInternalError()
#define AssertCuda(error_code)
static ::ExceptionBase & ExcNotInitialized()
#define AssertThrow(cond, exc)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
AdditionalData(bool use_level_analysis=true)
AdditionalData(bool use_level_analysis=true)
static constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE const T & value(const T &t)