22.cuBLAS开发指南中文版--cuBLAS中的Level-2函数spmv()

发布于:2023-01-15 ⋅ 阅读:(419) ⋅ 点赞:(0)

2.6.5. cublas<t>spmv()

在这里插入图片描述

cublasStatus_t cublasSspmv(cublasHandle_t handle, cublasFillMode_t uplo,
                           int n, const float  *alpha, const float  *AP,
                           const float  *x, int incx, const float  *beta,
                           float  *y, int incy)
cublasStatus_t cublasDspmv(cublasHandle_t handle, cublasFillMode_t uplo,
                           int n, const double *alpha, const double *AP,
                           const double *x, int incx, const double *beta,
                           double *y, int incy)

此函数执行对称带状矩阵向量乘法:

y = α A x + β y y = \alpha Ax+\beta y y=αAx+βy

其中 A 是具有 k 个子对角线和超对角线的 n*n 对称带状矩阵,并且是向量,x 和 y 是标量。

如果 uplo == CUBLAS_FILL_MODE_LOWER 则对称矩阵 a 的下三角部分中的元素被逐列填充在一起,没有间隙。因此,一般来说,元素 A(i,j) 存储在内存位置 AP[i+((2*n-j+1)*j)/2] 中 j=1,…,n 和 i > j i>j i>j 。 因此,打包格式只需要存储 n ( n + 1 ) 2 \frac{n(n+1)}{2} 2n(n+1)个元素。

如果 uplo == CUBLAS_FILL_MODE_UPPER 则对称矩阵 a 的下三角部分中的元素被逐列填充在一起,没有间隙.。因此,一般来说,元素 A(i,j) 存储在内存位置 AP[i+(j*(j+1))/2] 中 j=1,…,n 和 i < = j i <= j i<=j 。 因此,打包格式只需要存储 n ( n + 1 ) 2 \frac{n(n+1)}{2} 2n(n+1)个元素。

Param. Memory In/out Meaning
handle input handle to the cuBLAS library context.
uplo input indicates if matrix A lower or upper part is stored, the other symmetric part is not referenced and is inferred from the stored elements.
n input number of rows and columns of matrix A.
alpha host or device input <type> scalar used for multiplication.
AP device input <type> array with stored in packed format.
lda input leading dimension of two-dimensional array used to store matrix A.
x device input <type> vector with n elements.
incx input stride between consecutive elements of x.
beta host or device input <type> scalar used for multiplication, if beta==0 then y does not have to be a valid input.
y device in/out <type> vector at least (1+(m-1)*abs(incy)) elements if transa==CUBLAS_OP_N and at least (1+(n-1)*abs(incy)) elements otherwise.
incy input stride between consecutive elements of y.

该函数可能返回的错误值及其含义如下所列。

ErrorValue Meaning
CUBLAS_STATUS_SUCCESS 操作成功完成
CUBLAS_STATUS_NOT_INITIALIZED 库未初始化
CUBLAS_STATUS_INVALID_VALUE 参数 m,n<0 或 incx,incy=0
CUBLAS_STATUS_EXECUTION_FAILED 该功能无法在 GPU 上启动

请参考:

sspmv, dspmv

本文含有隐藏内容,请 开通VIP 后查看

网站公告

今日签到

点亮在社区的每一天
去签到