• 13.cuBLAS开发指南中文版--cuBLAS中的Level-1函数copy()和dot()


    2.5.5. cublascopy()

    在这里插入图片描述

    cublasStatus_t cublasScopy(cublasHandle_t handle, int n,
                               const float           *x, int incx,
                               float                 *y, int incy)
    cublasStatus_t cublasDcopy(cublasHandle_t handle, int n,
                               const double          *x, int incx,
                               double                *y, int incy)
    cublasStatus_t cublasCcopy(cublasHandle_t handle, int n,
                               const cuComplex       *x, int incx,
                               cuComplex             *y, int incy)
    cublasStatus_t cublasZcopy(cublasHandle_t handle, int n,
                               const cuDoubleComplex *x, int incx,
                               cuDoubleComplex       *y, int incy)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    该函数将向量 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_ALLOC_FAILED无法分配缩减缓冲区

    请参考:

    scopy, dcopy, ccopy, zcopy

    2.5.6. cublasdot()

    cublasStatus_t cublasSdot (cublasHandle_t handle, int n,
                               const float           *x, int incx,
                               const float           *y, int incy,
                               float           *result)
    cublasStatus_t cublasDdot (cublasHandle_t handle, int n,
                               const double          *x, int incx,
                               const double          *y, int incy,
                               double          *result)
    cublasStatus_t cublasCdotu(cublasHandle_t handle, int n,
                               const cuComplex       *x, int incx,
                               const cuComplex       *y, int incy,
                               cuComplex       *result)
    cublasStatus_t cublasCdotc(cublasHandle_t handle, int n,
                               const cuComplex       *x, int incx,
                               const cuComplex       *y, int incy,
                               cuComplex       *result)
    cublasStatus_t cublasZdotu(cublasHandle_t handle, int n,
                               const cuDoubleComplex *x, int incx,
                               const cuDoubleComplex *y, int incy,
                               cuDoubleComplex *result)
    cublasStatus_t cublasZdotc(cublasHandle_t handle, int n,
                               const cuDoubleComplex *x, int incx,
                               const cuDoubleComplex *y, int incy,
                               cuDoubleComplex       *result)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24

    此函数计算向量 x 和 y 的点积。 因此,结果是 ∑ i = 1 n ( x [ k ] × y [ j ] ) 其中 k = 1 + ( i - 1 ) * incx 和 j = 1 + ( i - 1 ) * incy 。 请注意,在第一个方程中,如果函数名称以字符“c”结尾,则应使用向量 x 的元素的共轭,并且最后两个方程反映了用于与 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.
    resulthost or deviceoutputthe resulting dot product, which is 0.0 if n<=0.

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

    Error ValueMeaning
    CUBLAS_STATUS_SUCCESS操作成功完成
    CUBLAS_STATUS_NOT_INITIALIZED库未初始化
    CUBLAS_STATUS_ALLOC_FAILED无法分配缩减缓冲区
    CUBLAS_STATUS_EXECUTION_FAILED该功能无法在 GPU 上启动

    请参考:
    sdot, ddot, cdotu, cdotc, zdotu, zdotc

  • 相关阅读:
    Edge Drawing: A combined real-time edge and segment detector 翻译
    用户体验设计常犯逻辑谬误
    数据结构系列学习(五) - 双向链表(Double_Linked_List)
    SortedSet 和 List 异同点
    mysql 导出查询结果成 excel 文件
    用正向迭代器封装实现反向迭代器
    Linux入门与进阶(二)
    数据可视化项目1
    Cookie:实现网站十天内免密登录
    「Go框架」gin框架是如何处理panic的?
  • 原文地址:https://blog.csdn.net/kunhe0512/article/details/126264446