Sparse Auxiliary Functions#

This module holds all sparse auxiliary functions.

The functions that are contained in the auxiliary module describe all available helper functions that are required for subsequent library calls.

The functions in this module do not support execution in a hipGraph context.

rocsparse_create_handle()#

rocsparse_status rocsparse_create_handle(rocsparse_handle *handle)#

Create a rocsparse handle.

rocsparse_create_handle creates the rocSPARSE library context. It must be initialized before any other rocSPARSE API function is invoked and must be passed to all subsequent library function calls. The handle should be destroyed at the end using rocsparse_destroy_handle().

Parameters:

handle[out] the pointer to the handle to the rocSPARSE library context.

Return values:
  • rocsparse_status_success – the initialization succeeded.

  • rocsparse_status_invalid_handlehandle pointer is invalid.

  • rocsparse_status_internal_error – an internal error occurred.

rocsparse_destroy_handle()#

rocsparse_status rocsparse_destroy_handle(rocsparse_handle handle)#

Destroy a rocsparse handle.

rocsparse_destroy_handle destroys the rocSPARSE library context and releases all resources used by the rocSPARSE library.

Parameters:

handle[in] the handle to the rocSPARSE library context.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_handlehandle is invalid.

  • rocsparse_status_internal_error – an internal error occurred.

rocsparse_set_stream()#

rocsparse_status rocsparse_set_stream(rocsparse_handle handle, hipStream_t stream)#

Specify user defined HIP stream.

rocsparse_set_stream specifies the stream to be used by the rocSPARSE library context and all subsequent function calls.

Example

This example illustrates, how a user defined stream can be used in rocSPARSE.

// Create rocSPARSE handle
rocsparse_handle handle;
rocsparse_create_handle(&handle);

// Create stream
hipStream_t stream;
hipStreamCreate(&stream);

// Set stream to rocSPARSE handle
rocsparse_set_stream(handle, stream);

// Do some work
// ...

// Clean up
rocsparse_destroy_handle(handle);
hipStreamDestroy(stream);

Parameters:
  • handle[inout] the handle to the rocSPARSE library context.

  • stream[in] the stream to be used by the rocSPARSE library context.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_handlehandle is invalid.

rocsparse_get_stream()#

rocsparse_status rocsparse_get_stream(rocsparse_handle handle, hipStream_t *stream)#

Get current stream from library context.

rocsparse_get_stream gets the rocSPARSE library context stream which is currently used for all subsequent function calls.

Parameters:
  • handle[in] the handle to the rocSPARSE library context.

  • stream[out] the stream currently used by the rocSPARSE library context.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_handlehandle is invalid.

rocsparse_set_pointer_mode()#

rocsparse_status rocsparse_set_pointer_mode(rocsparse_handle handle, rocsparse_pointer_mode pointer_mode)#

Specify pointer mode.

rocsparse_set_pointer_mode specifies the pointer mode to be used by the rocSPARSE library context and all subsequent function calls. By default, all values are passed by reference on the host. Valid pointer modes are rocsparse_pointer_mode_host or rocsparse_pointer_mode_device.

Parameters:
  • handle[in] the handle to the rocSPARSE library context.

  • pointer_mode[in] the pointer mode to be used by the rocSPARSE library context.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_handlehandle is invalid.

rocsparse_get_pointer_mode()#

rocsparse_status rocsparse_get_pointer_mode(rocsparse_handle handle, rocsparse_pointer_mode *pointer_mode)#

Get current pointer mode from library context.

rocsparse_get_pointer_mode gets the rocSPARSE library context pointer mode which is currently used for all subsequent function calls.

Parameters:
  • handle[in] the handle to the rocSPARSE library context.

  • pointer_mode[out] the pointer mode that is currently used by the rocSPARSE library context.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_handlehandle is invalid.

rocsparse_get_version()#

rocsparse_status rocsparse_get_version(rocsparse_handle handle, int *version)#

Get rocSPARSE version.

rocsparse_get_version gets the rocSPARSE library version number.

  • patch = version % 100

  • minor = version / 100 % 1000

  • major = version / 100000

Parameters:
  • handle[in] the handle to the rocSPARSE library context.

  • version[out] the version number of the rocSPARSE library.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_handlehandle is invalid.

rocsparse_get_git_rev()#

rocsparse_status rocsparse_get_git_rev(rocsparse_handle handle, char *rev)#

Get rocSPARSE git revision.

rocsparse_get_git_rev gets the rocSPARSE library git commit revision (SHA-1).

Parameters:
  • handle[in] the handle to the rocSPARSE library context.

  • rev[out] the git commit revision (SHA-1).

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_handlehandle is invalid.

rocsparse_create_mat_descr()#

rocsparse_status rocsparse_create_mat_descr(rocsparse_mat_descr *descr)#

Create a matrix descriptor.

rocsparse_create_mat_descr creates a matrix descriptor. It initializes rocsparse_matrix_type to rocsparse_matrix_type_general and rocsparse_index_base to rocsparse_index_base_zero. It should be destroyed at the end using rocsparse_destroy_mat_descr().

Parameters:

descr[out] the pointer to the matrix descriptor.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerdescr pointer is invalid.

rocsparse_destroy_mat_descr()#

rocsparse_status rocsparse_destroy_mat_descr(rocsparse_mat_descr descr)#

Destroy a matrix descriptor.

