aboutsummaryrefslogtreecommitdiff
path: root/mt/ds_matmul.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/ds_matmul.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/ds_matmul.c')
-rw-r--r--mt/ds_matmul.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/mt/ds_matmul.c b/mt/ds_matmul.c
new file mode 100644
index 0000000..3b48267
--- /dev/null
+++ b/mt/ds_matmul.c
@@ -0,0 +1,32 @@
+#include "stdlib.h"
+
+#include "util.h"
+
+#include "dataset.h"
+void __attribute__((noinline)) matmul(const int coreid, const int ncores, const int lda, const data_t A[], const data_t B[], data_t C[] )
+{
+int i,j,k,a,b,b1,a1,a2,a3,c,c1,c2,c3,b2,b3;
+ for (j=coreid*4; j<lda; j+=4*ncores){
+ a=j*lda;
+ a1=(j+1)*lda;
+ a2=(j+2)*lda;
+ a3=(j+3)*lda;
+ for (k=0;k<lda; k+=2)
+ {
+ b = k*lda;
+ b1 = (k+1)*lda;
+ for (i=0;i<lda;i++){
+ c = B[b+i];
+ c1 = B[b1+i];
+ C[i+a]+=A[a+k]*c;
+ C[i+a1]+=A[a1+k]*c;
+ C[i+a2]+=A[a2+k]*c;
+ C[i+a3]+=A[a3+k]*c;
+ C[i+a]+=A[a+k+1]*c1;
+ C[i+a1]+=A[a1+k+1]*c1;
+ C[i+a2]+=A[a2+k+1]*c1;
+ C[i+a3]+=A[a3+k+1]*c1;
+}
+}
+}
+}