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(cusolverSpDcsrlsvchol(sp_handle, n, nnz, descrA, Dval,
43 Dptr, Dind, Drhv, tol, reorder,
50 throw std::runtime_error(
"error sparse Cholesky is only GPU");
61 #ifdef MONOLISH_USE_GPU
63 cusolverSpHandle_t sp_handle;
64 cusolverSpCreate(&sp_handle);
66 cusparseMatDescr_t descrA;
67 internal::check_CUDA(cusparseCreateMatDescr(&descrA));
69 cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL));
71 cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ZERO));
73 cusparseSetMatDiagType(descrA, CUSPARSE_DIAG_TYPE_NON_UNIT));
78 float *Dval = A.
val.data();
82 const float *Drhv = b.
data();
83 float *Dsol = x.
data();
85 #pragma omp target data use_device_ptr(Dval, Dptr, Dind, Drhv, Dsol)
87 internal::check_CUDA(cusolverSpScsrlsvchol(sp_handle, n, nnz, descrA, Dval,
88 Dptr, Dind, Drhv, tol, reorder,