rocsparse_destroy_mat_descr destroys a matrix descriptor and releases all resources used by the descriptor.

Parameters:

descr[in] the matrix descriptor.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerdescr is invalid.

rocsparse_copy_mat_descr()#

rocsparse_status rocsparse_copy_mat_descr(rocsparse_mat_descr dest, const rocsparse_mat_descr src)#

Copy a matrix descriptor.

rocsparse_copy_mat_descr copies a matrix descriptor. Both, source and destination matrix descriptors must be initialized prior to calling rocsparse_copy_mat_descr.

Parameters:
  • dest[out] the pointer to the destination matrix descriptor.

  • src[in] the pointer to the source matrix descriptor.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointersrc or dest pointer is invalid.

rocsparse_set_mat_index_base()#

rocsparse_status rocsparse_set_mat_index_base(rocsparse_mat_descr descr, rocsparse_index_base base)#

Specify the index base of a matrix descriptor.

rocsparse_set_mat_index_base sets the index base of a matrix descriptor. Valid options are rocsparse_index_base_zero or rocsparse_index_base_one.

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerdescr pointer is invalid.

  • rocsparse_status_invalid_valuebase is invalid.

rocsparse_get_mat_index_base()#

rocsparse_index_base rocsparse_get_mat_index_base(const rocsparse_mat_descr descr)#

Get the index base of a matrix descriptor.

rocsparse_get_mat_index_base returns the index base of a matrix descriptor.

Parameters:

descr[in] the matrix descriptor.

Returns:

rocsparse_index_base_zero or rocsparse_index_base_one.

rocsparse_set_mat_type()#

rocsparse_status rocsparse_set_mat_type(rocsparse_mat_descr descr, rocsparse_matrix_type type)#

Specify the matrix type of a matrix descriptor.

rocsparse_set_mat_type sets the matrix type of a matrix descriptor. Valid matrix types are rocsparse_matrix_type_general, rocsparse_matrix_type_symmetric, rocsparse_matrix_type_hermitian or rocsparse_matrix_type_triangular.

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerdescr pointer is invalid.

  • rocsparse_status_invalid_valuetype is invalid.

rocsparse_get_mat_type()#

rocsparse_matrix_type rocsparse_get_mat_type(const rocsparse_mat_descr descr)#

Get the matrix type of a matrix descriptor.

rocsparse_get_mat_type returns the matrix type of a matrix descriptor.

Parameters:

descr[in] the matrix descriptor.

Returns:

rocsparse_matrix_type_general, rocsparse_matrix_type_symmetric, rocsparse_matrix_type_hermitian or rocsparse_matrix_type_triangular.

rocsparse_set_mat_fill_mode()#

rocsparse_status rocsparse_set_mat_fill_mode(rocsparse_mat_descr descr, rocsparse_fill_mode fill_mode)#

Specify the matrix fill mode of a matrix descriptor.

rocsparse_set_mat_fill_mode sets the matrix fill mode of a matrix descriptor. Valid fill modes are rocsparse_fill_mode_lower or rocsparse_fill_mode_upper.

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerdescr pointer is invalid.

  • rocsparse_status_invalid_valuefill_mode is invalid.

rocsparse_get_mat_fill_mode()#

rocsparse_fill_mode rocsparse_get_mat_fill_mode(const rocsparse_mat_descr descr)#

Get the matrix fill mode of a matrix descriptor.

rocsparse_get_mat_fill_mode returns the matrix fill mode of a matrix descriptor.

Parameters:

descr[in] the matrix descriptor.

Returns:

rocsparse_fill_mode_lower or rocsparse_fill_mode_upper.

rocsparse_set_mat_diag_type()#

rocsparse_status rocsparse_set_mat_diag_type(rocsparse_mat_descr descr, rocsparse_diag_type diag_type)#

Specify the matrix diagonal type of a matrix descriptor.

rocsparse_set_mat_diag_type sets the matrix diagonal type of a matrix descriptor. Valid diagonal types are rocsparse_diag_type_unit or rocsparse_diag_type_non_unit.

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerdescr pointer is invalid.

  • rocsparse_status_invalid_valuediag_type is invalid.

rocsparse_get_mat_diag_type()#

rocsparse_diag_type rocsparse_get_mat_diag_type(const rocsparse_mat_descr descr)#

Get the matrix diagonal type of a matrix descriptor.

rocsparse_get_mat_diag_type returns the matrix diagonal type of a matrix descriptor.

Parameters:

descr[in] the matrix descriptor.

Returns:

rocsparse_diag_type_unit or rocsparse_diag_type_non_unit.

rocsparse_set_mat_storage_mode()#

rocsparse_status rocsparse_set_mat_storage_mode(rocsparse_mat_descr descr, rocsparse_storage_mode storage_mode)#

Specify the matrix storage mode of a matrix descriptor.

rocsparse_set_mat_storage_mode sets the matrix storage mode of a matrix descriptor. Valid fill modes are rocsparse_storage_mode_sorted or rocsparse_storage_mode_unsorted.

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerdescr pointer is invalid.

  • rocsparse_status_invalid_valuestorage_mode is invalid.

rocsparse_get_mat_storage_mode()#

rocsparse_storage_mode rocsparse_get_mat_storage_mode(const rocsparse_mat_descr descr)#

Get the matrix storage mode of a matrix descriptor.

