hipsparsexcsr2bsrnnz Interface Reference

hipsparsexcsr2bsrnnz Interface Reference#

HIPFORT API Reference: hipfort_hipsparse::hipsparsexcsr2bsrnnz Interface Reference
hipfort_hipsparse::hipsparsexcsr2bsrnnz Interface Reference

This function computes the number of non-zero block columns per row and the total number of non-zero blocks in a sparse BSR matrix, given a sparse CSR matrix as input. More...

Public Member Functions

integer(kind(hipsparse_status_success)) function hipsparsexcsr2bsrnnz_ (handle, dira, m, n, descra, csrrowptra, csrcolinda, blockdim, descrc, bsrrowptrc, bsrnnzb)
 
integer(kind(hipsparse_status_success)) function hipsparsexcsr2bsrnnz_rank_0 (handle, dira, m, n, descra, csrrowptra, csrcolinda, blockdim, descrc, bsrrowptrc, bsrnnzb)
 
integer(kind(hipsparse_status_success)) function hipsparsexcsr2bsrnnz_rank_1 (handle, dira, m, n, descra, csrrowptra, csrcolinda, blockdim, descrc, bsrrowptrc, bsrnnzb)
 

Detailed Description

This function computes the number of non-zero block columns per row and the total number of non-zero blocks in a sparse BSR matrix, given a sparse CSR matrix as input.

Consider the matrix:

\[ \begin{bmatrix} 1 & 0 & 0 & 2 \\% 3 & 4 & 0 & 0 \\% 5 & 0 & 6 & 7 \\% 1 & 2 & 3 & 4 \end{bmatrix} \]

stored as a sparse CSR matrix. This function computes both the BSR row pointer array as well as the total number of non-zero blocks that results when converting the CSR matrix to the BSR format. Assuming a block dimension of 2, the above matrix, after conversion to the BSR format, looks 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] \]

and the resulting BSR row pointer array and total non-zero blocks after hipsparseXcsr2bsrNnz has been called looks like:

\[ \begin{align} \text{bsrRowPtrC} &= \begin{bmatrix} 0 & 2 & 4 \end{bmatrix} \\% \text{bsrNnzb} &= 4 \end{align} \]

In general, when converting a CSR matrix of size m x n to a BSR matrix, the resulting BSR matrix will have size mb x nb where mb and nb equal:

\[ \begin{align} \text{mb} &= \text{(m - 1) / blockDim + 1} \\% \text{nb} &= \text{(n - 1) / blockDim + 1} \end{align} \]

In particular, it can be the case that blockDim does not divide evenly into m and/or n. In these cases, the CSR matrix is expanded in size to fit full BSR blocks. For example, using the original CSR matrix and block dimension 3 instead of 2, the function hipsparseXcsr2bsrNnz computes the BSR row pointer array and total number of non-zero blocks for the BSR matrix:

\[ \left[ \begin{array}{c | c} \begin{array}{c c c} 1 & 0 & 0 \\% 3 & 4 & 0 \\% 5 & 0 & 6 \end{array} & \begin{array}{c c c} 2 & 0 & 0 \\% 0 & 0 & 0 \\% 7 & 0 & 0 \end{array} \\% \hline \begin{array}{c c c} 1 & 2 & 3 \\% 0 & 0 & 0 \\% 0 & 0 & 0 \end{array} & \begin{array}{c c c} 4 & 0 & 0 \\% 0 & 0 & 0 \\% 0 & 0 & 0 \end{array} \\% \end{array} \right] \]

See hipsparseScsr2bsr() for a full code example.

Note
The routine supports asynchronous execution if the pointer mode is set to device.
Parameters
[in]handle- handle to the hipSPARSE library context queue.
[in]dirA- direction that specifies whether to count non-zero elements by HIPSPARSE_DIRECTION_ROW or by HIPSPARSE_DIRECTION_COLUMN.
[in]m- number of rows of the sparse CSR matrix. Must be non-negative.
[in]n- number of columns of the sparse CSR matrix.
[in]descrA- descriptor of the sparse CSR matrix. Currently, only HIPSPARSE_MATRIX_TYPE_GENERAL is supported.
[in]csrRowPtrA- integer array containing m+1 elements that points to the start of each row of the CSR matrix.
[in]csrColIndA- integer array of the column indices for each non-zero element in the CSR matrix.
[in]blockDim- the block dimension of the BSR matrix, which is between \(1\) and \(\min(m, n)\).
[in]descrC- descriptor of the sparse BSR matrix. Currently, only HIPSPARSE_MATRIX_TYPE_GENERAL is supported.
[out]bsrRowPtrC- integer array containing mb+1 elements that point to the start of each block row of the BSR matrix.
[out]bsrNnzb- total number of non-zero elements in device or host memory.
Return values
HIPSPARSE_STATUS_SUCCESSthe operation completed successfully.
HIPSPARSE_STATUS_INVALID_VALUEhandle, m, n, blockDim, csrRowPtrA, csrColIndA, bsrRowPtrC, or bsrNnzb pointer is invalid.

Member Function/Subroutine Documentation

◆ hipsparsexcsr2bsrnnz_()

integer(kind(hipsparse_status_success)) function hipfort_hipsparse::hipsparsexcsr2bsrnnz::hipsparsexcsr2bsrnnz_ ( 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  csrrowptra,
type(c_ptr), value  csrcolinda,
integer(c_int), value  blockdim,
type(c_ptr), value  descrc,
type(c_ptr), value  bsrrowptrc,
type(c_ptr), value  bsrnnzb 
)

◆ hipsparsexcsr2bsrnnz_rank_0()

integer(kind(hipsparse_status_success)) function hipfort_hipsparse::hipsparsexcsr2bsrnnz::hipsparsexcsr2bsrnnz_rank_0 ( type(c_ptr)  handle,
integer(kind(hipsparse_direction_row))  dira,
integer(c_int)  m,
integer(c_int)  n,
type(c_ptr)  descra,
integer(c_int), target  csrrowptra,
integer(c_int), target  csrcolinda,
integer(c_int)  blockdim,
type(c_ptr)  descrc,
integer(c_int), target  bsrrowptrc,
integer(c_int), target  bsrnnzb 
)

◆ hipsparsexcsr2bsrnnz_rank_1()

integer(kind(hipsparse_status_success)) function hipfort_hipsparse::hipsparsexcsr2bsrnnz::hipsparsexcsr2bsrnnz_rank_1 ( type(c_ptr)  handle,
integer(kind(hipsparse_direction_row))  dira,
integer(c_int)  m,
integer(c_int)  n,
type(c_ptr)  descra,
integer(c_int), dimension(:), target  csrrowptra,
integer(c_int), dimension(:), target  csrcolinda,
integer(c_int)  blockdim,
type(c_ptr)  descrc,
integer(c_int), dimension(:), target  bsrrowptrc,
integer(c_int), dimension(:), target  bsrnnzb 
)

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