hipsparsesprunedense2csrnnz Interface Reference

hipsparsesprunedense2csrnnz Interface Reference#

HIPFORT API Reference: hipfort_hipsparse::hipsparsesprunedense2csrnnz Interface Reference
hipfort_hipsparse::hipsparsesprunedense2csrnnz Interface Reference

hipsparseXpruneDense2csrNnz computes the number of non-zero elements per row and the total number of non-zero elements in a dense matrix after the elements less than the (non-negative) threshold are pruned from the matrix. More...

Public Member Functions

integer(kind(hipsparse_status_success)) function hipsparsesprunedense2csrnnz_ (handle, m, n, a, lda, threshold, descr, csrrowptr, nnztotaldevhostptr, buffer)
 
integer(kind(hipsparse_status_success)) function hipsparsesprunedense2csrnnz_rank_0 (handle, m, n, a, lda, threshold, descr, csrrowptr, nnztotaldevhostptr, buffer)
 
integer(kind(hipsparse_status_success)) function hipsparsesprunedense2csrnnz_rank_1 (handle, m, n, a, lda, threshold, descr, csrrowptr, nnztotaldevhostptr, buffer)
 
integer(kind(hipsparse_status_success)) function hipsparsesprunedense2csrnnz_full_rank (handle, m, n, a, lda, threshold, descr, csrrowptr, nnztotaldevhostptr, buffer)
 

Detailed Description

hipsparseXpruneDense2csrNnz computes the number of non-zero elements per row and the total number of non-zero elements in a dense matrix after the elements less than the (non-negative) threshold are pruned from the matrix.

Given an input dense column ordered matrix A, with leading dimension lda where lda>=m, the resulting pruned sparse CSR matrix \(C\) is computed using:

\[ |C(i,j)| = A(i, j) \text{ if |A(i, j)| > threshold} \]

First, the user must determine the size of the required temporary buffer using the routine hipsparseSpruneDense2csr_bufferSize "hipsparseXpruneDense2csr_bufferSize()" and then allocate it. Next, the user allocates csrRowPtr with size m+1. Then the function passes both the temporary storage buffer and csrRowPtr to hipsparseXpruneDense2csrNnz to determine the total number of non-zeros that will exist in the sparse CSR matrix C (after pruning has been performed on A ) as well as fill the output CSR row pointer array csrRowPtr.

For example, given the dense matrix:

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

and the threshold value 5, the resulting matrix after pruning is:

\[ \begin{bmatrix} 6 & 0 & 0 & 7 \\% 0 & 6 & 7 & 8 \\% 0 & 0 & 8 & 0 \end{bmatrix} \]

and the corresponding row pointer array and non-zero count:

\[ \begin{align} \text{csrRowPtr} &= \begin{bmatrix} 0 & 2 & 5 & 6 \end{bmatrix} \\% \text{nnzTotalDevHostPtr} &= 6 \end{align} \]

The above example assumes a zero index base for the output CSR matrix. Users can set the desired index base in the output CSR matrix by setting it in the hipsparseMatDescr_t. See hipsparseSetMatIndexBase ().

For a full code example on how to use this routine, see hipsparseSpruneDense2csr().

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]m- number of rows of the dense matrix A.
[in]n- number of columns of the dense matrix A.
[in]A- array of dimensions (lda, n).
[in]lda- leading dimension of the dense array A.
[in]threshold- pointer to the pruning non-negative threshold, which can exist in either host or device memory.
[in]descr- the descriptor of the dense matrix A.
[out]csrRowPtr- integer array of m+1 elements that contains the start of every row and the end of the last row plus one.
[out]nnzTotalDevHostPtr- total number of non-zero elements in device or host memory.
[out]buffer- buffer allocated by the user whose size is determined by calling hipsparseSpruneDense2csr_bufferSize "hipsparseXpruneDense2csr_bufferSize()" or hipsparseSpruneDense2csr_bufferSizeExt "hipsparseXpruneDense2csr_bufferSizeExt()".
Return values
HIPSPARSE_STATUS_SUCCESSthe operation completed successfully.
HIPSPARSE_STATUS_INVALID_VALUEhandle, m, n, lda, A, threshold, descr, csrRowPtr, nnzTotalDevHostPtr, or buffer pointer is invalid.

Member Function/Subroutine Documentation

◆ hipsparsesprunedense2csrnnz_()

integer(kind(hipsparse_status_success)) function hipfort_hipsparse::hipsparsesprunedense2csrnnz::hipsparsesprunedense2csrnnz_ ( type(c_ptr), value  handle,
integer(c_int), value  m,
integer(c_int), value  n,
type(c_ptr), value  a,
integer(c_int), value  lda,
real(c_float)  threshold,
type(c_ptr), value  descr,
type(c_ptr), value  csrrowptr,
integer(c_int)  nnztotaldevhostptr,
type(c_ptr), value  buffer 
)

◆ hipsparsesprunedense2csrnnz_full_rank()

integer(kind(hipsparse_status_success)) function hipfort_hipsparse::hipsparsesprunedense2csrnnz::hipsparsesprunedense2csrnnz_full_rank ( type(c_ptr)  handle,
integer(c_int)  m,
integer(c_int)  n,
real(c_float), dimension(:,:), target  a,
integer(c_int)  lda,
real(c_float)  threshold,
type(c_ptr)  descr,
integer(c_int), dimension(:), target  csrrowptr,
integer(c_int)  nnztotaldevhostptr,
type(c_ptr)  buffer 
)

◆ hipsparsesprunedense2csrnnz_rank_0()

integer(kind(hipsparse_status_success)) function hipfort_hipsparse::hipsparsesprunedense2csrnnz::hipsparsesprunedense2csrnnz_rank_0 ( type(c_ptr)  handle,
integer(c_int)  m,
integer(c_int)  n,
real(c_float), target  a,
integer(c_int)  lda,
real(c_float)  threshold,
type(c_ptr)  descr,
integer(c_int), target  csrrowptr,
integer(c_int)  nnztotaldevhostptr,
type(c_ptr)  buffer 
)

◆ hipsparsesprunedense2csrnnz_rank_1()

integer(kind(hipsparse_status_success)) function hipfort_hipsparse::hipsparsesprunedense2csrnnz::hipsparsesprunedense2csrnnz_rank_1 ( type(c_ptr)  handle,
integer(c_int)  m,
integer(c_int)  n,
real(c_float), dimension(:), target  a,
integer(c_int)  lda,
real(c_float)  threshold,
type(c_ptr)  descr,
integer(c_int), dimension(:), target  csrrowptr,
integer(c_int)  nnztotaldevhostptr,
type(c_ptr)  buffer 
)

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