imate
C++/CUDA Reference
cusparse_interface Namespace Reference

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

Functions

template<>
void create_cusparse_matrix< float > (cusparseSpMatDescr_t &cusparse_matrix, const LongIndexType num_rows, const LongIndexType num_columns, const LongIndexType nnz, float *device_A_data, LongIndexType *device_A_indices, LongIndexType *device_A_index_pointer)
 A template wrapper for cusparseSpMatDescr_t for the float precision data. More...
 
template<>
void create_cusparse_matrix< double > (cusparseSpMatDescr_t &cusparse_matrix, const LongIndexType num_rows, const LongIndexType num_columns, const LongIndexType nnz, double *device_A_data, LongIndexType *device_A_indices, LongIndexType *device_A_index_pointer)
 A template wrapper for cusparseSpMatDescr_t for the double precision data. More...
 
template<>
void create_cusparse_vector< float > (cusparseDnVecDescr_t &cusparse_vector, const LongIndexType vector_size, float *device_vector)
 A template wrapper for cusparseDnVecDescr_t for the float precision data. More...
 
template<>
void create_cusparse_vector< double > (cusparseDnVecDescr_t &cusparse_vector, const LongIndexType vector_size, double *device_vector)
 A template wrapper for cusparseDnVecDescr_t for the double precision data. More...
 
void destroy_cusparse_matrix (cusparseSpMatDescr_t &cusparse_matrix)
 Destroys cusparse matrix. More...
 
void destroy_cusparse_vector (cusparseDnVecDescr_t &cusparse_vector)
 Destroys cusparse vector. More...
 
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 cusparseSpMat_buffersize for float precision data. This function determines the buffer size needed for matrix-vector multiplication using cusparseSpMV. The output is buffer_size variable. More...
 
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 cusparseSpMat_buffersize for double precision data. This function determines the buffer size needed for matrix-vector multiplication using cusparseSpMV. The output is buffer_size variable. More...
 
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 uasing float precision data. More...
 
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 uasing double precision data. More...
 
template<typename DataType >
void create_cusparse_matrix (cusparseSpMatDescr_t &cusparse_matrix, const LongIndexType num_rows, const LongIndexType num_columns, const LongIndexType nnz, DataType *device_A_data, LongIndexType *device_A_indices, LongIndexType *device_A_index_pointer)
 
template<typename DataType >
void create_cusparse_vector (cusparseDnVecDescr_t &cusparse_vector, const LongIndexType vector_size, DataType *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_matrix()

template<typename DataType >
void cusparse_interface::create_cusparse_matrix ( cusparseSpMatDescr_t &  cusparse_matrix,
const LongIndexType  num_rows,
const LongIndexType  num_columns,
const LongIndexType  nnz,
DataType *  device_A_data,
LongIndexType device_A_indices,
LongIndexType 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_matrix< double >()

template<>
void cusparse_interface::create_cusparse_matrix< double > ( cusparseSpMatDescr_t &  cusparse_matrix,
const LongIndexType  num_rows,
const LongIndexType  num_columns,
const LongIndexType  nnz,
double *  device_A_data,
LongIndexType device_A_indices,
LongIndexType device_A_index_pointer 
)

A template wrapper for cusparseSpMatDescr_t for the double precision data.

Definition at line 67 of file cusparse_interface.cu.

75  {
76  cusparseStatus_t status = cusparseCreateCsr(
77  &cusparse_matrix, num_rows, num_columns, nnz,
78  device_A_index_pointer, device_A_indices, device_A_data,
79  CUSPARSE_INDEX_32I, CUSPARSE_INDEX_32I,
80  CUSPARSE_INDEX_BASE_ZERO, CUDA_R_64F);
81 
82  assert(status == CUSPARSE_STATUS_SUCCESS);
83  }
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_matrix< float >()

template<>
void cusparse_interface::create_cusparse_matrix< float > ( cusparseSpMatDescr_t &  cusparse_matrix,
const LongIndexType  num_rows,
const LongIndexType  num_columns,
const LongIndexType  nnz,
float *  device_A_data,
LongIndexType device_A_indices,
LongIndexType device_A_index_pointer 
)

A template wrapper for cusparseSpMatDescr_t for the float precision data.

Definition at line 40 of file cusparse_interface.cu.

48  {
49  cusparseStatus_t status = cusparseCreateCsr(
50  &cusparse_matrix, num_rows, num_columns, nnz,
51  device_A_index_pointer, device_A_indices, device_A_data,
52  CUSPARSE_INDEX_32I, CUSPARSE_INDEX_32I,
53  CUSPARSE_INDEX_BASE_ZERO, CUDA_R_32F);
54 
55  assert(status == CUSPARSE_STATUS_SUCCESS);
56  }

References cusparseCreateCsr().

Here is the call graph for this function:

◆ create_cusparse_vector()

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

◆ create_cusparse_vector< double >()

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

A template wrapper for cusparseDnVecDescr_t 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.

Definition at line 122 of file cusparse_interface.cu.

126  {
127  cusparseStatus_t status = cusparseCreateDnVec(
128  &cusparse_vector, vector_size, device_vector, CUDA_R_64F);
129 
130  assert(status == CUSPARSE_STATUS_SUCCESS);
131  }
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_interface::create_cusparse_vector< float > ( cusparseDnVecDescr_t &  cusparse_vector,
const LongIndexType  vector_size,
float *  device_vector 
)

A template wrapper for cusparseDnVecDescr_t 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.

Definition at line 98 of file cusparse_interface.cu.

102  {
103  cusparseStatus_t status = cusparseCreateDnVec(
104  &cusparse_vector, vector_size, device_vector, CUDA_R_32F);
105 
106  assert(status == CUSPARSE_STATUS_SUCCESS);
107  }

References cusparseCreateDnVec().

Here is the call graph for this function:

◆ cusparse_matrix_buffer_size()

template<typename DataType >
void cusparse_interface::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_interface::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 cusparseSpMat_buffersize for double precision data. This function determines the buffer size needed for matrix-vector multiplication using cusparseSpMV. The output is buffer_size variable.

Definition at line 204 of file cusparse_interface.cu.

214  {
215  cusparseStatus_t status = cusparseSpMV_bufferSize(
216  cusparse_handle, cusparse_operation, &alpha, cusparse_matrix,
217  cusparse_input_vector, &beta, cusparse_output_vector,
218  CUDA_R_64F, algorithm, buffer_size);
219 
220  assert(status == CUSPARSE_STATUS_SUCCESS);
221  }
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_interface::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 cusparseSpMat_buffersize for float precision data. This function determines the buffer size needed for matrix-vector multiplication using cusparseSpMV. The output is buffer_size variable.

Definition at line 174 of file cusparse_interface.cu.

184  {
185  cusparseStatus_t status = cusparseSpMV_bufferSize(
186  cusparse_handle, cusparse_operation, &alpha, cusparse_matrix,
187  cusparse_input_vector, &beta, cusparse_output_vector,
188  CUDA_R_32F, algorithm, buffer_size);
189 
190  assert(status == CUSPARSE_STATUS_SUCCESS);
191  }

References cusparseSpMV_bufferSize().

Here is the call graph for this function:

◆ cusparse_matvec()

template<typename DataType >
void cusparse_interface::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_interface::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 uasing double precision data.

Definition at line 263 of file cusparse_interface.cu.

273  {
274  cusparseStatus_t status = cusparseSpMV(cusparse_handle,
275  cusparse_operation, &alpha,
276  cusparse_matrix,
277  cusparse_input_vector, &beta,
278  cusparse_output_vector,
279  CUDA_R_64F, algorithm,
280  external_buffer);
281 
282  assert(status == CUSPARSE_STATUS_SUCCESS);
283  }
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_interface::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 uasing float precision data.

Definition at line 232 of file cusparse_interface.cu.

242  {
243  cusparseStatus_t status = cusparseSpMV(cusparse_handle,
244  cusparse_operation, &alpha,
245  cusparse_matrix,
246  cusparse_input_vector, &beta,
247  cusparse_output_vector,
248  CUDA_R_32F, algorithm,
249  external_buffer);
250 
251  assert(status == CUSPARSE_STATUS_SUCCESS);
252  }

References cusparseSpMV().

Here is the call graph for this function:

◆ destroy_cusparse_matrix()

void cusparse_interface::destroy_cusparse_matrix ( cusparseSpMatDescr_t &  cusparse_matrix)

Destroys cusparse matrix.

Definition at line 141 of file cusparse_interface.cu.

143  {
144  cusparseStatus_t status = cusparseDestroySpMat(cusparse_matrix);
145  assert(status == CUSPARSE_STATUS_SUCCESS);
146  }
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_interface::destroy_cusparse_vector ( cusparseDnVecDescr_t &  cusparse_vector)

Destroys cusparse vector.

Definition at line 156 of file cusparse_interface.cu.

158  {
159  cusparseStatus_t status = cusparseDestroyDnVec(cusparse_vector);
160  assert(status == CUSPARSE_STATUS_SUCCESS);
161  }
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: