Sparse Vector APIs

The cuSPARSE helper functions for sparse vector descriptor are described in this section.

See the Sparse Vector Format section for the detailed description of the storage format.

cusparseCreateSpVec()

cusparseStatus_t
cusparseCreateSpVec(cusparseSpVecDescr_t* spVecDescr,
                    int64_t               size,
                    int64_t               nnz,
                    void*                 indices,
                    void*                 values,
                    cusparseIndexType_t   idxType,
                    cusparseIndexBase_t   idxBase,
                    cudaDataType          valueType)

cusparseStatus_t
cusparseCreateConstSpVec(cusparseConstSpVecDescr_t* spVecDescr,
                         int64_t                    size,
                         int64_t                    nnz,
                         const void*                indices,
                         const void*                values,
                         cusparseIndexType_t        idxType,
                         cusparseIndexBase_t        idxBase,
                         cudaDataType               valueType)

This function initializes the sparse matrix descriptor spVecDescr.

Param.

Memory

In/out

Meaning

spVecDescr

HOST

OUT

Sparse vector descriptor

size

HOST

IN

Size of the sparse vector

nnz

HOST

IN

Number of non-zero entries of the sparse vector

indices

DEVICE

IN

Indices of the sparse vector. Array with nnz elements

values

DEVICE

IN

Values of the sparse vector. Array with nnz elements

idxType

HOST

IN

Enumerator specifying the data type of indices

idxBase

HOST

IN

Enumerator specifying the the index base of indices

valueType

HOST

IN

Enumerator specifying the datatype of values

See cusparseStatus_t for the description of the return status.


cusparseDestroySpVec()

cusparseStatus_t
cusparseDestroySpVec(cusparseConstSpVecDescr_t spVecDescr) // non-const descriptor supported

This function releases the host memory allocated for the sparse vector descriptor spVecDescr.

Param.

Memory

In/out

Meaning

spVecDescr

HOST

IN

Sparse vector descriptor

See cusparseStatus_t for the description of the return status.


cusparseSpVecGet()

cusparseStatus_t
cusparseSpVecGet(cusparseSpVecDescr_t spVecDescr,
                 int64_t*             size,
                 int64_t*             nnz,
                 void**               indices,
                 void**               values,
                 cusparseIndexType_t* idxType,
                 cusparseIndexBase_t* idxBase,
                 cudaDataType*        valueType)

cusparseStatus_t
cusparseConstSpVecGet(cusparseConstSpVecDescr_t spVecDescr,
                      int64_t*                  size,
                      int64_t*                  nnz,
                      const void**              indices,
                      const void**              values,
                      cusparseIndexType_t*      idxType,
                      cusparseIndexBase_t*      idxBase,
                      cudaDataType*             valueType)

This function returns the fields of the sparse vector descriptor spVecDescr.

Param.

Memory

In/out

Meaning

spVecDescr

HOST

IN

Sparse vector descriptor

size

HOST

OUT

Size of the sparse vector

nnz

HOST

OUT

Number of non-zero entries of the sparse vector

indices

DEVICE

OUT

Indices of the sparse vector. Array with nnz elements

values

DEVICE

OUT

Values of the sparse vector. Array with nnz elements

idxType

HOST

OUT

Enumerator specifying the data type of indices

idxBase

HOST

OUT

Enumerator specifying the the index base of indices

valueType

HOST

OUT

Enumerator specifying the datatype of values

See cusparseStatus_t for the description of the return status.


cusparseSpVecGetIndexBase()

cusparseStatus_t
cusparseSpVecGetIndexBase(cusparseConstSpVecDescr_t spVecDescr, // non-const descriptor supported
                          cusparseIndexBase_t*      idxBase)

This function returns the idxBase field of the sparse vector descriptor spVecDescr.

Param.

Memory

In/out

Meaning

spVecDescr

HOST

IN

Sparse vector descriptor

idxBase

HOST

OUT

Enumerator specifying the the index base of indices

See cusparseStatus_t for the description of the return status.


cusparseSpVecGetValues()

cusparseStatus_t
cusparseSpVecGetValues(cusparseSpVecDescr_t spVecDescr,
                       void**               values)

cusparseStatus_t
cusparseConstSpVecGetValues(cusparseConstSpVecDescr_t spVecDescr,
                            const void**              values)

This function returns the values field of the sparse vector descriptor spVecDescr.

Param.

Memory

In/out

Meaning

spVecDescr

HOST

IN

Sparse vector descriptor

values

DEVICE

OUT

Values of the sparse vector. Array with nnz elements

See cusparseStatus_t for the description of the return status.


cusparseSpVecSetValues()

cusparseStatus_t
cusparseSpVecSetValues(cusparseSpVecDescr_t spVecDescr,
                       void*                values)

This function set the values field of the sparse vector descriptor spVecDescr.

Param.

Memory

In/out

Meaning

spVecDescr

HOST

IN

Sparse vector descriptor

values

DEVICE

IN

Values of the sparse vector. Array with nnz elements

See cusparseStatus_t for the description of the return status.