rocsparse_coosort_by_row Interface Reference

rocsparse_coosort_by_row Interface Reference#

HIPFORT API Reference: hipfort_rocsparse::rocsparse_coosort_by_row Interface Reference
hipfort_rocsparse::rocsparse_coosort_by_row Interface Reference

Sort a sparse COO matrix by row. More...

Public Member Functions

integer(kind(rocsparse_status_success)) function rocsparse_coosort_by_row_ (handle, m, n, nnz, coo_row_ind, coo_col_ind, perm, temp_buffer)
 
integer(kind(rocsparse_status_success)) function rocsparse_coosort_by_row_rank_0 (handle, m, n, nnz, coo_row_ind, coo_col_ind, perm, temp_buffer)
 
integer(kind(rocsparse_status_success)) function rocsparse_coosort_by_row_rank_1 (handle, m, n, nnz, coo_row_ind, coo_col_ind, perm, temp_buffer)
 

Detailed Description

Sort a sparse COO matrix by row.

rocsparse_coosort_by_row sorts a matrix in COO format by row. The sorted permutation vector perm can be used to obtain sorted coo_val array. In this case, perm must be initialized as the identity permutation, see rocsparse_create_identity_permutation().

rocsparse_coosort_by_row requires extra temporary storage buffer that has to be allocated by the user. Storage buffer size can be determined by rocsparse_coosort_buffer_size().

Note
perm can be NULL 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]handlehandle to the rocsparse library context queue.
[in]mnumber of rows of the sparse COO matrix.
[in]nnumber of columns of the sparse COO matrix.
[in]nnznumber of non-zero entries of the sparse COO matrix.
[in,out]coo_row_indarray of nnz elements containing the row indices of the sparse COO matrix.
[in,out]coo_col_indarray of nnz elements containing the column indices of the sparse COO matrix.
[in,out]permarray of nnz integers containing the unsorted map indices, can be NULL.
[in]temp_buffertemporary storage buffer allocated by the user, size is returned by rocsparse_coosort_buffer_size().
Return values
rocsparse_status_successthe operation completed successfully.
rocsparse_status_invalid_handlethe library context was not initialized.
rocsparse_status_invalid_sizem, n or nnz is invalid.
rocsparse_status_invalid_pointercoo_row_ind, coo_col_ind or temp_buffer pointer is invalid.
rocsparse_status_internal_erroran internal error occurred.
Example
The following example sorts a \(3 \times 3\) COO matrix by row indices.
/ 1 2 3
/ A = 4 5 6
/ 7 8 9
rocsparse_int m = 3;
rocsparse_int n = 3;
rocsparse_int nnz = 9;
coo_row_ind[nnz] = {0, 1, 2, 0, 1, 2, 0, 1, 2};/ device memory
coo_col_ind[nnz] = {0, 0, 0, 1, 1, 1, 2, 2, 2};/ device memory
coo_val[nnz] = {1, 4, 7, 2, 5, 8, 3, 6, 9};/ device memory
/ Create permutation vector perm as the identity map
rocsparse_int* perm;
hipMalloc((void**)&perm, sizeof(rocsparse_int) * nnz);
rocsparse_create_identity_permutation(handle, nnz, perm);
/ Allocate temporary buffer
size_t buffer_size;
void* temp_buffer;
rocsparse_coosort_buffer_size(handle,
m,
n,
nnz,
coo_row_ind,
coo_col_ind,
&buffer_size);
hipMalloc(&temp_buffer, buffer_size);
/ Sort the COO matrix
rocsparse_coosort_by_row(handle,
m,
n,
nnz,
coo_row_ind,
coo_col_ind,
perm,
temp_buffer);
/ Gather sorted coo_val array
float* coo_val_sorted;
hipMalloc((void**)&coo_val_sorted, sizeof(float) * nnz);
rocsparse_sgthr(handle, nnz, coo_val, coo_val_sorted, perm, rocsparse_index_base_zero);
/ Clean up
hipFree(temp_buffer);
hipFree(perm);
hipFree(coo_val);
@ memory
Definition: hipfort_enums.f:50
@ the
Definition: hipfort_enums.f:49
@ rocsparse_index_base_zero
Definition: hipfort_rocsparse_enums.f:40

Member Function/Subroutine Documentation

◆ rocsparse_coosort_by_row_()

integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_coosort_by_row::rocsparse_coosort_by_row_ ( type(c_ptr), value  handle,
integer(c_int), value  m,
integer(c_int), value  n,
integer(c_int), value  nnz,
type(c_ptr), value  coo_row_ind,
type(c_ptr), value  coo_col_ind,
type(c_ptr), value  perm,
type(c_ptr), value  temp_buffer 
)

◆ rocsparse_coosort_by_row_rank_0()

integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_coosort_by_row::rocsparse_coosort_by_row_rank_0 ( type(c_ptr)  handle,
integer(c_int)  m,
integer(c_int)  n,
integer(c_int)  nnz,
integer(c_int), target  coo_row_ind,
integer(c_int), target  coo_col_ind,
integer(c_int), target  perm,
type(c_ptr)  temp_buffer 
)

◆ rocsparse_coosort_by_row_rank_1()

integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_coosort_by_row::rocsparse_coosort_by_row_rank_1 ( type(c_ptr)  handle,
integer(c_int)  m,
integer(c_int)  n,
integer(c_int)  nnz,
integer(c_int), dimension(:), target  coo_row_ind,
integer(c_int), dimension(:), target  coo_col_ind,
integer(c_int), dimension(:), target  perm,
type(c_ptr)  temp_buffer 
)

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