This page contains proposed changes for a future release of ROCm. Read the latest Linux release of ROCm documentation for your production environments.

rocsparse_csr2coo Interface Reference

rocsparse_csr2coo Interface Reference#

HIPFORT API Reference: hipfort_rocsparse::rocsparse_csr2coo Interface Reference
hipfort_rocsparse::rocsparse_csr2coo Interface Reference

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

Public Member Functions

integer(kind(rocsparse_status_success)) function rocsparse_csr2coo_ (handle, csr_row_ptr, nnz, m, coo_row_ind, idx_base)
 
integer(kind(rocsparse_status_success)) function rocsparse_csr2coo_rank_0 (handle, csr_row_ptr, nnz, m, coo_row_ind, idx_base)
 
integer(kind(rocsparse_status_success)) function rocsparse_csr2coo_rank_1 (handle, csr_row_ptr, nnz, m, coo_row_ind, idx_base)
 

Detailed Description

Convert a sparse CSR matrix into a sparse COO matrix.

rocsparse_csr2coo converts the CSR array containing the row offsets, that point to the start of every row, into a COO array of row indices.

Note
It can also be used to convert a CSC array containing the column offsets into a COO array of column indices.
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]csr_row_ptrarray of m+1 elements that point to the start of every row of the sparse CSR matrix.
[in]nnznumber of non-zero entries of the sparse CSR matrix.
[in]mnumber of rows of the sparse CSR matrix.
[out]coo_row_indarray of nnz elements containing the row indices of the sparse COO 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_pointercsr_row_ptr or coo_row_ind pointer is invalid.
rocsparse_status_arch_mismatchthe device is not supported.
Example
This example converts a CSR matrix into a COO 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;
csr_row_ptr[m+1] = {0, 3, 5, 8};/ device memory
csr_col_ind[nnz] = {0, 1, 3, 1, 2, 0, 3, 4};/ device memory
csr_val[nnz] = {1, 2, 3, 4, 5, 6, 7, 8};/ device memory
/ Allocate COO matrix arrays
rocsparse_int* coo_row_ind;
rocsparse_int* coo_col_ind;
float* coo_val;
hipMalloc((void**)&coo_row_ind, sizeof(rocsparse_int) * nnz);
hipMalloc((void**)&coo_col_ind, sizeof(rocsparse_int) * nnz);
hipMalloc((void**)&coo_val, sizeof(float) * nnz);
/ Convert the csr row offsets into coo row indices
rocsparse_csr2coo(handle,
csr_row_ptr,
nnz,
m,
coo_row_ind,
/ Copy the column and value arrays
hipMemcpy(coo_col_ind,
csr_col_ind,
sizeof(rocsparse_int) * nnz,
hipMemcpyDeviceToDevice);
hipMemcpy(coo_val,
csr_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_csr2coo_()

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

◆ rocsparse_csr2coo_rank_0()

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

◆ rocsparse_csr2coo_rank_1()

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

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