rocsparse_get_mat_storage_mode returns the matrix storage mode of a matrix descriptor.

Parameters:

descr[in] the matrix descriptor.

Returns:

rocsparse_storage_mode_sorted or rocsparse_storage_mode_unsorted.

rocsparse_create_hyb_mat()#

rocsparse_status rocsparse_create_hyb_mat(rocsparse_hyb_mat *hyb)#

Create a HYB matrix structure.

rocsparse_create_hyb_mat creates a structure that holds the matrix in HYB storage format. It should be destroyed at the end using rocsparse_destroy_hyb_mat().

Parameters:

hyb[inout] the pointer to the hybrid matrix.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerhyb pointer is invalid.

rocsparse_destroy_hyb_mat()#

rocsparse_status rocsparse_destroy_hyb_mat(rocsparse_hyb_mat hyb)#

Destroy a HYB matrix structure.

rocsparse_destroy_hyb_mat destroys a HYB structure.

Parameters:

hyb[in] the hybrid matrix structure.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerhyb pointer is invalid.

  • rocsparse_status_internal_error – an internal error occurred.

rocsparse_copy_hyb_mat()#

rocsparse_status rocsparse_copy_hyb_mat(rocsparse_hyb_mat dest, const rocsparse_hyb_mat src)#

Copy a HYB matrix structure.

rocsparse_copy_hyb_mat copies a matrix info structure. Both, source and destination matrix info structure must be initialized prior to calling rocsparse_copy_hyb_mat.

Parameters:
  • dest[out] the pointer to the destination matrix info structure.

  • src[in] the pointer to the source matrix info structure.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerhyb pointer is invalid.

rocsparse_create_mat_info()#

rocsparse_status rocsparse_create_mat_info(rocsparse_mat_info *info)#

Create a matrix info structure.

rocsparse_create_mat_info creates a structure that holds the matrix info data that is gathered during the analysis routines available. It should be destroyed at the end using rocsparse_destroy_mat_info().

Parameters:

info[inout] the pointer to the info structure.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerinfo pointer is invalid.

rocsparse_copy_mat_info()#

rocsparse_status rocsparse_copy_mat_info(rocsparse_mat_info dest, const rocsparse_mat_info src)#

Copy a matrix info structure.

rocsparse_copy_mat_info copies a matrix info structure. Both, source and destination matrix info structure must be initialized prior to calling rocsparse_copy_mat_info.

Parameters:
  • dest[out] the pointer to the destination matrix info structure.

  • src[in] the pointer to the source matrix info structure.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointersrc or dest pointer is invalid.

rocsparse_destroy_mat_info()#

rocsparse_status rocsparse_destroy_mat_info(rocsparse_mat_info info)#

Destroy a matrix info structure.

rocsparse_destroy_mat_info destroys a matrix info structure.

Parameters:

info[in] the info structure.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerinfo pointer is invalid.

  • rocsparse_status_internal_error – an internal error occurred.

rocsparse_create_color_info()#

rocsparse_status rocsparse_create_color_info(rocsparse_color_info *info)#

Create a color info structure.

rocsparse_create_color_info creates a structure that holds the color info data that is gathered during the analysis routines available. It should be destroyed at the end using rocsparse_destroy_color_info().

Parameters:

info[inout] the pointer to the info structure.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerinfo pointer is invalid.

rocsparse_destroy_color_info()#

rocsparse_status rocsparse_destroy_color_info(rocsparse_color_info info)#

Destroy a color info structure.

rocsparse_destroy_color_info destroys a color info structure.

Parameters:

info[in] the info structure.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerinfo pointer is invalid.

  • rocsparse_status_internal_error – an internal error occurred.

rocsparse_copy_color_info()#

rocsparse_status rocsparse_copy_color_info(rocsparse_color_info dest, const rocsparse_color_info src)#

Copy a color info structure.

rocsparse_copy_color_info copies a color info structure. Both, source and destination color info structure must be initialized prior to calling rocsparse_copy_color_info.

Parameters:
  • dest[out] the pointer to the destination color info structure.

  • src[in] the pointer to the source color info structure.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointersrc or dest pointer is invalid.

rocsparse_create_spvec_descr()#

rocsparse_status rocsparse_create_spvec_descr(rocsparse_spvec_descr *descr, int64_t size, int64_t nnz, void *indices, void *values, rocsparse_indextype idx_type, rocsparse_index_base idx_base, rocsparse_datatype data_type)#

Create a sparse vector descriptor.

rocsparse_create_spvec_descr creates a sparse vector descriptor. It should be destroyed at the end using rocsparse_destroy_mat_descr().

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or indices or values is invalid.

  • rocsparse_status_invalid_size – if size or nnz is invalid.

  • rocsparse_status_invalid_value – if idx_type or idx_base or data_type is invalid.

rocsparse_destroy_spvec_descr()#

rocsparse_status rocsparse_destroy_spvec_descr(rocsparse_const_spvec_descr descr)#

Destroy a sparse vector descriptor.

rocsparse_destroy_spvec_descr destroys a sparse vector descriptor and releases all resources used by the descriptor.

Parameters:

descr[in] the matrix descriptor.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerdescr is invalid.

rocsparse_spvec_get()#

