diff options
author | Henry Cook <hcook@eecs.berkeley.edu> | 2014-11-06 17:24:39 -0800 |
---|---|---|
committer | Henry Cook <hcook@eecs.berkeley.edu> | 2014-11-07 16:52:51 -0800 |
commit | d537de7deffa6036dab573ff174b7f8c8e470437 (patch) | |
tree | ddc921eb337cda4889570f0251bdba85059a2531 /mt/ar_matmul.c | |
parent | 5afc6b9bc2e3685220cffb3da66ad9f5f1f7b14f (diff) | |
download | riscv-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/ar_matmul.c')
-rwxr-xr-x | mt/ar_matmul.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/mt/ar_matmul.c b/mt/ar_matmul.c new file mode 100755 index 0000000..2299906 --- /dev/null +++ b/mt/ar_matmul.c @@ -0,0 +1,41 @@ +#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 ***** // + // ***************************** // + // + // feel free to make a separate function for MI and MSI versions. + + int i, j, k, B_t[32*32], x, y; + int ALoc, BLoc, CLoc; +// int ii = 0, done = 0; + //for(x = coreid*(lda/ncores); x < (coreid+1)*(lda/ncores) && x < lda; x++) { + for (x = 0; x < lda; x++) { + for(y = 0; y < lda; y++) { + B_t[y*lda + x] = B[x*lda + y]; + } + } + // for ( ii = lda/4 ; ii < lda ; ii += lda/4) + //{ +// for ( i = coreid*(ii/ncores); i < (coreid+1)*(ii/ncores) && i < ii; i++ ) + for ( i = coreid*(lda/ncores); i < (coreid+1)*(lda/ncores) && i < lda; i++ ) + { + ALoc = i*lda; + for ( j = 0; j < lda; j++ ) + { + BLoc = j*lda; + CLoc = i*lda + j; + for ( k = 0; k < lda; k++ ) + { + C[CLoc] += A[ALoc + k] * B_t[BLoc + k]; + } + } + } + //} +} |