From 43ecfce7d20360a5fdc53e5ced266eccc8723242 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Fri, 29 May 2020 14:41:05 -0700 Subject: blas code update --- sys/libmath/blas.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'sys/libmath/blas.c') diff --git a/sys/libmath/blas.c b/sys/libmath/blas.c index 224480b..4c9e67b 100644 --- a/sys/libmath/blas.c +++ b/sys/libmath/blas.c @@ -6,38 +6,47 @@ #include -#define NCOL 20000 -#define NROW 20000 -#define NIT 2000 +#define NCOL 2*512 +#define NROW 2*512 +#define NSUM 2*512 +#define NIT 10 #define INC 1 error main() { int i, j, nit; - double *x, *y, res[2]; + double *x, *y, *z, *w, res[2]; clock_t t; double tprof[2] = { 0 }; rng·init(0); - x = malloc(sizeof(*x)*NCOL); - y = malloc(sizeof(*x)*NROW); + x = malloc(sizeof(*x)*NROW*NCOL); + y = malloc(sizeof(*x)*NROW*NCOL); + z = malloc(sizeof(*x)*NROW*NCOL); + w = malloc(sizeof(*x)*NROW*NCOL); #define DO_0 t = clock(); \ - res[0] += blas·dasum(NROW/INC, x, INC); \ + blas·dgemm(0,0,NROW,NCOL,NSUM,10.1,x,NROW,y,NROW,1.2,z,NROW);\ t = clock() - t; \ + res[0] += blas·dasum(NROW*NCOL,z,INC); \ tprof[0] += 1000.*t/CLOCKS_PER_SEC; \ #define DO_1 t = clock(); \ - res[1] += cblas_dasum(NROW/INC, x, INC); \ + cblas_dgemm(CblasRowMajor,CblasNoTrans,CblasNoTrans,NROW,NCOL,NSUM,10.1,x,NROW,y,NROW,1.2,w,NROW);\ t = clock() - t; \ + res[1] += cblas_dasum(NROW*NCOL,w,INC); \ tprof[1] += 1000.*t/CLOCKS_PER_SEC; for (nit = 0; nit < NIT; nit++) { for (i = 0; i < NROW; i++) { - x[i] = rng·random(); - y[i] = rng·random(); + for (j = 0; j < NCOL; j++) { + x[j + NROW*i] = rng·random(); + y[j + NROW*i] = rng·random(); + z[j + NROW*i] = rng·random(); + w[j + NROW*i] = z[j + NROW*i]; + } } switch (nit % 2) { -- cgit v1.2.1