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

case magma_mic_SCOPY:
{
    //printf("copy\n");
    magma_mic_scopy_param scopy_param;

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

    mic_time = dsecnd();
    call_scopy(scopy_param);
    mic_time = dsecnd() - mic_time;

    break;
}


case magma_mic_SGEMM:
{
    //printf("gemm\n");
    magma_mic_sgemm_param sgemm_param;

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

    mic_time = dsecnd();
    call_sgemm(sgemm_param);
    mic_time = dsecnd() - mic_time;

    m = sgemm_param.m;
    n = sgemm_param.n;
    k = sgemm_param.k;
    gflops = MICFLOPS_GEMM((float)m, (float)n, (float)k) * 1e-9;
    //printf("sgemm: %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_SSYMM:
{
    //printf("symm\n");                                                                                                          
    magma_mic_ssymm_param ssymm_param;

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

    mic_time = dsecnd();
    call_ssymm(ssymm_param);
    mic_time = dsecnd() - mic_time;

    m = ssymm_param.m;
    n = ssymm_param.n;
    magma_side_t side = ssymm_param.side;

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

case magma_mic_SGEMV:
{
    //printf("gemv\n");
    magma_mic_sgemv_param sgemv_param;

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

    mic_time = dsecnd();
    call_sgemv(sgemv_param);
    mic_time = dsecnd() - mic_time;

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

case magma_mic_SSYMV:
{
    //printf("symv\n");
    magma_mic_ssymv_param symv_param;

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

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

    break;
}

case magma_mic_SSYMV2:
{
    //printf("symv2\n");
    magma_mic_ssymv2_param symv_param;

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

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

    break;
}

case magma_mic_STRSM:
{
    //printf("strsm\n");                                                                                                                                                                                                                          
    magma_mic_strsm_param strsm_param;
    if (mic_recv(&strsm_param, sizeof(strsm_param)) == MIC_FAILURE) {
        printf("scif_recv failed for STRSM\n");
        return;
    }

    mic_time = dsecnd();
    call_strsm(strsm_param);
    mic_time = dsecnd() - mic_time;

    side = strsm_param.side;
    m = strsm_param.m;
    n = strsm_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("strsm: %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_STRSV:
{
   //printf("strsv\n");

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

   mic_time = dsecnd();
   call_strsv(strsv_param);
   mic_time = dsecnd() - mic_time;

   break;
}

case magma_mic_STRMV:
{
   //printf("strmv\n");

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

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

   break;
}

case magma_mic_STRMM:
{
    //printf("strmm\n");
    magma_mic_strmm_param strmm_param;
    if (mic_recv(&strmm_param, sizeof(strmm_param)) == MIC_FAILURE) {
        printf("scif_recv failed for STRMM\n");
        return;
    }

    mic_time = dsecnd();
    call_strmm(strmm_param);
    mic_time = dsecnd() - mic_time;

    side = strmm_param.side;
    m = strmm_param.m;
    n = strmm_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("strmm: %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_SSYRK:
{
    //printf("ssyrk\n");
    magma_mic_ssyrk_param ssyrk_param;
    if (mic_recv(&ssyrk_param, sizeof(ssyrk_param)) == MIC_FAILURE) {
        printf("scif_recv failed for SSYRK\n");
        return;
    }

    mic_time = dsecnd();
    call_ssyrk(ssyrk_param);
    mic_time = dsecnd() - mic_time;

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

case magma_mic_SSYRK_MMIC:
{
    //printf("ssyrk\n");
    magma_mic_ssyrk_mmic_param ssyrk_mmic_param;
    if (mic_recv(&ssyrk_mmic_param, sizeof(ssyrk_mmic_param)) == MIC_FAILURE) {
        printf("scif_recv failed for SSYRK_MMIC\n");
        return;
    }

    mic_time = dsecnd();
    call_ssyrk_mmic(ssyrk_mmic_param);
    mic_time = dsecnd() - mic_time;

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


case magma_mic_SSYR2K:
{
    //printf("ssyr2k\n");
    magma_mic_ssyr2k_param ssyr2k_param;
    if (mic_recv(&ssyr2k_param, sizeof(ssyr2k_param)) == MIC_FAILURE) {
        printf("scif_recv failed for SSYR2K\n");
        return;
    }

    mic_time = dsecnd();
    call_ssyr2k(ssyr2k_param);
    mic_time = dsecnd() - mic_time;

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

case magma_mic_SSYR2K_MMIC:
{
    //printf("ssyr2k_mmic\n");
    magma_mic_ssyr2k_mmic_param ssyr2k_mmic_param;
    if (mic_recv(&ssyr2k_mmic_param, sizeof(ssyr2k_mmic_param)) == MIC_FAILURE) {
        printf("scif_recv failed for SSYR2K_MMIC\n");
        return;
    }

    //mic_time = dsecnd();
    call_ssyr2k_mmic(ssyr2k_mmic_param);
    //mic_time = dsecnd() - mic_time;

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

case magma_mic_SLARFT:
{
    //printf("slarft\n");                                                                                                                                                                                                                         
    magma_mic_slarft_param slarft_param;
    if (mic_recv(&slarft_param, sizeof(slarft_param)) == MIC_FAILURE) {
        printf("scif_recv failed for SLARFT\n");
        return;
    }

    //mic_time = dsecnd();
    call_slarft(slarft_param);
    //mic_time = dsecnd() - mic_time;

    //gflops = MICFLOPS_GEMM((float)m, (float)n, (float)k) * 1e-9;
    //printf("slarft: %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_SLARFB:
{
    //printf("slarfb\n");                                                                                                                                                                                                                         
    magma_mic_slarfb_param slarfb_param;
    if (mic_recv(&slarfb_param, sizeof(slarfb_param)) == MIC_FAILURE) {
        printf("scif_recv failed for SLARFB\n");
        return;
    }

    //mic_time = dsecnd();
    call_slarfb(slarfb_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_SLARFB_GEMM:
{
    //printf("dlarfb\n");
    

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

    //mic_time = dsecnd();
    call_slarfb_gemm(slarfb_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_STRSM_GEMM:
{
    //printf("strsmgemm\n");
    magma_mic_strsmgemm_param strsmgemm_param;
    magma_mic_sgemm_param sgemm_param;
    magma_mic_strsm_param strsm_param;

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

    mic_time = dsecnd();
    call_strsmgemm(strsmgemm_param);
    mic_time = dsecnd() - mic_time;

    break;
}    

case magma_mic_SLASET:
{
    magma_mic_slaset_param slaset_param;
    if (mic_recv(&slaset_param, sizeof(slaset_param)) == MIC_FAILURE) {
      printf("scif_recv failed for SLASET\n");
      return;
    }

    call_slaset(slaset_param);

    break;
}

case magma_mic_SLASWP:
{
    magma_mic_slaswp_param slaswp_param;
    if (mic_recv(&slaswp_param, sizeof(slaswp_param)) == MIC_FAILURE) {
        printf("scif_recv failed for SLASWP\n");
        return;
    }

    call_slaswp(slaswp_param);

    break;
}

case magma_mic_SSWAP:
{
    magma_mic_sswap_param sswap_param;
    if (mic_recv(&sswap_param, sizeof(sswap_param)) == MIC_FAILURE) {
        printf("scif_recv failed for SSWAP\n");
        return;
    }

    call_sswap(sswap_param);

    break;
}

case magma_mic_STRANSPOSE:
{
    magma_mic_stranspose_param stranspose_param;
    if (mic_recv(&stranspose_param, sizeof(stranspose_param)) == MIC_FAILURE) {
        printf("scif_recv failed for STRANSPOSE\n");
        return;
    }

    call_stranspose(stranspose_param);

    break;
}
