aboutsummaryrefslogtreecommitdiff
path: root/sys/libmath/blas.c
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2020-05-14 18:15:23 -0700
committerNicholas Noll <nbnoll@eml.cc>2020-05-14 18:15:23 -0700
commit463ed852261da4d1dd1b859fa717a1d683306c9d (patch)
treed832d08663dcb53f86073d4fbb1609712fe5513f /sys/libmath/blas.c
parentd982e7c2fdebf560ccce193cb98b85d4fac28a45 (diff)
feat: begun work on final blas level 2
Diffstat (limited to 'sys/libmath/blas.c')
-rw-r--r--sys/libmath/blas.c27
1 files changed, 17 insertions, 10 deletions
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 <vendor/blas/cblas.h>
-#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) {