From: Henry Cook Date: Wed, 12 Nov 2014 00:03:24 +0000 (-0800) Subject: blocked mt-matmul X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8d6a0e0da4c228659077e56fc3988e6b3d321dc4;p=riscv-tests.git blocked mt-matmul --- diff --git a/benchmarks/mt-matmul/matmul.c b/benchmarks/mt-matmul/matmul.c index c38914d..5d11fa3 100644 --- a/benchmarks/mt-matmul/matmul.c +++ b/benchmarks/mt-matmul/matmul.c @@ -1,22 +1,20 @@ #include "dataset.h" #include "util.h" -//-------------------------------------------------------------------------- -// single-thread, naive version -// 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; - - for ( i = 0; i < lda; i++ ) + int block = lda / ncores; + int start = block * coreid; + + for ( j = start; j < (start+block); j++ ) { - for ( j = 0; j < lda; j++ ) + for ( k = 0; k < lda; k++ ) { - for ( k = coreid; k < lda; k+=ncores ) + for ( i = 0; i < lda; i++ ) { C[i + j*lda] += A[j*lda + k] * B[k*lda + i]; } - barrier(ncores); } } }