/*
 *   -- 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 d Fri Nov 22 14:21:24 2013
 */

case magma_mic_DCOPY:
{
    //printf("copy\n");
    magma_mic_dcopy_param dcopy_param;

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

    mic_time = dsecnd();
    call_dcopy(dcopy_param);
    mic_time = dsecnd() - mic_time;

    break;
}


case magma_mic_DGEMM:
{
    //printf("gemm\n");
    magma_mic_dgemm_param dgemm_param;

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

    mic_time = dsecnd();
    call_dgemm(dgemm_param);
    mic_time = dsecnd() - mic_time;

    m = dgemm_param.m;
    n = dgemm_param.n;
    k = dgemm_param.k;
    gflops = MICFLOPS_GEMM((double)m, (double)n, (double)k) * 1e-9;
    //printf("dgemm: %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_DSYMM:
{
    //printf("symm\n");                                                                                                          
    magma_mic_dsymm_param dsymm_param;

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

    mic_time = dsecnd();
    call_dsymm(dsymm_param);
    mic_time = dsecnd() - mic_time;

    m = dsymm_param.m;
    n = dsymm_param.n;
    magma_side_t side = dsymm_param.side;

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

case magma_mic_DGEMV:
{
    //printf("gemv\n");
    magma_mic_dgemv_param dgemv_param;

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

    mic_time = dsecnd();
    call_dgemv(dgemv_param);
    mic_time = dsecnd() - mic_time;

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

case magma_mic_DSYMV:
{
    //printf("symv\n");
    magma_mic_dsymv_param symv_param;

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

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

    break;
}

case magma_mic_DSYMV2:
{
    //printf("symv2\n");
    magma_mic_dsymv2_param symv_param;

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

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

    break;
}

case magma_mic_DTRSM:
{
    //printf("dtrsm\n");                                                                                                                                                                                                                          
    magma_mic_dtrsm_param dtrsm_param;
    if (mic_recv(&dtrsm_param, sizeof(dtrsm_param)) == MIC_FAILURE) {
        printf("scif_recv failed for DTRSM\n");
        return;
    }

    mic_time = dsecnd();
    call_dtrsm(dtrsm_param);
    mic_time = dsecnd() - mic_time;

    side = dtrsm_param.side;
    m = dtrsm_param.m;
    n = dtrsm_param.n;

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

    //printf("dtrsm: %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_DTRSV:
{
   //printf("dtrsv\n");

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

   mic_time = dsecnd();
   call_dtrsv(dtrsv_param);
   mic_time = dsecnd() - mic_time;

   break;
}

case magma_mic_DTRMV:
{
   //printf("dtrmv\n");

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

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

   break;
}

case magma_mic_DTRMM:
{
    //printf("dtrmm\n");
    magma_mic_dtrmm_param dtrmm_param;
    if (mic_recv(&dtrmm_param, sizeof(dtrmm_param)) == MIC_FAILURE) {
        printf("scif_recv failed for DTRMM\n");
        return;
    }

    mic_time = dsecnd();
    call_dtrmm(dtrmm_param);
    mic_time = dsecnd() - mic_time;

    side = dtrmm_param.side;
    m = dtrmm_param.m;
    n = dtrmm_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("dtrmm: %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_DSYRK:
{
    //printf("dsyrk\n");
    magma_mic_dsyrk_param dsyrk_param;
    if (mic_recv(&dsyrk_param, sizeof(dsyrk_param)) == MIC_FAILURE) {
        printf("scif_recv failed for DSYRK\n");
        return;
    }

    mic_time = dsecnd();
    call_dsyrk(dsyrk_param);
    mic_time = dsecnd() - mic_time;

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

case magma_mic_DSYRK_MMIC:
{
    //printf("dsyrk\n");
    magma_mic_dsyrk_mmic_param dsyrk_mmic_param;
    if (mic_recv(&dsyrk_mmic_param, sizeof(dsyrk_mmic_param)) == MIC_FAILURE) {
        printf("scif_recv failed for DSYRK_MMIC\n");
        return;
    }

    mic_time = dsecnd();
    call_dsyrk_mmic(dsyrk_mmic_param);
    mic_time = dsecnd() - mic_time;

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


case magma_mic_DSYR2K:
{
    //printf("dsyr2k\n");
    magma_mic_dsyr2k_param dsyr2k_param;
    if (mic_recv(&dsyr2k_param, sizeof(dsyr2k_param)) == MIC_FAILURE) {
        printf("scif_recv failed for DSYR2K\n");
        return;
    }

    mic_time = dsecnd();
    call_dsyr2k(dsyr2k_param);
    mic_time = dsecnd() - mic_time;

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

case magma_mic_DSYR2K_MMIC:
{
    //printf("dsyr2k_mmic\n");
    magma_mic_dsyr2k_mmic_param dsyr2k_mmic_param;
    if (mic_recv(&dsyr2k_mmic_param, sizeof(dsyr2k_mmic_param)) == MIC_FAILURE) {
        printf("scif_recv failed for DSYR2K_MMIC\n");
        return;
    }

    //mic_time = dsecnd();
    call_dsyr2k_mmic(dsyr2k_mmic_param);
    //mic_time = dsecnd() - mic_time;

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

case magma_mic_DLARFT:
{
    //printf("dlarft\n");                                                                                                                                                                                                                         
    magma_mic_dlarft_param dlarft_param;
    if (mic_recv(&dlarft_param, sizeof(dlarft_param)) == MIC_FAILURE) {
        printf("scif_recv failed for DLARFT\n");
        return;
    }

    //mic_time = dsecnd();
    call_dlarft(dlarft_param);
    //mic_time = dsecnd() - mic_time;

    //gflops = MICFLOPS_GEMM((float)m, (float)n, (float)k) * 1e-9;
    //printf("dlarft: %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_DLARFB:
{
    //printf("dlarfb\n");                                                                                                                                                                                                                         
    magma_mic_dlarfb_param dlarfb_param;
    if (mic_recv(&dlarfb_param, sizeof(dlarfb_param)) == MIC_FAILURE) {
        printf("scif_recv failed for DLARFB\n");
        return;
    }

    //mic_time = dsecnd();
    call_dlarfb(dlarfb_param);
    //mic_time = dsecnd();

    //gflops = MICFLOPS_GEMM((float)m, (float)n, (float)k) * 1e-9;
    //printf("dlarfb: %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_DLARFB_GEMM:
{
    //printf("dlarfb\n");
    

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

    //mic_time = dsecnd();
    call_dlarfb_gemm(dlarfb_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_DTRSM_GEMM:
{
    //printf("dtrsmgemm\n");
    magma_mic_dtrsmgemm_param dtrsmgemm_param;
    magma_mic_dgemm_param dgemm_param;
    magma_mic_dtrsm_param dtrsm_param;

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

    mic_time = dsecnd();
    call_dtrsmgemm(dtrsmgemm_param);
    mic_time = dsecnd() - mic_time;

    break;
}    

case magma_mic_DLASET:
{
    magma_mic_dlaset_param dlaset_param;
    if (mic_recv(&dlaset_param, sizeof(dlaset_param)) == MIC_FAILURE) {
      printf("scif_recv failed for DLASET\n");
      return;
    }

    call_dlaset(dlaset_param);

    break;
}

case magma_mic_DLASWP:
{
    magma_mic_dlaswp_param dlaswp_param;
    if (mic_recv(&dlaswp_param, sizeof(dlaswp_param)) == MIC_FAILURE) {
        printf("scif_recv failed for DLASWP\n");
        return;
    }

    call_dlaswp(dlaswp_param);

    break;
}

case magma_mic_DSWAP:
{
    magma_mic_dswap_param dswap_param;
    if (mic_recv(&dswap_param, sizeof(dswap_param)) == MIC_FAILURE) {
        printf("scif_recv failed for DSWAP\n");
        return;
    }

    call_dswap(dswap_param);

    break;
}

case magma_mic_DTRANSPOSE:
{
    magma_mic_dtranspose_param dtranspose_param;
    if (mic_recv(&dtranspose_param, sizeof(dtranspose_param)) == MIC_FAILURE) {
        printf("scif_recv failed for DTRANSPOSE\n");
        return;
    }

    call_dtranspose(dtranspose_param);

    break;
}
