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

#ifndef MAGMA_BLAS_S_H
#define MAGMA_BLAS_S_H

#include "magma_types.h"

#ifdef __cplusplus
extern "C" {
#endif

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

magma_err_t
magma_sgetmatrix(
    magma_int_t m, magma_int_t n,
    magmaFloat_const_ptr dA_src, size_t dA_offset, magma_int_t ldda,
    float*          hA_dst, size_t hA_offset, magma_int_t ldha,
    magma_queue_t queue );

magma_err_t
magma_ssetmatrix_async(
    magma_int_t m, magma_int_t n,
    float const* hA_src, size_t hA_offset, magma_int_t ldha,
    magmaFloat_ptr    dA_dst, size_t dA_offset, magma_int_t ldda,
    magma_queue_t queue, magma_event_t *event );

magma_err_t
magma_sgetmatrix_async(
    magma_int_t m, magma_int_t n,
    magmaFloat_const_ptr dA_src, size_t dA_offset, magma_int_t ldda,
    float*          hA_dst, size_t hA_offset, magma_int_t ldha,
    magma_queue_t queue, magma_event_t *event );

magma_err_t
magma_ssetintarray_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_sinplace_transpose(
//    magmaFloat_ptr dA, size_t dA_offset, int lda, int n,
//    magma_queue_t queue );

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

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

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

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

magma_err_t
magma_sswap(magma_int_t n, float *dA1T, magma_int_t lda1, float *dA2T, magma_int_t lda2, magma_queue_t queue);

magma_err_t
magma_slaswp(magma_int_t n, magmaFloat_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_scopy(
    magma_int_t n,
    magmaFloat_ptr dx, size_t dx_offset, magma_int_t incx,
    magmaFloat_ptr dy, size_t dy_offset, magma_int_t incy,
    magma_queue_t queue );

magma_err_t
magma_sgemm(
    magma_trans_t transA, magma_trans_t transB,
    magma_int_t m, magma_int_t n, magma_int_t k,
    float alpha, magmaFloat_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaFloat_const_ptr dB, size_t dB_offset, magma_int_t ldb,
    float beta,  magmaFloat_ptr       dC, size_t dC_offset, magma_int_t ldc,
    magma_queue_t queue );

magma_err_t
magma_sgemv(
    magma_trans_t transA,
    magma_int_t m, magma_int_t n,
    float alpha, magmaFloat_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaFloat_const_ptr dx, size_t dx_offset, magma_int_t incx,
    float beta,  magmaFloat_ptr       dy, size_t dy_offset, magma_int_t incy,
    magma_queue_t queue );

magma_err_t
magma_ssymm(
    magma_side_t side, magma_uplo_t uplo,
    magma_int_t m, magma_int_t n,
    float alpha, magmaFloat_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaFloat_const_ptr dB, size_t dB_offset, magma_int_t ldb,
    float beta,  magmaFloat_ptr       dC, size_t dC_offset, magma_int_t ldc,
    magma_queue_t queue );

magma_err_t
magma_ssymm_ours(
    magma_side_t side, magma_uplo_t uplo,
    magma_int_t m, magma_int_t n,
    float alpha, magmaFloat_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaFloat_const_ptr dB, size_t dB_offset, magma_int_t ldb,
    float beta,  magmaFloat_ptr       dC, size_t dC_offset, magma_int_t ldc,
    magma_int_t globaldAoffset,
    magma_queue_t queue );

magma_err_t
magma_ssymv(
    magma_uplo_t uplo,
    magma_int_t n,
    float alpha, magmaFloat_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaFloat_const_ptr dx, size_t dx_offset, magma_int_t incx,
    float beta,  magmaFloat_ptr       dy, size_t dy_offset, magma_int_t incy,
    magma_queue_t queue );

magma_err_t
magma_ssymv2(
    magma_uplo_t uplo,
    magma_int_t n,
    float alpha, magmaFloat_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaFloat_const_ptr dx, size_t dx_offset, magma_int_t incx,
    float beta,  magmaFloat_ptr       dy, size_t dy_offset, magma_int_t incy,
    magma_queue_t queue );


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

void magmablas_ssyrk_mmic2(                                                                                                                    
    char uplo, char trans, magma_int_t n, magma_int_t k,                                                                                
    float alpha, float *dA[], magma_int_t lda, magma_int_t aoff,                                                                             
    float beta,           float *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_ssyrk_mmic(                                                                                                                    
    magma_uplo_t uplo, magma_trans_t trans, magma_int_t n, magma_int_t k,                                                                                
    float alpha, magmaFloat_const_ptr dA, magma_int_t lda, magma_int_t dAoff,                                                                             
    float beta, magmaFloat_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_ssyr2k(
    magma_uplo_t uplo, magma_trans_t trans,
    magma_int_t n, magma_int_t k,
    float alpha, magmaFloat_const_ptr dA, size_t dA_offset, magma_int_t lda,
    magmaFloat_const_ptr dB, size_t dB_offset, magma_int_t ldb,
    float beta,  magmaFloat_ptr       dC, size_t dC_offset, magma_int_t ldc,
    magma_queue_t queue );

void magmablas_ssyr2k_mmic2(                                                                                                                    
    char uplo, char trans, magma_int_t n, magma_int_t k,                                                                                
    float alpha, float *dA[], magma_int_t lda, magma_int_t aoff,                                                                             
    float *dB[], magma_int_t ldb, magma_int_t boff,                                               
    float beta,           float *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_ssyr2k_mmic(
    magma_uplo_t uplo, magma_trans_t trans, magma_int_t n, magma_int_t k,                                                                                
    float alpha, magmaFloat_const_ptr dA, magma_int_t lda, magma_int_t dAoff,                                                                             
    magmaFloat_const_ptr dB, magma_int_t ldb, magma_int_t dBoff,                                               
    float beta,           magmaFloat_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_strsm(
    magma_side_t side, magma_uplo_t uplo, magma_trans_t trans, magma_diag_t diag,
    magma_int_t m, magma_int_t n,
    float alpha, magmaFloat_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaFloat_ptr       dB, size_t dB_offset, magma_int_t ldb,
    magma_queue_t queue );

magma_err_t
magma_strsv(
    magma_uplo_t uplo, magma_trans_t trans, magma_diag_t diag,
    magma_int_t n,
    magmaFloat_const_ptr dA, size_t dA_offset, magma_int_t lda,
    magmaFloat_ptr dx, size_t dx_offset, magma_int_t incx,
    magma_queue_t queue );

magma_err_t
magma_strmm(
    magma_side_t side, magma_uplo_t uplo, magma_trans_t trans, magma_diag_t diag,
    magma_int_t m, magma_int_t n,
    float alpha, magmaFloat_const_ptr dA, size_t dA_offset, magma_int_t lda,
                              magmaFloat_ptr       dB, size_t dB_offset, magma_int_t ldb,
    magma_queue_t queue );

magma_err_t
magma_strmv(
    magma_uplo_t uplo, magma_trans_t trans, magma_diag_t diag,
    magma_int_t n,
    magmaFloat_const_ptr dA, size_t dA_offset, magma_int_t lda,
    magmaFloat_ptr dx, size_t dx_offset, magma_int_t incx,
    magma_queue_t queue );



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

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

magma_err_t
magma_slaset(magma_uplo_t uplo,
             magma_int_t m, magma_int_t n,
             float alpha, float beta,
             magmaFloat_ptr dA, size_t dA_offset, magma_int_t lda,
             magma_queue_t queue);

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

#ifdef __cplusplus
}
#endif

#endif        //  #ifndef MAGMA_BLAS_H
