6d7b97863a5a023ffffa2f04e4152b736a900784
[riscv-tests.git] / benchmarks / mt-matmul / matmul.c
1 // See LICENSE for license details.
2
3 #include "dataset.h"
4 #include "util.h"
5 #include <stddef.h>
6
7 #pragma GCC optimize ("unroll-loops")
8
9 void matmul(const size_t coreid, const size_t ncores, const size_t lda, const data_t A[], const data_t B[], data_t C[])
10 {
11 size_t i, j, k;
12 size_t block = lda / ncores;
13 size_t start = block * coreid;
14
15 for (i = 0; i < lda; i++) {
16 for (j = start; j < (start+block); j++) {
17 data_t sum = 0;
18 for (k = 0; k < lda; k++)
19 sum += A[j*lda + k] * B[k*lda + i];
20 C[i + j*lda] = sum;
21 }
22 }
23 }