From 8d6a0e0da4c228659077e56fc3988e6b3d321dc4 Mon Sep 17 00:00:00 2001 From: Henry Cook Date: Tue, 11 Nov 2014 16:03:24 -0800 Subject: [PATCH] blocked mt-matmul --- benchmarks/mt-matmul/matmul.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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); } } } -- 2.30.2