aboutsummaryrefslogtreecommitdiff
path: root/mt/do_matmul.c
blob: 7a6b75527db9c11ceae543a2b31f18838cdbc212 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#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[] )
{
    int i, j, k;
    data_t acc_temp;
    data_t *A_j, *B_i;
    int j_start = coreid*(32/ncores);
    int j_end = (coreid+1)*(32/ncores);
    for ( i = 0; i < 32; i++ ) {
        B_i = B + i;
        for ( j = j_start; j < j_end; j++ )  
        {
            acc_temp = 0;
            A_j = A + j*32;
            for ( k = 0; k < 32; k++ ) 
            {
                acc_temp += *(A_j + k) * *(B_i + k*32);
            }
            C[i + j*32] = acc_temp;
        }
    }
}