• 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

  • 相关阅读:
    数据结构——排序算法(C语言)
    【Python入门基础2】关于print()函数 及 格式化输出
    Go语言核心编程(三) --协程
    C盘扩容(微PE工具箱)
    servlet 的XML Schema从哪边获取
    LeetCode_二叉树_中等_1372.二叉树中的最长交错路径
    统一异常处理
    vue:如何实现通过判断数组中每个对象的其中一个属性,从而更改另一个属性的值
    初识C++|类和对象(中)——类的默认成员函数
    【python】爬虫记录每小时金价
  • 原文地址:https://blog.csdn.net/kunhe0512/article/details/126371258