1#include <muda/check/check_cusolver.h>
5namespace details::linear_system
8 void svqr(cusolverSpHandle_t handle,
11 const cusparseMatDescr_t descrA,
13 const int* csrRowPtrA,
14 const int* csrColIndA,
22 if constexpr(std::is_same_v<T, float>)
24 checkCudaErrors(cusolverSpScsrlsvqr(
25 handle, m, nnz, descrA, csrValA, csrRowPtrA, csrColIndA, b, tol, reorder, x, singularity));
27 else if constexpr(std::is_same_v<T, double>)
29 checkCudaErrors(cusolverSpDcsrlsvqr(
30 handle, m, nnz, descrA, csrValA, csrRowPtrA, csrColIndA, b, tol, reorder, x, singularity));
34 static_assert(always_false_v<T>,
"Unsupported type");
41void LinearSystemContext::solve(DenseVectorView<T> x, CCSRMatrixView<T> A, CDenseVectorView<T> b)
43 MUDA_ASSERT(!A.is_trans(),
"CSRMatrix A must not be transposed");
45 auto handle = cusolver_sp();
47 auto singularity = std::make_shared<int>(0);
49 details::linear_system::svqr(handle,
57 m_tolerance.solve_sparse_error_threshold<T>(),
58 m_reorder.reorder_method_int(),
62 std::string label{this->label()};
66 [info = std::move(singularity), label = std::move(label)]()
mutable
71 MUDA_KERNEL_WARN_WITH_LOCATION(
"In calling label %s: A*x=b solving failed. R(%d,%d) is almost 0",