rocsparse_status rocsparse_spvec_get(const rocsparse_spvec_descr descr, int64_t *size, int64_t *nnz, void **indices, void **values, rocsparse_indextype *idx_type, rocsparse_index_base *idx_base, rocsparse_datatype *data_type)#

Get the fields of the sparse vector descriptor.

rocsparse_spvec_get gets the fields of the sparse vector descriptor

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or indices or values is invalid.

  • rocsparse_status_invalid_size – if size or nnz is invalid.

  • rocsparse_status_invalid_value – if idx_type or idx_base or data_type is invalid.

rocsparse_spvec_get_index_base()#

rocsparse_status rocsparse_spvec_get_index_base(rocsparse_const_spvec_descr descr, rocsparse_index_base *idx_base)#

Get the index base stored in the sparse vector descriptor.

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr is invalid.

  • rocsparse_status_invalid_value – if idx_base is invalid.

rocsparse_spvec_get_values()#

rocsparse_status rocsparse_spvec_get_values(const rocsparse_spvec_descr descr, void **values)#

Get the values array stored in the sparse vector descriptor.

Parameters:
  • descr[in] the pointer to the sparse vector descriptor.

  • values[out] non-zero values in the sparse vector (must be array of length nnz ).

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or values is invalid.

rocsparse_spvec_set_values()#

rocsparse_status rocsparse_spvec_set_values(rocsparse_spvec_descr descr, void *values)#

Set the values array in the sparse vector descriptor.

Parameters:
  • descr[inout] the pointer to the sparse vector descriptor.

  • values[in] non-zero values in the sparse vector (must be array of length nnz ).

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or values is invalid.

rocsparse_create_coo_descr#

rocsparse_status rocsparse_create_coo_descr(rocsparse_spmat_descr *descr, int64_t rows, int64_t cols, int64_t nnz, void *coo_row_ind, void *coo_col_ind, void *coo_val, rocsparse_indextype idx_type, rocsparse_index_base idx_base, rocsparse_datatype data_type)#

Create a sparse COO matrix descriptor.

rocsparse_create_coo_descr creates a sparse COO matrix descriptor. It should be destroyed at the end using rocsparse_destroy_spmat_descr.

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or coo_row_ind or coo_col_ind or coo_val is invalid.

  • rocsparse_status_invalid_size – if rows or cols or nnz is invalid.

  • rocsparse_status_invalid_value – if idx_type or idx_base or data_type is invalid.

rocsparse_create_coo_aos_descr#

rocsparse_status rocsparse_create_coo_aos_descr(rocsparse_spmat_descr *descr, int64_t rows, int64_t cols, int64_t nnz, void *coo_ind, void *coo_val, rocsparse_indextype idx_type, rocsparse_index_base idx_base, rocsparse_datatype data_type)#

Create a sparse COO AoS matrix descriptor.

rocsparse_create_coo_aos_descr creates a sparse COO AoS matrix descriptor. It should be destroyed at the end using rocsparse_destroy_spmat_descr.

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or coo_ind or coo_val is invalid.

  • rocsparse_status_invalid_size – if rows or cols or nnz is invalid.

  • rocsparse_status_invalid_value – if idx_type or idx_base or data_type is invalid.

rocsparse_create_csr_descr#

rocsparse_status rocsparse_create_csr_descr(rocsparse_spmat_descr *descr, int64_t rows, int64_t cols, int64_t nnz, void *csr_row_ptr, void *csr_col_ind, void *csr_val, rocsparse_indextype row_ptr_type, rocsparse_indextype col_ind_type, rocsparse_index_base idx_base, rocsparse_datatype data_type)#

Create a sparse CSR matrix descriptor.

rocsparse_create_csr_descr creates a sparse CSR matrix descriptor. It should be destroyed at the end using rocsparse_destroy_spmat_descr.

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or csr_row_ptr or csr_col_ind or csr_val is invalid.

  • rocsparse_status_invalid_size – if rows or cols or nnz is invalid.

  • rocsparse_status_invalid_value – if row_ptr_type or col_ind_type or idx_base or data_type is invalid.

rocsparse_create_csc_descr#

rocsparse_status rocsparse_create_csc_descr(rocsparse_spmat_descr *descr, int64_t rows, int64_t cols, int64_t nnz, void *csc_col_ptr, void *csc_row_ind, void *csc_val, rocsparse_indextype col_ptr_type, rocsparse_indextype row_ind_type, rocsparse_index_base idx_base, rocsparse_datatype data_type)#

Create a sparse CSC matrix descriptor.

rocsparse_create_csc_descr creates a sparse CSC matrix descriptor. It should be destroyed at the end using rocsparse_destroy_spmat_descr.

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or csc_col_ptr or csc_row_ind or csc_val is invalid.

  • rocsparse_status_invalid_size – if rows or cols or nnz is invalid.

  • rocsparse_status_invalid_value – if col_ptr_type or row_ind_type or idx_base or data_type is invalid.

rocsparse_create_ell_descr#

rocsparse_status rocsparse_create_ell_descr(rocsparse_spmat_descr *descr, int64_t rows, int64_t cols, void *ell_col_ind, void *ell_val, int64_t ell_width, rocsparse_indextype idx_type, rocsparse_index_base idx_base, rocsparse_datatype data_type)#

Create a sparse ELL matrix descriptor.

rocsparse_create_ell_descr creates a sparse ELL matrix descriptor. It should be destroyed at the end using rocsparse_destroy_spmat_descr.

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or ell_col_ind or ell_val is invalid.

  • rocsparse_status_invalid_size – if rows or cols or ell_width is invalid.

  • rocsparse_status_invalid_value – if idx_type or idx_base or data_type is invalid.

rocsparse_create_bell_descr#

rocsparse_status rocsparse_create_bell_descr(rocsparse_spmat_descr *descr, int64_t rows, int64_t cols, rocsparse_direction ell_block_dir, int64_t ell_block_dim, int64_t ell_cols, void *ell_col_ind, void *ell_val, rocsparse_indextype idx_type, rocsparse_index_base idx_base, rocsparse_datatype data_type)#

Create a sparse blocked ELL matrix descriptor.

rocsparse_create_bell_descr creates a sparse blocked ELL matrix descriptor. It should be destroyed at the end using rocsparse_destroy_spmat_descr.

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or ell_cols or ell_col_ind or ell_val is invalid.

  • rocsparse_status_invalid_size – if rows or cols is invalid.

  • rocsparse_status_invalid_value – if idx_type or idx_base or data_type is invalid.

rocsparse_destroy_spmat_descr#

rocsparse_status rocsparse_destroy_spmat_descr(rocsparse_const_spmat_descr descr)#

Destroy a sparse matrix descriptor.

rocsparse_destroy_spmat_descr destroys a sparse matrix descriptor and releases all resources used by the descriptor.

Parameters:

descr[in] the matrix descriptor.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerdescr is invalid.

rocsparse_coo_get#

rocsparse_status rocsparse_coo_get(const rocsparse_spmat_descr descr, int64_t *rows, int64_t *cols, int64_t *nnz, void **coo_row_ind, void **coo_col_ind, void **coo_val, rocsparse_indextype *idx_type, rocsparse_index_base *idx_base, rocsparse_datatype *data_type)#

Get the fields of the sparse COO matrix descriptor.

rocsparse_coo_get gets the fields of the sparse COO matrix descriptor

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or coo_row_ind or coo_col_ind or coo_val is invalid.

  • rocsparse_status_invalid_size – if rows or cols or nnz is invalid.

  • rocsparse_status_invalid_value – if idx_type or idx_base or data_type is invalid.

rocsparse_coo_aos_get#

rocsparse_status rocsparse_coo_aos_get(const rocsparse_spmat_descr descr, int64_t *rows, int64_t *cols, int64_t *nnz, void **coo_ind, void **coo_val, rocsparse_indextype *idx_type, rocsparse_index_base *idx_base, rocsparse_datatype *data_type)#

Get the fields of the sparse COO AoS matrix descriptor.

rocsparse_coo_aos_get gets the fields of the sparse COO AoS matrix descriptor

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or coo_ind or coo_val is invalid.

  • rocsparse_status_invalid_size – if rows or cols or nnz is invalid.

  • rocsparse_status_invalid_value – if idx_type or idx_base or data_type is invalid.

rocsparse_csr_get#

rocsparse_status rocsparse_csr_get(const rocsparse_spmat_descr descr, int64_t *rows, int64_t *cols, int64_t *nnz, void **csr_row_ptr, void **csr_col_ind, void **csr_val, rocsparse_indextype *row_ptr_type, rocsparse_indextype *col_ind_type, rocsparse_index_base *idx_base, rocsparse_datatype *data_type)#

Get the fields of the sparse CSR matrix descriptor.

rocsparse_csr_get gets the fields of the sparse CSR matrix descriptor

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or csr_row_ptr or csr_col_ind or csr_val is invalid.

  • rocsparse_status_invalid_size – if rows or cols or nnz is invalid.

  • rocsparse_status_invalid_value – if row_ptr_type or col_ind_type or idx_base or data_type is invalid.

rocsparse_ell_get#

rocsparse_status rocsparse_ell_get(const rocsparse_spmat_descr descr, int64_t *rows, int64_t *cols, void **ell_col_ind, void **ell_val, int64_t *ell_width, rocsparse_indextype *idx_type, rocsparse_index_base *idx_base, rocsparse_datatype *data_type)#

Get the fields of the sparse ELL matrix descriptor.

rocsparse_ell_get gets the fields of the sparse ELL matrix descriptor

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or ell_col_ind or ell_val is invalid.

  • rocsparse_status_invalid_size – if rows or cols or ell_width is invalid.

  • rocsparse_status_invalid_value – if idx_type or idx_base or data_type is invalid.

rocsparse_bell_get#

rocsparse_status rocsparse_bell_get(const rocsparse_spmat_descr descr, int64_t *rows, int64_t *cols, rocsparse_direction *ell_block_dir, int64_t *ell_block_dim, int64_t *ell_cols, void **ell_col_ind, void **ell_val, rocsparse_indextype *idx_type, rocsparse_index_base *idx_base, rocsparse_datatype *data_type)#

Get the fields of the sparse blocked ELL matrix descriptor.

rocsparse_bell_get gets the fields of the sparse blocked ELL matrix descriptor

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or ell_cols or ell_col_ind or ell_val is invalid.

  • rocsparse_status_invalid_size – if rows or cols or ell_block_dim is invalid.

  • rocsparse_status_invalid_value – if ell_block_dir or idx_type or idx_base or data_type is invalid.

rocsparse_coo_set_pointers#

