Sparse Matrix APIs
The cuSPARSE helper functions for sparse matrix descriptor are described in this section.
See the COO, CSR , CSC , SELL , BSR, Blocked-Ell sections for the detailed description of the storage formats.
Coordinate (COO)
cusparseCreateCoo()
cusparseStatus_t
cusparseCreateCoo(cusparseSpMatDescr_t* spMatDescr,
int64_t rows,
int64_t cols,
int64_t nnz,
void* cooRowInd,
void* cooColInd,
void* cooValues,
cusparseIndexType_t cooIdxType,
cusparseIndexBase_t idxBase,
cudaDataType valueType)
cusparseStatus_t
cusparseCreateConstCoo(cusparseConstSpMatDescr_t* spMatDescr,
int64_t rows,
int64_t cols,
int64_t nnz,
const void* cooRowInd,
const void* cooColInd,
const void* cooValues,
cusparseIndexType_t cooIdxType,
cusparseIndexBase_t idxBase,
cudaDataType valueType)
This function initializes the sparse matrix descriptor spMatDescr in the COO format (Structure of Arrays layout).
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
OUT |
Sparse matrix descriptor |
|
HOST |
IN |
Number of rows of the sparse matrix |
|
HOST |
IN |
Number of columns of the sparse matrix |
|
HOST |
IN |
Number of non-zero entries of the sparse matrix |
|
DEVICE |
IN |
Row indices of the sparse matrix. Array with |
|
DEVICE |
IN |
Column indices of the sparse matrix. Array with |
|
DEVICE |
IN |
Values of the sparse matrix. Array with |
|
HOST |
IN |
Data type of |
|
HOST |
IN |
Index base of |
|
HOST |
IN |
Datatype of |
cusparseCreateCoo() has the following constraints:
cooRowInd,cooColInd, andcooValuesmust be aligned to the size of the datatypes specified bycooIdxType,cooIdxType, andvalueType. respectively. See cudaDataType_t for the description of the datatypes.
See cusparseStatus_t for the description of the return status.
cusparseCooGet()
cusparseStatus_t
cusparseCooGet(cusparseSpMatDescr_t spMatDescr,
int64_t* rows,
int64_t* cols,
int64_t* nnz,
void** cooRowInd,
void** cooColInd,
void** cooValues,
cusparseIndexType_t* idxType,
cusparseIndexBase_t* idxBase,
cudaDataType* valueType)
cusparseStatus_t
cusparseConstCooGet(cusparseConstSpMatDescr_t spMatDescr,
int64_t* rows,
int64_t* cols,
int64_t* nnz,
const void** cooRowInd,
const void** cooColInd,
const void** cooValues,
cusparseIndexType_t* idxType,
cusparseIndexBase_t* idxBase,
cudaDataType* valueType)
This function returns the fields of the sparse matrix descriptor spMatDescr stored in COO format (Array of Structures layout).
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
IN |
Sparse matrix descriptor |
|
HOST |
OUT |
Number of rows of the sparse matrix |
|
HOST |
OUT |
Number of columns of the sparse matrix |
|
HOST |
OUT |
Number of non-zero entries of the sparse matrix |
|
DEVICE |
OUT |
Row indices of the sparse matrix. Array |
|
DEVICE |
OUT |
Column indices of the sparse matrix. Array |
|
DEVICE |
OUT |
Values of the sparse matrix. Array |
|
HOST |
OUT |
Data type of |
|
HOST |
OUT |
Index base of |
|
HOST |
OUT |
Datatype of |
See cusparseStatus_t for the description of the return status.
cusparseCooSetPointers()
cusparseStatus_t
cusparseCooSetPointers(cusparseSpMatDescr_t spMatDescr,
void* cooRows,
void* cooColumns,
void* cooValues)
This function sets the pointers of the sparse matrix descriptor spMatDescr.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
IN |
Sparse matrix descriptor |
|
DEVICE |
IN |
Row indices of the sparse matrix. Array with |
|
DEVICE |
IN |
Column indices of the sparse matrix. Array with |
|
DEVICE |
IN |
Values of the sparse matrix. Array with |
cusparseCooSetPointers() has the following constraints:
cooRows,cooColumns, andcooValuesmust be aligned to the size of their corresponding datatypes specified inspMatDescr. See cudaDataType_t for the description of the datatypes.
See cusparseStatus_t for the description of the return status.
cusparseCooSetStridedBatch()
cusparseStatus_t
cusparseCooSetStridedBatch(cusparseSpMatDescr_t spMatDescr,
int batchCount,
int64_t batchStride)
This function sets the batchCount and the batchStride fields of the sparse matrix descriptor spMatDescr.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
IN |
Sparse matrix descriptor |
|
HOST |
IN |
Number of batches of the sparse matrix |
|
HOST |
IN |
address offset between consecutive batches |
See cusparseStatus_t for the description of the return status.
Compressed Sparse Row (CSR)
cusparseCreateCsr()
cusparseStatus_t
cusparseCreateCsr(cusparseSpMatDescr_t* spMatDescr,
int64_t rows,
int64_t cols,
int64_t nnz,
void* csrRowOffsets,
void* csrColInd,
void* csrValues,
cusparseIndexType_t csrRowOffsetsType,
cusparseIndexType_t csrColIndType,
cusparseIndexBase_t idxBase,
cudaDataType valueType)
cusparseStatus_t
cusparseCreateConstCsr(cusparseConstSpMatDescr_t* spMatDescr,
int64_t rows,
int64_t cols,
int64_t nnz,
const void* csrRowOffsets,
const void* csrColInd,
const void* csrValues,
cusparseIndexType_t csrRowOffsetsType,
cusparseIndexType_t csrColIndType,
cusparseIndexBase_t idxBase,
cudaDataType valueType)
This function initializes the sparse matrix descriptor spMatDescr in the CSR format.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
OUT |
Sparse matrix descriptor |
|
HOST |
IN |
Number of rows of the sparse matrix |
|
HOST |
IN |
Number of columns of the sparse matrix |
|
HOST |
IN |
Number of non-zero entries of the sparse matrix |
|
DEVICE |
IN |
Row offsets of the sparse matrix. Array with |
|
DEVICE |
IN |
Column indices of the sparse matrix. Array with |
|
DEVICE |
IN |
Values of the sparse matrix. Array with |
|
HOST |
IN |
Data type of |
|
HOST |
IN |
Data type of |
|
HOST |
IN |
Index base of |
|
HOST |
IN |
Datatype of |
cusparseCreateCsr() has the following constraints:
csrRowOffsets,csrColInd, andcsrValuesmust be aligned to the size of the datatypes specified bycsrRowOffsetsType,csrColIndType, andvalueType, respectively. See cudaDataType_t for the description of the datatypes.
See cusparseStatus_t for the description of the return status.
cusparseCsrGet()
cusparseStatus_t
cusparseCsrGet(cusparseSpMatDescr_t spMatDescr,
int64_t* rows,
int64_t* cols,
int64_t* nnz,
void** csrRowOffsets,
void** csrColInd,
void** csrValues,
cusparseIndexType_t* csrRowOffsetsType,
cusparseIndexType_t* csrColIndType,
cusparseIndexBase_t* idxBase,
cudaDataType* valueType)
cusparseStatus_t
cusparseConstCsrGet(cusparseConstSpMatDescr_t spMatDescr,
int64_t* rows,
int64_t* cols,
int64_t* nnz,
const void** csrRowOffsets,
const void** csrColInd,
const void** csrValues,
cusparseIndexType_t* csrRowOffsetsType,
cusparseIndexType_t* csrColIndType,
cusparseIndexBase_t* idxBase,
cudaDataType* valueType)
This function returns the fields of the sparse matrix descriptor spMatDescr stored in CSR format.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
IN |
Sparse matrix descriptor |
|
HOST |
OUT |
Number of rows of the sparse matrix |
|
HOST |
OUT |
Number of columns of the sparse matrix |
|
HOST |
OUT |
Number of non-zero entries of the sparse matrix |
|
DEVICE |
OUT |
Row offsets of the sparse matrix. Array with |
|
DEVICE |
OUT |
Column indices of the sparse matrix. Array with |
|
DEVICE |
OUT |
Values of the sparse matrix. Array with |
|
HOST |
OUT |
Data type of |
|
HOST |
OUT |
Data type of |
|
HOST |
OUT |
Index base of |
|
HOST |
OUT |
Datatype of |
See cusparseStatus_t for the description of the return status.
cusparseCsrSetPointers()
cusparseStatus_t
cusparseCsrSetPointers(cusparseSpMatDescr_t spMatDescr,
void* csrRowOffsets,
void* csrColInd,
void* csrValues)
This function sets the pointers of the sparse matrix descriptor spMatDescr.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
IN |
Sparse matrix descriptor |
|
DEVICE |
IN |
Row offsets of the sparse matrix. Array with |
|
DEVICE |
IN |
Column indices of the sparse matrix. Array with |
|
DEVICE |
IN |
Values of the sparse matrix. Array with |
cusparseCsrSetPointers() has the following constraints:
csrRowOffsets,csrColInd, andcsrValuesmust be aligned to the size of their corresponding datatypes specified inspMatDescr. See cudaDataType_t for the description of the datatypes.
See cusparseStatus_t for the description of the return status.
cusparseCsrSetStridedBatch()
cusparseStatus_t
cusparseCsrSetStridedBatch(cusparseSpMatDescr_t spMatDescr,
int batchCount,
int64_t offsetsBatchStride,
int64_t columnsValuesBatchStride)
This function sets the batchCount and the batchStride fields of the sparse matrix descriptor spMatDescr.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
IN |
Sparse matrix descriptor |
|
HOST |
IN |
Number of batches of the sparse matrix |
|
HOST |
IN |
Address offset between consecutive batches for the row offset array |
|
HOST |
IN |
Address offset between consecutive batches for the column and value arrays |
See cusparseStatus_t for the description of the return status.
Compressed Sparse Column (CSC)
cusparseCreateCsc()
cusparseStatus_t
cusparseCreateCsc(cusparseSpMatDescr_t* spMatDescr,
int64_t rows,
int64_t cols,
int64_t nnz,
void* cscColOffsets,
void* cscRowInd,
void* cscValues,
cusparseIndexType_t cscColOffsetsType,
cusparseIndexType_t cscRowIndType,
cusparseIndexBase_t idxBase,
cudaDataType valueType)
cusparseStatus_t
cusparseCreateConstCsc(cusparseConstSpMatDescr_t* spMatDescr,
int64_t rows,
int64_t cols,
int64_t nnz,
const void* cscColOffsets,
const void* cscRowInd,
const void* cscValues,
cusparseIndexType_t cscColOffsetsType,
cusparseIndexType_t cscRowIndType,
cusparseIndexBase_t idxBase,
cudaDataType valueType)
This function initializes the sparse matrix descriptor spMatDescr in the CSC format.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
OUT |
Sparse matrix descriptor |
|
HOST |
IN |
Number of rows of the sparse matrix |
|
HOST |
IN |
Number of columns of the sparse matrix |
|
HOST |
IN |
Number of non-zero entries of the sparse matrix |
|
DEVICE |
IN |
Column offsets of the sparse matrix. Array with |
|
DEVICE |
IN |
Row indices of the sparse matrix. Array with |
|
DEVICE |
IN |
Values of the sparse matrix. Array with |
|
HOST |
IN |
Data type of |
|
HOST |
IN |
Data type of |
|
HOST |
IN |
Index base of |
|
HOST |
IN |
Datatype of |
cusparseCreateCsc() has the following constraints:
cscColOffsets,cscRowInd, andcscValuesmust be aligned to the size of the datatypes specified bycscColOffsetsType,cscRowIndType, andvalueType, respectively. See cudaDataType_t for the description of the datatypes.
See cusparseStatus_t for the description of the return status.
cusparseCscGet()
cusparseStatus_t
cusparseCscGet(cusparseSpMatDescr_t spMatDescr,
int64_t* rows,
int64_t* cols,
int64_t* nnz,
void** cscColOffsets,
void** cscRowInd,
void** cscValues,
cusparseIndexType_t* cscColOffsetsType,
cusparseIndexType_t* cscRowIndType,
cusparseIndexBase_t* idxBase,
cudaDataType* valueType)
cusparseStatus_t
cusparseConstCscGet(cusparseConstSpMatDescr_t spMatDescr,
int64_t* rows,
int64_t* cols,
int64_t* nnz,
const void** cscColOffsets,
const void** cscRowInd,
const void** cscValues,
cusparseIndexType_t* cscColOffsetsType,
cusparseIndexType_t* cscRowIndType,
cusparseIndexBase_t* idxBase,
cudaDataType* valueType)
This function returns the fields of the sparse matrix descriptor spMatDescr stored in CSC format.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
IN |
Sparse matrix descriptor |
|
HOST |
OUT |
Number of rows of the sparse matrix |
|
HOST |
OUT |
Number of columns of the sparse matrix |
|
HOST |
OUT |
Number of non-zero entries of the sparse matrix |
|
DEVICE |
OUT |
Row offsets of the sparse matrix. Array with |
|
DEVICE |
OUT |
Column indices of the sparse matrix. Array with |
|
DEVICE |
OUT |
Values of the sparse matrix. Array with |
|
HOST |
OUT |
Data type of |
|
HOST |
OUT |
Data type of |
|
HOST |
OUT |
Index base of |
|
HOST |
OUT |
Datatype of |
See cusparseStatus_t for the description of the return status.
cusparseCscSetPointers()
cusparseStatus_t
cusparseCscSetPointers(cusparseSpMatDescr_t spMatDescr,
void* cscColOffsets,
void* cscRowInd,
void* cscValues)
This function sets the pointers of the sparse matrix descriptor spMatDescr.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
IN |
Sparse matrix descriptor |
|
DEVICE |
IN |
Col offsets of the sparse matrix. Array with |
|
DEVICE |
IN |
Row indices of the sparse matrix. Array with |
|
DEVICE |
IN |
Values of the sparse matrix. Array with |
cusparseCscSetPointers() has the following constraints:
cscColOffsets,cscRowInd, andcscValuesmust be aligned to the size of their corresponding datatypes specified inspMatDescr. See cudaDataType_t for the description of the datatypes.
See cusparseStatus_t for the description of the return status.
Blocked-Ellpack (Blocked-ELL)
cusparseCreateBlockedEll()
cusparseStatus_t
cusparseCreateBlockedEll(cusparseSpMatDescr_t* spMatDescr,
int64_t rows,
int64_t cols,
int64_t ellBlockSize,
int64_t ellCols,
void* ellColInd,
void* ellValue,
cusparseIndexType_t ellIdxType,
cusparseIndexBase_t idxBase,
cudaDataType valueType)
cusparseStatus_t
cusparseCreateConstBlockedEll(cusparseConstSpMatDescr_t* spMatDescr,
int64_t rows,
int64_t cols,
int64_t ellBlockSize,
int64_t ellCols,
const void* ellColInd,
const void* ellValue,
cusparseIndexType_t ellIdxType,
cusparseIndexBase_t idxBase,
cudaDataType valueType)
This function initializes the sparse matrix descriptor spMatDescr for the Blocked-Ellpack (ELL) format.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
OUT |
Sparse matrix descriptor |
|
HOST |
IN |
Number of rows of the sparse matrix |
|
HOST |
IN |
Number of columns of the sparse matrix |
|
HOST |
IN |
Size of the ELL-Block |
|
HOST |
IN |
Actual number of columns of the Blocked-Ellpack format ( |
|
DEVICE |
IN |
Blocked-ELL Column indices. Array with |
|
DEVICE |
IN |
Values of the sparse matrix. Array with |
|
HOST |
IN |
Data type of |
|
HOST |
IN |
Index base of |
|
HOST |
IN |
Data type of |
Blocked-ELL Column indices (ellColInd) are in the range [0, cols / ellBlockSize -1]. The array can contain -1 values for indicating empty blocks.
See cusparseStatus_t for the description of the return status.
cusparseBlockedEllGet()
cusparseStatus_t
cusparseBlockedEllGet(cusparseSpMatDescr_t spMatDescr,
int64_t* rows,
int64_t* cols,
int64_t* ellBlockSize,
int64_t* ellCols,
void** ellColInd,
void** ellValue,
cusparseIndexType_t* ellIdxType,
cusparseIndexBase_t* idxBase,
cudaDataType* valueType)
cusparseStatus_t
cusparseConstBlockedEllGet(cusparseConstSpMatDescr_t spMatDescr,
int64_t* rows,
int64_t* cols,
int64_t* ellBlockSize,
int64_t* ellCols,
const void** ellColInd,
const void** ellValue,
cusparseIndexType_t* ellIdxType,
cusparseIndexBase_t* idxBase,
cudaDataType* valueType)
This function returns the fields of the sparse matrix descriptor spMatDescr stored in Blocked-Ellpack (ELL) format.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
IN |
Sparse matrix descriptor |
|
HOST |
OUT |
Number of rows of the sparse matrix |
|
HOST |
OUT |
Number of columns of the sparse matrix |
|
HOST |
OUT |
Size of the ELL-Block |
|
HOST |
OUT |
Actual number of columns of the Blocked-Ellpack format |
|
DEVICE |
OUT |
Column indices for the ELL-Block. Array with |
|
DEVICE |
OUT |
Values of the sparse matrix. Array with |
|
HOST |
OUT |
Data type of |
|
HOST |
OUT |
Index base of |
|
HOST |
OUT |
Datatype of |
See cusparseStatus_t for the description of the return status.
Sliced-Ellpack (SELL)
cusparseCreateSlicedEll()
cusparseStatus_t
cusparseCreateSlicedEll(cusparseSpMatDescr_t* spMatDescr,
int64_t rows,
int64_t cols,
int64_t nnz,
int64_t sellValuesSize,
int64_t sliceSize,
void* sellSliceOffsets,
void* sellColInd,
void* sellValues,
cusparseIndexType_t sellSliceOffsetsType,
cusparseIndexType_t sellColIndType,
cusparseIndexBase_t idxBase,
cudaDataType valueType)
cusparseStatus_t
cusparseCreateConstSlicedEll(cusparseConstSpMatDescr_t* spMatDescr,
int64_t rows,
int64_t cols,
int64_t nnz,
int64_t sellValuesSize,
int64_t sliceSize,
const void* sellSliceOffsets,
const void* sellColInd,
const void* sellValues,
cusparseIndexType_t sellSliceOffsetsType,
cusparseIndexType_t sellColIndType,
cusparseIndexBase_t idxBase,
cudaDataType valueType)
This function initializes the sparse matrix descriptor spMatDescr for the Sliced Ellpack (SELL) format.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
OUT |
Sparse matrix descriptor |
|
HOST |
IN |
Number of rows of the sparse matrix |
|
HOST |
IN |
Number of columns of the sparse matrix |
|
HOST |
IN |
Number of nonzero elements in the sparse matrix |
|
HOST |
IN |
Total number of elements in |
|
HOST |
IN |
The number of rows per slice |
|
DEVICE |
IN |
Slice offsets of the sparse matrix. Array of size \(\left \lceil{\frac{rows}{sliceSize}}\right \rceil + 1\) |
|
DEVICE |
IN |
Column indexes of the sparse matrix. Array of size |
|
DEVICE |
IN |
Values of the sparse matrix. Array of size |
|
HOST |
IN |
Data type of |
|
HOST |
IN |
Data type of |
|
HOST |
IN |
Index base of |
|
HOST |
IN |
Data type of |
Note
Sliced Ellpack Column array sellColInd contains -1 values for indicating padded entries.
cusparseCreateSlicedEll() has the following constraints:
sellSliceOffsets,sellColInd, andsellValuesmust be aligned to the size of the datatypes specified bysellSliceOffsetsType,sellColIndType, andvalueType, respectively. See cudaDataType_t for the description of the datatypes.
See cusparseStatus_t for the description of the return status.
Block Sparse Row (BSR)
cusparseCreateBsr()
cusparseStatus_t
cusparseCreateBsr(cusparseSpMatDescr_t* spMatDescr,
int64_t brows,
int64_t bcols,
int64_t bnnz,
int64_t rowBlockSize,
int64_t colBlockSize,
void* bsrRowOffsets,
void* bsrColInd,
void* bsrValues,
cusparseIndexType_t bsrRowOffsetsType,
cusparseIndexType_t bsrColIndType,
cusparseIndexBase_t idxBase,
cudaDataType valueType,
cusparseOrder_t order)
cusparseStatus_t
cusparseCreateConstBsr(cusparseConstSpMatDescr_t* spMatDescr,
int64_t brows,
int64_t bcols,
int64_t bnnz,
int64_t rowBlockSize,
int64_t colBlockSize,
const void* bsrRowOffsets,
const void* bsrColInd,
const void* bsrValues,
cusparseIndexType_t bsrRowOffsetsType,
cusparseIndexType_t bsrColIndType,
cusparseIndexBase_t idxBase,
cudaDataType valueType,
cusparseOrder_t order)
This function initializes the sparse matrix descriptor spMatDescr for the Block Compressed Row (BSR) format.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
OUT |
Sparse matrix descriptor |
|
HOST |
IN |
Number of block rows of the sparse matrix |
|
HOST |
IN |
Number of block columns of the sparse matrix |
|
HOST |
IN |
Number of blocks of the sparse matrix |
|
HOST |
IN |
Number of rows of each block |
|
HOST |
IN |
Number of columns of each block |
|
DEVICE |
IN |
Block row offsets of the sparse matrix. Array of size |
|
DEVICE |
IN |
Block column indices of the sparse matrix. Array of size |
|
DEVICE |
IN |
Values of the sparse matrix. Array of size |
|
HOST |
IN |
Data type of |
|
HOST |
IN |
Data type of |
|
HOST |
IN |
Base index of |
|
HOST |
IN |
Datatype of |
|
HOST |
IN |
Enumerator specifying the memory layout of values in each block |
cusparseCreateBsr() has the following constraints:
bsrRowOffsets,bsrColInd, andbsrValuesmust be aligned to the size of the datatypes specified bybsrRowOffsetsType,bsrColIndType, andvalueType, respectively. See cudaDataType_t for the description of the datatypes.
See cusparseStatus_t for the description of the return status.
cusparseBsrSetStridedBatch()
cusparseStatus_t
cusparseBsrSetStridedBatch(cusparseSpMatDescr_t spMatDescr,
int batchCount,
int64_t offsetsBatchStride,
int64_t columnsBatchStride,
int64_t valuesBatchStride)
This function sets the batchCount and the batchStride fields of the sparse matrix descriptor spMatDescr.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
IN |
Sparse matrix descriptor |
|
HOST |
IN |
Number of batches of the sparse matrix |
|
HOST |
IN |
Address offset between consecutive batches for the row offset array |
|
HOST |
IN |
Address offset between consecutive batches for the column array |
|
HOST |
IN |
Address offset between consecutive batches for the values array |
See cusparseStatus_t for the description of the return status.
All Sparse Formats
cusparseDestroySpMat()
cusparseStatus_t
cusparseDestroySpMat(cusparseConstSpMatDescr_t spMatDescr) // non-const descriptor supported
This function releases the host memory allocated for the sparse matrix descriptor spMatDescr.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
IN |
Sparse matrix descriptor |
See cusparseStatus_t for the description of the return status.
cusparseSpMatGetSize()
cusparseStatus_t
cusparseSpMatGetSize(cusparseConstSpMatDescr_t spMatDescr, // non-const descriptor supported
int64_t* rows,
int64_t* cols,
int64_t* nnz)
This function returns the sizes of the sparse matrix spMatDescr.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
IN |
Sparse matrix descriptor |
|
HOST |
OUT |
Number of rows of the sparse matrix |
|
HOST |
OUT |
Number of columns of the sparse matrix |
|
HOST |
OUT |
Number of non-zero entries of the sparse matrix |
See cusparseStatus_t for the description of the return status.
cusparseSpMatGetFormat()
cusparseStatus_t
cusparseSpMatGetFormat(cusparseConstSpMatDescr_t spMatDescr, // non-const descriptor supported
cusparseFormat_t* format)
This function returns the format field of the sparse matrix descriptor spMatDescr.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
IN |
Sparse matrix descriptor |
|
HOST |
OUT |
Storage format of the sparse matrix |
See cusparseStatus_t for the description of the return status.
cusparseSpMatGetIndexBase()
cusparseStatus_t
cusparseSpMatGetIndexBase(cusparseConstSpMatDescr_t spMatDescr, // non-const descriptor supported
cusparseIndexBase_t* idxBase)
This function returns the idxBase field of the sparse matrix descriptor spMatDescr.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
IN |
Sparse matrix descriptor |
|
HOST |
OUT |
Index base of the sparse matrix |
See cusparseStatus_t for the description of the return status.
cusparseSpMatGetValues()
cusparseStatus_t
cusparseSpMatGetValues(cusparseSpMatDescr_t spMatDescr,
void** values)
cusparseStatus_t
cusparseConstSpMatGetValues(cusparseConstSpMatDescr_t spMatDescr,
const void** values)
This function returns the values field of the sparse matrix descriptor spMatDescr.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
IN |
Sparse matrix descriptor |
|
DEVICE |
OUT |
Values of the sparse matrix. Array with |
See cusparseStatus_t for the description of the return status.
cusparseSpMatSetValues()
cusparseStatus_t
cusparseSpMatSetValues(cusparseSpMatDescr_t spMatDescr,
void* values)
This function sets the values field of the sparse matrix descriptor spMatDescr.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
IN |
Sparse matrix descriptor |
|
DEVICE |
IN |
Values of the sparse matrix. Array with |
cusparseSpMatSetValues() has the following constraints:
valuesmust be aligned to the size of its corresponding datatype specified inspMatDescr. See cudaDataType_t for the description of the datatypes.
See cusparseStatus_t for the description of the return status.
cusparseSpMatGetStridedBatch()
cusparseStatus_t
cusparseSpMatGetStridedBatch(cusparseConstSpMatDescr_t spMatDescr, // non-const descriptor supported
int* batchCount)
This function returns the batchCount field of the sparse matrix descriptor spMatDescr.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
IN |
Sparse matrix descriptor |
|
HOST |
OUT |
Number of batches of the sparse matrix |
See cusparseStatus_t for the description of the return status.
cusparseSpMatGetAttribute()
cusparseStatus_t
cusparseSpMatGetAttribute(cusparseConstSpMatDescr_t spMatDescr, // non-const descriptor supported
cusparseSpMatAttribute_t attribute,
void* data,
size_t dataSize)
The function gets the attributes of the sparse matrix descriptor spMatDescr.
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
IN |
Sparse matrix descriptor |
|
HOST |
IN |
Attribute enumerator |
|
HOST |
OUT |
Attribute value |
|
HOST |
IN |
Size of the attribute in bytes for safety |
Attribute |
Meaning |
Possible Values |
|---|---|---|
|
Indicates if the lower or upper part of a matrix is stored in sparse storage |
|
|
Indicates if the matrix diagonal entries are unity |
|
See cusparseStatus_t for the description of the return status.
cusparseSpMatSetAttribute()
cusparseStatus_t
cusparseSpMatSetAttribute(cusparseSpMatDescr_t spMatDescr,
cusparseSpMatAttribute_t attribute,
const void* data,
size_t dataSize)
The function sets the attributes of the sparse matrix descriptor spMatDescr
Param. |
Memory |
In/out |
Meaning |
|---|---|---|---|
|
HOST |
OUT |
Sparse matrix descriptor |
|
HOST |
IN |
Attribute enumerator |
|
HOST |
IN |
Attribute value |
|
HOST |
IN |
Size of the attribute in bytes for safety |
Attribute |
Meaning |
Possible Values |
|---|---|---|
|
Indicates if the lower or upper part of a matrix is stored in sparse storage |
|
|
Indicates if the matrix diagonal entries are unity |
|
See cusparseStatus_t for the description of the return status.