Dense Matrix APIs

The cuSPARSE helper functions for dense matrix descriptor are described in this section.

See the Dense Matrix Format section for the detailed description of the storage format.

cusparseCreateDnMat()

cusparseStatus_t
cusparseCreateDnMat(cusparseDnMatDescr_t* dnMatDescr,
                    int64_t               rows,
                    int64_t               cols,
                    int64_t               ld,
                    void*                 values,
                    cudaDataType          valueType,
                    cusparseOrder_t       order)

cusparseStatus_t
cusparseCreateConstDnMat(cusparseConstDnMatDescr_t* dnMatDescr,
                         int64_t                    rows,
                         int64_t                    cols,
                         int64_t                    ld,
                         const void*                values,
                         cudaDataType               valueType,
                         cusparseOrder_t            order)

The function initializes the dense matrix descriptor dnMatDescr.

Param.

Memory

In/out

Meaning

dnMatDescr

HOST

OUT

Dense matrix descriptor

rows

HOST

IN

Number of rows of the dense matrix

cols

HOST

IN

Number of columns of the dense matrix

ld

HOST

IN

Leading dimension of the dense matrix

values

DEVICE

IN

Values of the dense matrix. Array with size elements

valueType

HOST

IN

Enumerator specifying the datatype of values

order

HOST

IN

Enumerator specifying the memory layout of the dense matrix

cusparseCreateDnMat() has the following constraints:

  • values must be aligned to the size of the datatype specified by valueType. See cudaDataType_t for the description of the datatypes.

See cusparseStatus_t for the description of the return status.


cusparseDestroyDnMat()

cusparseStatus_t
cusparseDestroyDnMat(cusparseConstDnMatDescr_t dnMatDescr) // non-const descriptor supported

This function releases the host memory allocated for the dense matrix descriptor dnMatDescr.

Param.

Memory

In/out

Meaning

dnMatDescr

HOST

IN

Dense matrix descriptor

See cusparseStatus_t for the description of the return status.


cusparseDnMatGet()

cusparseStatus_t
cusparseDnMatGet(cusparseDnMatDescr_t dnMatDescr,
                 int64_t*             rows,
                 int64_t*             cols,
                 int64_t*             ld,
                 void**               values,
                 cudaDataType*        type,
                 cusparseOrder_t*     order)

cusparseStatus_t
cusparseConstDnMatGet(cusparseConstDnMatDescr_t dnMatDescr,
                      int64_t*             rows,
                      int64_t*             cols,
                      int64_t*             ld,
                      const void**         values,
                      cudaDataType*        type,
                      cusparseOrder_t*     order)

This function returns the fields of the dense matrix descriptor dnMatDescr.

Param.

Memory

In/out

Meaning

dnMatDescr

HOST

IN

Dense matrix descriptor

rows

HOST

OUT

Number of rows of the dense matrix

cols

HOST

OUT

Number of columns of the dense matrix

ld

HOST

OUT

Leading dimension of the dense matrix

values

DEVICE

OUT

Values of the dense matrix. Array with ld * cols elements

valueType

HOST

OUT

Enumerator specifying the datatype of values

order

HOST

OUT

Enumerator specifying the memory layout of the dense matrix

See cusparseStatus_t for the description of the return status.


cusparseDnMatGetValues()

cusparseStatus_t
cusparseDnMatGetValues(cusparseDnMatDescr_t dnMatDescr,
                       void**               values)

cusparseStatus_t
cusparseConstDnMatGetValues(cusparseConstDnMatDescr_t dnMatDescr,
                            const void**              values)

This function returns the values field of the dense matrix descriptor dnMatDescr.

Param.

Memory

In/out

Meaning

dnMatDescr

HOST

IN

Dense matrix descriptor

values

DEVICE

OUT

Values of the dense matrix. Array with ld * cols elements

See cusparseStatus_t for the description of the return status.


cusparseDnMatSetValues()

cusparseStatus_t
cusparseDnMatSetValues(cusparseDnMatDescr_t dnMatDescr,
                       void*                values)

This function sets the values field of the dense matrix descriptor dnMatDescr.

Param.

Memory

In/out

Meaning

dnMatDescr

HOST

IN

Dense matrix descriptor

values

DEVICE

IN

Values of the dense matrix. Array with ld * cols elements

cusparseDnMatSetValues() has the following constraints:

  • values must be aligned to the size of the datatype specified in dnMatDescr. See cudaDataType_t for the description of the datatypes.

See cusparseStatus_t for the description of the return status.


cusparseDnMatGetStridedBatch()

cusparseStatus_t
cusparseDnMatGetStridedBatch(cusparseConstDnMatDescr_t dnMatDescr, // non-const descriptor supported
                             int*                      batchCount,
                             int64_t*                  batchStride)

The function returns the number of batches and the batch stride of the dense matrix descriptor dnMatDescr.

Param.

Memory

In/out

Meaning

dnMatDescr

HOST

IN

Dense matrix descriptor

batchCount

HOST

OUT

Number of batches of the dense matrix

batchStride

HOST

OUT

Address offset between a matrix and the next one in the batch

See cusparseStatus_t for the description of the return status.


cusparseDnMatSetStridedBatch()

cusparseStatus_t
cusparseDnMatSetStridedBatch(cusparseDnMatDescr_t dnMatDescr,
                             int                  batchCount,
                             int64_t              batchStride)

The function sets the number of batches and the batch stride of the dense matrix descriptor dnMatDescr.

Param.

Memory

In/out

Meaning

dnMatDescr

HOST

IN

Dense matrix descriptor

batchCount

HOST

IN

Number of batches of the dense matrix

batchStride

HOST

IN

Address offset between a matrix and the next one in the batch. batchStride ld * cols if the matrix uses column-major layout, batchStride ld * rows otherwise

See cusparseStatus_t for the description of the return status.