cuda_zgeadd.c 2.69 KB
Newer Older
Mathieu Faverge's avatar
Mathieu Faverge committed
1
/**
2 3
 *
 * @file cuda_zgeadd.c
Mathieu Faverge's avatar
Mathieu Faverge committed
4
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
5 6
 * @copyright 2009-2014 The University of Tennessee and The University of
 *                      Tennessee Research Foundation. All rights reserved.
PRUVOST Florent's avatar
PRUVOST Florent committed
7
 * @copyright 2012-2019 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8
 *                      Univ. Bordeaux. All rights reserved.
Mathieu Faverge's avatar
Mathieu Faverge committed
9
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
10
 ***
Mathieu Faverge's avatar
Mathieu Faverge committed
11
 *
12
 * @brief Chameleon cuda_zgeadd GPU kernel
Mathieu Faverge's avatar
Mathieu Faverge committed
13
 *
PRUVOST Florent's avatar
PRUVOST Florent committed
14
 * @version 0.9.2
Mathieu Faverge's avatar
Mathieu Faverge committed
15
 * @author Mathieu Faverge
PRUVOST Florent's avatar
PRUVOST Florent committed
16
 * @date 2017-04-10
Mathieu Faverge's avatar
Mathieu Faverge committed
17 18
 * @precisions normal z -> c d s
 *
19
 */
20
#include "cudablas.h"
Mathieu Faverge's avatar
Mathieu Faverge committed
21 22 23 24 25

#if !defined(CHAMELEON_USE_CUBLAS_V2)
#error "This file requires cublas api v2 support"
#endif

26 27 28
/**
 ******************************************************************************
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
29
 * @ingroup CUDA_CHAMELEON_Complex64_t
30 31 32 33 34 35 36 37 38 39 40 41
 *
 *  CUDA_zgeadd adds to matrices together as in PBLAS pzgeadd.
 *
 *       B <- alpha * op(A)  + beta * B,
 *
 * where op(X) = X, X', or conj(X')
 *
 *******************************************************************************
 *
 * @param[in] trans
 *          Specifies whether the matrix A is non-transposed, transposed, or
 *          conjugate transposed
Mathieu Faverge's avatar
Mathieu Faverge committed
42 43 44
 *          = ChamNoTrans:   op(A) = A
 *          = ChamTrans:     op(A) = A'
 *          = ChamConjTrans: op(A) = conj(A')
45 46 47 48 49 50 51 52 53 54 55
 *
 * @param[in] M
 *          Number of rows of the matrices op(A) and B.
 *
 * @param[in] N
 *          Number of columns of the matrices op(A) and B.
 *
 * @param[in] alpha
 *          Scalar factor of A.
 *
 * @param[in] A
Mathieu Faverge's avatar
Mathieu Faverge committed
56
 *          Matrix of size LDA-by-N, if trans = ChamNoTrans, LDA-by-M
57 58 59 60
 *          otherwise.
 *
 * @param[in] LDA
 *          Leading dimension of the array A. LDA >= max(1,k), with k=M, if
Mathieu Faverge's avatar
Mathieu Faverge committed
61
 *          trans = ChamNoTrans, and k=N otherwise.
62 63 64 65 66 67 68 69 70 71 72 73 74
 *
 * @param[in] beta
 *          Scalar factor of B.
 *
 * @param[in,out] B
 *          Matrix of size LDB-by-N.
 *          On exit, B = alpha * op(A) + beta * B
 *
 * @param[in] LDB
 *          Leading dimension of the array B. LDB >= max(1,M)
 *
 *******************************************************************************
 *
75 76
 * @retval CHAMELEON_SUCCESS successful exit
 * @retval <0 if -i, the i-th argument had an illegal value
77
 *
78
 */
Mathieu Faverge's avatar
Mathieu Faverge committed
79
int CUDA_zgeadd(cham_trans_t trans,
Mathieu Faverge's avatar
Mathieu Faverge committed
80 81 82 83 84 85
                int m, int n,
                const cuDoubleComplex *alpha,
                const cuDoubleComplex *A, int lda,
                const cuDoubleComplex *beta,
                cuDoubleComplex *B, int ldb,
                CUBLAS_STREAM_PARAM)
Mathieu Faverge's avatar
Mathieu Faverge committed
86 87
{
    cublasZgeam(CUBLAS_HANDLE
Mathieu Faverge's avatar
Mathieu Faverge committed
88
                chameleon_cublas_const(trans), chameleon_cublas_const(ChamNoTrans),
Mathieu Faverge's avatar
Mathieu Faverge committed
89
                m, n,
Mathieu Faverge's avatar
Mathieu Faverge committed
90
                CUBLAS_VALUE(alpha), A, lda,
Mathieu Faverge's avatar
Mathieu Faverge committed
91 92
                CUBLAS_VALUE(beta),  B, ldb,
                B, ldb);
Mathieu Faverge's avatar
Mathieu Faverge committed
93 94 95

    assert( CUBLAS_STATUS_SUCCESS == cublasGetError() );

Mathieu Faverge's avatar
Mathieu Faverge committed
96
    return CHAMELEON_SUCCESS;
Mathieu Faverge's avatar
Mathieu Faverge committed
97
}