Hi,

Many thanks for interested in.
I used following program to major the FLOPS. I'll provide more in details.
you many need <blas.h> but you can change dgemm_f77 to something else to link
agianst GotoBLAS (ports/math/gotoblas). I think you can use math/atlas but
it takes too long time to compile...
---
#include <complex>
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
#include <sys/resource.h>

#define F77_FUNC(name,NAME) name ## _ 
#include <blas.h>

#define MAXLOOP 10

unsigned long long microseconds()
{
    rusage  t;
    timeval tv;
    getrusage( RUSAGE_SELF, &t );
    tv = t.ru_utime;
    return ((unsigned long long)tv.tv_sec)*1000000 + tv.tv_usec;
}

double gettimeofday_sec()
{
    struct timeval tv;
    gettimeofday(&tv, NULL);
    return tv.tv_sec + (double)tv.tv_usec*1e-6;
}

int
main()
{
    int n;
    int incx = 1, incy = 1;
    double alpha = 3.14, beta = 2.717;
    double dgemmtime, t1, t2, t_1, t_2;

     for (n = 3000 ; n < 10000; n=n+100) {
        printf("n: %d\n", (int)n);
        double *A = new double[n*n];
        double *B = new double[n*n];
        double *C = new double[n*n];
        for (int i = 0; i < n; i++) {
          for (int j = 0; j < n; j++) {
            A[i*n+j] = i * j + 1;
            B[i*n+j] = (i+1) * (j+1) + 1;
            C[i*n+j] = (i+1) - (j+1) + 1;
          }
        }
    t1 = (double)microseconds(); t_1 = gettimeofday_sec();
      for (int p = 0 ; p < MAXLOOP; p++ ){
           dgemm_f77("n", "n", &n, &n, &n, &alpha, A, &n, B, &n, &beta, C, &n);
      }
    t2 = (double)microseconds(); t_2 = gettimeofday_sec();
 //     dgemmtime = (t2 - t1) * 1e-6;
        dgemmtime = (t_2 - t_1);
        printf("time : %lf or %lf \n", (t2 - t1) * 1e-6, t_2 - t_1);
        printf("Mflops : %lf\n", ( 2.0 * (double)n * (double)n * (double)n + 
2.0 * (double)n* (double)n )* MAXLOOP / dgemmtime / (1000*1000) );
        delete[]C;
        delete[]B;
        delete[]A;
    }
}


-- Nakata Maho http://accc.riken.jp/maho/ , http://ja.openoffice.org/ 
   Nakata Maho's PGP public keys: http://accc.riken.jp/maho/maho.pgp.txt
_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscr...@freebsd.org"

Reply via email to