/*
 *   -- clMAGMA (version 0.1) --
 *      Univ. of Tennessee, Knoxville
 *      Univ. of California, Berkeley
 *      Univ. of Colorado, Denver
 *      April 2012
 *
 * @author Mark Gates
 * @generated c Fri Nov 22 14:21:02 2013
 */

#ifndef MAGMA_BLAS_C_H
#define MAGMA_BLAS_C_H

#include "magma_types.h"

#ifdef __cplusplus
extern "C" {
#endif

// ========================================
// copying sub-matrices (contiguous columns)
magma_err_t
magma_csetmatrix(
    magma_int_t m, magma_int_t n,
    magmaFloatComplex const* hA_src, size_t hA_offset, magma_int_t ldha,
    magmaFloatComplex_ptr    dA_dst, size_t dA_offset, magma_int_t ldda,
    magma_queue_t queue );

magma_err_t
magma_cgetmatrix(
    magma_int_t m, magma_int_t n,
    magmaFloatComplex_const_ptr dA_src, size_t dA_offset, magma_int_t ldda,
    magmaFloatComplex*          hA_dst, size_t hA_offset, magma_int_t ldha,
    magma_queue_t queue );

magma_err_t
magma_csetmatrix_async(
    magma_int_t m, magma_int_t n,
    magmaFloatComplex const* hA_src, size_t hA_offset, magma_int_t ldha,
    magmaFloatComplex_ptr    dA_dst, size_t dA_offset, magma_int_t ldda,
    magma_queue_t queue, magma_event_t *event );

magma_err_t
magma_cgetmatrix_async(
    magma_int_t m, magma_int_t n,
    magmaFloatComplex_const_ptr dA_src, size_t dA_offset, magma_int_t ldda,
    magmaFloatComplex*          hA_dst, size_t hA_offset, magma_int_t ldha,
    magma_queue_t queue, magma_event_t *event );

magma_err_t
magma_csetintarray_async(
    magma_int_t lda, magma_int_t const* hA_src, size_t hA_offset, magma_int_t *dA_dst, size_t dA_offset, magma_queue_t queue, magma_event_t *event );


// ========================================
// matrix transpose and swapping functions
//magma_err_t
//magma_cinplace_transpose(
//    magmaFloatComplex_ptr dA, size_t dA_offset, int lda, int n,
//    magma_queue_t queue );

#define magma_cinplace_transpose( dAT, dAT_offset, ldda, lddat, queue ) ; 

//magma_err_t
//magma_ctranspose2(
//    magmaFloatComplex_ptr odata, size_t odata_offset, int ldo,
//    magmaFloatComplex_ptr idata, size_t idata_offset, int ldi,
//    int m, int n,
//    magma_queue_t queue );

#define magma_ctranspose2( dAT, dAT_offset, lddat, dA, dA_offset,  ldda, m, n, queue ) \
    magma_ctranspose(dAT, 0, lddat, dA, 0, ldda, m, n, queue)

magma_err_t
magma_ctranspose(
    magmaFloatComplex_ptr odata, int offo, int ldo,
    magmaFloatComplex_ptr idata, int offi, int ldi,
    int m, int n,
    magma_queue_t queue );

magma_err_t
magma_cswap(magma_int_t n, magmaFloatComplex *dA1T, magma_int_t lda1, magmaFloatComplex *dA2T, magma_int_t lda2, magma_queue_t queue);

magma_err_t
magma_claswp(magma_int_t n, magmaFloatComplex_ptr d_A, magma_int_t ldda, magma_int_t k1, magma_int_t k2, magma_int_t *d_ipiv, magma_int_t incx, magma_queue_t queue);

// ========================================
// BLAS functions
magma_err_t
magma_ccopy(
    magma_int_t n,
    magmaFloatComplex_ptr dx, size_t dx_offset, magma_int_t incx,
    magmaFloatComplex_ptr dy, size_t dy_offset, magma_int_t incy,
    magma_queue_t queue );

magma_err_t
magma_cgemm(
    magma_trans_t transA, magma_trans_t transB,
    magma_int_t m, magma_int_t n, magma_int_t k,
    magmaFloatComplex alpha, magmaFloatComplex_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaFloatComplex_const_ptr dB, size_t dB_offset, magma_int_t ldb,
    magmaFloatComplex beta,  magmaFloatComplex_ptr       dC, size_t dC_offset, magma_int_t ldc,
    magma_queue_t queue );

magma_err_t
magma_cgemv(
    magma_trans_t transA,
    magma_int_t m, magma_int_t n,
    magmaFloatComplex alpha, magmaFloatComplex_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaFloatComplex_const_ptr dx, size_t dx_offset, magma_int_t incx,
    magmaFloatComplex beta,  magmaFloatComplex_ptr       dy, size_t dy_offset, magma_int_t incy,
    magma_queue_t queue );

magma_err_t
magma_chemm(
    magma_side_t side, magma_uplo_t uplo,
    magma_int_t m, magma_int_t n,
    magmaFloatComplex alpha, magmaFloatComplex_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaFloatComplex_const_ptr dB, size_t dB_offset, magma_int_t ldb,
    magmaFloatComplex beta,  magmaFloatComplex_ptr       dC, size_t dC_offset, magma_int_t ldc,
    magma_queue_t queue );

magma_err_t
magma_chemm_ours(
    magma_side_t side, magma_uplo_t uplo,
    magma_int_t m, magma_int_t n,
    magmaFloatComplex alpha, magmaFloatComplex_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaFloatComplex_const_ptr dB, size_t dB_offset, magma_int_t ldb,
    magmaFloatComplex beta,  magmaFloatComplex_ptr       dC, size_t dC_offset, magma_int_t ldc,
    magma_int_t globaldAoffset,
    magma_queue_t queue );

magma_err_t
magma_chemv(
    magma_uplo_t uplo,
    magma_int_t n,
    magmaFloatComplex alpha, magmaFloatComplex_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaFloatComplex_const_ptr dx, size_t dx_offset, magma_int_t incx,
    magmaFloatComplex beta,  magmaFloatComplex_ptr       dy, size_t dy_offset, magma_int_t incy,
    magma_queue_t queue );

magma_err_t
magma_csymv2(
    magma_uplo_t uplo,
    magma_int_t n,
    magmaFloatComplex alpha, magmaFloatComplex_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaFloatComplex_const_ptr dx, size_t dx_offset, magma_int_t incx,
    magmaFloatComplex beta,  magmaFloatComplex_ptr       dy, size_t dy_offset, magma_int_t incy,
    magma_queue_t queue );


magma_err_t
magma_cherk(
    magma_uplo_t uplo, magma_trans_t trans,
    magma_int_t n, magma_int_t k,
    float alpha, magmaFloatComplex_const_ptr dA, size_t dA_offset, magma_int_t lda,
    float beta,  magmaFloatComplex_ptr       dC, size_t dC_offset, magma_int_t ldc,
    magma_queue_t queue );

void magmablas_cherk_mmic2(                                                                                                                    
    char uplo, char trans, magma_int_t n, magma_int_t k,                                                                                
    float alpha, magmaFloatComplex *dA[], magma_int_t lda, magma_int_t aoff,                                                                             
    float beta,           magmaFloatComplex *dC[], magma_int_t ldc,  magma_int_t offset, 
    magma_int_t nmic, magma_int_t nb, magma_queue_t queue);  
 
magma_err_t
magma_cherk_mmic(                                                                                                                    
    magma_uplo_t uplo, magma_trans_t trans, magma_int_t n, magma_int_t k,                                                                                
    float alpha, magmaFloatComplex_const_ptr dA, magma_int_t lda, magma_int_t dAoff,                                                                             
    float beta, magmaFloatComplex_const_ptr dC, magma_int_t ldc,  magma_int_t offset, 
    magma_int_t nmic, magma_int_t nb, magma_int_t my_id);  

magma_err_t
magma_cher2k(
    magma_uplo_t uplo, magma_trans_t trans,
    magma_int_t n, magma_int_t k,
    magmaFloatComplex alpha, magmaFloatComplex_const_ptr dA, size_t dA_offset, magma_int_t lda,
    magmaFloatComplex_const_ptr dB, size_t dB_offset, magma_int_t ldb,
    float beta,  magmaFloatComplex_ptr       dC, size_t dC_offset, magma_int_t ldc,
    magma_queue_t queue );

void magmablas_cher2k_mmic2(                                                                                                                    
    char uplo, char trans, magma_int_t n, magma_int_t k,                                                                                
    magmaFloatComplex alpha, magmaFloatComplex *dA[], magma_int_t lda, magma_int_t aoff,                                                                             
    magmaFloatComplex *dB[], magma_int_t ldb, magma_int_t boff,                                               
    float beta,           magmaFloatComplex *dC[], magma_int_t ldc,  magma_int_t offset, 
    magma_int_t nmic, magma_int_t nb, magma_queue_t queue);  

magma_err_t
magma_cher2k_mmic(
    magma_uplo_t uplo, magma_trans_t trans, magma_int_t n, magma_int_t k,                                                                                
    magmaFloatComplex alpha, magmaFloatComplex_const_ptr dA, magma_int_t lda, magma_int_t dAoff,                                                                             
    magmaFloatComplex_const_ptr dB, magma_int_t ldb, magma_int_t dBoff,                                               
    float beta,           magmaFloatComplex_const_ptr dC, magma_int_t ldc,  magma_int_t offset, 
    magma_int_t nmic, magma_int_t nb, magma_int_t my_id);  

magma_err_t
magma_ctrsm(
    magma_side_t side, magma_uplo_t uplo, magma_trans_t trans, magma_diag_t diag,
    magma_int_t m, magma_int_t n,
    magmaFloatComplex alpha, magmaFloatComplex_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaFloatComplex_ptr       dB, size_t dB_offset, magma_int_t ldb,
    magma_queue_t queue );

magma_err_t
magma_ctrsv(
    magma_uplo_t uplo, magma_trans_t trans, magma_diag_t diag,
    magma_int_t n,
    magmaFloatComplex_const_ptr dA, size_t dA_offset, magma_int_t lda,
    magmaFloatComplex_ptr dx, size_t dx_offset, magma_int_t incx,
    magma_queue_t queue );

magma_err_t
magma_ctrmm(
    magma_side_t side, magma_uplo_t uplo, magma_trans_t trans, magma_diag_t diag,
    magma_int_t m, magma_int_t n,
    magmaFloatComplex alpha, magmaFloatComplex_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaFloatComplex_ptr       dB, size_t dB_offset, magma_int_t ldb,
    magma_queue_t queue );

magma_err_t
magma_ctrmv(
    magma_uplo_t uplo, magma_trans_t trans, magma_diag_t diag,
    magma_int_t n,
    magmaFloatComplex_const_ptr dA, size_t dA_offset, magma_int_t lda,
    magmaFloatComplex_ptr dx, size_t dx_offset, magma_int_t incx,
    magma_queue_t queue );



magma_err_t
magma_clarfb( magma_int_t side, magma_int_t trans, magma_int_t direct, magma_int_t storev,
              magma_int_t m, magma_int_t n, magma_int_t k,
              magmaFloatComplex_ptr dV, size_t dV_offset, magma_int_t ldv,
              magmaFloatComplex_ptr dT, size_t dT_offset, magma_int_t ldt,
              magmaFloatComplex_ptr dC, size_t dC_offset, magma_int_t ldc,
              magmaFloatComplex_ptr dwork, size_t dwork_offset, magma_int_t ldwork,
              magma_queue_t queue);

magma_err_t
magma_clarfb_gemm(magma_int_t side, magma_int_t trans, magma_int_t direct, magma_int_t storev,
              magma_int_t m, magma_int_t n, magma_int_t k,
              magmaFloatComplex_ptr dV, size_t dV_offset, magma_int_t ldv,
              magmaFloatComplex_ptr dT, size_t dT_offset, magma_int_t ldt,
              magmaFloatComplex_ptr dC, size_t dC_offset, magma_int_t ldc,
              magmaFloatComplex_ptr dwork, size_t dwork_offset, magma_int_t ldwork,
              magmaFloatComplex_ptr dworkvt, size_t dworkvt_offset, magma_int_t ldworkvt,
              magma_queue_t queue);

magma_err_t
magma_claset(magma_uplo_t uplo,
             magma_int_t m, magma_int_t n,
             magmaFloatComplex alpha, magmaFloatComplex beta,
             magmaFloatComplex_ptr dA, size_t dA_offset, magma_int_t lda,
             magma_queue_t queue);

// ========================================
// BLAS functions -- combined for MIC
magma_err_t
magma_ctrsmgemm(
    magma_side_t side, magma_uplo_t uplo, magma_trans_t trans, magma_diag_t diag,
    magma_int_t tm, magma_int_t tn,
    magmaFloatComplex talpha, magmaFloatComplex_const_ptr tdA, size_t tdA_offset, magma_int_t tlda,
                              magmaFloatComplex_ptr       tdB, size_t tdB_offset, magma_int_t tldb,
    magma_trans_t transA, magma_trans_t transB,
    magma_int_t m, magma_int_t n, magma_int_t k,
    magmaFloatComplex alpha, magmaFloatComplex_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaFloatComplex_const_ptr dB, size_t dB_offset, magma_int_t ldb,
    magmaFloatComplex beta,  magmaFloatComplex_ptr       dC, size_t dC_offset, magma_int_t ldc,
    magma_queue_t queue );

#ifdef __cplusplus
}
#endif

#endif        //  #ifndef MAGMA_BLAS_H
