rocsparse_coo2csr Interface Reference

rocsparse_coo2csr Interface Reference#

HIPFORT API Reference: hipfort_rocsparse::rocsparse_coo2csr Interface Reference
hipfort_rocsparse::rocsparse_coo2csr Interface Reference

Convert a sparse COO matrix into a sparse CSR matrix. More...

Public Member Functions

integer(kind(rocsparse_status_success)) function rocsparse_coo2csr_ (handle, coo_row_ind, nnz, m, csr_row_ptr, idx_base)
 
integer(kind(rocsparse_status_success)) function rocsparse_coo2csr_rank_0 (handle, coo_row_ind, nnz, m, csr_row_ptr, idx_base)
 
integer(kind(rocsparse_status_success)) function rocsparse_coo2csr_rank_1 (handle, coo_row_ind, nnz, m, csr_row_ptr, idx_base)
 

Detailed Description

Convert a sparse COO matrix into a sparse CSR matrix.

rocsparse_coo2csr converts the COO array containing the row indices into a CSR array of row offsets, that point to the start of every row. It is assumed that the COO row index array is sorted.

Note
It can also be used, to convert a COO array containing the column indices into a CSC array of column offsets, that point to the start of every column. Then, it is assumed that the COO column index array is sorted, instead.
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]coo_row_indarray of nnz elements containing the row indices of the sparse COO matrix.
[in]nnznumber of non-zero entries of the sparse CSR matrix.
[in]mnumber of rows of the sparse CSR matrix.
[out]csr_row_ptrarray of m+1 elements that point to the start of every row of the sparse CSR matrix.
[in]idx_baserocsparse_index_base_zero or rocsparse_index_base_one.
Return values
rocsparse_status_successthe operation completed successfully.
rocsparse_status_invalid_handlethe library context was not initialized.
rocsparse_status_invalid_sizem or nnz is invalid.
rocsparse_status_invalid_pointercoo_row_ind or csr_row_ptr pointer is invalid.
Example
This example converts a COO matrix into a CSR matrix.
/ 1 2 0 3 0
/ A = 0 4 5 0 0
/ 6 0 0 7 8
rocsparse_int m = 3;
rocsparse_int n = 5;
rocsparse_int nnz = 8;
coo_row_ind[nnz] = {0, 0, 0, 1, 1, 2, 2, 2};/ device memory
coo_col_ind[nnz] = {0, 1, 3, 1, 2, 0, 3, 4};/ device memory
coo_val[nnz] = {1, 2, 3, 4, 5, 6, 7, 8};/ device memory
/ Allocate CSR matrix arrays
rocsparse_int* csr_row_ptr;
rocsparse_int* csr_col_ind;
float* csr_val;
hipMalloc((void**)&csr_row_ptr, sizeof(rocsparse_int) * (m + 1));
hipMalloc((void**)&csr_col_ind, sizeof(rocsparse_int) * nnz);
hipMalloc((void**)&csr_val, sizeof(float) * nnz);
/ Convert the coo row indices into csr row offsets
rocsparse_coo2csr(handle,
coo_row_ind,
nnz,
m,
csr_row_ptr,
/ Copy the column and value arrays
hipMemcpy(csr_col_ind,
coo_col_ind,
sizeof(rocsparse_int) * nnz,
hipMemcpyDeviceToDevice);
hipMemcpy(csr_val,
coo_val,
sizeof(float) * nnz,
hipMemcpyDeviceToDevice);
@ 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_coo2csr_()

integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_coo2csr::rocsparse_coo2csr_ ( type(c_ptr), value  handle,
type(c_ptr), value  coo_row_ind,
integer(c_int), value  nnz,
integer(c_int), value  m,
type(c_ptr), value  csr_row_ptr,
integer(kind(rocsparse_index_base_zero)), value  idx_base 
)

◆ rocsparse_coo2csr_rank_0()

integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_coo2csr::rocsparse_coo2csr_rank_0 ( type(c_ptr)  handle,
integer(c_int), target  coo_row_ind,
integer(c_int)  nnz,
integer(c_int)  m,
integer(c_int), target  csr_row_ptr,
integer(kind(rocsparse_index_base_zero))  idx_base 
)

◆ rocsparse_coo2csr_rank_1()

integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_coo2csr::rocsparse_coo2csr_rank_1 ( type(c_ptr)  handle,
integer(c_int), dimension(:), target  coo_row_ind,
integer(c_int)  nnz,
integer(c_int)  m,
integer(c_int), dimension(:), target  csr_row_ptr,
integer(kind(rocsparse_index_base_zero))  idx_base 
)

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