rocsparse_csrsort Interface Reference#
hipfort_rocsparse::rocsparse_csrsort Interface Reference
Sort a sparse CSR matrix. More...
Public Member Functions | |
integer(kind(rocsparse_status_success)) function | rocsparse_csrsort_ (handle, m, n, nnz, descr, csr_row_ptr, csr_col_ind, perm, temp_buffer) |
integer(kind(rocsparse_status_success)) function | rocsparse_csrsort_rank_0 (handle, m, n, nnz, descr, csr_row_ptr, csr_col_ind, perm, temp_buffer) |
integer(kind(rocsparse_status_success)) function | rocsparse_csrsort_rank_1 (handle, m, n, nnz, descr, csr_row_ptr, csr_col_ind, perm, temp_buffer) |
Detailed Description
Sort a sparse CSR matrix.
rocsparse_csrsort
sorts a matrix in CSR format. The sorted permutation vector perm
can be used to obtain sorted csr_val
array. In this case, perm
must be initialized as the identity permutation, see rocsparse_create_identity_permutation().
rocsparse_csrsort
requires extra temporary storage buffer that has to be allocated by the user. Storage buffer size can be determined by rocsparse_csrsort_buffer_size().
- Note
perm
can beNULL
if a sorted permutation vector is not required.- This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.
- Parameters
-
[in] handle handle to the rocsparse library context queue. [in] m number of rows of the sparse CSR matrix. [in] n number of columns of the sparse CSR matrix. [in] nnz number of non-zero entries of the sparse CSR matrix. [in] descr descriptor of the sparse CSR matrix. Currently, only rocsparse_matrix_type_general
is supported.[in] csr_row_ptr array of m+1
elements that point to the start of every row of the sparse CSR matrix.[in,out] csr_col_ind array of nnz
elements containing the column indices of the sparse CSR matrix.[in,out] perm array of nnz
integers containing the unsorted map indices, can beNULL
.[in] temp_buffer temporary storage buffer allocated by the user, size is returned by rocsparse_csrsort_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 m
,n
ornnz
is invalid.rocsparse_status_invalid_pointer descr
,csr_row_ptr
,csr_col_ind
ortemp_buffer
pointer is invalid.rocsparse_status_internal_error an internal error occurred. rocsparse_status_not_implemented rocsparse_matrix_type
!=rocsparse_matrix_type_general
.
- Example
- The following example sorts a \(3 \times 3\) CSR matrix. / 1 2 3/ A = 4 5 6/ 7 8 9rocsparse_int m = 3;rocsparse_int n = 3;rocsparse_int nnz = 9;csr_row_ptr[m + 1] = {0, 3, 6, 9};/ device memorycsr_col_ind[nnz] = {2, 0, 1, 0, 1, 2, 0, 2, 1};/ device memorycsr_val[nnz] = {3, 1, 2, 4, 5, 6, 7, 9, 8};/ device memory/ Create permutation vector perm as the identity maprocsparse_int* perm;hipMalloc((void**)&perm, sizeof(rocsparse_int) * nnz);rocsparse_create_identity_permutation(handle, nnz, perm);/ Allocate temporary buffersize_t buffer_size;void* temp_buffer;rocsparse_csrsort_buffer_size(handle, m, n, nnz, csr_row_ptr, csr_col_ind, &buffer_size);hipMalloc(&temp_buffer, buffer_size);/ Sort the CSR matrixrocsparse_csrsort(handle, m, n, nnz, descr, csr_row_ptr, csr_col_ind, perm, temp_buffer);/ Gather sorted csr_val arrayfloat* csr_val_sorted;hipMalloc((void**)&csr_val_sorted, sizeof(float) * nnz);rocsparse_sgthr(handle, nnz, csr_val, csr_val_sorted, perm, rocsparse_index_base_zero);/ Clean uphipFree(temp_buffer);hipFree(perm);hipFree(csr_val);@ rocsparse_index_base_zeroDefinition: hipfort_rocsparse_enums.f:40
Member Function/Subroutine Documentation
◆ rocsparse_csrsort_()
integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_csrsort::rocsparse_csrsort_ | ( | type(c_ptr), value | handle, |
integer(c_int), value | m, | ||
integer(c_int), value | n, | ||
integer(c_int), value | nnz, | ||
type(c_ptr), value | descr, | ||
type(c_ptr), value | csr_row_ptr, | ||
type(c_ptr), value | csr_col_ind, | ||
type(c_ptr), value | perm, | ||
type(c_ptr), value | temp_buffer | ||
) |
◆ rocsparse_csrsort_rank_0()
integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_csrsort::rocsparse_csrsort_rank_0 | ( | type(c_ptr) | handle, |
integer(c_int) | m, | ||
integer(c_int) | n, | ||
integer(c_int) | nnz, | ||
type(c_ptr) | descr, | ||
integer(c_int), target | csr_row_ptr, | ||
integer(c_int), target | csr_col_ind, | ||
integer(c_int), target | perm, | ||
type(c_ptr) | temp_buffer | ||
) |
◆ rocsparse_csrsort_rank_1()
integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_csrsort::rocsparse_csrsort_rank_1 | ( | type(c_ptr) | handle, |
integer(c_int) | m, | ||
integer(c_int) | n, | ||
integer(c_int) | nnz, | ||
type(c_ptr) | descr, | ||
integer(c_int), dimension(:), target | csr_row_ptr, | ||
integer(c_int), dimension(:), target | csr_col_ind, | ||
integer(c_int), dimension(:), target | perm, | ||
type(c_ptr) | temp_buffer | ||
) |
The documentation for this interface was generated from the following file: