text: /*
  
      Copyright (C) 2014, The University of Texas at Austin
  
      This file is part of libflame and is available under the 3-Clause
      BSD license, which can be found in the LICENSE file at the top-level
      directory, or at http://opensource.org/licenses/BSD-3-Clause
  
  */
  
  
  #include "FLAME.h"
  
  #define FLA_ALG_REFERENCE 0
  #define FLA_ALG_FRONT     1
  
  
  FLA_Error REF_Copy( FLA_Obj A, FLA_Obj B );
  void time_Copy(
                 int param_combo, int type, int nrepeats, int m, int n,
                 FLA_Obj A, FLA_Obj C, FLA_Obj C_ref,
                 double *dtime, double *diff, double *gflops );
  
  
  void time_Copy( 
                 int param_combo, int type, int nrepeats, int m, int n,
                 FLA_Obj A, FLA_Obj C, FLA_Obj C_ref,
                 double *dtime, double *diff, double *gflops )
  {
    int
      irep;
  
    double
      dtime_old = 1.0e9;
  
    FLA_Obj
      C_old, A_flat, C_flat;
  
    FLASH_Obj_create_conf_to( FLA_NO_TRANSPOSE, C, &C_old );
    FLASH_Obj_create_flat_conf_to_hier( FLA_NO_TRANSPOSE, A, &A_flat );
    FLASH_Obj_create_flat_conf_to_hier( FLA_NO_TRANSPOSE, C, &C_flat );
  
    FLASH_Copy( C, C_old );
  
    for ( irep = 0 ; irep < nrepeats; irep++ )
    {
      FLASH_Copy( C_old, C );
      FLASH_Obj_flatten( A, A_flat );
      FLASH_Obj_flatten( C, C_flat );
  
      *dtime = FLA_Clock();
  
      switch( param_combo ){
  
      // Time parameter combination 0
      case 0:{
        switch( type ){
        case FLA_ALG_REFERENCE:
          REF_Copy( A_flat, C_flat );
          break;
        case FLA_ALG_FRONT:
          FLASH_Copy( A, C );
          break;
        default:
          printf("trouble\n");
        }
  
        break;
      }
  
      }
  	
      *dtime = FLA_Clock() - *dtime;
      dtime_old = min( *dtime, dtime_old );
    }
  
  
    if ( type == FLA_ALG_REFERENCE )
    {
      FLASH_Obj_hierarchify( C_flat, C_ref );
      *diff = 0.0;
    }
    else
    {
      *diff = FLASH_Max_elemwise_diff( C, C_ref );
    }
  
    *gflops = 2.0 * m * n / 
              dtime_old / 
              1.0e9;
  
    *dtime = dtime_old;
  
    FLASH_Copy( C_old, C );
  
    FLASH_Obj_free( &C_old );
    FLASH_Obj_free( &A_flat );
    FLASH_Obj_free( &C_flat );
  }
  
  