rocsparse_scsrsv_solve Interface Reference#
Sparse triangular solve using CSR storage format. More...
Public Member Functions | |
| integer(kind(rocsparse_status_success)) function | rocsparse_scsrsv_solve_ (handle, trans, m, nnz, alpha, descr, csr_val, csr_row_ptr, csr_col_ind, myinfo, x, y, policy, temp_buffer) |
| integer(kind(rocsparse_status_success)) function | rocsparse_scsrsv_solve_rank_0 (handle, trans, m, nnz, alpha, descr, csr_val, csr_row_ptr, csr_col_ind, myinfo, x, y, policy, temp_buffer) |
| integer(kind(rocsparse_status_success)) function | rocsparse_scsrsv_solve_rank_1 (handle, trans, m, nnz, alpha, descr, csr_val, csr_row_ptr, csr_col_ind, myinfo, x, y, policy, temp_buffer) |
Detailed Description
Sparse triangular solve using CSR storage format.
rocsparse_csrsv_solve solves a sparse triangular linear system of a sparse \(m \times m\) matrix, defined in CSR storage format, a dense solution vector \(y\) and the right-hand side \(x\) that is multiplied by \(\alpha\), such that
\[ op(A) \cdot y = \alpha \cdot x, \]
with
\[ op(A) = \left\{ \begin{array}{ll} A, & \text{if trans == rocsparse_operation_none} \\% A^T, & \text{if trans == rocsparse_operation_transpose} \\% A^H, & \text{if trans == rocsparse_operation_conjugate_transpose} \end{array} \right. \]
Performing the above operation requires three steps. First, call rocsparse_Xcsrsv_buffer_size(), which determines the size of the required temporary storage buffer. Then allocate this buffer and call rocsparse_Xcsrsv_analysis(), which will perform analysis on the sparse matrix \(op(A)\). Finally, complete the computation by calling rocsparse_csrsv_solve. The buffer size, buffer allocation, and analysis only need to be called once for a given sparse matrix \(op(A)\), while the computation stage can be repeatedly used with different \(x\) and \(y\) vectors. After all calls to rocsparse_csrsv_solve are complete, the temporary buffer can be deallocated.
Solving a triangular system involves division by the diagonal elements. This means that if the sparse matrix is missing the diagonal entry (referred to as a structural zero) or the diagonal entry is zero (referred to as a numerical zero), then a division by zero would occur. rocsparse_csrsv_solve tracks the location of the first zero pivot (either numerical or structural zero). The zero pivot status can be checked by calling rocsparse_csrsv_zero_pivot (). If rocsparse_csrsv_zero_pivot () returns rocsparse_status_success, then no zero pivot was found and therefore the matrix does not have a structural or numerical zero.
The user can specify that the sparse matrix should be interpreted as having ones on the diagonal by setting the diagonal type on the descriptor descr to rocsparse_diag_type_unit using rocsparse_set_mat_diag_type. If rocsparse_diag_type == rocsparse_diag_type_unit, no zero pivot will be reported, even if \(A_{j,j} = 0\) for some \(j\).
The sparse CSR matrix passed to rocsparse_csrsv_solve does not actually have to be a triangular matrix. Instead the triangular upper or lower part of the sparse matrix is solved based on rocsparse_fill_mode set on the descriptor descr. If the fill mode is set to rocsparse_fill_mode_lower, then the lower triangular matrix is solved. If the fill mode is set to rocsparse_fill_mode_upper, then the upper triangular matrix is solved.
- Note
- The sparse CSR matrix has to be sorted. This can be achieved by calling
rocsparse_csrsort(). - This function is non-blocking and executed asynchronously with respect to the host. It can return before the actual computation has finished.
-
Currently, only
trans==rocsparse_operation_noneandtrans==rocsparse_operation_transposeis supported. - This routine supports execution in a hipGraph context.
- Parameters
-
[in] handle - handle to the rocSPARSE library context queue. [in] trans - matrix operation type. [in] m - number of rows of the sparse CSR matrix. [in] nnz - number of non-zero entries of the sparse CSR matrix. [in] alpha - scalar \(\alpha\). [in] descr - descriptor of the sparse CSR matrix. [in] csr_val - array of nnzelements of the sparse CSR matrix.[in] csr_row_ptr - array of m+1elements that point to the start of every row of the sparse CSR matrix.[in] csr_col_ind - array of nnzelements containing the column indices of the sparse CSR matrix.[in] myInfo - structure that holds the information collected during the analysis step. [in] x - array of melements, holding the right-hand side.[out] y - array of melements, holding the solution.[in] policy - rocsparse_solve_policy_auto.[in] temp_buffer - temporary storage buffer allocated by the user.
- Return values
-
rocsparse_status_success the operation completed successfully. rocsparse_status_invalid_handle the library context was not initialized. rocsparse_status_invalid_size mornnzis invalid.rocsparse_status_invalid_pointer descr,alpha,csr_val,csr_row_ptr,csr_col_ind,x, orypointer is invalid.rocsparse_status_arch_mismatch the device is not supported. rocsparse_status_internal_error an internal error occurred. rocsparse_status_not_implemented trans==rocsparse_operation_conjugate_transposeorrocsparse_matrix_type!=rocsparse_matrix_type_general.
- Example
- Consider the lower triangular \(m \times m\) matrix \(L\), stored in CSR storage format with unit diagonal. The following example solves \(L \cdot y = x\).
Member Function/Subroutine Documentation
◆ rocsparse_scsrsv_solve_()
| integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_scsrsv_solve::rocsparse_scsrsv_solve_ | ( | type(c_ptr), value | handle, |
| integer(kind(rocsparse_operation_none)), value | trans, | ||
| integer(c_int), value | m, | ||
| integer(c_int), value | nnz, | ||
| real(c_float) | alpha, | ||
| type(c_ptr), value | descr, | ||
| type(c_ptr), value | csr_val, | ||
| type(c_ptr), value | csr_row_ptr, | ||
| type(c_ptr), value | csr_col_ind, | ||
| type(c_ptr), value | myinfo, | ||
| type(c_ptr), value | x, | ||
| type(c_ptr), value | y, | ||
| integer(kind(rocsparse_solve_policy_auto)), value | policy, | ||
| type(c_ptr), value | temp_buffer | ||
| ) |
◆ rocsparse_scsrsv_solve_rank_0()
| integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_scsrsv_solve::rocsparse_scsrsv_solve_rank_0 | ( | type(c_ptr) | handle, |
| integer(kind(rocsparse_operation_none)) | trans, | ||
| integer(c_int) | m, | ||
| integer(c_int) | nnz, | ||
| real(c_float) | alpha, | ||
| type(c_ptr) | descr, | ||
| real(c_float), target | csr_val, | ||
| integer(c_int), target | csr_row_ptr, | ||
| integer(c_int), target | csr_col_ind, | ||
| type(c_ptr) | myinfo, | ||
| real(c_float), target | x, | ||
| real(c_float), target | y, | ||
| integer(kind(rocsparse_solve_policy_auto)) | policy, | ||
| type(c_ptr) | temp_buffer | ||
| ) |
◆ rocsparse_scsrsv_solve_rank_1()
| integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_scsrsv_solve::rocsparse_scsrsv_solve_rank_1 | ( | type(c_ptr) | handle, |
| integer(kind(rocsparse_operation_none)) | trans, | ||
| integer(c_int) | m, | ||
| integer(c_int) | nnz, | ||
| real(c_float) | alpha, | ||
| type(c_ptr) | descr, | ||
| real(c_float), dimension(:), target | csr_val, | ||
| integer(c_int), dimension(:), target | csr_row_ptr, | ||
| integer(c_int), dimension(:), target | csr_col_ind, | ||
| type(c_ptr) | myinfo, | ||
| real(c_float), dimension(:), target | x, | ||
| real(c_float), dimension(:), target | y, | ||
| integer(kind(rocsparse_solve_policy_auto)) | policy, | ||
| type(c_ptr) | temp_buffer | ||
| ) |
The documentation for this interface was generated from the following file: