18.cuBLAS开发指南中文版--cuBLAS中的Level-2函数gbmv()
2.6. cuBLAS Level-2 函数参考
在本章中,我们将描述执行矩阵向量运算的 Level-2 基本线性代数子程序 (BLAS2) 函数。

2.6.1. cublasgbmv()
cublasStatus_t cublasSgbmv(cublasHandle_t handle, cublasOperation_t trans,int m, int n, int kl, int ku,const float *alpha,const float *A, int lda,const float *x, int incx,const float *beta,float *y, int incy)
cublasStatus_t cublasDgbmv(cublasHandle_t handle, cublasOperation_t trans,int m, int n, int kl, int ku,const double *alpha,const double *A, int lda,const double *x, int incx,const double *beta,double *y, int incy)
cublasStatus_t cublasCgbmv(cublasHandle_t handle, cublasOperation_t trans,int m, int n, int kl, int ku,const cuComplex *alpha,const cuComplex *A, int lda,const cuComplex *x, int incx,const cuComplex *beta,cuComplex *y, int incy)
cublasStatus_t cublasZgbmv(cublasHandle_t handle, cublasOperation_t trans,int m, int n, int kl, int ku,const cuDoubleComplex *alpha,const cuDoubleComplex *A, int lda,const cuDoubleComplex *x, int incx,const cuDoubleComplex *beta,cuDoubleComplex *y, int incy)
此函数执行带状矩阵向量乘法
y = α o p ( A ) x + β y y=\alpha op(A)x + \beta y y=αop(A)x+βy
其中 A 是具有 kl 次对角线和 ku 超对角线的带状矩阵,x 和 y 是向量, α \alpha α 和 β \beta β 是标量。 此外,对于矩阵 A:
o p ( A ) = { A 如果 t r a n s a = = C U B L A S O P N , A T 如果 t r a n s a = = C U B L A S O P T , A H 如果 t r a n s a = = C U B L A S O P H op(A)= \begin{cases} A\ \ \ \ 如果 transa == CUBLAS_OP_N,\\ A^T \ \ 如果 transa == CUBLAS_OP_T,\\ A^H \ \ 如果 transa == CUBLAS_OP_H \end{cases} op(A)=⎩ ⎨ ⎧A 如果transa==CUBLASOPN,AT 如果transa==CUBLASOPT,AH 如果transa==CUBLASOPH
带状矩阵 A 逐列存储,主对角线存储在 ku+1 行(从第一个位置开始),第一个上对角线存储在 ku 行(从第二个位置开始),第一个子对角线存储在 ku+2 行 (从第一个位置开始)等等。所以一般来说,元素 A(i,j) 存储在内存位置 A(ku+1+i-j,j) 中,因为 j=1,…,n 和 i ∈ [ m a x ( 1 , j − k u ) , m i n ( m , j + k l ) ] i\in[max(1,j-ku), min(m, j+kl)] i∈[max(1,j−ku),min(m,j+kl)] . 此外,数组 A 中的元素在概念上不对应于带状矩阵中的元素(左上角 ku * ku 和右下角 kl *kl 三角形)不被引用。
| Param. | Memory | In/out | Meaning |
|---|---|---|---|
| handle | input | handle to the cuBLAS library context. | |
| trans | input | operation op(A) that is non- or (conj.) transpose. | |
| m | input | number of rows of matrix A. | |
| n | input | number of columns of matrix A. | |
| kl | input | number of subdiagonals of matrix A. | |
| ku | input | number of superdiagonals of matrix A. | |
| alpha | host or device | input | scalar used for multiplication. |
| A | device | input | array of dimension lda x n with lda>=kl+ku+1. |
| lda | input | leading dimension of two-dimensional array used to store matrix A. | |
| x | device | input | vector with n elements if transa == CUBLAS_OP_N and m elements otherwise. |
| incx | input | stride between consecutive elements of x. | |
| beta | host or device | input | scalar used for multiplication, if beta == 0 then y does not have to be a valid input. |
| y | device | in/out | vector with m elements if transa == CUBLAS_OP_N and n elements otherwise. |
| incy | input | stride between consecutive elements of y. |
该函数可能返回的错误值及其含义如下所列。
| Error Value | Meaning |
|---|---|
| CUBLAS_STATUS_SUCCESS | 操作成功完成 |
| CUBLAS_STATUS_NOT_INITIALIZED | 库未初始化 |
| CUBLAS_STATUS_INVALID_VALUE |
|
| CUBLAS_STATUS_EXECUTION_FAILED | 该功能无法在 GPU 上启动 |
请参考:
sgbmv, dgbmv, cgbmv, zgbmv
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
