From 463ed852261da4d1dd1b859fa717a1d683306c9d Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Thu, 14 May 2020 18:15:23 -0700 Subject: feat: begun work on final blas level 2 --- sys/libmath/blas.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'sys/libmath/blas.c') diff --git a/sys/libmath/blas.c b/sys/libmath/blas.c index f5392c8..43b0e70 100644 --- a/sys/libmath/blas.c +++ b/sys/libmath/blas.c @@ -6,37 +6,44 @@ #include -#define LEN 2000000 -#define NIT 2000 -#define INC 2 +#define NCOL 2000 +#define NROW 2000 +#define NIT 2000 +#define INC 2 error main() { - int i, nit; - double *x, *y, res[2]; + int i, j, nit; + double *x, *y, *m, res[2]; clock_t t; double tprof[2] = { 0 }; rng·init(0); - x = malloc(sizeof(*x)*LEN); - y = malloc(sizeof(*x)*LEN); + x = malloc(sizeof(*x)*NCOL); + y = malloc(sizeof(*x)*NROW); + m = malloc(sizeof(*x)*NROW*NCOL); #define DO_0 t = clock(); \ - res[0] += blas·sumd(LEN/INC, x, INC); \ + blas·gerd(NROW/INC, NCOL/INC, 1.2, x, INC, y, INC, m, NCOL); \ + res[0] += m[0]; \ t = clock() - t; \ tprof[0] += 1000.*t/CLOCKS_PER_SEC; \ #define DO_1 t = clock(); \ - res[1] += cblas_dsum(LEN/INC, x, INC); \ + cblas_dger(CblasRowMajor, NROW/INC, NCOL/INC, 1.2, x, INC, y, INC, m, NCOL); \ + res[1] += m[0]; \ t = clock() - t; \ tprof[1] += 1000.*t/CLOCKS_PER_SEC; for (nit = 0; nit < NIT; nit++) { - for (i = 0; i < LEN; i++) { + for (i = 0; i < NROW; i++) { x[i] = rng·random(); y[i] = rng·random(); + for (j = 0; j < NCOL; j++) { + m[j + NCOL*i] = rng·random(); + } } switch (nit % 2) { -- cgit v1.2.1