cuSPARSE Types Reference

cudaDataType_t

The section describes the types shared by multiple CUDA Libraries and defined in the header file library_types.h. The cudaDataType type is an enumerator to specify the data precision. It is used when the data reference does not carry the type itself (e.g. void*). For example, it is used in the routine cusparseSpMM().

Value

Meaning

Data Type

Header

CUDA_R_16F

The data type is 16-bit IEEE-754 floating-point

__half

cuda_fp16.h

CUDA_C_16F

The data type is 16-bit complex IEEE-754 floating-point

__half2

cuda_fp16.h

CUDA_R_16BF

The data type is 16-bit bfloat floating-point

__nv_bfloat16

cuda_bf16.h

CUDA_C_16BF

The data type is 16-bit complex bfloat floating-point

__nv_bfloat162

cuda_bf16.h

CUDA_R_32F

The data type is 32-bit IEEE-754 floating-point

float

CUDA_C_32F

The data type is 32-bit complex IEEE-754 floating-point

cuComplex

cuComplex.h

CUDA_R_64F

The data type is 64-bit IEEE-754 floating-point

double

CUDA_C_64F

The data type is 64-bit complex IEEE-754 floating-point

cuDoubleComplex

cuComplex.h

CUDA_R_8I

The data type is 8-bit integer

int8_t

stdint.h

CUDA_R_32I

The data type is 32-bit integer

int32_t

stdint.h

IMPORTANT: The Generic API routines allow all data types reported in the respective section of the documentation only on GPU architectures with native support for them. If a specific GPU model does not provide native support for a given data type, the routine returns CUSPARSE_STATUS_ARCH_MISMATCH error.

Unsupported data types and Compute Capability (CC):

  • __half on GPUs with CC < 53 (e.g. Kepler)

  • __nv_bfloat16 on GPUs with CC < 80 (e.g. Kepler, Maxwell, Pascal, Volta, Turing)

see https://developer.nvidia.com/cuda-gpus


cusparseStatus_t

This data type represents the status returned by the library functions and it can have the following values

Value

Description

CUSPARSE_STATUS_SUCCESS

The operation completed successfully

CUSPARSE_STATUS_NOT_INITIALIZED

The cuSPARSE library was not initialized. This is usually caused by the lack of a prior call, an error in the CUDA Runtime API called by the cuSPARSE routine, or an error in the hardware setup

To correct: call cusparseCreate() prior to the function call; and check that the hardware, an appropriate version of the driver, and the cuSPARSE library are correctly installed

The error also applies to generic APIs ( Generic APIs reference) for indicating a matrix/vector descriptor not initialized

CUSPARSE_STATUS_ALLOC_FAILED

Resource allocation failed inside the cuSPARSE library. This is usually caused by a device memory allocation (cudaMalloc()) or by a host memory allocation failure

To correct: prior to the function call, deallocate previously allocated memory as much as possible

CUSPARSE_STATUS_INVALID_VALUE

An unsupported value or parameter was passed to the function (a negative vector size, for example)

To correct: ensure that all the parameters being passed have valid values

CUSPARSE_STATUS_ARCH_MISMATCH

The function requires a feature absent from the device architecture

To correct: compile and run the application on a device with appropriate compute capability

CUSPARSE_STATUS_EXECUTION_FAILED

The GPU program failed to execute. This is often caused by a launch failure of the kernel on the GPU, which can be caused by multiple reasons

To correct: check that the hardware, an appropriate version of the driver, and the cuSPARSE library are correctly installed

CUSPARSE_STATUS_INTERNAL_ERROR

An internal cuSPARSE operation failed

To correct: check that the hardware, an appropriate version of the driver, and the cuSPARSE library are correctly installed. Also, check that the memory passed as a parameter to the routine is not being deallocated prior to the routine completion

CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED

The matrix type is not supported by this function. This is usually caused by passing an invalid matrix descriptor to the function

To correct: check that the fields in cusparseMatDescr_t descrA were set correctly

CUSPARSE_STATUS_NOT_SUPPORTED

The operation or data type combination is currently not supported by the function

CUSPARSE_STATUS_INSUFFICIENT_RESOURCES

The resources for the computation, such as GPU global or shared memory, are not sufficient to complete the operation. The error can also indicate that the current computation mode (e.g. bit size of sparse matrix indices) does not allow to handle the given input


cusparseHandle_t

This is a pointer type to an opaque cuSPARSE context, which the user must initialize by calling prior to calling cusparseCreate() any other library function. The handle created and returned by cusparseCreate() must be passed to every cuSPARSE function.


cusparsePointerMode_t

This type indicates whether the scalar values are passed by reference on the host or device. It is important to point out that if several scalar values are passed by reference in the function call, all of them will conform to the same single pointer mode. The pointer mode can be set and retrieved using cusparseSetPointerMode() and cusparseGetPointerMode() routines, respectively.

Value

Meaning

CUSPARSE_POINTER_MODE_HOST

The scalars are passed by reference on the host.

CUSPARSE_POINTER_MODE_DEVICE

The scalars are passed by reference on the device.


cusparseOperation_t

This type indicates which operations is applied to the related input (e.g. sparse matrix, or vector).

Value

Meaning

CUSPARSE_OPERATION_NON_TRANSPOSE

The non-transpose operation is selected.

CUSPARSE_OPERATION_TRANSPOSE

The transpose operation is selected.

CUSPARSE_OPERATION_CONJUGATE_TRANSPOSE

The conjugate transpose operation is selected.


cusparseDiagType_t

This type indicates if the matrix diagonal entries are unity. The diagonal elements are always assumed to be present, but if CUSPARSE_DIAG_TYPE_UNIT is passed to an API routine, then the routine assumes that all diagonal entries are unity and will not read or modify those entries. Note that in this case the routine assumes the diagonal entries are equal to one, regardless of what those entries are actually set to in memory.

Value

Meaning

CUSPARSE_DIAG_TYPE_NON_UNIT

The matrix diagonal has non-unit elements.

CUSPARSE_DIAG_TYPE_UNIT

The matrix diagonal has unit elements.


cusparseFillMode_t

This type indicates if the lower or upper part of a matrix is stored in sparse storage.

Value

Meaning

CUSPARSE_FILL_MODE_LOWER

The lower triangular part is stored.

CUSPARSE_FILL_MODE_UPPER

The upper triangular part is stored.


cusparseIndexBase_t

This type indicates if the base of the matrix indices is zero or one.

Value

Meaning

CUSPARSE_INDEX_BASE_ZERO

The base index is zero (C compatibility).

CUSPARSE_INDEX_BASE_ONE

The base index is one (Fortran compatibility).


cusparseDirection_t

This type indicates whether the elements of a dense matrix should be parsed by rows or by columns (assuming column-major storage in memory of the dense matrix) in function cusparse[S|D|C|Z]nnz. Besides storage format of blocks in BSR format is also controlled by this type.

Value

Meaning

CUSPARSE_DIRECTION_ROW

The matrix should be parsed by rows.

CUSPARSE_DIRECTION_COLUMN

The matrix should be parsed by columns.