hipsparsescsr2bsr Interface Reference#
Convert a sparse CSR matrix into a sparse BSR matrix. More...
Public Member Functions | |
| integer(kind(hipsparse_status_success)) function | hipsparsescsr2bsr_ (handle, dira, m, n, descra, csrvala, csrrowptra, csrcolinda, blockdim, descrc, bsrvalc, bsrrowptrc, bsrcolindc) |
| integer(kind(hipsparse_status_success)) function | hipsparsescsr2bsr_rank_0 (handle, dira, m, n, descra, csrvala, csrrowptra, csrcolinda, blockdim, descrc, bsrvalc, bsrrowptrc, bsrcolindc) |
| integer(kind(hipsparse_status_success)) function | hipsparsescsr2bsr_rank_1 (handle, dira, m, n, descra, csrvala, csrrowptra, csrcolinda, blockdim, descrc, bsrvalc, bsrrowptrc, bsrcolindc) |
Detailed Description
Convert a sparse CSR matrix into a sparse BSR matrix.
hipsparseXcsr2bsr completes the conversion of a CSR matrix into a BSR matrix. It is assumed that bsrValC, bsrColIndC, and bsrRowPtrC are allocated. The allocation size for bsrRowPtr is computed as mb+1, where mb is the number of block rows in the BSR matrix defined as:
\[ \begin{align} \text{mb} &= \text{(m - 1) / blockDim + 1} \end{align} \]
The allocation size for bsrColIndC, that is, bsrNnzb, is computed using hipsparseXcsr2bsrNnz(), which also fills the bsrRowPtrC array. The allocation size for bsrValC is then equal to:
\[ \text{bsrNnzb * blockDim * blockDim} \]
For example, given the CSR matrix:
\[ \begin{bmatrix} 1 & 0 & 0 & 2 \\% 3 & 4 & 0 & 0 \\% 5 & 0 & 6 & 7 \\% 1 & 2 & 3 & 4 \end{bmatrix} \]
The resulting BSR matrix using block dimension 2 would look like:
\[ \left[ \begin{array}{c | c} \begin{array}{c c} 1 & 0 \\% 3 & 4 \end{array} & \begin{array}{c c} 0 & 2 \\% 0 & 0 \end{array} \\% \hline \begin{array}{c c} 5 & 0 \\% 1 & 2 \end{array} & \begin{array}{c c} 6 & 7 \\% 3 & 4 \end{array} \\% \end{array} \right] \]
The call to hipsparseXcsr2bsrNnz results in the BSR row pointer array:
\[ \begin{align} \text{bsrRowPtrC} &= \begin{bmatrix} 0 & 2 & 4 \end{bmatrix} \\% \end{align} \]
and the call to hipsparseXcsr2bsr completes the conversion resulting in the BSR column indices and values arrays:
\[ \begin{align} \text{bsrColIndC} &= \begin{bmatrix} 0 & 1 & 0 & 1 \end{bmatrix} \\% \text{bsrValC} &= \begin{bmatrix} 1 & 0 & 3 & 4 & 0 & 2 & 0 & 0 & 5 & 0 & 1 & 2 & 6 & 7 & 3 & 4 \end{bmatrix} \\% \end{align} \]
The dirA parameter determines the order of the BSR block values. The example above uses row order. Using column ordering would result instead in the BSR values array:
\[ \text{bsrValC} &= \begin{bmatrix} 1 & 3 & 0 & 4 & 0 & 0 & 2 & 0 & 5 & 1 & 0 & 2 & 6 & 3 & 7 & 4 \end{bmatrix} \\% \]
- Note
hipsparseXcsr2bsrrequires extra temporary storage that is allocated internally ifblockDim> 16.
- Parameters
-
[in] handle - handle to the hipSPARSE library context queue. [in] dirA - the storage format of the blocks, HIPSPARSE_DIRECTION_ROWorHIPSPARSE_DIRECTION_COLUMN.[in] m - number of rows in the sparse CSR matrix. [in] n - number of columns in the sparse CSR matrix. [in] descrA - descriptor of the sparse CSR matrix. Currently, only HIPSPARSE_MATRIX_TYPE_GENERALis supported.[in] csrValA - array of nnzelements containing the values of the sparse CSR matrix.[in] csrRowPtrA - array of m+1elements that point to the start of every row of the sparse CSR matrix.[in] csrColIndA - array of nnzelements containing the column indices of the sparse CSR matrix.[in] blockDim - size of the blocks in the sparse BSR matrix. [in] descrC - descriptor of the sparse BSR matrix. Currently, only HIPSPARSE_MATRIX_TYPE_GENERALis supported.[out] bsrValC - array of nnzb*blockDim*blockDimcontaining the values of the sparse BSR matrix.[out] bsrRowPtrC - array of mb+1elements that point to the start of every block row of the sparse BSR matrix.[out] bsrColIndC - array of nnzbelements containing the block column indices of the sparse BSR matrix.
- Return values
-
HIPSPARSE_STATUS_SUCCESS the operation completed successfully. HIPSPARSE_STATUS_INVALID_VALUE handle,m,n,blockDim,bsrValC,bsrRowPtrC,bsrColIndC,csrValA,csrRowPtrA, orcsrColIndApointer is invalid.
Member Function/Subroutine Documentation
◆ hipsparsescsr2bsr_()
| integer(kind(hipsparse_status_success)) function hipfort_hipsparse::hipsparsescsr2bsr::hipsparsescsr2bsr_ | ( | type(c_ptr), value | handle, |
| integer(kind(hipsparse_direction_row)), value | dira, | ||
| integer(c_int), value | m, | ||
| integer(c_int), value | n, | ||
| type(c_ptr), value | descra, | ||
| type(c_ptr), value | csrvala, | ||
| type(c_ptr), value | csrrowptra, | ||
| type(c_ptr), value | csrcolinda, | ||
| integer(c_int), value | blockdim, | ||
| type(c_ptr), value | descrc, | ||
| type(c_ptr), value | bsrvalc, | ||
| type(c_ptr), value | bsrrowptrc, | ||
| type(c_ptr), value | bsrcolindc | ||
| ) |
◆ hipsparsescsr2bsr_rank_0()
| integer(kind(hipsparse_status_success)) function hipfort_hipsparse::hipsparsescsr2bsr::hipsparsescsr2bsr_rank_0 | ( | type(c_ptr) | handle, |
| integer(kind(hipsparse_direction_row)) | dira, | ||
| integer(c_int) | m, | ||
| integer(c_int) | n, | ||
| type(c_ptr) | descra, | ||
| real(c_float), target | csrvala, | ||
| integer(c_int), target | csrrowptra, | ||
| integer(c_int), target | csrcolinda, | ||
| integer(c_int) | blockdim, | ||
| type(c_ptr) | descrc, | ||
| real(c_float), target | bsrvalc, | ||
| integer(c_int), target | bsrrowptrc, | ||
| integer(c_int), target | bsrcolindc | ||
| ) |
◆ hipsparsescsr2bsr_rank_1()
| integer(kind(hipsparse_status_success)) function hipfort_hipsparse::hipsparsescsr2bsr::hipsparsescsr2bsr_rank_1 | ( | type(c_ptr) | handle, |
| integer(kind(hipsparse_direction_row)) | dira, | ||
| integer(c_int) | m, | ||
| integer(c_int) | n, | ||
| type(c_ptr) | descra, | ||
| real(c_float), dimension(:), target | csrvala, | ||
| integer(c_int), dimension(:), target | csrrowptra, | ||
| integer(c_int), dimension(:), target | csrcolinda, | ||
| integer(c_int) | blockdim, | ||
| type(c_ptr) | descrc, | ||
| real(c_float), dimension(:), target | bsrvalc, | ||
| integer(c_int), dimension(:), target | bsrrowptrc, | ||
| integer(c_int), dimension(:), target | bsrcolindc | ||
| ) |
The documentation for this interface was generated from the following file: