SHARE
TWEET

Untitled

a guest Dec 8th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <time.h>
  4.  
  5. #include "FLAME.h"
  6.  
  7. /* Various constants that control what gets timed */
  8.  
  9. #define TRUE 1
  10. #define FALSE 0
  11.  
  12. void trmm_llnn_unb_var1( FLA_Obj, FLA_Obj );
  13.  
  14. int main(int argc, char *argv[])
  15. {
  16.   int n, nfirst, nlast, ninc, i, irep, nrepeats;
  17.  
  18.   double
  19.     dtime, dtime_best,
  20.     diff;
  21.  
  22.   dtime_best = 0.0;
  23.  
  24.   FLA_Obj
  25.     Lobj, Bobj, Bold, Bref, Cobj, Cold, Cref;
  26.  
  27.   /* Initialize FLAME. */
  28.   FLA_Init( );
  29.  
  30.  
  31.   //copy old into reference. in for loop, keep copying old into object so tests don't disrupt eachother
  32.   // more o tab
  33.   /* Every time trial is repeated "repeat" times and the fastest run in recorded */
  34.   printf( "%% number of repeats:" );
  35.   scanf( "%d", &nrepeats );
  36.   printf( "%% %d\n", nrepeats );
  37.  
  38.   /* Timing trials for matrix sizes n=nfirst to nlast in increments
  39.      of ninc will be performed. */
  40.   printf( "%% enter nfirst, nlast, ninc:" );
  41.   scanf( "%d%d%d", &nfirst, &nlast, &ninc );
  42.   printf( "%% %d %d %d \n", nfirst, nlast, ninc );
  43.   fflush( stdout );
  44.  
  45.   i = 1;
  46.   for ( n=nfirst; n<= nlast; n+=ninc ){
  47.  
  48.     /* Allocate space for the matrices and vectors */
  49.     FLA_Obj_create( FLA_DOUBLE, n, n, 1, n, &Lobj );
  50.     FLA_Obj_create( FLA_DOUBLE, n, n, 1, n, &Bobj );
  51.     FLA_Obj_create( FLA_DOUBLE, n, n, 1, n, &Bold );
  52.     FLA_Obj_create( FLA_DOUBLE, n, n, 1, n, &Bref );
  53.     FLA_Obj_create( FLA_DOUBLE, n, n, 1, n, &Cobj );
  54.     FLA_Obj_create( FLA_DOUBLE, n, n, 1, n, &Cold );
  55.     FLA_Obj_create( FLA_DOUBLE, n, n, 1, n, &Cref );
  56.  
  57.  
  58.     /* Generate random matrix A, and vectors x, and y */
  59.     FLA_Random_matrix( Lobj );
  60.     FLA_Random_matrix( Bold );
  61.     FLA_Random_tri_matrix( FLA_UPPER_TRIANGULAR , FLA_NONUNIT_DIAG, Cobj);
  62.     FLA_Random_tri_matrix( FLA_UPPER_TRIANGULAR , FLA_NONUNIT_DIAG, Cref);
  63.  
  64.  
  65.  
  66.  
  67.     for ( irep=0; irep<nrepeats; irep++ ) {
  68.     /* Time reference implementation (from libflame) */
  69.       FLA_Copy( Cold, Cref );
  70.    
  71.       /* start clock */
  72.       dtime = FLA_Clock();
  73.    
  74.       /* Compute Bref = L Bref where L is lower triangular stored in the
  75.      lower triangular part of array L, by calling FLA_Trmm.  The
  76.      result ends up in Bref, which we will consider to be the
  77.      correct result. */
  78.       FLA_Syr2k(FLA_UPPER_TRIANGULAR, FLA_NO_TRANSPOSE, FLA_ONE, Lobj, Bobj, FLA_ONE, Cref );
  79.          syr2k_un_blk(Lobj, Bobj, Cref, 1);
  80.      
  81.       /* stop clock */
  82.       dtime = FLA_Clock() - dtime;
  83.    
  84.       if ( irep == 0 )
  85.     dtime_best = dtime;
  86.       else
  87.     dtime_best = ( dtime < dtime_best ? dtime : dtime_best );
  88.     }
  89.  
  90.     printf( "data_ref( %d, 1:2 ) = [ %d %le ];\n", i, n, dtime_best );
  91.     fflush( stdout );
  92.  
  93.     /* Time your unblocked Variant 1 */
  94.  
  95.     for ( irep=0; irep<nrepeats; irep++ ){
  96.       /* Copy vector yold to y */
  97.       FLA_Copy( Cold, Cobj );
  98.    
  99.       /* start clock */
  100.       dtime = FLA_Clock();
  101.  
  102.       syr2k_un_blk_var1( Lobj, Bobj, Cobj );
  103.  
  104.  
  105.       /* stop clock */
  106.       dtime = FLA_Clock() - dtime;
  107.    
  108.       if ( irep == 0 )
  109.     dtime_best = dtime;
  110.       else
  111.     dtime_best = ( dtime < dtime_best ? dtime : dtime_best );
  112.     }
  113.  
  114.     diff = FLA_Max_elemwise_diff( Cobj, Cref );
  115.  
  116.     printf( "data_unb_var1( %d, 1:3 ) = [ %d %le %le];\n", i, n,
  117.         dtime_best, diff  );
  118.  
  119.     fflush( stdout );
  120.  
  121.     FLA_Obj_free( &Lobj );
  122.     FLA_Obj_free( &Bobj );
  123.     FLA_Obj_free( &Bref );
  124.     FLA_Obj_free( &Bold );
  125.     FLA_Obj_free( &Cold );
  126.     FLA_Obj_free( &Cref );
  127.     FLA_Obj_free( &Cobj );
  128.  
  129.     i++;
  130.   }
  131.   FLA_Finalize( );
  132.  
  133.   exit( 0 );
  134. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top