• 12.cuBLAS开发指南中文版--cuBLAS中的Level-1函数asum()和axpy()


    cuBLAS中的Level-1函数asum()和axpy()

    在这里插入图片描述

    2.5.3. cublasasum()

    cublasStatus_t  cublasSasum(cublasHandle_t handle, int n,
                                const float           *x, int incx, float  *result)
    cublasStatus_t  cublasDasum(cublasHandle_t handle, int n,
                                const double          *x, int incx, double *result)
    cublasStatus_t cublasScasum(cublasHandle_t handle, int n,
                                const cuComplex       *x, int incx, float  *result)
    cublasStatus_t cublasDzasum(cublasHandle_t handle, int n,
                                const cuDoubleComplex *x, int incx, double *result)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    此函数计算向量 x 的元素的绝对值之和。 因此,结果是 ∑ i = 1 n | I m ( x [ j ] ) | + | R e ( x [ j ] ) | 其中 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 elements.
    incxinputstride between consecutive elements of x.
    resulthost or deviceoutputthe resulting index, which is 0.0 if n,incx<=0

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

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

    请参考:

    sasum, dasum, scasum, dzasum

    2.5.4. cublasaxpy()

    cublasStatus_t cublasSaxpy(cublasHandle_t handle, int n,
                               const float           *alpha,
                               const float           *x, int incx,
                               float                 *y, int incy)
    cublasStatus_t cublasDaxpy(cublasHandle_t handle, int n,
                               const double          *alpha,
                               const double          *x, int incx,
                               double                *y, int incy)
    cublasStatus_t cublasCaxpy(cublasHandle_t handle, int n,
                               const cuComplex       *alpha,
                               const cuComplex       *x, int incx,
                               cuComplex             *y, int incy)
    cublasStatus_t cublasZaxpy(cublasHandle_t handle, int n,
                               const cuDoubleComplex *alpha,
                               const cuDoubleComplex *x, int incx,
                               cuDoubleComplex       *y, int incy)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16

    此函数将向量 x 乘以标量并将其添加到向量 y 中,并用结果覆盖最新的向量。 因此,对 i = 1 , … , n 、 k = 1 + ( i - 1 ) * incx 和 j = 1 + ( i - 1 ) * incy 执行的操作是 y [ j ] = α × x [ k ] + y [ j ]。 请注意,最后两个等式反映了用于与 Fortran 兼容的基于 1 的索引。

    Param.MemoryIn/outMeaning
    handleinputhandle to the cuBLAS library context.
    alphahost or deviceinput scalar used for multiplication.
    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无法分配缩减缓冲区
    CUBLAS_STATUS_EXECUTION_FAILED该功能无法在 GPU 上启动

    请参考:

    saxpy, daxpy, caxpy, zaxpy

  • 相关阅读:
    LCR 026. 重排链表
    网页制作课作业基于HTML+CSS+JavaScript+jquery仿慕课网教学培训网站设计实例 企业网站制作
    Adafruit_GFX matrix ws2812像素屏库使用教程AWTRIX2.0像素时钟
    【Java快速入门】Java语言的抽象类和接口(十)
    【软件设计师】常见的算法设计方法——迭代法
    从零开始学习 Java:简单易懂的入门指南之Map集合(二十三)
    853. 车队【力扣】
    图像处理领域之►边缘检测大合集◄【应该是全网仅有的了吧】
    32 道 Spring 常见面试题!万字总结!
    华为OD机试真题-分积木-2023年OD统一考试(B卷)
  • 原文地址:https://blog.csdn.net/kunhe0512/article/details/126243890