![]() |
cuLite v0.3.1
A lite CUDA C++ Interface
|
The cuSparse handler class. More...
Public Member Functions | |
| CuSparseHandler () | |
| Constructor. | |
| ~CuSparseHandler () | |
| Destructor. | |
| cusparseHandle_t | handle () |
| Get the cuSPARSE handle. | |
| void | clear () |
| Clear the internal workspace buffers. | |
| cusparsePointerMode_t | setPointerMode (cusparsePointerMode_t mode) |
| Set the pointer mode for cuSPARSE operations. | |
| cusparsePointerMode_t | pointerMode () |
| Get the current pointer mode. | |
| template<typename T_Scalar> | |
| void | reserveSpmv (op_t opA, const T_Scalar *alpha, const cusparse::SpMatBase &matA, const cusparse::DnVec< T_Scalar > &vecX, const T_Scalar *beta, cusparse::DnVec< T_Scalar > &vecY, cusparseSpMVAlg_t alg=cusparseSpMVAlg_t::CUSPARSE_SPMV_CSR_ALG1) |
| Reserve workspace memory for sparse matrix-vector multiplication (SpMV). | |
| template<typename T_Scalar> | |
| void | preprocessSpmv (op_t opA, const T_Scalar *alpha, const cusparse::SpMatBase &matA, const cusparse::DnVec< T_Scalar > &vecX, const T_Scalar *beta, cusparse::DnVec< T_Scalar > &vecY, cusparseSpMVAlg_t alg=cusparseSpMVAlg_t::CUSPARSE_SPMV_CSR_ALG1) |
| Preprocess the sparse matrix-vector multiplication operation. | |
| template<typename T_Scalar> | |
| void | performSpmv (op_t opA, const T_Scalar *alpha, const cusparse::SpMatBase &matA, const cusparse::DnVec< T_Scalar > &vecX, const T_Scalar *beta, cusparse::DnVec< T_Scalar > &vecY, cusparseSpMVAlg_t alg=cusparseSpMVAlg_t::CUSPARSE_SPMV_CSR_ALG1) |
| Perform sparse matrix-vector multiplication. | |
| template<typename T_Scalar> | |
| void | reserveSpmm (op_t opA, op_t opB, const T_Scalar *alpha, const cusparse::SpMatBase &matA, const cusparse::DnMat< T_Scalar > &matB, const T_Scalar *beta, cusparse::DnMat< T_Scalar > &matC, cusparseSpMMAlg_t alg=cusparseSpMMAlg_t::CUSPARSE_SPMM_CSR_ALG1) |
| Reserve workspace memory for sparse matrix-matrix multiplication (SpMM). | |
| template<typename T_Scalar> | |
| void | preprocessSpmm (op_t opA, op_t opB, const T_Scalar *alpha, const cusparse::SpMatBase &matA, const cusparse::DnMat< T_Scalar > &matB, const T_Scalar *beta, cusparse::DnMat< T_Scalar > &matC, cusparseSpMMAlg_t alg=cusparseSpMMAlg_t::CUSPARSE_SPMM_CSR_ALG1) |
| Preprocess the sparse matrix-matrix multiplication operation. | |
| template<typename T_Scalar> | |
| void | performSpmm (op_t opA, op_t opB, const T_Scalar *alpha, const cusparse::SpMatBase &matA, const cusparse::DnMat< T_Scalar > &matB, const T_Scalar *beta, cusparse::DnMat< T_Scalar > &matC, cusparseSpMMAlg_t alg=cusparseSpMMAlg_t::CUSPARSE_SPMM_CSR_ALG1) |
| Perform sparse matrix-matrix multiplication. | |
The cuSparse handler class.
This class provides a wrapper around the cuSPARSE library for performing sparse linear algebra operations on GPU devices. It manages the cuSPARSE handle and internal workspace buffers required for factorization and solve operations.
| culite::CuSparseHandler::CuSparseHandler | ( | ) |
Constructor.
Initializes the cuSPARSE handle and internal state.
| culite::CuSparseHandler::~CuSparseHandler | ( | ) |
Destructor.
Destroys the cuSPARSE handle and releases all allocated resources.
| cusparseHandle_t culite::CuSparseHandler::handle | ( | ) |
Get the cuSPARSE handle.
| void culite::CuSparseHandler::clear | ( | ) |
Clear the internal workspace buffers.
Releases all internal workspace memory allocated for cuSPARSE operations.
| cusparsePointerMode_t culite::CuSparseHandler::setPointerMode | ( | cusparsePointerMode_t | mode | ) |
Set the pointer mode for cuSPARSE operations.
Changes the pointer mode and returns the previous mode. The pointer mode determines whether scalar values (alpha, beta) are passed by reference on the host or device.
| [in] | mode | The new pointer mode to set. |
| cusparsePointerMode_t culite::CuSparseHandler::pointerMode | ( | ) |
Get the current pointer mode.
Returns the current pointer mode setting for cuSPARSE operations.
| void culite::CuSparseHandler::reserveSpmv | ( | op_t | opA, |
| const T_Scalar * | alpha, | ||
| const cusparse::SpMatBase & | matA, | ||
| const cusparse::DnVec< T_Scalar > & | vecX, | ||
| const T_Scalar * | beta, | ||
| cusparse::DnVec< T_Scalar > & | vecY, | ||
| cusparseSpMVAlg_t | alg = cusparseSpMVAlg_t::CUSPARSE_SPMV_CSR_ALG1 ) |
Reserve workspace memory for sparse matrix-vector multiplication (SpMV).
Queries the required buffer size for the SpMV operation and allocates the necessary workspace memory on the device.
| T_Scalar | The scalar type (e.g., float, double, complex). |
| [in] | opA | Operation to apply to matrix A (e.g., no-transpose, transpose, conjugate-transpose). |
| [in] | alpha | Pointer to scalar alpha. |
| [in] | matA | Sparse matrix. |
| [in] | vecX | Input dense vector X. |
| [in] | beta | Pointer to scalar beta. |
| [in,out] | vecY | Dense vector Y for buffer size computation. |
| [in] | alg | Algorithm to use for SpMV (default: CUSPARSE_SPMV_CSR_ALG1). |
| void culite::CuSparseHandler::preprocessSpmv | ( | op_t | opA, |
| const T_Scalar * | alpha, | ||
| const cusparse::SpMatBase & | matA, | ||
| const cusparse::DnVec< T_Scalar > & | vecX, | ||
| const T_Scalar * | beta, | ||
| cusparse::DnVec< T_Scalar > & | vecY, | ||
| cusparseSpMVAlg_t | alg = cusparseSpMVAlg_t::CUSPARSE_SPMV_CSR_ALG1 ) |
Preprocess the sparse matrix-vector multiplication operation.
Performs any necessary preprocessing steps for the SpMV operation, which may optimize subsequent repeated operations with the same sparsity pattern.
| T_Scalar | The scalar type (e.g., float, double, complex). |
| [in] | opA | Operation to apply to matrix A (e.g., no-transpose, transpose, conjugate-transpose). |
| [in] | alpha | Pointer to scalar alpha. |
| [in] | matA | Sparse matrix. |
| [in] | vecX | Input dense vector X. |
| [in] | beta | Pointer to scalar beta. |
| [in,out] | vecY | Dense vector Y for preprocessing. |
| [in] | alg | Algorithm to use for SpMV (default: CUSPARSE_SPMV_CSR_ALG1). |
| void culite::CuSparseHandler::performSpmv | ( | op_t | opA, |
| const T_Scalar * | alpha, | ||
| const cusparse::SpMatBase & | matA, | ||
| const cusparse::DnVec< T_Scalar > & | vecX, | ||
| const T_Scalar * | beta, | ||
| cusparse::DnVec< T_Scalar > & | vecY, | ||
| cusparseSpMVAlg_t | alg = cusparseSpMVAlg_t::CUSPARSE_SPMV_CSR_ALG1 ) |
Perform sparse matrix-vector multiplication.
Computes Y = alpha * op(A) * X + beta * Y, where A is a sparse matrix, X and Y are dense vectors, and op(A) is either A, A^T, or A^H.
| T_Scalar | The scalar type (e.g., float, double, complex). |
| [in] | opA | Operation to apply to matrix A (e.g., no-transpose, transpose, conjugate-transpose). |
| [in] | alpha | Pointer to scalar alpha. |
| [in] | matA | Sparse matrix. |
| [in] | vecX | Input dense vector X. |
| [in] | beta | Pointer to scalar beta. |
| [in,out] | vecY | Output dense vector Y. |
| [in] | alg | Algorithm to use for SpMV (default: CUSPARSE_SPMV_CSR_ALG1). |
| void culite::CuSparseHandler::reserveSpmm | ( | op_t | opA, |
| op_t | opB, | ||
| const T_Scalar * | alpha, | ||
| const cusparse::SpMatBase & | matA, | ||
| const cusparse::DnMat< T_Scalar > & | matB, | ||
| const T_Scalar * | beta, | ||
| cusparse::DnMat< T_Scalar > & | matC, | ||
| cusparseSpMMAlg_t | alg = cusparseSpMMAlg_t::CUSPARSE_SPMM_CSR_ALG1 ) |
Reserve workspace memory for sparse matrix-matrix multiplication (SpMM).
Queries the required buffer size for the SpMM operation and allocates the necessary workspace memory on the device.
| T_Scalar | The scalar type (e.g., float, double, complex). |
| [in] | opA | Operation to apply to matrix A (e.g., no-transpose, transpose, conjugate-transpose). |
| [in] | opB | Operation to apply to matrix B (e.g., no-transpose, transpose, conjugate-transpose). |
| [in] | alpha | Pointer to scalar alpha. |
| [in] | matA | Sparse matrix A. |
| [in] | matB | Dense matrix B. |
| [in] | beta | Pointer to scalar beta. |
| [in,out] | matC | Dense matrix C for buffer size computation. |
| [in] | alg | Algorithm to use for SpMM (default: CUSPARSE_SPMM_CSR_ALG1). |
| void culite::CuSparseHandler::preprocessSpmm | ( | op_t | opA, |
| op_t | opB, | ||
| const T_Scalar * | alpha, | ||
| const cusparse::SpMatBase & | matA, | ||
| const cusparse::DnMat< T_Scalar > & | matB, | ||
| const T_Scalar * | beta, | ||
| cusparse::DnMat< T_Scalar > & | matC, | ||
| cusparseSpMMAlg_t | alg = cusparseSpMMAlg_t::CUSPARSE_SPMM_CSR_ALG1 ) |
Preprocess the sparse matrix-matrix multiplication operation.
Performs any necessary preprocessing steps for the SpMM operation, which may optimize subsequent repeated operations with the same sparsity pattern.
| T_Scalar | The scalar type (e.g., float, double, complex). |
| [in] | opA | Operation to apply to matrix A (e.g., no-transpose, transpose, conjugate-transpose). |
| [in] | opB | Operation to apply to matrix B (e.g., no-transpose, transpose, conjugate-transpose). |
| [in] | alpha | Pointer to scalar alpha. |
| [in] | matA | Sparse matrix A. |
| [in] | matB | Dense matrix B. |
| [in] | beta | Pointer to scalar beta. |
| [in,out] | matC | Dense matrix C for preprocessing. |
| [in] | alg | Algorithm to use for SpMM (default: CUSPARSE_SPMM_CSR_ALG1). |
| void culite::CuSparseHandler::performSpmm | ( | op_t | opA, |
| op_t | opB, | ||
| const T_Scalar * | alpha, | ||
| const cusparse::SpMatBase & | matA, | ||
| const cusparse::DnMat< T_Scalar > & | matB, | ||
| const T_Scalar * | beta, | ||
| cusparse::DnMat< T_Scalar > & | matC, | ||
| cusparseSpMMAlg_t | alg = cusparseSpMMAlg_t::CUSPARSE_SPMM_CSR_ALG1 ) |
Perform sparse matrix-matrix multiplication.
Computes C = alpha * op(A) * op(B) + beta * C, where A is a sparse matrix, B and C are dense matrices, and op(X) is either X, X^T, or X^H.
| T_Scalar | The scalar type (e.g., float, double, complex). |
| [in] | opA | Operation to apply to matrix A (e.g., no-transpose, transpose, conjugate-transpose). |
| [in] | opB | Operation to apply to matrix B (e.g., no-transpose, transpose, conjugate-transpose). |
| [in] | alpha | Pointer to scalar alpha. |
| [in] | matA | Sparse matrix A. |
| [in] | matB | Dense matrix B. |
| [in] | beta | Pointer to scalar beta. |
| [in,out] | matC | Output dense matrix C. |
| [in] | alg | Algorithm to use for SpMM (default: CUSPARSE_SPMM_CSR_ALG1). |