aboutsummaryrefslogtreecommitdiff
path: root/mt/vvadd3.c
diff options
context:
space:
mode:
authorHenry Cook <hcook@eecs.berkeley.edu>2014-11-06 17:24:39 -0800
committerHenry Cook <hcook@eecs.berkeley.edu>2014-11-07 16:52:51 -0800
commitd537de7deffa6036dab573ff174b7f8c8e470437 (patch)
treeddc921eb337cda4889570f0251bdba85059a2531 /mt/vvadd3.c
parent5afc6b9bc2e3685220cffb3da66ad9f5f1f7b14f (diff)
downloadriscv-tests-d537de7deffa6036dab573ff174b7f8c8e470437.zip
riscv-tests-d537de7deffa6036dab573ff174b7f8c8e470437.tar.gz
riscv-tests-d537de7deffa6036dab573ff174b7f8c8e470437.tar.bz2
Clean up canonical mt benchmarks and reorganize extra versions in /mt. All versions support support at least 1/2/4 threads.
Diffstat (limited to 'mt/vvadd3.c')
-rwxr-xr-xmt/vvadd3.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/mt/vvadd3.c b/mt/vvadd3.c
new file mode 100755
index 0000000..d18d2de
--- /dev/null
+++ b/mt/vvadd3.c
@@ -0,0 +1,22 @@
+#include "stdlib.h"
+#include "dataset.h"
+
+void __attribute__((noinline)) vvadd(int coreid, int ncores, size_t n, const data_t* x, const data_t* y, data_t* z)
+{
+ data_t* to = &z[coreid * (n / ncores)];
+ const data_t* from1 = &x[coreid * (n / ncores)];
+ const data_t* from2 = &y[coreid * (n / ncores)];
+ size_t count = n / ncores;
+ size_t c = (count + 7) / 8;
+ switch(count % 8) {
+ case 0: do { *to++ = *from1++ + *from2++;
+ case 7: *to++ = *from1++ + *from2++;
+ case 6: *to++ = *from1++ + *from2++;
+ case 5: *to++ = *from1++ + *from2++;
+ case 4: *to++ = *from1++ + *from2++;
+ case 3: *to++ = *from1++ + *from2++;
+ case 2: *to++ = *from1++ + *from2++;
+ case 1: *to++ = *from1++ + *from2++;
+ } while(--c > 0);
+ }
+}