rocsparse_scsr2gebsr Interface Reference

rocsparse_scsr2gebsr Interface Reference#

HIPFORT API Reference: hipfort_rocsparse::rocsparse_scsr2gebsr Interface Reference
hipfort_rocsparse::rocsparse_scsr2gebsr Interface Reference

Convert a sparse CSR matrix into a sparse general BSR matrix. More...

Public Member Functions

integer(kind(rocsparse_status_success)) function rocsparse_scsr2gebsr_ (handle, dir, m, n, csr_descr, csr_val, csr_row_ptr, csr_col_ind, bsr_descr, bsr_val, bsr_row_ptr, bsr_col_ind, row_block_dim, col_block_dim, temp_buffer)
 
integer(kind(rocsparse_status_success)) function rocsparse_scsr2gebsr_rank_0 (handle, dir, m, n, csr_descr, csr_val, csr_row_ptr, csr_col_ind, bsr_descr, bsr_val, bsr_row_ptr, bsr_col_ind, row_block_dim, col_block_dim, temp_buffer)
 
integer(kind(rocsparse_status_success)) function rocsparse_scsr2gebsr_rank_1 (handle, dir, m, n, csr_descr, csr_val, csr_row_ptr, csr_col_ind, bsr_descr, bsr_val, bsr_row_ptr, bsr_col_ind, row_block_dim, col_block_dim, temp_buffer)
 

Detailed Description

Convert a sparse CSR matrix into a sparse general BSR matrix.

rocsparse_csr2gebsr converts a CSR matrix into a general 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 general BSR matrix:

\[ mb = (m + row\_block\_dim - 1) / row\_block\_dim \\% nb = (n + col\_block\_dim - 1) / col\_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 general BSR matrix requires three steps. First, call rocsparse_Xcsr2gebsr_buffer_size() to determine the size of the required temporary storage buffer. After this has been determined, allocate this buffer. Also now allocate the bsr_row_ptr array to have length mb+1 and pass it to the function rocsparse_csr2gebsr_nnz. This will fill the bsr_row_ptr array and also compute the total number of non-zero blocks in the general 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_csr2gebsr to complete the conversion. 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_row or rocsparse_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_general is supported.
[in]csr_val- array of nnz elements containing the values of the sparse CSR matrix.
[in]csr_row_ptr- array of m+1 elements that point to the start of every row of the sparse CSR matrix.
[in]csr_col_ind- array of nnz elements containing the column indices of the sparse CSR matrix.
[in]bsr_descr- descriptor of the sparse BSR matrix. Currently, only rocsparse_matrix_type_general is supported.
[out]bsr_val- array of nnzb* row_block_dim* col_block_dim containing the values of the sparse BSR matrix.
[out]bsr_row_ptr- array of mb+1 elements that point to the start of every block row of the sparse BSR matrix.
[out]bsr_col_ind- array of nnzb elements containing the block column indices of the sparse BSR matrix.
[in]row_block_dim- row size of the blocks in the sparse general BSR matrix.
[in]col_block_dim- col size of the blocks in the sparse general BSR matrix.
[in]temp_buffer- buffer allocated by the user. Its size is determined by calling rocsparse_Xcsr2gebsr_buffer_size().
Return values
rocsparse_status_successthe operation completed successfully.
rocsparse_status_invalid_handlethe library context was not initialized.
rocsparse_status_invalid_sizem, n, row_block_dim, or col_block_dim is invalid.
rocsparse_status_invalid_pointerbsr_val, bsr_row_ptr, bsr_col_ind, csr_val, csr_row_ptr, or csr_col_ind pointer is invalid.
Example
This example converts a CSR matrix into an BSR matrix.

Member Function/Subroutine Documentation

◆ rocsparse_scsr2gebsr_()

integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_scsr2gebsr::rocsparse_scsr2gebsr_ ( 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,
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,
integer(c_int), value  row_block_dim,
integer(c_int), value  col_block_dim,
type(c_ptr), value  temp_buffer 
)

◆ rocsparse_scsr2gebsr_rank_0()

integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_scsr2gebsr::rocsparse_scsr2gebsr_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,
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,
integer(c_int)  row_block_dim,
integer(c_int)  col_block_dim,
type(c_ptr)  temp_buffer 
)

◆ rocsparse_scsr2gebsr_rank_1()

integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_scsr2gebsr::rocsparse_scsr2gebsr_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,
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,
integer(c_int)  row_block_dim,
integer(c_int)  col_block_dim,
type(c_ptr)  temp_buffer 
)

The documentation for this interface was generated from the following file: