11#ifndef _CU_BASIC_ALGEBRA_CUSPARSE_API_H_
12#define _CU_BASIC_ALGEBRA_CUSPARSE_API_H_
28#include "../_definitions/types.h"
32 #define RESTRICT __restrict
33#elif defined(__INTEL_COMPILER)
34 #define RESTRICT __restrict
35#elif defined(__CUDA__) || defined(__GNUC__) || defined(__clang__)
36 #define RESTRICT __restrict__
53 template <
typename DataType,
typename DataIndexType>
55 cusparseSpMatDescr_t& cusparse_matrix,
56 const DataIndexType num_rows,
57 const DataIndexType num_columns,
58 const DataIndexType nnz,
60 DataIndexType*
RESTRICT device_A_indices,
61 DataIndexType*
RESTRICT device_A_index_pointer);
64 template <
typename DataType,
typename DataIndexType>
66 cusparseSpMatDescr_t& cusparse_matrix,
67 const DataIndexType num_rows,
68 const DataIndexType num_columns,
69 const DataIndexType nnz,
71 DataIndexType*
RESTRICT device_A_indices,
72 DataIndexType*
RESTRICT device_A_index_pointer);
75 template <
typename DataType>
77 cusparseDnVecDescr_t& cusparse_vector,
83 cusparseSpMatDescr_t& cusparse_matrix);
87 cusparseDnVecDescr_t& cusparse_vector);
90 template <
typename DataType>
92 cusparseHandle_t cusparse_handle,
93 cusparseOperation_t cusparse_operation,
95 cusparseSpMatDescr_t cusparse_matrix,
96 cusparseDnVecDescr_t cusparse_input_vector,
98 cusparseDnVecDescr_t cusparse_output_vector,
99 cusparseSpMVAlg_t algorithm,
100 size_t* buffer_size);
103 template <
typename DataType>
105 cusparseHandle_t cusparse_handle,
106 cusparseOperation_t cusparse_operation,
107 const DataType alpha,
108 cusparseSpMatDescr_t cusparse_matrix,
109 cusparseDnVecDescr_t cusparse_input_vector,
111 cusparseDnVecDescr_t cusparse_output_vector,
112 cusparseSpMVAlg_t algorithm,
113 void* external_buffer);
A collection of templates to wrapper cusparse functions.
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)
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)
void destroy_cusparse_matrix(cusparseSpMatDescr_t &cusparse_matrix)
Destroy cusparse matrix.
void create_cusparse_vector(cusparseDnVecDescr_t &cusparse_vector, const LongIndexType vector_size, DataType *RESTRICT device_vector)
void destroy_cusparse_vector(cusparseDnVecDescr_t &cusparse_vector)
Destroys cusparse vector.
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)
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)