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

#ifndef MAGMA_BLAS_D_H
#define MAGMA_BLAS_D_H

#include "magma_types.h"

#ifdef __cplusplus
extern "C" {
#endif

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

magma_err_t
magma_dgetmatrix(
    magma_int_t m, magma_int_t n,
    magmaDouble_const_ptr dA_src, size_t dA_offset, magma_int_t ldda,
    double*          hA_dst, size_t hA_offset, magma_int_t ldha,
    magma_queue_t queue );

magma_err_t
magma_dsetmatrix_async(
    magma_int_t m, magma_int_t n,
    double const* hA_src, size_t hA_offset, magma_int_t ldha,
    magmaDouble_ptr    dA_dst, size_t dA_offset, magma_int_t ldda,
    magma_queue_t queue, magma_event_t *event );

magma_err_t
magma_dgetmatrix_async(
    magma_int_t m, magma_int_t n,
    magmaDouble_const_ptr dA_src, size_t dA_offset, magma_int_t ldda,
    double*          hA_dst, size_t hA_offset, magma_int_t ldha,
    magma_queue_t queue, magma_event_t *event );

magma_err_t
magma_dsetintarray_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_dinplace_transpose(
//    magmaDouble_ptr dA, size_t dA_offset, int lda, int n,
//    magma_queue_t queue );

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

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

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

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

magma_err_t
magma_dswap(magma_int_t n, double *dA1T, magma_int_t lda1, double *dA2T, magma_int_t lda2, magma_queue_t queue);

magma_err_t
magma_dlaswp(magma_int_t n, magmaDouble_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_dcopy(
    magma_int_t n,
    magmaDouble_ptr dx, size_t dx_offset, magma_int_t incx,
    magmaDouble_ptr dy, size_t dy_offset, magma_int_t incy,
    magma_queue_t queue );

magma_err_t
magma_dgemm(
    magma_trans_t transA, magma_trans_t transB,
    magma_int_t m, magma_int_t n, magma_int_t k,
    double alpha, magmaDouble_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaDouble_const_ptr dB, size_t dB_offset, magma_int_t ldb,
    double beta,  magmaDouble_ptr       dC, size_t dC_offset, magma_int_t ldc,
    magma_queue_t queue );

magma_err_t
magma_dgemv(
    magma_trans_t transA,
    magma_int_t m, magma_int_t n,
    double alpha, magmaDouble_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaDouble_const_ptr dx, size_t dx_offset, magma_int_t incx,
    double beta,  magmaDouble_ptr       dy, size_t dy_offset, magma_int_t incy,
    magma_queue_t queue );

magma_err_t
magma_dsymm(
    magma_side_t side, magma_uplo_t uplo,
    magma_int_t m, magma_int_t n,
    double alpha, magmaDouble_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaDouble_const_ptr dB, size_t dB_offset, magma_int_t ldb,
    double beta,  magmaDouble_ptr       dC, size_t dC_offset, magma_int_t ldc,
    magma_queue_t queue );

magma_err_t
magma_dsymm_ours(
    magma_side_t side, magma_uplo_t uplo,
    magma_int_t m, magma_int_t n,
    double alpha, magmaDouble_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaDouble_const_ptr dB, size_t dB_offset, magma_int_t ldb,
    double beta,  magmaDouble_ptr       dC, size_t dC_offset, magma_int_t ldc,
    magma_int_t globaldAoffset,
    magma_queue_t queue );

magma_err_t
magma_dsymv(
    magma_uplo_t uplo,
    magma_int_t n,
    double alpha, magmaDouble_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaDouble_const_ptr dx, size_t dx_offset, magma_int_t incx,
    double beta,  magmaDouble_ptr       dy, size_t dy_offset, magma_int_t incy,
    magma_queue_t queue );

magma_err_t
magma_dsymv2(
    magma_uplo_t uplo,
    magma_int_t n,
    double alpha, magmaDouble_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaDouble_const_ptr dx, size_t dx_offset, magma_int_t incx,
    double beta,  magmaDouble_ptr       dy, size_t dy_offset, magma_int_t incy,
    magma_queue_t queue );


magma_err_t
magma_dsyrk(
    magma_uplo_t uplo, magma_trans_t trans,
    magma_int_t n, magma_int_t k,
    double alpha, magmaDouble_const_ptr dA, size_t dA_offset, magma_int_t lda,
    double beta,  magmaDouble_ptr       dC, size_t dC_offset, magma_int_t ldc,
    magma_queue_t queue );

void magmablas_dsyrk_mmic2(                                                                                                                    
    char uplo, char trans, magma_int_t n, magma_int_t k,                                                                                
    double alpha, double *dA[], magma_int_t lda, magma_int_t aoff,                                                                             
    double beta,           double *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_dsyrk_mmic(                                                                                                                    
    magma_uplo_t uplo, magma_trans_t trans, magma_int_t n, magma_int_t k,                                                                                
    double alpha, magmaDouble_const_ptr dA, magma_int_t lda, magma_int_t dAoff,                                                                             
    double beta, magmaDouble_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_dsyr2k(
    magma_uplo_t uplo, magma_trans_t trans,
    magma_int_t n, magma_int_t k,
    double alpha, magmaDouble_const_ptr dA, size_t dA_offset, magma_int_t lda,
    magmaDouble_const_ptr dB, size_t dB_offset, magma_int_t ldb,
    double beta,  magmaDouble_ptr       dC, size_t dC_offset, magma_int_t ldc,
    magma_queue_t queue );

void magmablas_dsyr2k_mmic2(                                                                                                                    
    char uplo, char trans, magma_int_t n, magma_int_t k,                                                                                
    double alpha, double *dA[], magma_int_t lda, magma_int_t aoff,                                                                             
    double *dB[], magma_int_t ldb, magma_int_t boff,                                               
    double beta,           double *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_dsyr2k_mmic(
    magma_uplo_t uplo, magma_trans_t trans, magma_int_t n, magma_int_t k,                                                                                
    double alpha, magmaDouble_const_ptr dA, magma_int_t lda, magma_int_t dAoff,                                                                             
    magmaDouble_const_ptr dB, magma_int_t ldb, magma_int_t dBoff,                                               
    double beta,           magmaDouble_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_dtrsm(
    magma_side_t side, magma_uplo_t uplo, magma_trans_t trans, magma_diag_t diag,
    magma_int_t m, magma_int_t n,
    double alpha, magmaDouble_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaDouble_ptr       dB, size_t dB_offset, magma_int_t ldb,
    magma_queue_t queue );

magma_err_t
magma_dtrsv(
    magma_uplo_t uplo, magma_trans_t trans, magma_diag_t diag,
    magma_int_t n,
    magmaDouble_const_ptr dA, size_t dA_offset, magma_int_t lda,
    magmaDouble_ptr dx, size_t dx_offset, magma_int_t incx,
    magma_queue_t queue );

magma_err_t
magma_dtrmm(
    magma_side_t side, magma_uplo_t uplo, magma_trans_t trans, magma_diag_t diag,
    magma_int_t m, magma_int_t n,
    double alpha, magmaDouble_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaDouble_ptr       dB, size_t dB_offset, magma_int_t ldb,
    magma_queue_t queue );

magma_err_t
magma_dtrmv(
    magma_uplo_t uplo, magma_trans_t trans, magma_diag_t diag,
    magma_int_t n,
    magmaDouble_const_ptr dA, size_t dA_offset, magma_int_t lda,
    magmaDouble_ptr dx, size_t dx_offset, magma_int_t incx,
    magma_queue_t queue );



magma_err_t
magma_dlarfb( 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,
              magmaDouble_ptr dV, size_t dV_offset, magma_int_t ldv,
              magmaDouble_ptr dT, size_t dT_offset, magma_int_t ldt,
              magmaDouble_ptr dC, size_t dC_offset, magma_int_t ldc,
              magmaDouble_ptr dwork, size_t dwork_offset, magma_int_t ldwork,
              magma_queue_t queue);

magma_err_t
magma_dlarfb_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,
              magmaDouble_ptr dV, size_t dV_offset, magma_int_t ldv,
              magmaDouble_ptr dT, size_t dT_offset, magma_int_t ldt,
              magmaDouble_ptr dC, size_t dC_offset, magma_int_t ldc,
              magmaDouble_ptr dwork, size_t dwork_offset, magma_int_t ldwork,
              magmaDouble_ptr dworkvt, size_t dworkvt_offset, magma_int_t ldworkvt,
              magma_queue_t queue);

magma_err_t
magma_dlaset(magma_uplo_t uplo,
             magma_int_t m, magma_int_t n,
             double alpha, double beta,
             magmaDouble_ptr dA, size_t dA_offset, magma_int_t lda,
             magma_queue_t queue);

// ========================================
// BLAS functions -- combined for MIC
magma_err_t
magma_dtrsmgemm(
    magma_side_t side, magma_uplo_t uplo, magma_trans_t trans, magma_diag_t diag,
    magma_int_t tm, magma_int_t tn,
    double talpha, magmaDouble_const_ptr tdA, size_t tdA_offset, magma_int_t tlda,
                              magmaDouble_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,
    double alpha, magmaDouble_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaDouble_const_ptr dB, size_t dB_offset, magma_int_t ldb,
    double beta,  magmaDouble_ptr       dC, size_t dC_offset, magma_int_t ldc,
    magma_queue_t queue );

#ifdef __cplusplus
}
#endif

#endif        //  #ifndef MAGMA_BLAS_H
