• 17.cuBLAS开发指南中文版--cuBLAS中的Level-1函数scal()和swap()


    cuBLAS开发指南中文版–cuBLAS中的Level-1函数scal()和swap()

    在这里插入图片描述

    2.5.12. cublasscal()

    cublasStatus_t  cublasSscal(cublasHandle_t handle, int n,
                                const float           *alpha,
                                float           *x, int incx)
    cublasStatus_t  cublasDscal(cublasHandle_t handle, int n,
                                const double          *alpha,
                                double          *x, int incx)
    cublasStatus_t  cublasCscal(cublasHandle_t handle, int n,
                                const cuComplex       *alpha,
                                cuComplex       *x, int incx)
    cublasStatus_t cublasCsscal(cublasHandle_t handle, int n,
                                const float           *alpha,
                                cuComplex       *x, int incx)
    cublasStatus_t  cublasZscal(cublasHandle_t handle, int n,
                                const cuDoubleComplex *alpha,
                                cuDoubleComplex *x, int incx)
    cublasStatus_t cublasZdscal(cublasHandle_t handle, int n,
                                const double          *alpha,
                                cuDoubleComplex *x, int incx)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    该函数通过标量 α 缩放向量 x 并用结果覆盖它。 因此,执行的操作是 x [ j ] = α × x [ j ] 对于 i = 1 , … , n 和 j = 1 + ( i - 1) *incx。 请注意,最后两个等式反映了用于与 Fortran 兼容的基于 1 的索引。

    Param.MemoryIn/outMeaning
    handleinputhandle to the cuBLAS library context.
    ninputnumber of elements in the vector x.
    xdeviceinput vector with n elements.
    incxinputstride between consecutive elements of x.

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

    Error ValueMeaning
    CUBLAS_STATUS_SUCCESS操作成功完成
    CUBLAS_STATUS_NOT_INITIALIZED库未初始化
    CUBLAS_STATUS_EXECUTION_FAILED该功能无法在 GPU 上启动

    请参考:
    sscal, dscal, csscal, cscal, zdscal, zscal

    2.5.13. cublasswap()

    cublasStatus_t cublasSswap(cublasHandle_t handle, int n, float           *x,
                               int incx, float           *y, int incy)
    cublasStatus_t cublasDswap(cublasHandle_t handle, int n, double          *x,
                               int incx, double          *y, int incy)
    cublasStatus_t cublasCswap(cublasHandle_t handle, int n, cuComplex       *x,
                               int incx, cuComplex       *y, int incy)
    cublasStatus_t cublasZswap(cublasHandle_t handle, int n, cuDoubleComplex *x,
                               int incx, cuDoubleComplex *y, int incy)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    此函数交换向量 x 和 y 的元素。 因此,执行的操作是 y [ j ] ⇔ x [ k ] 对于 i = 1 , … , n , k = 1 + ( i - 1 ) * incx 和 j = 1 + ( i - 1 ) * incy 。 请注意,最后两个等式反映了用于与 Fortran 兼容的基于 1 的索引。

    Param.MemoryIn/outMeaning
    handleinputhandle to the cuBLAS library context.
    ninputnumber of elements in the vector x.
    xdeviceinput vector with n elements.
    incxinputstride between consecutive elements of x.
    ydevicein/out vector with n elements.
    incyinputstride between consecutive elements of y.

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

    Error ValueMeaning
    CUBLAS_STATUS_SUCCESS操作成功完成
    CUBLAS_STATUS_NOT_INITIALIZED库未初始化
    CUBLAS_STATUS_EXECUTION_FAILED该功能无法在 GPU 上启动

    请参考:
    sswap, dswap, cswap, zswap

  • 相关阅读:
    [附源码]java毕业设计基于协同过滤推荐的电影推荐系统
    系统软件开发基础知识
    数列计算
    Gson转换错误导致Int变为Double类型
    Excel·VBA制作工资条
    撸一个随机数生成器
    【数据结构】二叉树的遍历
    python中的none
    Matlab导入数据(一定有用!!)
    OVN 流表基础 -- 基于 kubeOVN (二)
  • 原文地址:https://blog.csdn.net/kunhe0512/article/details/126296587