rocsparse_status rocsparse_coo_set_pointers(rocsparse_spmat_descr descr, void *coo_row_ind, void *coo_col_ind, void *coo_val)#

Set the row indices, column indices and values array in the sparse COO matrix descriptor.

Parameters:
  • descr[inout] the pointer to the sparse vector descriptor.

  • coo_row_ind[in] row indices of the COO matrix (must be array of length nnz ).

  • coo_col_ind[in] column indices of the COO matrix (must be array of length nnz ).

  • coo_val[in] values of the COO matrix (must be array of length nnz ).

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or coo_row_ind or coo_col_ind or coo_val is invalid.

rocsparse_coo_aos_set_pointers#

rocsparse_status rocsparse_coo_aos_set_pointers(rocsparse_spmat_descr descr, void *coo_ind, void *coo_val)#

Set the <row, column> indices and values array in the sparse COO AoS matrix descriptor.

Parameters:
  • descr[inout] the pointer to the sparse vector descriptor.

  • coo_ind[in] <row, column> indices of the COO matrix (must be array of length nnz ).

  • coo_val[in] values of the COO matrix (must be array of length nnz ).

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or coo_ind or coo_val is invalid.

rocsparse_csr_set_pointers#

rocsparse_status rocsparse_csr_set_pointers(rocsparse_spmat_descr descr, void *csr_row_ptr, void *csr_col_ind, void *csr_val)#

Set the row offsets, column indices and values array in the sparse CSR matrix descriptor.

Parameters:
  • descr[inout] the pointer to the sparse vector descriptor.

  • csr_row_ptr[in] row offsets of the CSR matrix (must be array of length rows+1 ).

  • csr_col_ind[in] column indices of the CSR matrix (must be array of length nnz ).

  • csr_val[in] values of the CSR matrix (must be array of length nnz ).

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or coo_ind or coo_val is invalid.

rocsparse_csc_set_pointers#

rocsparse_status rocsparse_csc_set_pointers(rocsparse_spmat_descr descr, void *csc_col_ptr, void *csc_row_ind, void *csc_val)#

Set the column offsets, row indices and values array in the sparse CSC matrix descriptor.

Parameters:
  • descr[inout] the pointer to the sparse vector descriptor.

  • csc_col_ptr[in] column offsets of the CSC matrix (must be array of length cols+1 ).

  • csc_row_ind[in] row indices of the CSC matrix (must be array of length nnz ).

  • csc_val[in] values of the CSC matrix (must be array of length nnz ).

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or csc_col_ptr or csc_row_ind or csc_val is invalid.

rocsparse_ell_set_pointers#

rocsparse_status rocsparse_ell_set_pointers(rocsparse_spmat_descr descr, void *ell_col_ind, void *ell_val)#

Set the column indices and values array in the sparse ELL matrix descriptor.

Parameters:
  • descr[inout] the pointer to the sparse vector descriptor.

  • ell_col_ind[in] column indices of the ELL matrix (must be array of length rows*ell_width ).

  • ell_val[in] values of the ELL matrix (must be array of length rows*ell_width ).

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or ell_col_ind or ell_val is invalid.

rocsparse_bsr_set_pointers#

rocsparse_status rocsparse_bsr_set_pointers(rocsparse_spmat_descr descr, void *bsr_row_ptr, void *bsr_col_ind, void *bsr_val)#

Set the row offsets, column indices and values array in the sparse BSR matrix descriptor.

Parameters:
  • descr[inout] the pointer to the sparse vector descriptor.

  • bsr_row_ptr[in] row offsets of the BSR matrix (must be array of length rows+1 ).

  • bsr_col_ind[in] column indices of the BSR matrix (must be array of length nnzb ).

  • bsr_val[in] values of the BSR matrix (must be array of length nnzb*block_dim*block_dim ).

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or bsr_row_ptr or bsr_col_ind or bsr_val is invalid.

rocsparse_spmat_get_size#

rocsparse_status rocsparse_spmat_get_size(rocsparse_const_spmat_descr descr, int64_t *rows, int64_t *cols, int64_t *nnz)#

Get the number of rows, columns and non-zeros from the sparse matrix descriptor.

Parameters:
  • descr[in] the pointer to the sparse matrix descriptor.

  • rows[out] number of rows in the sparse matrix.

  • cols[out] number of columns in the sparse matrix.

  • nnz[out] number of non-zeros in sparse matrix.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr is invalid.

  • rocsparse_status_invalid_size – if rows or cols or nnz is invalid.

rocsparse_spmat_get_format#

rocsparse_status rocsparse_spmat_get_format(rocsparse_const_spmat_descr descr, rocsparse_format *format)#

Get the sparse matrix format from the sparse matrix descriptor.

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr is invalid.

  • rocsparse_status_invalid_value – if format is invalid.

rocsparse_spmat_get_index_base#

rocsparse_status rocsparse_spmat_get_index_base(rocsparse_const_spmat_descr descr, rocsparse_index_base *idx_base)#

Get the sparse matrix index base from the sparse matrix descriptor.

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr is invalid.

  • rocsparse_status_invalid_value – if idx_base is invalid.

rocsparse_spmat_get_values#

rocsparse_status rocsparse_spmat_get_values(rocsparse_spmat_descr descr, void **values)#

Get the values array from the sparse matrix descriptor.

Parameters:
  • descr[in] the pointer to the sparse matrix descriptor.

  • values[out] values array of the sparse matrix.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or values is invalid.

rocsparse_spmat_set_values#

rocsparse_status rocsparse_spmat_set_values(rocsparse_spmat_descr descr, void *values)#

Set the values array in the sparse matrix descriptor.

Parameters:
  • descr[inout] the pointer to the sparse matrix descriptor.

  • values[in] values array of the sparse matrix.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or values is invalid.

rocsparse_spmat_get_strided_batch#

rocsparse_status rocsparse_spmat_get_strided_batch(rocsparse_const_spmat_descr descr, int *batch_count)#

Get the strided batch count from the sparse matrix descriptor.

Parameters:
  • descr[in] the pointer to the sparse matrix descriptor.

  • batch_count[out] batch_count of the sparse matrix.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr is invalid.

  • rocsparse_status_invalid_size – if batch_count is invalid.

rocsparse_spmat_set_strided_batch#

rocsparse_status rocsparse_spmat_set_strided_batch(rocsparse_spmat_descr descr, int batch_count)#

Set the strided batch count in the sparse matrix descriptor.

Parameters:
  • descr[in] the pointer to the sparse matrix descriptor.

  • batch_count[in] batch_count of the sparse matrix.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr is invalid.

  • rocsparse_status_invalid_size – if batch_count is invalid.

rocsparse_coo_set_strided_batch#

rocsparse_status rocsparse_coo_set_strided_batch(rocsparse_spmat_descr descr, int batch_count, int64_t batch_stride)#

Set the batch count and batch stride in the sparse COO matrix descriptor.

Parameters:
  • descr[inout] the pointer to the sparse COO matrix descriptor.

  • batch_count[in] batch_count of the sparse COO matrix.

  • batch_stride[in] batch stride of the sparse COO matrix.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr is invalid.

  • rocsparse_status_invalid_size – if batch_count or batch_stride is invalid.

rocsparse_csr_set_strided_batch#

rocsparse_status rocsparse_csr_set_strided_batch(rocsparse_spmat_descr descr, int batch_count, int64_t offsets_batch_stride, int64_t columns_values_batch_stride)#

Set the batch count, row offset batch stride and the column indices batch stride in the sparse CSR matrix descriptor.

Parameters:
  • descr[inout] the pointer to the sparse CSR matrix descriptor.

  • batch_count[in] batch_count of the sparse CSR matrix.

  • offsets_batch_stride[in] row offset batch stride of the sparse CSR matrix.

  • columns_values_batch_stride[in] column indices batch stride of the sparse CSR matrix.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr is invalid.

  • rocsparse_status_invalid_size – if batch_count or offsets_batch_stride or columns_values_batch_stride is invalid.

rocsparse_csc_set_strided_batch#

rocsparse_status rocsparse_csc_set_strided_batch(rocsparse_spmat_descr descr, int batch_count, int64_t offsets_batch_stride, int64_t rows_values_batch_stride)#

Set the batch count, column offset batch stride and the row indices batch stride in the sparse CSC matrix descriptor.

Parameters:
  • descr[inout] the pointer to the sparse CSC matrix descriptor.

  • batch_count[in] batch_count of the sparse CSC matrix.

  • offsets_batch_stride[in] column offset batch stride of the sparse CSC matrix.

  • rows_values_batch_stride[in] row indices batch stride of the sparse CSC matrix.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr is invalid.

  • rocsparse_status_invalid_size – if batch_count or offsets_batch_stride or rows_values_batch_stride is invalid.

rocsparse_spmat_get_attribute#

rocsparse_status rocsparse_spmat_get_attribute(rocsparse_const_spmat_descr descr, rocsparse_spmat_attribute attribute, void *data, size_t data_size)#

Get the requested attribute data from the sparse matrix descriptor.

Parameters:
  • descr[in] the pointer to the sparse matrix descriptor.

  • attribute[in] rocsparse_spmat_fill_mode or rocsparse_spmat_diag_type or rocsparse_spmat_matrix_type or rocsparse_spmat_storage_mode

  • data[out] attribute data

  • data_size[in] attribute data size.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or data is invalid.

  • rocsparse_status_invalid_value – if attribute is invalid.

  • rocsparse_status_invalid_size – if data_size is invalid.

rocsparse_spmat_set_attribute#

rocsparse_status rocsparse_spmat_set_attribute(rocsparse_spmat_descr descr, rocsparse_spmat_attribute attribute, const void *data, size_t data_size)#

Set the requested attribute data in the sparse matrix descriptor.

Parameters:
  • descr[inout] the pointer to the sparse matrix descriptor.

  • attribute[in] rocsparse_spmat_fill_mode or rocsparse_spmat_diag_type or rocsparse_spmat_matrix_type or rocsparse_spmat_storage_mode

  • data[in] attribute data

  • data_size[in] attribute data size.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or data is invalid.

  • rocsparse_status_invalid_value – if attribute is invalid.

  • rocsparse_status_invalid_size – if data_size is invalid.

rocsparse_create_dnvec_descr#

rocsparse_status rocsparse_create_dnvec_descr(rocsparse_dnvec_descr *descr, int64_t size, void *values, rocsparse_datatype data_type)#

Create a dense vector descriptor.

rocsparse_create_dnvec_descr creates a dense vector descriptor. It should be destroyed at the end using rocsparse_destroy_dnvec_descr().

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or values is invalid.

  • rocsparse_status_invalid_size – if size is invalid.

  • rocsparse_status_invalid_value – if data_type is invalid.

rocsparse_destroy_dnvec_descr#

rocsparse_status rocsparse_destroy_dnvec_descr(rocsparse_const_dnvec_descr descr)#

Destroy a dense vector descriptor.

rocsparse_destroy_dnvec_descr destroys a dense vector descriptor and releases all resources used by the descriptor.

Parameters:

descr[in] the matrix descriptor.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerdescr is invalid.

rocsparse_dnvec_get#

rocsparse_status rocsparse_dnvec_get(const rocsparse_dnvec_descr descr, int64_t *size, void **values, rocsparse_datatype *data_type)#

Get the fields of the dense vector descriptor.

rocsparse_dnvec_get gets the fields of the dense vector descriptor

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or values is invalid.

  • rocsparse_status_invalid_size – if size is invalid.

  • rocsparse_status_invalid_value – if data_type is invalid.

rocsparse_dnvec_get_values#

rocsparse_status rocsparse_dnvec_get_values(const rocsparse_dnvec_descr descr, void **values)#

Get the values array from a dense vector descriptor.

Parameters:
  • descr[in] the matrix descriptor.

  • values[out] non-zero values in the dense vector (must be array of length size ).

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerdescr or values is invalid.

rocsparse_dnvec_set_values#

rocsparse_status rocsparse_dnvec_set_values(rocsparse_dnvec_descr descr, void *values)#

Set the values array in a dense vector descriptor.

Parameters:
  • descr[inout] the matrix descriptor.

  • values[in] non-zero values in the dense vector (must be array of length size ).

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerdescr or values is invalid.

rocsparse_create_dnmat_descr#

rocsparse_status rocsparse_create_dnmat_descr(rocsparse_dnmat_descr *descr, int64_t rows, int64_t cols, int64_t ld, void *values, rocsparse_datatype data_type, rocsparse_order order)#

Create a dense matrix descriptor.

rocsparse_create_dnmat_descr creates a dense matrix descriptor. It should be destroyed at the end using rocsparse_destroy_dnmat_descr().

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or values is invalid.

  • rocsparse_status_invalid_size – if rows or cols or ld is invalid.

  • rocsparse_status_invalid_value – if data_type or order is invalid.

rocsparse_destroy_dnmat_descr#

rocsparse_status rocsparse_destroy_dnmat_descr(rocsparse_const_dnmat_descr descr)#

Destroy a dense matrix descriptor.

rocsparse_destroy_dnmat_descr destroys a dense matrix descriptor and releases all resources used by the descriptor.

Parameters:

descr[in] the matrix descriptor.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerdescr is invalid.

rocsparse_dnmat_get#

rocsparse_status rocsparse_dnmat_get(const rocsparse_dnmat_descr descr, int64_t *rows, int64_t *cols, int64_t *ld, void **values, rocsparse_datatype *data_type, rocsparse_order *order)#

Get the fields of the dense matrix descriptor.

Parameters:
Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or values is invalid.

  • rocsparse_status_invalid_size – if rows or cols or ld is invalid.

  • rocsparse_status_invalid_value – if data_type or order is invalid.

rocsparse_dnmat_get_values#

rocsparse_status rocsparse_dnmat_get_values(const rocsparse_dnmat_descr descr, void **values)#

Get the values array from the dense matrix descriptor.

Parameters:
  • descr[in] the pointer to the dense matrix descriptor.

  • values[out] non-zero values in the dense matrix (must be array of length ld*rows if order=rocsparse_order_column or ld*cols if order=rocsparse_order_row ).

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr or values is invalid.

rocsparse_dnmat_set_values#

rocsparse_status rocsparse_dnmat_set_values(rocsparse_dnmat_descr descr, void *values)#

Set the values array in a dense matrix descriptor.

Parameters:
  • descr[inout] the matrix descriptor.

  • values[in] non-zero values in the dense matrix (must be array of length ld*rows if order=rocsparse_order_column or ld*cols if order=rocsparse_order_row ).

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointerdescr or values is invalid.

rocsparse_dnmat_get_strided_batch#

rocsparse_status rocsparse_dnmat_get_strided_batch(rocsparse_const_dnmat_descr descr, int *batch_count, int64_t *batch_stride)#

Get the batch count and batch stride from the dense matrix descriptor.

Parameters:
  • descr[in] the pointer to the dense matrix descriptor.

  • batch_count[out] the batch count in the dense matrix.

  • batch_stride[out] the batch stride in the dense matrix.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr is invalid.

  • rocsparse_status_invalid_size – if batch_count or batch_stride is invalid.

rocsparse_dnmat_set_strided_batch#

rocsparse_status rocsparse_dnmat_set_strided_batch(rocsparse_dnmat_descr descr, int batch_count, int64_t batch_stride)#

Set the batch count and batch stride in the dense matrix descriptor.

Parameters:
  • descr[inout] the pointer to the dense matrix descriptor.

  • batch_count[in] the batch count in the dense matrix.

  • batch_stride[in] the batch stride in the dense matrix.

Return values:
  • rocsparse_status_success – the operation completed successfully.

  • rocsparse_status_invalid_pointer – if descr is invalid.

  • rocsparse_status_invalid_size – if batch_count or batch_stride is invalid.