/*
 *   -- micMAGMA (version 0.1) --
 *      Univ. of Tennessee, Knoxville
 *      Univ. of California, Berkeley
 *      Univ. of Colorado, Denver
 *      April 2012
 *
 *   @author Azzam Haidar
 *   @author Khairul Kabir 
 *
 *   @generated c Fri Nov 22 14:21:24 2013
 */

case magma_mic_CCOPY:
{
    //printf("copy\n");
    magma_mic_ccopy_param ccopy_param;

    if (mic_recv(&ccopy_param, sizeof(ccopy_param)) == MIC_FAILURE) {
        printf("scif_recv failed for CCOPY\n");
        return;
    }

    mic_time = dsecnd();
    call_ccopy(ccopy_param);
    mic_time = dsecnd() - mic_time;

    break;
}


case magma_mic_CGEMM:
{
    //printf("gemm\n");
    magma_mic_cgemm_param cgemm_param;

    if (mic_recv(&cgemm_param, sizeof(cgemm_param)) == MIC_FAILURE) {
        printf("scif_recv failed for CGEMM\n");
        return;
    }

    mic_time = dsecnd();
    call_cgemm(cgemm_param);
    mic_time = dsecnd() - mic_time;

    m = cgemm_param.m;
    n = cgemm_param.n;
    k = cgemm_param.k;
    gflops = MICFLOPS_GEMM((float)m, (float)n, (float)k) * 1e-9;
    //printf("cgemm: %d\t%d\t%d\t%8.2lf\t%8.2lf\t%8.2lf\n", m, n, k, mic_time, gflops, gflops/mic_time);
    break;
}

case magma_mic_CHEMM:
{
    //printf("hemm\n");                                                                                                          
    magma_mic_chemm_param chemm_param;

    if (mic_recv(&chemm_param, sizeof(chemm_param)) == MIC_FAILURE) {
        printf("scif_recv failed for CHEMM\n");
        return;
    }

    mic_time = dsecnd();
    call_chemm(chemm_param);
    mic_time = dsecnd() - mic_time;

    m = chemm_param.m;
    n = chemm_param.n;
    magma_side_t side = chemm_param.side;

    //gflops = MICFLOPS_SYMM((magma_side_t)side, (float)m, (float)n ) * 1e-9;
    //printf("chemm: %d\t%d\t%g\t%g\t%g\n", m, n, mic_time,gflops, gflops/mic_time);
    break;
}

case magma_mic_CGEMV:
{
    //printf("gemv\n");
    magma_mic_cgemv_param cgemv_param;

    if (mic_recv(&cgemv_param, sizeof(cgemv_param)) == MIC_FAILURE) {
        printf("scif_recv failed for CGEMV\n");
        return;
    }

    mic_time = dsecnd();
    call_cgemv(cgemv_param);
    mic_time = dsecnd() - mic_time;

    m = cgemv_param.m;
    n = cgemv_param.n;
    //gflops = MICFLOPS_GEMV((float)m, (float)n) * 1e-9;
    //printf("cgemv: %d\t%d\t%g\t%g\t%g\n", m, n, mic_time,
    //        gflops, gflops/mic_time);
    break;
}

case magma_mic_CHEMV:
{
    //printf("hemv\n");
    magma_mic_chemv_param hemv_param;

    if (mic_recv(&hemv_param, sizeof(hemv_param)) == MIC_FAILURE) {
        printf("scif_recv failed for CHEMV\n");
        return;
    }

    mic_time = dsecnd();
    call_chemv(hemv_param);
    mic_time = dsecnd() - mic_time;

    break;
}

case magma_mic_CSYMV2:
{
    //printf("symv2\n");
    magma_mic_csymv2_param symv_param;

    if (mic_recv(&symv_param, sizeof(symv_param)) == MIC_FAILURE) {
        printf("scif_recv failed for CHEMV\n");
        return;
    }

    mic_time = dsecnd();
    call_csymv2(symv_param);
    mic_time = dsecnd() - mic_time;

    break;
}

case magma_mic_CTRSM:
{
    //printf("ctrsm\n");                                                                                                                                                                                                                          
    magma_mic_ctrsm_param ctrsm_param;
    if (mic_recv(&ctrsm_param, sizeof(ctrsm_param)) == MIC_FAILURE) {
        printf("scif_recv failed for CTRSM\n");
        return;
    }

    mic_time = dsecnd();
    call_ctrsm(ctrsm_param);
    mic_time = dsecnd() - mic_time;

    side = ctrsm_param.side;
    m = ctrsm_param.m;
    n = ctrsm_param.n;

    if(side == MagmaLeft)
        gflops = MICFLOPS_TRSM_L((float)m, (float)n) * 1e-9;
    else
        gflops = MICFLOPS_TRSM_R((float)m, (float)n) * 1e-9;

    //printf("ctrsm: %c\t%d\t%d\t%f\t%f\t%f\n", side, m, n, mic_time,
    //     gflops, gflops/mic_time);
    break;
}

case magma_mic_CTRSV:
{
   //printf("ctrsv\n");

   magma_mic_ctrsv_param ctrsv_param;
   if (mic_recv(&ctrsv_param, sizeof(ctrsv_param)) == MIC_FAILURE) {
     printf("scif_recv failed for CTRSV\n");
     return;
   }

   mic_time = dsecnd();
   call_ctrsv(ctrsv_param);
   mic_time = dsecnd() - mic_time;

   break;
}

case magma_mic_CTRMV:
{
   //printf("ctrmv\n");

   magma_mic_ctrmv_param trmv_param;
   if (mic_recv(&trmv_param, sizeof(trmv_param)) == MIC_FAILURE) {
     printf("scif_recv failed for CTRMV\n");
     return;
   }

   mic_time = dsecnd();
   call_ctrmv(trmv_param);
   mic_time = dsecnd() - mic_time;

   break;
}

case magma_mic_CTRMM:
{
    //printf("ctrmm\n");
    magma_mic_ctrmm_param ctrmm_param;
    if (mic_recv(&ctrmm_param, sizeof(ctrmm_param)) == MIC_FAILURE) {
        printf("scif_recv failed for CTRMM\n");
        return;
    }

    mic_time = dsecnd();
    call_ctrmm(ctrmm_param);
    mic_time = dsecnd() - mic_time;

    side = ctrmm_param.side;
    m = ctrmm_param.m;
    n = ctrmm_param.n;

    //if(side == 'L')
    //    gflops = MICFLOPS_TRSM_L((float)m, (float)n) * 1e-9;
    //else
    //    gflops = MICFLOPS_TRSM_R((float)m, (float)n) * 1e-9;

    //printf("ctrmm: %c\t%d\t%d\t%f\t%f\t%f\n", side, m, n, mic_time, gflops, gflops/mic_time);
    break;
}

case magma_mic_CHERK:
{
    //printf("cherk\n");
    magma_mic_cherk_param cherk_param;
    if (mic_recv(&cherk_param, sizeof(cherk_param)) == MIC_FAILURE) {
        printf("scif_recv failed for CHERK\n");
        return;
    }

    mic_time = dsecnd();
    call_cherk(cherk_param);
    mic_time = dsecnd() - mic_time;

    n = cherk_param.n;
    k = cherk_param.k;
    //gflops = MICFLOPS_SYRK((float)n, (float)k) * 1e-9;
    //printf("cherk: %d\t%d\t%f\t%f\t%f\n", n, k, mic_time, gflops, gflops/mic_time);
    break;
}

case magma_mic_CHERK_MMIC:
{
    //printf("cherk\n");
    magma_mic_cherk_mmic_param cherk_mmic_param;
    if (mic_recv(&cherk_mmic_param, sizeof(cherk_mmic_param)) == MIC_FAILURE) {
        printf("scif_recv failed for CHERK_MMIC\n");
        return;
    }

    mic_time = dsecnd();
    call_cherk_mmic(cherk_mmic_param);
    mic_time = dsecnd() - mic_time;

    n = cherk_mmic_param.n;
    k = cherk_mmic_param.k;
    //gflops = MICFLOPS_SYRK((float)n, (float)k) * 1e-9;
    //printf("cherk: %d\t%d\t%f\t%f\t%f\n", n, k, mic_time, gflops, gflops/mic_time);
    break;
}


case magma_mic_CHER2K:
{
    //printf("cher2k\n");
    magma_mic_cher2k_param cher2k_param;
    if (mic_recv(&cher2k_param, sizeof(cher2k_param)) == MIC_FAILURE) {
        printf("scif_recv failed for CHER2K\n");
        return;
    }

    mic_time = dsecnd();
    call_cher2k(cher2k_param);
    mic_time = dsecnd() - mic_time;

    n = cher2k_param.n;
    k = cher2k_param.k;
    //gflops = MICFLOPS_SYR2K((float)n, (float)k) * 1e-9;
    //printf("cher2k: %d\t%d\t%f\t%f\t%f\n", n, k, mic_time, gflops, gflops/mic_time);
    break;
}

case magma_mic_CHER2K_MMIC:
{
    //printf("cher2k_mmic\n");
    magma_mic_cher2k_mmic_param cher2k_mmic_param;
    if (mic_recv(&cher2k_mmic_param, sizeof(cher2k_mmic_param)) == MIC_FAILURE) {
        printf("scif_recv failed for CHER2K_MMIC\n");
        return;
    }

    //mic_time = dsecnd();
    call_cher2k_mmic(cher2k_mmic_param);
    //mic_time = dsecnd() - mic_time;

    n = cher2k_mmic_param.n;
    k = cher2k_mmic_param.k;
    //gflops = MICFLOPS_SYRK((float)n, (float)k) * 1e-9;
    //printf("cherk: %d\t%d\t%f\t%f\t%f\n", n, k, mic_time, gflops, gflops/mic_time);
    break;
}

case magma_mic_CLARFT:
{
    //printf("clarft\n");                                                                                                                                                                                                                         
    magma_mic_clarft_param clarft_param;
    if (mic_recv(&clarft_param, sizeof(clarft_param)) == MIC_FAILURE) {
        printf("scif_recv failed for CLARFT\n");
        return;
    }

    //mic_time = dsecnd();
    call_clarft(clarft_param);
    //mic_time = dsecnd() - mic_time;

    //gflops = MICFLOPS_GEMM((float)m, (float)n, (float)k) * 1e-9;
    //printf("clarft: %d\t%d\t%d\t%f\t%f\t%f\n", m, n, k, mic_time,                                                                                                                                                                               
    //     gflops, gflops/mic_time);                                                                                                                                                                                                            
    break;
}

case magma_mic_CLARFB:
{
    //printf("clarfb\n");                                                                                                                                                                                                                         
    magma_mic_clarfb_param clarfb_param;
    if (mic_recv(&clarfb_param, sizeof(clarfb_param)) == MIC_FAILURE) {
        printf("scif_recv failed for CLARFB\n");
        return;
    }

    //mic_time = dsecnd();
    call_clarfb(clarfb_param);
    //mic_time = dsecnd();

    //gflops = MICFLOPS_GEMM((float)m, (float)n, (float)k) * 1e-9;
    //printf("clarfb: %d\t%d\t%d\t%f\t%f\t%f\n", m, n, k, mic_time,                                                                                                                                                                               
    //     gflops, gflops/mic_time);                                                                                                                                                                                                            
    break;
}

case magma_mic_CLARFB_GEMM:
{
    //printf("dlarfb\n");
    

    magma_mic_clarfb_gemm_param clarfb_gemm_param;
    if (mic_recv(&clarfb_gemm_param, sizeof(clarfb_gemm_param)) == MIC_FAILURE) {
        printf("scif_recv failed for CLARFB_GEMM\n");
        return;
    }

    //mic_time = dsecnd();
    call_clarfb_gemm(clarfb_gemm_param);
    //mic_time = dsecnd();

    //gflops = MICFLOPS_GEMM((float)m, (float)n, (float)k) * 1e-9;
    //printf("slarfb: %d\t%d\t%d\t%f\t%f\t%f\n", m, n, k, mic_time,
    //     gflops, gflops/mic_time);
    break;
}

case magma_mic_CTRSM_GEMM:
{
    //printf("ctrsmgemm\n");
    magma_mic_ctrsmgemm_param ctrsmgemm_param;
    magma_mic_cgemm_param cgemm_param;
    magma_mic_ctrsm_param ctrsm_param;

    if (mic_recv(&ctrsmgemm_param, sizeof(ctrsmgemm_param)) == MIC_FAILURE) {
        printf("scif_recv failed for CTRSM_GEMM\n");
        return;
    }

    mic_time = dsecnd();
    call_ctrsmgemm(ctrsmgemm_param);
    mic_time = dsecnd() - mic_time;

    break;
}    

case magma_mic_CLASET:
{
    magma_mic_claset_param claset_param;
    if (mic_recv(&claset_param, sizeof(claset_param)) == MIC_FAILURE) {
      printf("scif_recv failed for CLASET\n");
      return;
    }

    call_claset(claset_param);

    break;
}

case magma_mic_CLASWP:
{
    magma_mic_claswp_param claswp_param;
    if (mic_recv(&claswp_param, sizeof(claswp_param)) == MIC_FAILURE) {
        printf("scif_recv failed for CLASWP\n");
        return;
    }

    call_claswp(claswp_param);

    break;
}

case magma_mic_CSWAP:
{
    magma_mic_cswap_param cswap_param;
    if (mic_recv(&cswap_param, sizeof(cswap_param)) == MIC_FAILURE) {
        printf("scif_recv failed for CSWAP\n");
        return;
    }

    call_cswap(cswap_param);

    break;
}

case magma_mic_CTRANSPOSE:
{
    magma_mic_ctranspose_param ctranspose_param;
    if (mic_recv(&ctranspose_param, sizeof(ctranspose_param)) == MIC_FAILURE) {
        printf("scif_recv failed for CTRANSPOSE\n");
        return;
    }

    call_ctranspose(ctranspose_param);

    break;
}
