rocsparse_sgebsr2gebsr Interface Reference#
This function converts the general BSR sparse matrix \(A\) to another general BSR sparse matrix \(C\). More...
Public Member Functions | |
| integer(kind(rocsparse_status_success)) function | rocsparse_sgebsr2gebsr_ (handle, dir, mb, nb, nnzb, descr_a, bsr_val_a, bsr_row_ptr_a, bsr_col_ind_a, row_block_dim_a, col_block_dim_a, descr_c, bsr_val_c, bsr_row_ptr_c, bsr_col_ind_c, row_block_dim_c, col_block_dim_c, temp_buffer) |
Detailed Description
This function converts the general BSR sparse matrix \(A\) to another general BSR sparse matrix \(C\).
rocsparse_gebsr2gebsr converts a general BSR matrix \(A\) into a general BSR matrix \(C\). The input and output matrices can have different row and column block dimensions. The input matrix \(A\) is assumed to be allocated such that array bsr_row_ptr_A has length mb+1, bsr_col_ind_A has length nnzb, and bsr_val_A has length nnzb*row_block_dim_A*col_block_dim_A. The output matrix \(C\) is assumed to be allocated such that array bsr_row_ptr_C has length mb_C+1, bsr_col_ind_C has length nnzb_C, and bsr_val_C has length nnzb_C*row_block_dim_C*col_block_dim_C where:
\[ m = mb * row\_block\_dim\_A \\% n = nb * col\_block\_dim\_A \]
and
\[ mb\_C = (m + row\_block\_dim\_C - 1) / row\_block\_dim\_C \\% nb\_C = (n + col\_block\_dim\_C - 1) / col\_block\_dim\_C \]
The number of non-zero blocks in the output sparse \(C\) matrix (i.e. nnzb_C) is computed using rocsparse_gebsr2gebsr_nnz() which also fills in the bsr_row_ptr_C array.
Converting from a sparse general BSR matrix to a sparse general BSR matrix requires three steps. First, call rocsparse_Xgebsr2gebsr_buffer_size() to determine the size of the required temporary storage buffer. After this has been determined, allocate this buffer. Also allocate the bsr_row_ptr_C array to have length mb_C+1 and pass it to the function rocsparse_gebsr2gebsr_nnz. This will fill the bsr_row_ptr_C array and also compute the total number of non-zero blocks in the general BSR output \(C\) matrix. Now that the total number of non-zero blocks is known, allocate the bsr_col_ind_C and bsr_val_C arrays. Finally, call rocsparse_gebsr2gebsr to complete the conversion. After the conversion is complete, the temporary storage buffer can be deallocated. See the example below.
- 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] mb - number of block rows of the general BSR sparse matrix \(A\). [in] nb - number of block columns of the general BSR sparse matrix \(A\). [in] nnzb - number of blocks in the general BSR sparse matrix \(A\). [in] descr_A - the descriptor of the general BSR sparse matrix \(A\). The supported matrix type is rocsparse_matrix_type_generaland also any valid value of therocsparse_index_base.[in] bsr_val_A - array of nnzb*row_block_dim_A*col_block_dim_Acontaining the values of the sparse general BSR matrix \(A\).[in] bsr_row_ptr_A - array of mb+1elements that point to the start of every block row of the sparse general BSR matrix \(A\).[in] bsr_col_ind_A - array of nnzbelements containing the block column indices of the sparse general BSR matrix \(A\).[in] row_block_dim_A - row size of the blocks in the sparse general BSR matrix \(A\). [in] col_block_dim_A - column size of the blocks in the sparse general BSR matrix \(A\). [in] descr_C - the descriptor of the general BSR sparse matrix \(C\). The supported matrix type is rocsparse_matrix_type_generaland also any valid value of therocsparse_index_base.[in] bsr_val_C - array of nnzb_C*row_block_dim_C*col_block_dim_Ccontaining the values of the sparse general BSR matrix \(C\).[in] bsr_row_ptr_C - array of mb_C+1elements that point to the start of every block row of the sparse general BSR matrix \(C\).[in] bsr_col_ind_C - array of nnzb_Celements containing the block column indices of the sparse general BSR matrix \(C\).[in] row_block_dim_C - row size of the blocks in the sparse general BSR matrix \(C\). [in] col_block_dim_C - column size of the blocks in the sparse general BSR matrix \(C\). [out] temp_buffer - buffer allocated by the user. Its size is determined by calling rocsparse_Xgebsr2gebsr_buffer_size().
- Return values
-
rocsparse_status_success the operation completed successfully. rocsparse_status_invalid_handle the library context was not initialized. rocsparse_status_invalid_size mb,nb,nnzb,row_block_dim_A,col_block_dim_A,row_block_dim_C, orcol_block_dim_Cis invalid.rocsparse_status_invalid_pointer bsr_row_ptr_A,bsr_col_ind_A,bsr_val_A,bsr_row_ptr_C,bsr_col_ind_C,bsr_val_C,descr_A,descr_C, ortemp_bufferpointer is invalid.
- Example
- This example converts a general BSR matrix into an general BSR matrix.
Member Function/Subroutine Documentation
◆ rocsparse_sgebsr2gebsr_()
| integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_sgebsr2gebsr::rocsparse_sgebsr2gebsr_ | ( | type(c_ptr), value | handle, |
| integer(kind(rocsparse_direction_row)), value | dir, | ||
| integer(c_int), value | mb, | ||
| integer(c_int), value | nb, | ||
| integer(c_int), value | nnzb, | ||
| type(c_ptr), value | descr_a, | ||
| type(c_ptr), value | bsr_val_a, | ||
| type(c_ptr), value | bsr_row_ptr_a, | ||
| type(c_ptr), value | bsr_col_ind_a, | ||
| integer(c_int), value | row_block_dim_a, | ||
| integer(c_int), value | col_block_dim_a, | ||
| type(c_ptr), value | descr_c, | ||
| type(c_ptr), value | bsr_val_c, | ||
| type(c_ptr), value | bsr_row_ptr_c, | ||
| type(c_ptr), value | bsr_col_ind_c, | ||
| integer(c_int), value | row_block_dim_c, | ||
| integer(c_int), value | col_block_dim_c, | ||
| type(c_ptr), value | temp_buffer | ||
| ) |
The documentation for this interface was generated from the following file: