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


    2.6.5. cublasspmv()

    在这里插入图片描述

    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)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

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

    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.MemoryIn/outMeaning
    handleinputhandle to the cuBLAS library context.
    uploinputindicates if matrix A lower or upper part is stored, the other symmetric part is not referenced and is inferred from the stored elements.
    ninputnumber of rows and columns of matrix A.
    alphahost or deviceinput scalar used for multiplication.
    APdeviceinput array with stored in packed format.
    ldainputleading dimension of two-dimensional array used to store matrix A.
    xdeviceinput vector with n elements.
    incxinputstride between consecutive elements of x.
    betahost or deviceinput scalar used for multiplication, if beta==0 then y does not have to be a valid input.
    ydevicein/out vector at least (1+(m-1)*abs(incy)) elements if transa==CUBLAS_OP_N and at least (1+(n-1)*abs(incy)) elements otherwise.
    incyinputstride between consecutive elements of y.

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

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

    请参考:

    sspmv, dspmv

  • 相关阅读:
    【SLAM】Sophus库的超详细解析
    机器人到达指定位置的方法数问题
    [react] React项目中使用阿里font-icon的svg形式
    【服务器数据恢复】raidz多块硬盘离线的数据恢复案例
    [NOIP2003 普及组] 乒乓球
    教程图文详解 - 广域网通信(第三章)
    LASSO回归
    JavaScript 的面向对象基础,设计模式中的原型模式(设计模式与开发实践 P2)
    clickhouse、Doris、Kylin对比
    【Typescript综合】模块化开发
  • 原文地址:https://blog.csdn.net/kunhe0512/article/details/126371258