aboutsummaryrefslogtreecommitdiff
path: root/mt/an_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/an_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/an_matmul.c')
-rwxr-xr-xmt/an_matmul.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/mt/an_matmul.c b/mt/an_matmul.c
new file mode 100755
index 0000000..eb76ffa
--- /dev/null
+++ b/mt/an_matmul.c
@@ -0,0 +1,40 @@
+#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[] )
+{
+
+ // ***************************** //
+ // **** ADD YOUR CODE HERE ***** //
+ int i, j, k, limit, end, kblock, iblock, r, jblock;
+ int tempA1;
+ int tempB1;
+
+ limit = lda / ncores;
+ j = (coreid)*limit;
+ end = (coreid+1)*limit;
+
+ kblock = 1;
+ iblock = 1;
+ jblock = 1;
+ for (; j < end; j+= jblock)
+ for ( k = 0; k < lda; k = k + kblock )
+ {
+ r = j*lda + k;
+ tempA1 = A[r];
+
+ for ( i = 0; i < lda; i = i + iblock ) {
+ tempB1 = k*lda + i;
+
+ C[i + j*lda] += tempA1*B[tempB1];
+
+ }
+ barrier(ncores);
+ }
+ // ***************************** //
+ //
+ // feel free to make a separate function for MI and MSI versions.
+
+}