diff options
author | Nicholas <nbnoll@eml.cc> | 2021-11-12 09:22:01 -0800 |
---|---|---|
committer | Nicholas <nbnoll@eml.cc> | 2021-11-12 09:22:01 -0800 |
commit | ce05175372a9ddca1a225db0765ace1127a39293 (patch) | |
tree | 5988b4d4f6b402e4953945886fc90aae11203df6 /src/libmath/blas1.c | |
parent | b375f3cdedb5b0e08745d100b40e38d2f8396a58 (diff) |
chore: simplified organizational structurelaptop
Diffstat (limited to 'src/libmath/blas1.c')
-rw-r--r-- | src/libmath/blas1.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/libmath/blas1.c b/src/libmath/blas1.c new file mode 100644 index 0000000..a8ca085 --- /dev/null +++ b/src/libmath/blas1.c @@ -0,0 +1,58 @@ +#include <u.h> +#include <libmath.h> + +// ----------------------------------------------------------------------- +// Templates + +#include "loop.h" +#define BODY_XY() \ + LOOP(UNROLL, 0, INIT); \ + n = ROUNDBY(len, UNROLL); \ + if (incx == 1 && incy == 1) { \ + for (i = 0; i < n; i+=UNROLL) { \ + LOOP(UNROLL,0,KERNEL,1,1); \ + } \ + } else { \ + for (i = 0; i < n; i+=UNROLL) { \ + LOOP(UNROLL,0,KERNEL,incx,incy);\ + } \ + } \ + \ + for (; i < len; i++) { \ + LOOP(1,0,KERNEL,incx,incy); \ + } + +#define BODY_X() \ + LOOP(UNROLL, 0, INIT); \ + n = ROUNDBY(len, UNROLL); \ + if (incx == 1) { \ + for (i = 0; i < n; i+=UNROLL) { \ + LOOP(UNROLL,0,KERNEL,1); \ + } \ + } else { \ + for (i = 0; i < n; i+=UNROLL) { \ + LOOP(UNROLL,0,KERNEL,incx); \ + } \ + } \ + \ + for (; i < len; i++) { \ + LOOP(1,0,KERNEL,incx); \ + } + +// ----------------------------------------------------------------------- +// Implementation + +#define UNROLL 8 +#define INT int + +#define FLOAT double +#define func(name) blas·d##name +#include "blas1body" + +#undef FLOAT +#undef func + +#define FLOAT float +#define func(name) blas·f##name +#include "blas1body" +#undef FLOAT |