Statistics
| Branch: | Revision:

root / synthbench / euroben-ports / base / C / mod2am / mod2am.c @ 0:839f52ef7657

History | View | Annotate | Download (1.2 kB)

1 0:839f52ef7657 louridas
#include <stdio.h>
2 0:839f52ef7657 louridas
#include <stdlib.h>
3 0:839f52ef7657 louridas
4 0:839f52ef7657 louridas
double cclock( void );
5 0:839f52ef7657 louridas
int    check( int m, int l, int n, double *c );
6 0:839f52ef7657 louridas
void   gendat( int, int, int, int, double *a, double *b );
7 0:839f52ef7657 louridas
void   mvm( int, int, int, int, double *a, double *b, double *c );
8 0:839f52ef7657 louridas
void   prthead( void );
9 0:839f52ef7657 louridas
void   prtspeed( int, int, int, double, int, int );
10 0:839f52ef7657 louridas
void   state( char * );
11 0:839f52ef7657 louridas
12 0:839f52ef7657 louridas
int main()
13 0:839f52ef7657 louridas
{
14 0:839f52ef7657 louridas
   int      lda, m, l, n;
15 0:839f52ef7657 louridas
   int      ok, nops, nrep;
16 0:839f52ef7657 louridas
   int      i;
17 0:839f52ef7657 louridas
   double   *a, *b, *c;
18 0:839f52ef7657 louridas
   double   time;
19 0:839f52ef7657 louridas
   FILE     *inl;
20 0:839f52ef7657 louridas
// ------------------------------------------------------------------------
21 0:839f52ef7657 louridas
   state( "mod2a" );
22 0:839f52ef7657 louridas
   prthead();
23 0:839f52ef7657 louridas
   inl = fopen( "mod2am.in", "r" );
24 0:839f52ef7657 louridas
   while( ( fscanf( inl, "%d%d%d%d\n", &m, &l, &n, &nrep ) != EOF ) ){
25 0:839f52ef7657 louridas
      lda = l + 1;
26 0:839f52ef7657 louridas
      a = calloc( m*lda, sizeof( double ) );
27 0:839f52ef7657 louridas
      b = calloc( l*n, sizeof( double ) );
28 0:839f52ef7657 louridas
      c = calloc( m*n, sizeof( double ) );
29 0:839f52ef7657 louridas
      gendat( lda, m, l, n, a, b );
30 0:839f52ef7657 louridas
      time = cclock();
31 0:839f52ef7657 louridas
      for( i = 0; i < nrep; i++ ){
32 0:839f52ef7657 louridas
         mxm( lda, m, l, n, a, b, c );
33 0:839f52ef7657 louridas
      }
34 0:839f52ef7657 louridas
      time = cclock() - time;
35 0:839f52ef7657 louridas
      ok   = check( m, l, n, c );
36 0:839f52ef7657 louridas
      time = time/nrep;
37 0:839f52ef7657 louridas
      nops  = 2*m*l*n;
38 0:839f52ef7657 louridas
      prtspeed( m, l, n, time, ok, nops );
39 0:839f52ef7657 louridas
      free( a ); free( b ); free( c);
40 0:839f52ef7657 louridas
   }
41 0:839f52ef7657 louridas
   printf( "-------------------------------------------------\n" );
42 0:839f52ef7657 louridas
}