Sparse Generic Functions#
This module holds all sparse generic routines.
The sparse generic routines describe operations that manipulate sparse matrices.
hipsparseAxpby()#
-
hipsparseStatus_t hipsparseAxpby(hipsparseHandle_t handle, const void *alpha, hipsparseSpVecDescr_t vecX, const void *beta, hipsparseDnVecDescr_t vecY)#
Description: Scale a sparse vector and add it to a scaled dense vector.
hipsparseAxpby multiplies the sparse vector \(x\) with scalar \(\alpha\) and adds the result to the dense vector \(y\) that is multiplied with scalar \(\beta\), such that
\[ y := \alpha \cdot x + \beta \cdot y \]for(i = 0; i < nnz; ++i) { y[x_ind[i]] = alpha * x_val[i] + beta * y[x_ind[i]] }
hipsparseGather()#
-
hipsparseStatus_t hipsparseGather(hipsparseHandle_t handle, hipsparseDnVecDescr_t vecY, hipsparseSpVecDescr_t vecX)#
Description: Gather elements from a dense vector and store them into a sparse vector.
hipsparseGather gathers the elements from the dense vector \(y\) and stores them in the sparse vector \(x\).
for(i = 0; i < nnz; ++i) { x_val[i] = y[x_ind[i]]; }
hipsparseScatter()#
-
hipsparseStatus_t hipsparseScatter(hipsparseHandle_t handle, hipsparseSpVecDescr_t vecX, hipsparseDnVecDescr_t vecY)#
Description: Scatter elements from a sparse vector into a dense vector.
hipsparseScatter scatters the elements from the sparse vector \(x\) in the dense vector \(y\).
for(i = 0; i < nnz; ++i) { y[x_ind[i]] = x_val[i]; }
hipsparseRot()#
-
hipsparseStatus_t hipsparseRot(hipsparseHandle_t handle, const void *c_coeff, const void *s_coeff, hipsparseSpVecDescr_t vecX, hipsparseDnVecDescr_t vecY)#
Description: Apply Givens rotation to a dense and a sparse vector.
hipsparseRot applies the Givens rotation matrix \(G\) to the sparse vector \(x\) and the dense vector \(y\), where
\[\begin{split} G = \begin{pmatrix} c & s \\ -s & c \end{pmatrix} \end{split}\]for(i = 0; i < nnz; ++i) { x_tmp = x_val[i]; y_tmp = y[x_ind[i]]; x_val[i] = c * x_tmp + s * y_tmp; y[x_ind[i]] = c * y_tmp - s * x_tmp; }
hipsparseSparseToDense_bufferSize()#
-
hipsparseStatus_t hipsparseSparseToDense_bufferSize(hipsparseHandle_t handle, hipsparseSpMatDescr_t matA, hipsparseDnMatDescr_t matB, hipsparseSparseToDenseAlg_t alg, size_t *bufferSize)#
Description: Sparse matrix to dense matrix conversion.
hipsparseSparseToDense_bufferSize
computes the required user allocated buffer size needed when converting a sparse matrix to a dense matrix.
hipsparseSparseToDense()#
-
hipsparseStatus_t hipsparseSparseToDense(hipsparseHandle_t handle, hipsparseSpMatDescr_t matA, hipsparseDnMatDescr_t matB, hipsparseSparseToDenseAlg_t alg, void *externalBuffer)#
Description: Sparse matrix to dense matrix conversion.
hipsparseSparseToDense
converts a sparse matrix to a dense matrix. This routine takes a user allocated buffer whose size must first be computed by callinghipsparseSparseToDense_bufferSize
hipsparseDenseToSparse_bufferSize()#
-
hipsparseStatus_t hipsparseDenseToSparse_bufferSize(hipsparseHandle_t handle, hipsparseDnMatDescr_t matA, hipsparseSpMatDescr_t matB, hipsparseDenseToSparseAlg_t alg, size_t *bufferSize)#
Description: Dense matrix to sparse matrix conversion.
hipsparseDenseToSparse_bufferSize
computes the required user allocated buffer size needed when converting a dense matrix to a sparse matrix.
hipsparseDenseToSparse_analysis()#
-
hipsparseStatus_t hipsparseDenseToSparse_analysis(hipsparseHandle_t handle, hipsparseDnMatDescr_t matA, hipsparseSpMatDescr_t matB, hipsparseDenseToSparseAlg_t alg, void *externalBuffer)#
Description: Dense matrix to sparse matrix conversion.
hipsparseDenseToSparse_analysis
performs analysis that is later used inhipsparseDenseToSparse_convert
when converting a dense matrix to sparse matrix. This routine takes a user allocated buffer whose size must first be computed usinghipsparseDenseToSparse_bufferSize
.
hipsparseDenseToSparse_convert()#
-
hipsparseStatus_t hipsparseDenseToSparse_convert(hipsparseHandle_t handle, hipsparseDnMatDescr_t matA, hipsparseSpMatDescr_t matB, hipsparseDenseToSparseAlg_t alg, void *externalBuffer)#
Description: Dense matrix to sparse matrix conversion.
hipsparseDenseToSparse_convert
converts a dense matrix to a sparse matrix. This routine requires a user allocated buffer whose size must be determined by first callinghipsparseDenseToSparse_bufferSize
.
hipsparseSpVV_bufferSize()#
-
hipsparseStatus_t hipsparseSpVV_bufferSize(hipsparseHandle_t handle, hipsparseOperation_t opX, hipsparseSpVecDescr_t vecX, hipsparseDnVecDescr_t vecY, void *result, hipDataType computeType, size_t *bufferSize)#
Description: Compute the inner dot product of a sparse vector with a dense vector.
hipsparseSpVV_bufferSize
computes the required user allocated buffer size needed when computing the inner dot product of a sparse vector with a dense vector
hipsparseSpVV()#
-
hipsparseStatus_t hipsparseSpVV(hipsparseHandle_t handle, hipsparseOperation_t opX, hipsparseSpVecDescr_t vecX, hipsparseDnVecDescr_t vecY, void *result, hipDataType computeType, void *externalBuffer)#
Description: Compute the inner dot product of a sparse vector with a dense vector.
hipsparseSpVV
computes the inner dot product of a sparse vector with a dense vector. This routine takes a user allocated buffer whose size must first be computed by callinghipsparseSpVV_bufferSize
hipsparseSpMV_bufferSize()#
-
hipsparseStatus_t hipsparseSpMV_bufferSize(hipsparseHandle_t handle, hipsparseOperation_t opA, const void *alpha, const hipsparseSpMatDescr_t matA, const hipsparseDnVecDescr_t vecX, const void *beta, const hipsparseDnVecDescr_t vecY, hipDataType computeType, hipsparseSpMVAlg_t alg, size_t *bufferSize)#
Description: Buffer size step of the sparse matrix multiplication with a dense vector.
hipsparseSpMV_bufferSize
computes the required user allocated buffer size needed when computing the sparse matrix multiplication with a dense vector
hipsparseSpMV()#
-
hipsparseStatus_t hipsparseSpMV(hipsparseHandle_t handle, hipsparseOperation_t opA, const void *alpha, const hipsparseSpMatDescr_t matA, const hipsparseDnVecDescr_t vecX, const void *beta, const hipsparseDnVecDescr_t vecY, hipDataType computeType, hipsparseSpMVAlg_t alg, void *externalBuffer)#
Description: Compute the sparse matrix multiplication with a dense vector.
hipsparseSpMV
computes sparse matrix multiplication with a dense vector
hipsparseSpMM_bufferSize()#
-
hipsparseStatus_t hipsparseSpMM_bufferSize(hipsparseHandle_t handle, hipsparseOperation_t opA, hipsparseOperation_t opB, const void *alpha, const hipsparseSpMatDescr_t matA, const hipsparseDnMatDescr_t matB, const void *beta, const hipsparseDnMatDescr_t matC, hipDataType computeType, hipsparseSpMMAlg_t alg, size_t *bufferSize)#
Description: Calculate the buffer size required for the sparse matrix multiplication with a dense matrix.
hipsparseSpMM_bufferSize
computes the required user allocated buffer size needed when computing the sparse matrix multiplication with a dense matrix
hipsparseSpMM_preprocess()#
-
hipsparseStatus_t hipsparseSpMM_preprocess(hipsparseHandle_t handle, hipsparseOperation_t opA, hipsparseOperation_t opB, const void *alpha, const hipsparseSpMatDescr_t matA, const hipsparseDnMatDescr_t matB, const void *beta, const hipsparseDnMatDescr_t matC, hipDataType computeType, hipsparseSpMMAlg_t alg, void *externalBuffer)#
Description: Preprocess step of the sparse matrix multiplication with a dense matrix.
hipsparseSpMM_preprocess
performs the required preprocessing used when computing the sparse matrix multiplication with a dense matrix
hipsparseSpMM()#
-
hipsparseStatus_t hipsparseSpMM(hipsparseHandle_t handle, hipsparseOperation_t opA, hipsparseOperation_t opB, const void *alpha, const hipsparseSpMatDescr_t matA, const hipsparseDnMatDescr_t matB, const void *beta, const hipsparseDnMatDescr_t matC, hipDataType computeType, hipsparseSpMMAlg_t alg, void *externalBuffer)#
Description: Compute the sparse matrix multiplication with a dense matrix.
hipsparseSpMM
computes sparse matrix multiplication with a dense matrix
hipsparseSpGEMM_createDescr()#
-
hipsparseStatus_t hipsparseSpGEMM_createDescr(hipsparseSpGEMMDescr_t *descr)#
Description: Create sparse matrix sparse matrix product descriptor.
hipsparseSpGEMM_createDescr
creates a sparse matrix sparse matrix product descriptor. It should be destroyed at the end using hipsparseSpGEMM_destroyDescr().
hipsparseSpGEMM_destroyDescr()#
-
hipsparseStatus_t hipsparseSpGEMM_destroyDescr(hipsparseSpGEMMDescr_t descr)#
Description: Destroy sparse matrix sparse matrix product descriptor.
hipsparseSpGEMM_destroyDescr
destroys a sparse matrix sparse matrix product descriptor and releases all resources used by the descriptor.
hipsparseSpGEMM_workEstimation()#
-
hipsparseStatus_t hipsparseSpGEMM_workEstimation(hipsparseHandle_t handle, hipsparseOperation_t opA, hipsparseOperation_t opB, const void *alpha, hipsparseSpMatDescr_t matA, hipsparseSpMatDescr_t matB, const void *beta, hipsparseSpMatDescr_t matC, hipDataType computeType, hipsparseSpGEMMAlg_t alg, hipsparseSpGEMMDescr_t spgemmDescr, size_t *bufferSize1, void *externalBuffer1)#
Description: Work estimation step of the sparse matrix sparse matrix product.
hipsparseSpGEMM_compute()#
-
hipsparseStatus_t hipsparseSpGEMM_compute(hipsparseHandle_t handle, hipsparseOperation_t opA, hipsparseOperation_t opB, const void *alpha, hipsparseSpMatDescr_t matA, hipsparseSpMatDescr_t matB, const void *beta, hipsparseSpMatDescr_t matC, hipDataType computeType, hipsparseSpGEMMAlg_t alg, hipsparseSpGEMMDescr_t spgemmDescr, size_t *bufferSize2, void *externalBuffer2)#
Description: Compute step of the sparse matrix sparse matrix product.
hipsparseSpGEMM_copy()#
-
hipsparseStatus_t hipsparseSpGEMM_copy(hipsparseHandle_t handle, hipsparseOperation_t opA, hipsparseOperation_t opB, const void *alpha, hipsparseSpMatDescr_t matA, hipsparseSpMatDescr_t matB, const void *beta, hipsparseSpMatDescr_t matC, hipDataType computeType, hipsparseSpGEMMAlg_t alg, hipsparseSpGEMMDescr_t spgemmDescr)#
hipsparseSDDMM_bufferSize()#
-
hipsparseStatus_t hipsparseSDDMM_bufferSize(hipsparseHandle_t handle, hipsparseOperation_t opA, hipsparseOperation_t opB, const void *alpha, const hipsparseDnMatDescr_t A, const hipsparseDnMatDescr_t B, const void *beta, hipsparseSpMatDescr_t C, hipDataType computeType, hipsparseSDDMMAlg_t alg, size_t *bufferSize)#
Description: Calculate the buffer size required for the sampled dense dense matrix multiplication.
hipsparseSDDMM_bufferSize
computes the required user allocated buffer size needed when computing the sampled dense dense matrix multiplication
hipsparseSDDMM_preprocess()#
-
hipsparseStatus_t hipsparseSDDMM_preprocess(hipsparseHandle_t handle, hipsparseOperation_t opA, hipsparseOperation_t opB, const void *alpha, const hipsparseDnMatDescr_t A, const hipsparseDnMatDescr_t B, const void *beta, hipsparseSpMatDescr_t C, hipDataType computeType, hipsparseSDDMMAlg_t alg, void *tempBuffer)#
Description: Preprocess step of the sampled dense dense matrix multiplication.
hipsparseSDDMM_preprocess
performs the required preprocessing used when computing the sampled dense dense matrix multiplication
hipsparseSDDMM()#
-
hipsparseStatus_t hipsparseSDDMM(hipsparseHandle_t handle, hipsparseOperation_t opA, hipsparseOperation_t opB, const void *alpha, const hipsparseDnMatDescr_t A, const hipsparseDnMatDescr_t B, const void *beta, hipsparseSpMatDescr_t C, hipDataType computeType, hipsparseSDDMMAlg_t alg, void *tempBuffer)#
Description: Sampled Dense-Dense Matrix Multiplication.
hipsparseSDDMM multiplies the scalar \(\alpha\) with the dense \(m \times k\) matrix \(A\), the dense \(k \times n\) matrix \(B\), filtered by the sparsity pattern of the \(m \times n\) sparse matrix \(C\) and adds the result to \(C\) scaled by \(\beta\). The final result is stored in the sparse \(m \times n\) matrix \(C\), such that
\[ C := \alpha ( opA(A) \cdot opB(B) ) \cdot spy(C) + \beta C, \]with\[\begin{split} op(A) = \left\{ \begin{array}{ll} A, & \text{if opA == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ A^T, & \text{if opA == HIPSPARSE_OPERATION_TRANSPOSE} \\ \end{array} \right. \end{split}\],\[\begin{split} op(B) = \left\{ \begin{array}{ll} B, & \text{if opB == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ B^T, & \text{if opB == HIPSPARSE_OPERATION_TRANSPOSE} \\ \end{array} \right. \end{split}\]and\[\begin{split} spy(C)_ij = \left\{ \begin{array}{ll} 1 \text{if i == j}, & 0 \text{if i != j} \\ \end{array} \right. \end{split}\]
hipsparseSpSV_createDescr()#
-
hipsparseStatus_t hipsparseSpSV_createDescr(hipsparseSpSVDescr_t *descr)#
Description: Create sparse matrix triangular solve descriptor.
hipsparseSpGEMM_createDescr
creates a sparse matrix triangular solve descriptor. It should be destroyed at the end using hipsparseSpSV_destroyDescr().
hipsparseSpSV_destroyDescr()#
-
hipsparseStatus_t hipsparseSpSV_destroyDescr(hipsparseSpSVDescr_t descr)#
Description: Destroy sparse matrix triangular solve descriptor.
hipsparseSpSV_destroyDescr
destroys a sparse matrix triangular solve descriptor and releases all resources used by the descriptor.
hipsparseSpSV_bufferSize()#
-
hipsparseStatus_t hipsparseSpSV_bufferSize(hipsparseHandle_t handle, hipsparseOperation_t opA, const void *alpha, const hipsparseSpMatDescr_t matA, const hipsparseDnVecDescr_t x, const hipsparseDnVecDescr_t y, hipDataType computeType, hipsparseSpSVAlg_t alg, hipsparseSpSVDescr_t spsvDescr, size_t *bufferSize)#
Description: Buffer size step of solution of triangular linear system op(A) * Y = alpha * X, where A is a sparse matrix in CSR storage format, x and Y are dense vectors.
hipsparseSpSV_bufferSize
computes the required user allocated buffer size needed when computing the solution of triangular linear system op(A) * Y = alpha * X, where A is a sparse matrix in CSR storage format, x and Y are dense vectors.
hipsparseSpSV_analysis()#
-
hipsparseStatus_t hipsparseSpSV_analysis(hipsparseHandle_t handle, hipsparseOperation_t opA, const void *alpha, const hipsparseSpMatDescr_t matA, const hipsparseDnVecDescr_t x, const hipsparseDnVecDescr_t y, hipDataType computeType, hipsparseSpSVAlg_t alg, hipsparseSpSVDescr_t spsvDescr, void *externalBuffer)#
Description: Analysis step of solution of triangular linear system op(A) * Y = alpha * X, where A is a sparse matrix in CSR storage format, x and Y are dense vectors.
hipsparseSpSV_analysis
performs the required analysis used when computing the solution of triangular linear system op(A) * Y = alpha * X, where A is a sparse matrix in CSR storage format, x and Y are dense vectors.
hipsparseSpSV_solve()#
-
hipsparseStatus_t hipsparseSpSV_solve(hipsparseHandle_t handle, hipsparseOperation_t opA, const void *alpha, const hipsparseSpMatDescr_t matA, const hipsparseDnVecDescr_t x, const hipsparseDnVecDescr_t y, hipDataType computeType, hipsparseSpSVAlg_t alg, hipsparseSpSVDescr_t spsvDescr)#
Description: Sparse triangular solve.
hipsparseSpSV_solve
solves a sparse triangular linear system of a sparse \(m \times m\) matrix, defined in CSR or COO storage format, a dense solution vector \(y\) and the right-hand side \(x\) that is multiplied by \(\alpha\), such that\[ op(A) \cdot y = \alpha \cdot x, \]with\[\begin{split} op(A) = \left\{ \begin{array}{ll} A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]
hipsparseSpSM_createDescr()#
-
hipsparseStatus_t hipsparseSpSM_createDescr(hipsparseSpSMDescr_t *descr)#
Description: Create sparse matrix triangular solve with multiple rhs descriptor.
hipsparseSpSM_createDescr
creates a sparse matrix triangular solve with multiple rhs descriptor. It should be destroyed at the end using hipsparseSpSM_destroyDescr().
hipsparseSpSM_destroyDescr()#
-
hipsparseStatus_t hipsparseSpSM_destroyDescr(hipsparseSpSMDescr_t descr)#
Description: Destroy sparse matrix triangular solve with multiple rhs descriptor.
hipsparseSpSM_destroyDescr
destroys a sparse matrix triangular solve with multiple rhs descriptor and releases all resources used by the descriptor.
hipsparseSpSM_bufferSize()#
-
hipsparseStatus_t hipsparseSpSM_bufferSize(hipsparseHandle_t handle, hipsparseOperation_t opA, hipsparseOperation_t opB, const void *alpha, const hipsparseSpMatDescr_t matA, const hipsparseDnMatDescr_t matB, const hipsparseDnMatDescr_t matC, hipDataType computeType, hipsparseSpSMAlg_t alg, hipsparseSpSMDescr_t spsmDescr, size_t *bufferSize)#
Description: Buffer size step of solution of triangular linear system op(A) * C = alpha * op(B), where A is a sparse matrix in CSR storage format, B and C are dense matrices.
hipsparseSpSV_bufferSize
computes the required user allocated buffer size needed when computing the solution of triangular linear system op(A) * C = alpha * op(B), where A is a sparse matrix in CSR storage format, B and C are dense matrices.
hipsparseSpSM_analysis()#
-
hipsparseStatus_t hipsparseSpSM_analysis(hipsparseHandle_t handle, hipsparseOperation_t opA, hipsparseOperation_t opB, const void *alpha, const hipsparseSpMatDescr_t matA, const hipsparseDnMatDescr_t matB, const hipsparseDnMatDescr_t matC, hipDataType computeType, hipsparseSpSMAlg_t alg, hipsparseSpSMDescr_t spsmDescr, void *externalBuffer)#
Description: Analysis step of solution of triangular linear system op(A) * C = alpha * op(B), where A is a sparse matrix in CSR storage format, B and C are dense vectors.
hipsparseSpSV_analysis
performs the required analysis used when computing the solution of triangular linear system op(A) * C = alpha * op(B), where A is a sparse matrix in CSR storage format, B and C are dense vectors.
hipsparseSpSM_solve()#
-
hipsparseStatus_t hipsparseSpSM_solve(hipsparseHandle_t handle, hipsparseOperation_t opA, hipsparseOperation_t opB, const void *alpha, const hipsparseSpMatDescr_t matA, const hipsparseDnMatDescr_t matB, const hipsparseDnMatDescr_t matC, hipDataType computeType, hipsparseSpSMAlg_t alg, hipsparseSpSMDescr_t spsmDescr, void *externalBuffer)#
Description: Sparse triangular system solve.
hipsparseSpSM_solve
solves a sparse triangular linear system of a sparse \(m \times m\) matrix, defined in CSR or COO storage format, a dense solution matrix \(C\) and the right-hand side \(B\) that is multiplied by \(\alpha\), such that\[ op(A) \cdot C = \alpha \cdot op(B), \]with\[\begin{split} op(A) = \left\{ \begin{array}{ll} A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]and\[\begin{split} op(B) = \left\{ \begin{array}{ll} B, & \text{if trans_B == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ B^T, & \text{if trans_B == HIPSPARSE_OPERATION_TRANSPOSE} \\ B^H, & \text{if trans_B == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]