1 #include "../../../include/monolish_blas.hpp"
2 #include "../../../include/monolish_equation.hpp"
3 #include "../../internal/monolish_internal.hpp"
5 #ifdef MONOLISH_USE_GPU
6 #include "cusolverSp.h"
17 #ifdef MONOLISH_USE_GPU
18 cusolverSpHandle_t sp_handle;
19 cusolverSpCreate(&sp_handle);
21 cusparseMatDescr_t descrA;
22 internal::check_CUDA(cusparseCreateMatDescr(&descrA));
24 cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL));
26 cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ZERO));
28 cusparseSetMatDiagType(descrA, CUSPARSE_DIAG_TYPE_NON_UNIT));
33 double *Dval = A.
val.data();
37 const double *Drhv = b.
data();
38 double *Dsol = x.
data();
40 #pragma omp target data use_device_ptr(Dval, Dptr, Dind, Drhv, Dsol)
42 internal::check_CUDA(cusolverSpDcsrlsvqr(sp_handle, n, nnz, descrA, Dval,
43 Dptr, Dind, Drhv, tol, reorder,
50 throw std::runtime_error(
"error sparse Cholesky is only GPU");
63 #ifdef MONOLISH_USE_GPU
64 cusolverSpHandle_t sp_handle;
65 cusolverSpCreate(&sp_handle);
67 cusparseMatDescr_t descrA;
68 internal::check_CUDA(cusparseCreateMatDescr(&descrA));
70 cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL));
72 cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ZERO));
74 cusparseSetMatDiagType(descrA, CUSPARSE_DIAG_TYPE_NON_UNIT));
79 float *Dval = A.
val.data();
83 const float *Drhv = b.
data();
84 float *Dsol = x.
data();
86 #pragma omp target data use_device_ptr(Dval, Dptr, Dind, Drhv, Dsol)
88 internal::check_CUDA(cusolverSpScsrlsvqr(sp_handle, n, nnz, descrA, Dval,
89 Dptr, Dind, Drhv, tol, reorder,
96 throw std::runtime_error(
"error sparse Cholesky is only GPU");