rocsparse_scsr2bsr Interface Reference#
Convert a sparse CSR matrix into a sparse BSR matrix. More...
Public Member Functions | |
| integer(kind(rocsparse_status_success)) function | rocsparse_scsr2bsr_ (handle, dir, m, n, csr_descr, csr_val, csr_row_ptr, csr_col_ind, block_dim, bsr_descr, bsr_val, bsr_row_ptr, bsr_col_ind) |
| integer(kind(rocsparse_status_success)) function | rocsparse_scsr2bsr_rank_0 (handle, dir, m, n, csr_descr, csr_val, csr_row_ptr, csr_col_ind, block_dim, bsr_descr, bsr_val, bsr_row_ptr, bsr_col_ind) |
| integer(kind(rocsparse_status_success)) function | rocsparse_scsr2bsr_rank_1 (handle, dir, m, n, csr_descr, csr_val, csr_row_ptr, csr_col_ind, block_dim, bsr_descr, bsr_val, bsr_row_ptr, bsr_col_ind) |
Detailed Description
Convert a sparse CSR matrix into a sparse BSR matrix.
rocsparse_csr2bsr converts a CSR matrix into a BSR matrix. It is assumed that bsr_val, bsr_col_ind, and bsr_row_ptr are allocated. The allocation size for bsr_row_ptr is computed as mb+1, where mb is the number of block rows and nb is the number of block columns in the BSR matrix:
\[ mb = (m + block\_dim - 1) / block\_dim \\% nb = (n + block\_dim - 1) / block\_dim \]
The allocation size for bsr_val and bsr_col_ind is computed using rocsparse_csr2bsr_nnz (), which also fills in bsr_row_ptr.
Converting from a sparse CSR matrix to a sparse BSR matrix requires two steps. First, allocate the bsr_row_ptr array to have length mb+1 and pass this to the function rocsparse_csr2bsr_nnz. This will fill the bsr_row_ptr array and also compute the total number of non-zero blocks in the BSR matrix. Now that the total number of non-zero blocks is known, allocate the bsr_col_ind and bsr_val arrays. Finally, call rocsparse_csr2bsr to complete the conversion. See the example below.
rocsparse_csr2bsr requires extra temporary storage that is allocated internally if block_dim>16.
- Note
- This function is blocking with respect to the host.
- This routine does not support execution in a hipGraph context.
- Parameters
-
[in] handle - handle to the rocSPARSE library context queue. [in] dir - the storage format of the blocks, rocsparse_direction_roworrocsparse_direction_column.[in] m - number of rows in the sparse CSR matrix. [in] n - number of columns in the sparse CSR matrix. [in] csr_descr - descriptor of the sparse CSR matrix. Currently, only rocsparse_matrix_type_generalis supported.[in] csr_val - array of nnzelements containing the values 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] block_dim - size of the blocks in the sparse BSR matrix. [in] bsr_descr - descriptor of the sparse BSR matrix. Currently, only rocsparse_matrix_type_generalis supported.[out] bsr_val - array of nnzb*block_dim*block_dimcontaining the values of the sparse BSR matrix.[out] bsr_row_ptr - array of mb+1elements that point to the start of every block row of the sparse BSR matrix.[out] bsr_col_ind - array of nnzbelements containing the block column indices of the sparse BSR matrix.
- Return values
-
rocsparse_status_success the operation completed successfully. rocsparse_status_invalid_handle the library context was not initialized. rocsparse_status_invalid_size m,n, orblock_dimis invalid.rocsparse_status_invalid_pointer bsr_val,bsr_row_ptr,bsr_col_ind,csr_val,csr_row_ptr, orcsr_col_indpointer is invalid.
- Example
- This example converts a CSR matrix into an BSR matrix.
Member Function/Subroutine Documentation
◆ rocsparse_scsr2bsr_()
| integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_scsr2bsr::rocsparse_scsr2bsr_ | ( | type(c_ptr), value | handle, |
| integer(kind(rocsparse_direction_row)), value | dir, | ||
| integer(c_int), value | m, | ||
| integer(c_int), value | n, | ||
| type(c_ptr), value | csr_descr, | ||
| type(c_ptr), value | csr_val, | ||
| type(c_ptr), value | csr_row_ptr, | ||
| type(c_ptr), value | csr_col_ind, | ||
| integer(c_int), value | block_dim, | ||
| type(c_ptr), value | bsr_descr, | ||
| type(c_ptr), value | bsr_val, | ||
| type(c_ptr), value | bsr_row_ptr, | ||
| type(c_ptr), value | bsr_col_ind | ||
| ) |
◆ rocsparse_scsr2bsr_rank_0()
| integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_scsr2bsr::rocsparse_scsr2bsr_rank_0 | ( | type(c_ptr) | handle, |
| integer(kind(rocsparse_direction_row)) | dir, | ||
| integer(c_int) | m, | ||
| integer(c_int) | n, | ||
| type(c_ptr) | csr_descr, | ||
| real(c_float), target | csr_val, | ||
| integer(c_int), target | csr_row_ptr, | ||
| integer(c_int), target | csr_col_ind, | ||
| integer(c_int) | block_dim, | ||
| type(c_ptr) | bsr_descr, | ||
| real(c_float), target | bsr_val, | ||
| integer(c_int), target | bsr_row_ptr, | ||
| integer(c_int), target | bsr_col_ind | ||
| ) |
◆ rocsparse_scsr2bsr_rank_1()
| integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_scsr2bsr::rocsparse_scsr2bsr_rank_1 | ( | type(c_ptr) | handle, |
| integer(kind(rocsparse_direction_row)) | dir, | ||
| integer(c_int) | m, | ||
| integer(c_int) | n, | ||
| type(c_ptr) | csr_descr, | ||
| real(c_float), dimension(:), target | csr_val, | ||
| integer(c_int), dimension(:), target | csr_row_ptr, | ||
| integer(c_int), dimension(:), target | csr_col_ind, | ||
| integer(c_int) | block_dim, | ||
| type(c_ptr) | bsr_descr, | ||
| real(c_float), dimension(:), target | bsr_val, | ||
| integer(c_int), dimension(:), target | bsr_row_ptr, | ||
| integer(c_int), dimension(:), target | bsr_col_ind | ||
| ) |
The documentation for this interface was generated from the following file: