imate
C++/CUDA Reference
Loading...
Searching...
No Matches
cusparse_api Namespace Reference

A collection of templates to wrapper cusparse functions. More...

Functions

template<>
void create_cusparse_csr_matrix< float, int32_t > (cusparseSpMatDescr_t &cusparse_matrix, const int32_t num_rows, const int32_t num_columns, const int32_t nnz, float *RESTRICT device_A_data, int32_t *RESTRICT device_A_indices, int32_t *RESTRICT device_A_index_pointer)
 A template wrapper for cusparseCreateCsr for the __nv_fp8_e5m2 precision data and int32_t index type.
 
template<>
void create_cusparse_csr_matrix< float, int64_t > (cusparseSpMatDescr_t &cusparse_matrix, const int64_t num_rows, const int64_t num_columns, const int64_t nnz, float *RESTRICT device_A_data, int64_t *RESTRICT device_A_indices, int64_t *RESTRICT device_A_index_pointer)
 A template wrapper for cusparseCreateCsr for the float precision data and int64_t index type.
 
template<>
void create_cusparse_csr_matrix< double, int32_t > (cusparseSpMatDescr_t &cusparse_matrix, const int32_t num_rows, const int32_t num_columns, const int32_t nnz, double *RESTRICT device_A_data, int32_t *RESTRICT device_A_indices, int32_t *RESTRICT device_A_index_pointer)
 A template wrapper for cusparseCreateCsr for the double precision data and int32_t index type.
 
template<>
void create_cusparse_csr_matrix< double, int64_t > (cusparseSpMatDescr_t &cusparse_matrix, const int64_t num_rows, const int64_t num_columns, const int64_t nnz, double *RESTRICT device_A_data, int64_t *RESTRICT device_A_indices, int64_t *RESTRICT device_A_index_pointer)
 A template wrapper for cusparseCreateCsr for the double precision data and int64_t index type.
 
template<>
void create_cusparse_csc_matrix< float, int32_t > (cusparseSpMatDescr_t &cusparse_matrix, const int32_t num_rows, const int32_t num_columns, const int32_t nnz, float *RESTRICT device_A_data, int32_t *RESTRICT device_A_indices, int32_t *RESTRICT device_A_index_pointer)
 A template wrapper for cusparseCreateCsc for the __nv_fp8_e5m2 precision data and int32_t index type.
 
template<>
void create_cusparse_csc_matrix< float, int64_t > (cusparseSpMatDescr_t &cusparse_matrix, const int64_t num_rows, const int64_t num_columns, const int64_t nnz, float *RESTRICT device_A_data, int64_t *RESTRICT device_A_indices, int64_t *RESTRICT device_A_index_pointer)
 A template wrapper for cusparseCreateCsc for the float precision data and int64_t index type.
 
template<>
void create_cusparse_csc_matrix< double, int32_t > (cusparseSpMatDescr_t &cusparse_matrix, const int32_t num_rows, const int32_t num_columns, const int32_t nnz, double *RESTRICT device_A_data, int32_t *RESTRICT device_A_indices, int32_t *RESTRICT device_A_index_pointer)
 A template wrapper for cusparseCreateCsc for the double precision data and int32_t index type.
 
template<>
void create_cusparse_csc_matrix< double, int64_t > (cusparseSpMatDescr_t &cusparse_matrix, const int64_t num_rows, const int64_t num_columns, const int64_t nnz, double *RESTRICT device_A_data, int64_t *RESTRICT device_A_indices, int64_t *RESTRICT device_A_index_pointer)
 A template wrapper for cusparseCreateCsc for the double precision data and int64_t index type.
 
template<>
void create_cusparse_vector< float > (cusparseDnVecDescr_t &cusparse_vector, const LongIndexType vector_size, float *RESTRICT device_vector)
 A template wrapper for cusparseCreateDnVec for the __nv_fp8_e5m2 precision data.
 
template<>
void create_cusparse_vector< double > (cusparseDnVecDescr_t &cusparse_vector, const LongIndexType vector_size, double *RESTRICT device_vector)
 A template wrapper for cusparseCreateDnVec for the double precision data.
 
void destroy_cusparse_matrix (cusparseSpMatDescr_t &cusparse_matrix)
 Destroy cusparse matrix.
 
void destroy_cusparse_vector (cusparseDnVecDescr_t &cusparse_vector)
 Destroys cusparse vector.
 
template<>
void cusparse_matrix_buffer_size< float > (cusparseHandle_t cusparse_handle, cusparseOperation_t cusparse_operation, const float alpha, cusparseSpMatDescr_t cusparse_matrix, cusparseDnVecDescr_t cusparse_input_vector, const float beta, cusparseDnVecDescr_t cusparse_output_vector, cusparseSpMVAlg_t algorithm, size_t *buffer_size)
 A template wrapper for cusparseSpMV_bufferSize for __nv_fp8_e5m2 precision data. This function determines the buffer size needed for matrix-vector multiplication using cusparseSpMV. The output is buffer_size variable.
 
template<>
void cusparse_matrix_buffer_size< double > (cusparseHandle_t cusparse_handle, cusparseOperation_t cusparse_operation, const double alpha, cusparseSpMatDescr_t cusparse_matrix, cusparseDnVecDescr_t cusparse_input_vector, const double beta, cusparseDnVecDescr_t cusparse_output_vector, cusparseSpMVAlg_t algorithm, size_t *buffer_size)
 A template wrapper for cusparseSpMV_bufferSize for double precision data. This function determines the buffer size needed for matrix-vector multiplication using cusparseSpMV. The output is buffer_size variable.
 
template<>
void cusparse_matvec< float > (cusparseHandle_t cusparse_handle, cusparseOperation_t cusparse_operation, const float alpha, cusparseSpMatDescr_t cusparse_matrix, cusparseDnVecDescr_t cusparse_input_vector, const float beta, cusparseDnVecDescr_t cusparse_output_vector, cusparseSpMVAlg_t algorithm, void *external_buffer)
 A wrapper for cusparseSpMV to perform sparse matrix-vector multiplication using __nv_fp8_e5m2 precision data.
 
template<>
void cusparse_matvec< double > (cusparseHandle_t cusparse_handle, cusparseOperation_t cusparse_operation, const double alpha, cusparseSpMatDescr_t cusparse_matrix, cusparseDnVecDescr_t cusparse_input_vector, const double beta, cusparseDnVecDescr_t cusparse_output_vector, cusparseSpMVAlg_t algorithm, void *external_buffer)
 A wrapper for cusparseSpMV to perform sparse matrix-vector multiplication using double precision data.
 
template<typename DataType , typename DataIndexType >
void create_cusparse_csr_matrix (cusparseSpMatDescr_t &cusparse_matrix, const DataIndexType num_rows, const DataIndexType num_columns, const DataIndexType nnz, DataType *RESTRICT device_A_data, DataIndexType *RESTRICT device_A_indices, DataIndexType *RESTRICT device_A_index_pointer)
 
template<typename DataType , typename DataIndexType >
void create_cusparse_csc_matrix (cusparseSpMatDescr_t &cusparse_matrix, const DataIndexType num_rows, const DataIndexType num_columns, const DataIndexType nnz, DataType *RESTRICT device_A_data, DataIndexType *RESTRICT device_A_indices, DataIndexType *RESTRICT device_A_index_pointer)
 
template<typename DataType >
void create_cusparse_vector (cusparseDnVecDescr_t &cusparse_vector, const LongIndexType vector_size, DataType *RESTRICT device_vector)
 
template<typename DataType >
void cusparse_matrix_buffer_size (cusparseHandle_t cusparse_handle, cusparseOperation_t cusparse_operation, const DataType alpha, cusparseSpMatDescr_t cusparse_matrix, cusparseDnVecDescr_t cusparse_input_vector, const DataType beta, cusparseDnVecDescr_t cusparse_output_vector, cusparseSpMVAlg_t algorithm, size_t *buffer_size)
 
template<typename DataType >
void cusparse_matvec (cusparseHandle_t cusparse_handle, cusparseOperation_t cusparse_operation, const DataType alpha, cusparseSpMatDescr_t cusparse_matrix, cusparseDnVecDescr_t cusparse_input_vector, const DataType beta, cusparseDnVecDescr_t cusparse_output_vector, cusparseSpMVAlg_t algorithm, void *external_buffer)
 

Detailed Description

A collection of templates to wrapper cusparse functions.

Note
The implementation in the cu file is wrapped inside the namepsace clause. This is not necessary in general, however, it is needed to avoid the old gcc compiler error (this is a gcc bug) which complains "no instance of function template matches the argument list const float".

Function Documentation

◆ create_cusparse_csc_matrix()

template<typename DataType , typename DataIndexType >
void cusparse_api::create_cusparse_csc_matrix ( cusparseSpMatDescr_t &  cusparse_matrix,
const DataIndexType  num_rows,
const DataIndexType  num_columns,
const DataIndexType  nnz,
DataType *RESTRICT  device_A_data,
DataIndexType *RESTRICT  device_A_indices,
DataIndexType *RESTRICT  device_A_index_pointer 
)

Referenced by cuCSCMatrix< DataType >::copy_host_to_device().

Here is the caller graph for this function:

◆ create_cusparse_csc_matrix< double, int32_t >()

template<>
void cusparse_api::create_cusparse_csc_matrix< double, int32_t > ( cusparseSpMatDescr_t &  cusparse_matrix,
const int32_t  num_rows,
const int32_t  num_columns,
const int32_t  nnz,
double *RESTRICT  device_A_data,
int32_t *RESTRICT  device_A_indices,
int32_t *RESTRICT  device_A_index_pointer 
)

A template wrapper for cusparseCreateCsc for the double precision data and int32_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of rows indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of columns plus one. This array resides on GPU device.
See also
create_cusparse_csr_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

Definition at line 1195 of file cusparse_api.cu.

1203 {
1204 cusparseStatus_t status = cusparseCreateCsc(
1205 &cusparse_matrix, num_rows, num_columns, nnz,
1206 device_A_index_pointer, device_A_indices, device_A_data,
1207 CUSPARSE_INDEX_32I, CUSPARSE_INDEX_32I,
1208 CUSPARSE_INDEX_BASE_ZERO, CUDA_R_64F);
1209
1210 assert(status == CUSPARSE_STATUS_SUCCESS);
1211 }
cusparseStatus_t cusparseCreateCsc(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)
Definition of CUDA's cusparseCreateCsc function using dynamically loaded cublas library.

References cusparseCreateCsc().

Here is the call graph for this function:

◆ create_cusparse_csc_matrix< double, int64_t >()

template<>
void cusparse_api::create_cusparse_csc_matrix< double, int64_t > ( cusparseSpMatDescr_t &  cusparse_matrix,
const int64_t  num_rows,
const int64_t  num_columns,
const int64_t  nnz,
double *RESTRICT  device_A_data,
int64_t *RESTRICT  device_A_indices,
int64_t *RESTRICT  device_A_index_pointer 
)

A template wrapper for cusparseCreateCsc for the double precision data and int64_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of rows indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of columns plus one. This array resides on GPU device.
See also
create_cusparse_csr_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

Definition at line 1248 of file cusparse_api.cu.

1256 {
1257 cusparseStatus_t status = cusparseCreateCsc(
1258 &cusparse_matrix, num_rows, num_columns, nnz,
1259 device_A_index_pointer, device_A_indices, device_A_data,
1260 CUSPARSE_INDEX_64I, CUSPARSE_INDEX_64I,
1261 CUSPARSE_INDEX_BASE_ZERO, CUDA_R_64F);
1262
1263 assert(status == CUSPARSE_STATUS_SUCCESS);
1264 }

References cusparseCreateCsc().

Here is the call graph for this function:

◆ create_cusparse_csc_matrix< float, int32_t >()

template<>
void cusparse_api::create_cusparse_csc_matrix< float, int32_t > ( cusparseSpMatDescr_t &  cusparse_matrix,
const int32_t  num_rows,
const int32_t  num_columns,
const int32_t  nnz,
float *RESTRICT  device_A_data,
int32_t *RESTRICT  device_A_indices,
int32_t *RESTRICT  device_A_index_pointer 
)

A template wrapper for cusparseCreateCsc for the __nv_fp8_e5m2 precision data and int32_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of rows indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of columns plus one. This array resides on GPU device.
See also
create_cusparse_csr_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

A template wrapper for cusparseCreateCsc for the __nv_fp8_e5m2 precision data and int64_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of rows indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of columns plus one. This array resides on GPU device.
See also
create_cusparse_csr_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

A template wrapper for cusparseCreateCsc for the __nv_fp8_e4m3 precision data and int32_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of rows indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of columns plus one. This array resides on GPU device.
See also
create_cusparse_csr_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

A template wrapper for cusparseCreateCsc for the __nv_fp8_e4m3 precision data and int64_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of rows indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of columns plus one. This array resides on GPU device.
See also
create_cusparse_csr_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

A template wrapper for cusparseCreateCsc for the __half precision data and int32_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of rows indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of columns plus one. This array resides on GPU device.
See also
create_cusparse_csr_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

A template wrapper for cusparseCreateCsc for the __half precision data and int64_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of rows indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of columns plus one. This array resides on GPU device.
See also
create_cusparse_csr_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

A template wrapper for cusparseCreateCsc for the __nv_bfloat16 precision data and int32_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of rows indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of columns plus one. This array resides on GPU device.
See also
create_cusparse_csr_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

A template wrapper for cusparseCreateCsc for the __nv_bfloat16 precision data and int64_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of rows indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of columns plus one. This array resides on GPU device.
See also
create_cusparse_csr_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

A template wrapper for cusparseCreateCsc for the float precision data and int32_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of rows indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of columns plus one. This array resides on GPU device.
See also
create_cusparse_csr_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

Definition at line 1089 of file cusparse_api.cu.

1097 {
1098 cusparseStatus_t status = cusparseCreateCsc(
1099 &cusparse_matrix, num_rows, num_columns, nnz,
1100 device_A_index_pointer, device_A_indices, device_A_data,
1101 CUSPARSE_INDEX_32I, CUSPARSE_INDEX_32I,
1102 CUSPARSE_INDEX_BASE_ZERO, CUDA_R_32F);
1103
1104 assert(status == CUSPARSE_STATUS_SUCCESS);
1105 }

References cusparseCreateCsc().

Here is the call graph for this function:

◆ create_cusparse_csc_matrix< float, int64_t >()

template<>
void cusparse_api::create_cusparse_csc_matrix< float, int64_t > ( cusparseSpMatDescr_t &  cusparse_matrix,
const int64_t  num_rows,
const int64_t  num_columns,
const int64_t  nnz,
float *RESTRICT  device_A_data,
int64_t *RESTRICT  device_A_indices,
int64_t *RESTRICT  device_A_index_pointer 
)

A template wrapper for cusparseCreateCsc for the float precision data and int64_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of rows indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of columns plus one. This array resides on GPU device.
See also
create_cusparse_csr_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

Definition at line 1142 of file cusparse_api.cu.

1150 {
1151 cusparseStatus_t status = cusparseCreateCsc(
1152 &cusparse_matrix, num_rows, num_columns, nnz,
1153 device_A_index_pointer, device_A_indices, device_A_data,
1154 CUSPARSE_INDEX_64I, CUSPARSE_INDEX_64I,
1155 CUSPARSE_INDEX_BASE_ZERO, CUDA_R_32F);
1156
1157 assert(status == CUSPARSE_STATUS_SUCCESS);
1158 }

References cusparseCreateCsc().

Here is the call graph for this function:

◆ create_cusparse_csr_matrix()

template<typename DataType , typename DataIndexType >
void cusparse_api::create_cusparse_csr_matrix ( cusparseSpMatDescr_t &  cusparse_matrix,
const DataIndexType  num_rows,
const DataIndexType  num_columns,
const DataIndexType  nnz,
DataType *RESTRICT  device_A_data,
DataIndexType *RESTRICT  device_A_indices,
DataIndexType *RESTRICT  device_A_index_pointer 
)

Referenced by cuCSCMatrix< DataType >::copy_host_to_device(), and cuCSRMatrix< DataType >::copy_host_to_device().

Here is the caller graph for this function:

◆ create_cusparse_csr_matrix< double, int32_t >()

template<>
void cusparse_api::create_cusparse_csr_matrix< double, int32_t > ( cusparseSpMatDescr_t &  cusparse_matrix,
const int32_t  num_rows,
const int32_t  num_columns,
const int32_t  nnz,
double *RESTRICT  device_A_data,
int32_t *RESTRICT  device_A_indices,
int32_t *RESTRICT  device_A_index_pointer 
)

A template wrapper for cusparseCreateCsr for the double precision data and int32_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of columns indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of rows plus one. This array resides on GPU device.
See also
create_cusparse_csc_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

Definition at line 579 of file cusparse_api.cu.

587 {
588 cusparseStatus_t status = cusparseCreateCsr(
589 &cusparse_matrix, num_rows, num_columns, nnz,
590 device_A_index_pointer, device_A_indices, device_A_data,
591 CUSPARSE_INDEX_32I, CUSPARSE_INDEX_32I,
592 CUSPARSE_INDEX_BASE_ZERO, CUDA_R_64F);
593
594 assert(status == CUSPARSE_STATUS_SUCCESS);
595 }
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)
Definition of CUDA's cusparseCreateCsr function using dynamically loaded cublas library.

References cusparseCreateCsr().

Here is the call graph for this function:

◆ create_cusparse_csr_matrix< double, int64_t >()

template<>
void cusparse_api::create_cusparse_csr_matrix< double, int64_t > ( cusparseSpMatDescr_t &  cusparse_matrix,
const int64_t  num_rows,
const int64_t  num_columns,
const int64_t  nnz,
double *RESTRICT  device_A_data,
int64_t *RESTRICT  device_A_indices,
int64_t *RESTRICT  device_A_index_pointer 
)

A template wrapper for cusparseCreateCsr for the double precision data and int64_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of columns indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of rows plus one. This array resides on GPU device.
See also
create_cusparse_csc_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

Definition at line 632 of file cusparse_api.cu.

640 {
641 cusparseStatus_t status = cusparseCreateCsr(
642 &cusparse_matrix, num_rows, num_columns, nnz,
643 device_A_index_pointer, device_A_indices, device_A_data,
644 CUSPARSE_INDEX_64I, CUSPARSE_INDEX_64I,
645 CUSPARSE_INDEX_BASE_ZERO, CUDA_R_64F);
646
647 assert(status == CUSPARSE_STATUS_SUCCESS);
648 }

References cusparseCreateCsr().

Here is the call graph for this function:

◆ create_cusparse_csr_matrix< float, int32_t >()

template<>
void cusparse_api::create_cusparse_csr_matrix< float, int32_t > ( cusparseSpMatDescr_t &  cusparse_matrix,
const int32_t  num_rows,
const int32_t  num_columns,
const int32_t  nnz,
float *RESTRICT  device_A_data,
int32_t *RESTRICT  device_A_indices,
int32_t *RESTRICT  device_A_index_pointer 
)

A template wrapper for cusparseCreateCsr for the __nv_fp8_e5m2 precision data and int32_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of columns indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of rows plus one. This array resides on GPU device.
See also
create_cusparse_csc_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

A template wrapper for cusparseCreateCsr for the __nv_fp8_e5m2 precision data and int64_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of columns indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of rows plus one. This array resides on GPU device.
See also
create_cusparse_csc_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

A template wrapper for cusparseCreateCsr for the __nv_fp8_e4m3 precision data and int32_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of columns indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of rows plus one. This array resides on GPU device.
See also
create_cusparse_csc_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

A template wrapper for cusparseCreateCsr for the __nv_fp8_e4m3 precision data and int64_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of columns indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of rows plus one. This array resides on GPU device.
See also
create_cusparse_csc_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

A template wrapper for cusparseCreateCsr for the __half precision data and int32_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of columns indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of rows plus one. This array resides on GPU device.
See also
create_cusparse_csc_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

A template wrapper for cusparseCreateCsr for the __half precision data and int64_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of columns indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of rows plus one. This array resides on GPU device.
See also
create_cusparse_csc_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

A template wrapper for cusparseCreateCsr for the __nv_bfloat16 precision data and int32_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of columns indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of rows plus one. This array resides on GPU device.
See also
create_cusparse_csc_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

A template wrapper for cusparseCreateCsr for the __nv_bfloat16 precision data and int64_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of columns indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of rows plus one. This array resides on GPU device.
See also
create_cusparse_csc_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

A template wrapper for cusparseCreateCsr for the float precision data and int32_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of columns indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of rows plus one. This array resides on GPU device.
See also
create_cusparse_csc_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

Definition at line 473 of file cusparse_api.cu.

481 {
482 cusparseStatus_t status = cusparseCreateCsr(
483 &cusparse_matrix, num_rows, num_columns, nnz,
484 device_A_index_pointer, device_A_indices, device_A_data,
485 CUSPARSE_INDEX_32I, CUSPARSE_INDEX_32I,
486 CUSPARSE_INDEX_BASE_ZERO, CUDA_R_32F);
487
488 assert(status == CUSPARSE_STATUS_SUCCESS);
489 }

References cusparseCreateCsr().

Here is the call graph for this function:

◆ create_cusparse_csr_matrix< float, int64_t >()

template<>
void cusparse_api::create_cusparse_csr_matrix< float, int64_t > ( cusparseSpMatDescr_t &  cusparse_matrix,
const int64_t  num_rows,
const int64_t  num_columns,
const int64_t  nnz,
float *RESTRICT  device_A_data,
int64_t *RESTRICT  device_A_indices,
int64_t *RESTRICT  device_A_index_pointer 
)

A template wrapper for cusparseCreateCsr for the float precision data and int64_t index type.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be created.
[in]num_rowsNumber of rows of matrix
[in]num_columnsNumber of columns of matrix
[in]nnzNumber of non-zero elements of sparse matrix
[in]device_A_dataArray of the data of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_indicesArray of columns indices of sparse matrix. The length of this array is nnz. This array resides on GPU device.
[in]device_A_index_pointerArray of row index pointers of sparse matrix. The length of this array is number of rows plus one. This array resides on GPU device.
See also
create_cusparse_csc_matrix, destroy_cusparse_matrix, create_cusparse_vector, destroy_cusparse_vector

Definition at line 526 of file cusparse_api.cu.

534 {
535 cusparseStatus_t status = cusparseCreateCsr(
536 &cusparse_matrix, num_rows, num_columns, nnz,
537 device_A_index_pointer, device_A_indices, device_A_data,
538 CUSPARSE_INDEX_64I, CUSPARSE_INDEX_64I,
539 CUSPARSE_INDEX_BASE_ZERO, CUDA_R_32F);
540
541 assert(status == CUSPARSE_STATUS_SUCCESS);
542 }

References cusparseCreateCsr().

Here is the call graph for this function:

◆ create_cusparse_vector()

template<typename DataType >
void cusparse_api::create_cusparse_vector ( cusparseDnVecDescr_t &  cusparse_vector,
const LongIndexType  vector_size,
DataType *RESTRICT  device_vector 
)

◆ create_cusparse_vector< double >()

template<>
void cusparse_api::create_cusparse_vector< double > ( cusparseDnVecDescr_t &  cusparse_vector,
const LongIndexType  vector_size,
double *RESTRICT  device_vector 
)

A template wrapper for cusparseCreateDnVec for the double precision data.

Note that according to the cusparse documentation for the function cusparseCreateDnVec, it is safe to use const_cast to cast the input vector.

Parameters
[out]cusparse_vectorReference to CuSparse vector object to be created.
[in]vector_sizeSize of vector array
[in]device_vectorArray data of vector on GPU device.
See also
destroy_cusparse_vector, create_cusparse_csr_matrix, create_cusparse_csc_matrix

Definition at line 1473 of file cusparse_api.cu.

1477 {
1478 cusparseStatus_t status = cusparseCreateDnVec(
1479 &cusparse_vector, vector_size, device_vector, CUDA_R_64F);
1480
1481 assert(status == CUSPARSE_STATUS_SUCCESS);
1482 }
cusparseStatus_t cusparseCreateDnVec(cusparseDnVecDescr_t *dnVecDescr, int64_t size, void *values, cudaDataType valueType)
Definition of CUDA's cusparseCreateDnVec function using dynamically loaded cublas library.

References cusparseCreateDnVec().

Here is the call graph for this function:

◆ create_cusparse_vector< float >()

template<>
void cusparse_api::create_cusparse_vector< float > ( cusparseDnVecDescr_t &  cusparse_vector,
const LongIndexType  vector_size,
float *RESTRICT  device_vector 
)

A template wrapper for cusparseCreateDnVec for the __nv_fp8_e5m2 precision data.

Note that according to the cusparse documentation for the function cusparseCreateDnVec, it is safe to use const_cast to cast the input vector.

Parameters
[out]cusparse_vectorReference to CuSparse vector object to be created.
[in]vector_sizeSize of vector array
[in]device_vectorArray data of vector on GPU device.
See also
destroy_cusparse_vector, create_cusparse_csr_matrix, create_cusparse_csc_matrix

A template wrapper for cusparseCreateDnVec for the __nv_fp8_e4m3 precision data.

Note that according to the cusparse documentation for the function cusparseCreateDnVec, it is safe to use const_cast to cast the input vector.

Parameters
[out]cusparse_vectorReference to CuSparse vector object to be created.
[in]vector_sizeSize of vector array
[in]device_vectorArray data of vector on GPU device.
See also
destroy_cusparse_vector, create_cusparse_csr_matrix, create_cusparse_csc_matrix

A template wrapper for cusparseCreateDnVec for the __half precision data.

Note that according to the cusparse documentation for the function cusparseCreateDnVec, it is safe to use const_cast to cast the input vector.

Parameters
[out]cusparse_vectorReference to CuSparse vector object to be created.
[in]vector_sizeSize of vector array
[in]device_vectorArray data of vector on GPU device.
See also
destroy_cusparse_vector, create_cusparse_csr_matrix, create_cusparse_csc_matrix

A template wrapper for cusparseCreateDnVec for the __nv_bfloat16 precision data.

Note that according to the cusparse documentation for the function cusparseCreateDnVec, it is safe to use const_cast to cast the input vector.

Parameters
[out]cusparse_vectorReference to CuSparse vector object to be created.
[in]vector_sizeSize of vector array
[in]device_vectorArray data of vector on GPU device.
See also
destroy_cusparse_vector, create_cusparse_csr_matrix, create_cusparse_csc_matrix

A template wrapper for cusparseCreateDnVec for the float precision data.

Note that according to the cusparse documentation for the function cusparseCreateDnVec, it is safe to use const_cast to cast the input vector.

Parameters
[out]cusparse_vectorReference to CuSparse vector object to be created.
[in]vector_sizeSize of vector array
[in]device_vectorArray data of vector on GPU device.
See also
destroy_cusparse_vector, create_cusparse_csr_matrix, create_cusparse_csc_matrix

Definition at line 1436 of file cusparse_api.cu.

1440 {
1441 cusparseStatus_t status = cusparseCreateDnVec(
1442 &cusparse_vector, vector_size, device_vector, CUDA_R_32F);
1443
1444 assert(status == CUSPARSE_STATUS_SUCCESS);
1445 }

References cusparseCreateDnVec().

Here is the call graph for this function:

◆ cusparse_matrix_buffer_size()

template<typename DataType >
void cusparse_api::cusparse_matrix_buffer_size ( cusparseHandle_t  cusparse_handle,
cusparseOperation_t  cusparse_operation,
const DataType  alpha,
cusparseSpMatDescr_t  cusparse_matrix,
cusparseDnVecDescr_t  cusparse_input_vector,
const DataType  beta,
cusparseDnVecDescr_t  cusparse_output_vector,
cusparseSpMVAlg_t  algorithm,
size_t *  buffer_size 
)

Referenced by cuCSCMatrix< DataType >::allocate_buffer(), and cuCSRMatrix< DataType >::allocate_buffer().

Here is the caller graph for this function:

◆ cusparse_matrix_buffer_size< double >()

template<>
void cusparse_api::cusparse_matrix_buffer_size< double > ( cusparseHandle_t  cusparse_handle,
cusparseOperation_t  cusparse_operation,
const double  alpha,
cusparseSpMatDescr_t  cusparse_matrix,
cusparseDnVecDescr_t  cusparse_input_vector,
const double  beta,
cusparseDnVecDescr_t  cusparse_output_vector,
cusparseSpMVAlg_t  algorithm,
size_t *  buffer_size 
)

A template wrapper for cusparseSpMV_bufferSize for double precision data. This function determines the buffer size needed for matrix-vector multiplication using cusparseSpMV. The output is buffer_size variable.

Parameters
[in]cusparse_handleHandle to the CuSparse library context
[in]cusparse_operationType of matrix operation. For non-transpose operation, this should be set to CUSPARSE_OPERATION_NON_TRANSPOSE and for transpose operation, this should be set to CUSPARSE_OPERATION_TRANSPOSE.
[in]alphaThe scalar parameter \( \alpha \) in matrix-vector product.
[in]cusparse_matrixCusparse object for matrix \( \mathbf{A} \).
[in]cusparse_input_vectorCusparse object for vector \( \boldsymbol{x} \).
[in]betaThe scalar parameter \( \beta \) in matrix-vector product.
[in]cusparse_output_vectorCusparse object for vector \( \boldsymbol{y} \).
[in]algorithmAlgorithm for the computation. Possible values can be CUSPARSE_SPMV_ALG_DEFAULT, CUSPARSE_SPMV_CSR_ALG1, and CUSPARSE_SPMV_CSR_ALG2.
[out]buffer_sizeThe size of buffer needed for computation.
See also
cusparse_matvec

Definition at line 1880 of file cusparse_api.cu.

1890 {
1891 cusparseStatus_t status = cusparseSpMV_bufferSize(
1892 cusparse_handle, cusparse_operation, &alpha, cusparse_matrix,
1893 cusparse_input_vector, &beta, cusparse_output_vector,
1894 CUDA_R_64F, algorithm, buffer_size);
1895
1896 assert(status == CUSPARSE_STATUS_SUCCESS);
1897 }
cusparseStatus_t cusparseSpMV_bufferSize(cusparseHandle_t handle, cusparseOperation_t opA, const void *alpha, cusparseConstSpMatDescr_t matA, cusparseConstDnVecDescr_t vecX, const void *beta, cusparseDnVecDescr_t vecY, cudaDataType computeType, cusparseSpMVAlg_t alg, size_t *bufferSize)
Definition of CUDA's cusparseSpMV_bufferSize function using dynamically loaded cublas library.

References cusparseSpMV_bufferSize().

Here is the call graph for this function:

◆ cusparse_matrix_buffer_size< float >()

template<>
void cusparse_api::cusparse_matrix_buffer_size< float > ( cusparseHandle_t  cusparse_handle,
cusparseOperation_t  cusparse_operation,
const float  alpha,
cusparseSpMatDescr_t  cusparse_matrix,
cusparseDnVecDescr_t  cusparse_input_vector,
const float  beta,
cusparseDnVecDescr_t  cusparse_output_vector,
cusparseSpMVAlg_t  algorithm,
size_t *  buffer_size 
)

A template wrapper for cusparseSpMV_bufferSize for __nv_fp8_e5m2 precision data. This function determines the buffer size needed for matrix-vector multiplication using cusparseSpMV. The output is buffer_size variable.

Note that this function uses mixed-precision computation where the matrix and vectors are __nv_fp8_e5m2 type while the compute type is CUDA_R_32.

Parameters
[in]cusparse_handleHandle to the CuSparse library context
[in]cusparse_operationType of matrix operation. For non-transpose operation, this should be set to CUSPARSE_OPERATION_NON_TRANSPOSE and for transpose operation, this should be set to CUSPARSE_OPERATION_TRANSPOSE.
[in]alphaThe scalar parameter \( \alpha \) in matrix-vector product.
[in]cusparse_matrixCusparse object for matrix \( \mathbf{A} \).
[in]cusparse_input_vectorCusparse object for vector \( \boldsymbol{x} \).
[in]betaThe scalar parameter \( \beta \) in matrix-vector product.
[in]cusparse_output_vectorCusparse object for vector \( \boldsymbol{y} \).
[in]algorithmAlgorithm for the computation. Possible values can be CUSPARSE_SPMV_ALG_DEFAULT, CUSPARSE_SPMV_CSR_ALG1, and CUSPARSE_SPMV_CSR_ALG2.
[out]buffer_sizeThe size of buffer needed for computation.
See also
cusparse_matvec

A template wrapper for cusparseSpMV_bufferSize for __nv_fp8_e4m3 precision data. This function determines the buffer size needed for matrix-vector multiplication using cusparseSpMV. The output is buffer_size variable.

Note that this function uses mixed-precision computation where the matrix and vectors are __nv_fp8_e4m3 type while the compute type is CUDA_R_32.

Parameters
[in]cusparse_handleHandle to the CuSparse library context
[in]cusparse_operationType of matrix operation. For non-transpose operation, this should be set to CUSPARSE_OPERATION_NON_TRANSPOSE and for transpose operation, this should be set to CUSPARSE_OPERATION_TRANSPOSE.
[in]alphaThe scalar parameter \( \alpha \) in matrix-vector product.
[in]cusparse_matrixCusparse object for matrix \( \mathbf{A} \).
[in]cusparse_input_vectorCusparse object for vector \( \boldsymbol{x} \).
[in]betaThe scalar parameter \( \beta \) in matrix-vector product.
[in]cusparse_output_vectorCusparse object for vector \( \boldsymbol{y} \).
[in]algorithmAlgorithm for the computation. Possible values can be CUSPARSE_SPMV_ALG_DEFAULT, CUSPARSE_SPMV_CSR_ALG1, and CUSPARSE_SPMV_CSR_ALG2.
[out]buffer_sizeThe size of buffer needed for computation.
See also
cusparse_matvec

A template wrapper for cusparseSpMV_bufferSize for __half precision data. This function determines the buffer size needed for matrix-vector multiplication using cusparseSpMV. The output is buffer_size variable.

Note that this function uses mixed-precision computation where the matrix and vectors are __half type while the compute type is CUDA_R_32.

Parameters
[in]cusparse_handleHandle to the CuSparse library context
[in]cusparse_operationType of matrix operation. For non-transpose operation, this should be set to CUSPARSE_OPERATION_NON_TRANSPOSE and for transpose operation, this should be set to CUSPARSE_OPERATION_TRANSPOSE.
[in]alphaThe scalar parameter \( \alpha \) in matrix-vector product.
[in]cusparse_matrixCusparse object for matrix \( \mathbf{A} \).
[in]cusparse_input_vectorCusparse object for vector \( \boldsymbol{x} \).
[in]betaThe scalar parameter \( \beta \) in matrix-vector product.
[in]cusparse_output_vectorCusparse object for vector \( \boldsymbol{y} \).
[in]algorithmAlgorithm for the computation. Possible values can be CUSPARSE_SPMV_ALG_DEFAULT, CUSPARSE_SPMV_CSR_ALG1, and CUSPARSE_SPMV_CSR_ALG2.
[out]buffer_sizeThe size of buffer needed for computation.
See also
cusparse_matvec

A template wrapper for cusparseSpMV_bufferSize for __nv_bfloat16 precision data. This function determines the buffer size needed for matrix-vector multiplication using cusparseSpMV. The output is buffer_size variable.

Note that this function uses mixed-precision computation where the matrix and vectors are __nv_bfloat16 type while the compute type is CUDA_R_32.

Parameters
[in]cusparse_handleHandle to the CuSparse library context
[in]cusparse_operationType of matrix operation. For non-transpose operation, this should be set to CUSPARSE_OPERATION_NON_TRANSPOSE and for transpose operation, this should be set to CUSPARSE_OPERATION_TRANSPOSE.
[in]alphaThe scalar parameter \( \alpha \) in matrix-vector product.
[in]cusparse_matrixCusparse object for matrix \( \mathbf{A} \).
[in]cusparse_input_vectorCusparse object for vector \( \boldsymbol{x} \).
[in]betaThe scalar parameter \( \beta \) in matrix-vector product.
[in]cusparse_output_vectorCusparse object for vector \( \boldsymbol{y} \).
[in]algorithmAlgorithm for the computation. Possible values can be CUSPARSE_SPMV_ALG_DEFAULT, CUSPARSE_SPMV_CSR_ALG1, and CUSPARSE_SPMV_CSR_ALG2.
[out]buffer_sizeThe size of buffer needed for computation.
See also
cusparse_matvec

A template wrapper for cusparseSpMV_bufferSize for float precision data. This function determines the buffer size needed for matrix-vector multiplication using cusparseSpMV. The output is buffer_size variable.

Parameters
[in]cusparse_handleHandle to the CuSparse library context
[in]cusparse_operationType of matrix operation. For non-transpose operation, this should be set to CUSPARSE_OPERATION_NON_TRANSPOSE and for transpose operation, this should be set to CUSPARSE_OPERATION_TRANSPOSE.
[in]alphaThe scalar parameter \( \alpha \) in matrix-vector product.
[in]cusparse_matrixCusparse object for matrix \( \mathbf{A} \).
[in]cusparse_input_vectorCusparse object for vector \( \boldsymbol{x} \).
[in]betaThe scalar parameter \( \beta \) in matrix-vector product.
[in]cusparse_output_vectorCusparse object for vector \( \boldsymbol{y} \).
[in]algorithmAlgorithm for the computation. Possible values can be CUSPARSE_SPMV_ALG_DEFAULT, CUSPARSE_SPMV_CSR_ALG1, and CUSPARSE_SPMV_CSR_ALG2.
[out]buffer_sizeThe size of buffer needed for computation.
See also
cusparse_matvec

Definition at line 1820 of file cusparse_api.cu.

1830 {
1831 cusparseStatus_t status = cusparseSpMV_bufferSize(
1832 cusparse_handle, cusparse_operation, &alpha, cusparse_matrix,
1833 cusparse_input_vector, &beta, cusparse_output_vector,
1834 CUDA_R_32F, algorithm, buffer_size);
1835
1836 assert(status == CUSPARSE_STATUS_SUCCESS);
1837 }

References cusparseSpMV_bufferSize().

Here is the call graph for this function:

◆ cusparse_matvec()

template<typename DataType >
void cusparse_api::cusparse_matvec ( cusparseHandle_t  cusparse_handle,
cusparseOperation_t  cusparse_operation,
const DataType  alpha,
cusparseSpMatDescr_t  cusparse_matrix,
cusparseDnVecDescr_t  cusparse_input_vector,
const DataType  beta,
cusparseDnVecDescr_t  cusparse_output_vector,
cusparseSpMVAlg_t  algorithm,
void *  external_buffer 
)

◆ cusparse_matvec< double >()

template<>
void cusparse_api::cusparse_matvec< double > ( cusparseHandle_t  cusparse_handle,
cusparseOperation_t  cusparse_operation,
const double  alpha,
cusparseSpMatDescr_t  cusparse_matrix,
cusparseDnVecDescr_t  cusparse_input_vector,
const double  beta,
cusparseDnVecDescr_t  cusparse_output_vector,
cusparseSpMVAlg_t  algorithm,
void *  external_buffer 
)

A wrapper for cusparseSpMV to perform sparse matrix-vector multiplication using double precision data.

Parameters
[in]cusparse_handleHandle to the CuSparse library context
[in]cusparse_operationType of matrix operation. For non-transpose operation, this should be set to CUSPARSE_OPERATION_NON_TRANSPOSE and for transpose operation, this should be set to CUSPARSE_OPERATION_TRANSPOSE.
[in]alphaThe scalar parameter \( \alpha \) in matrix-vector product.
[in]cusparse_matrixCusparse object for matrix \( \mathbf{A} \).
[in]cusparse_input_vectorCusparse object for vector \( \boldsymbol{x} \).
[in]betaThe scalar parameter \( \beta \) in matrix-vector product.
[out]cusparse_output_vectorCusparse object for vector \( \boldsymbol{y} \).
[in]algorithmAlgorithm for the computation. Possible values can be CUSPARSE_SPMV_ALG_DEFAULT, CUSPARSE_SPMV_CSR_ALG1, and CUSPARSE_SPMV_CSR_ALG2.
[in]external_bufferBuffer on GPU device needed for computation.
See also
cusparse_matrix_buffer_size

Definition at line 2251 of file cusparse_api.cu.

2261 {
2262 cusparseStatus_t status = cusparseSpMV(cusparse_handle,
2263 cusparse_operation, &alpha,
2264 cusparse_matrix,
2265 cusparse_input_vector, &beta,
2266 cusparse_output_vector,
2267 CUDA_R_64F, algorithm,
2268 external_buffer);
2269
2270 assert(status == CUSPARSE_STATUS_SUCCESS);
2271 }
cusparseStatus_t cusparseSpMV(cusparseHandle_t handle, cusparseOperation_t opA, const void *alpha, cusparseConstSpMatDescr_t matA, cusparseConstDnVecDescr_t vecX, const void *beta, cusparseDnVecDescr_t vecY, cudaDataType computeType, cusparseSpMVAlg_t alg, void *externalBuffer)
Definition of CUDA's cusparseSmMV function using dynamically loaded cublas library.

References cusparseSpMV().

Here is the call graph for this function:

◆ cusparse_matvec< float >()

template<>
void cusparse_api::cusparse_matvec< float > ( cusparseHandle_t  cusparse_handle,
cusparseOperation_t  cusparse_operation,
const float  alpha,
cusparseSpMatDescr_t  cusparse_matrix,
cusparseDnVecDescr_t  cusparse_input_vector,
const float  beta,
cusparseDnVecDescr_t  cusparse_output_vector,
cusparseSpMVAlg_t  algorithm,
void *  external_buffer 
)

A wrapper for cusparseSpMV to perform sparse matrix-vector multiplication using __nv_fp8_e5m2 precision data.

Note that this function uses mixed-precision computation where the matrix and vectors are __nv_fp8_e5m2 type while the compute type is CUDA_R_32.

Parameters
[in]cusparse_handleHandle to the CuSparse library context
[in]cusparse_operationType of matrix operation. For non-transpose operation, this should be set to CUSPARSE_OPERATION_NON_TRANSPOSE and for transpose operation, this should be set to CUSPARSE_OPERATION_TRANSPOSE.
[in]alphaThe scalar parameter \( \alpha \) in matrix-vector product.
[in]cusparse_matrixCusparse object for matrix \( \mathbf{A} \).
[in]cusparse_input_vectorCusparse object for vector \( \boldsymbol{x} \).
[in]betaThe scalar parameter \( \beta \) in matrix-vector product.
[out]cusparse_output_vectorCusparse object for vector \( \boldsymbol{y} \).
[in]algorithmAlgorithm for the computation. Possible values can be CUSPARSE_SPMV_ALG_DEFAULT, CUSPARSE_SPMV_CSR_ALG1, and CUSPARSE_SPMV_CSR_ALG2.
[in]external_bufferBuffer on GPU device needed for computation.
See also
cusparse_matrix_buffer_size

A wrapper for cusparseSpMV to perform sparse matrix-vector multiplication using __nv_fp8_e4m3 precision data.

Note that this function uses mixed-precision computation where the matrix and vectors are __nv_fp8_e4m3 type while the compute type is CUDA_R_32.

Parameters
[in]cusparse_handleHandle to the CuSparse library context
[in]cusparse_operationType of matrix operation. For non-transpose operation, this should be set to CUSPARSE_OPERATION_NON_TRANSPOSE and for transpose operation, this should be set to CUSPARSE_OPERATION_TRANSPOSE.
[in]alphaThe scalar parameter \( \alpha \) in matrix-vector product.
[in]cusparse_matrixCusparse object for matrix \( \mathbf{A} \).
[in]cusparse_input_vectorCusparse object for vector \( \boldsymbol{x} \).
[in]betaThe scalar parameter \( \beta \) in matrix-vector product.
[out]cusparse_output_vectorCusparse object for vector \( \boldsymbol{y} \).
[in]algorithmAlgorithm for the computation. Possible values can be CUSPARSE_SPMV_ALG_DEFAULT, CUSPARSE_SPMV_CSR_ALG1, and CUSPARSE_SPMV_CSR_ALG2.
[in]external_bufferBuffer on GPU device needed for computation.
See also
cusparse_matrix_buffer_size

A wrapper for cusparseSpMV to perform sparse matrix-vector multiplication using __half precision data.

Note that this function uses mixed-precision computation where the matrix and vectors are __half type while the compute type is CUDA_R_32.

Parameters
[in]cusparse_handleHandle to the CuSparse library context
[in]cusparse_operationType of matrix operation. For non-transpose operation, this should be set to CUSPARSE_OPERATION_NON_TRANSPOSE and for transpose operation, this should be set to CUSPARSE_OPERATION_TRANSPOSE.
[in]alphaThe scalar parameter \( \alpha \) in matrix-vector product.
[in]cusparse_matrixCusparse object for matrix \( \mathbf{A} \).
[in]cusparse_input_vectorCusparse object for vector \( \boldsymbol{x} \).
[in]betaThe scalar parameter \( \beta \) in matrix-vector product.
[out]cusparse_output_vectorCusparse object for vector \( \boldsymbol{y} \).
[in]algorithmAlgorithm for the computation. Possible values can be CUSPARSE_SPMV_ALG_DEFAULT, CUSPARSE_SPMV_CSR_ALG1, and CUSPARSE_SPMV_CSR_ALG2.
[in]external_bufferBuffer on GPU device needed for computation.
See also
cusparse_matrix_buffer_size

A wrapper for cusparseSpMV to perform sparse matrix-vector multiplication using __nv_bfloat16 precision data.

Note that this function uses mixed-precision computation where the matrix and vectors are __nv_bfloat16 type while the compute type is CUDA_R_32.

Parameters
[in]cusparse_handleHandle to the CuSparse library context
[in]cusparse_operationType of matrix operation. For non-transpose operation, this should be set to CUSPARSE_OPERATION_NON_TRANSPOSE and for transpose operation, this should be set to CUSPARSE_OPERATION_TRANSPOSE.
[in]alphaThe scalar parameter \( \alpha \) in matrix-vector product.
[in]cusparse_matrixCusparse object for matrix \( \mathbf{A} \).
[in]cusparse_input_vectorCusparse object for vector \( \boldsymbol{x} \).
[in]betaThe scalar parameter \( \beta \) in matrix-vector product.
[out]cusparse_output_vectorCusparse object for vector \( \boldsymbol{y} \).
[in]algorithmAlgorithm for the computation. Possible values can be CUSPARSE_SPMV_ALG_DEFAULT, CUSPARSE_SPMV_CSR_ALG1, and CUSPARSE_SPMV_CSR_ALG2.
[in]external_bufferBuffer on GPU device needed for computation.
See also
cusparse_matrix_buffer_size

A wrapper for cusparseSpMV to perform sparse matrix-vector multiplication using float precision data.

Parameters
[in]cusparse_handleHandle to the CuSparse library context
[in]cusparse_operationType of matrix operation. For non-transpose operation, this should be set to CUSPARSE_OPERATION_NON_TRANSPOSE and for transpose operation, this should be set to CUSPARSE_OPERATION_TRANSPOSE.
[in]alphaThe scalar parameter \( \alpha \) in matrix-vector product.
[in]cusparse_matrixCusparse object for matrix \( \mathbf{A} \).
[in]cusparse_input_vectorCusparse object for vector \( \boldsymbol{x} \).
[in]betaThe scalar parameter \( \beta \) in matrix-vector product.
[out]cusparse_output_vectorCusparse object for vector \( \boldsymbol{y} \).
[in]algorithmAlgorithm for the computation. Possible values can be CUSPARSE_SPMV_ALG_DEFAULT, CUSPARSE_SPMV_CSR_ALG1, and CUSPARSE_SPMV_CSR_ALG2.
[in]external_bufferBuffer on GPU device needed for computation.
See also
cusparse_matrix_buffer_size

Definition at line 2189 of file cusparse_api.cu.

2199 {
2200 cusparseStatus_t status = cusparseSpMV(cusparse_handle,
2201 cusparse_operation, &alpha,
2202 cusparse_matrix,
2203 cusparse_input_vector, &beta,
2204 cusparse_output_vector,
2205 CUDA_R_32F, algorithm,
2206 external_buffer);
2207
2208 assert(status == CUSPARSE_STATUS_SUCCESS);
2209 }

References cusparseSpMV().

Here is the call graph for this function:

◆ destroy_cusparse_matrix()

void cusparse_api::destroy_cusparse_matrix ( cusparseSpMatDescr_t &  cusparse_matrix)

Destroy cusparse matrix.

This function is a wrapper for cusparseDestroySpMat.

Parameters
[out]cusparse_matrixReference to CuSparse matrix object to be destroyed.
See also
destroy_cusparse_vector, create_cusparse_csr_matrix, create_cusparse_csc_matrix

Definition at line 1501 of file cusparse_api.cu.

1503 {
1504 cusparseStatus_t status = cusparseDestroySpMat(cusparse_matrix);
1505 assert(status == CUSPARSE_STATUS_SUCCESS);
1506 }
cusparseStatus_t cusparseDestroySpMat(cusparseConstSpMatDescr_t spMatDescr)
Definition of CUDA's cusparseDestroySpMat function using dynamically loaded cublas library.

References cusparseDestroySpMat().

Referenced by cuCSCMatrix< DataType >::~cuCSCMatrix(), and cuCSRMatrix< DataType >::~cuCSRMatrix().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ destroy_cusparse_vector()

void cusparse_api::destroy_cusparse_vector ( cusparseDnVecDescr_t &  cusparse_vector)

Destroys cusparse vector.

This function is a wrapper for cusparseDestroyDnVec.

Parameters
[out]cusparse_vectorReference to CuSparse vector object to be destroyed.
See also
destroy_cusparse_matrix, create_cusparse_vector

Definition at line 1523 of file cusparse_api.cu.

1525 {
1526 cusparseStatus_t status = cusparseDestroyDnVec(cusparse_vector);
1527 assert(status == CUSPARSE_STATUS_SUCCESS);
1528 }
cusparseStatus_t cusparseDestroyDnVec(cusparseConstDnVecDescr_t dnVecDescr)
Definition of CUDA's cusparseDestroyDnVec function using dynamically loaded cublas library.

References cusparseDestroyDnVec().

Referenced by cuCSCMatrix< DataType >::dot(), cuCSRMatrix< DataType >::dot(), cuCSCMatrix< DataType >::dot_plus(), cuCSRMatrix< DataType >::dot_plus(), cuCSCMatrix< DataType >::transpose_dot(), cuCSRMatrix< DataType >::transpose_dot(), cuCSCMatrix< DataType >::transpose_dot_plus(), and cuCSRMatrix< DataType >::transpose_dot_plus().

Here is the call graph for this function:
Here is the caller graph for this function: