-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmm.c
More file actions
40 lines (32 loc) · 890 Bytes
/
mm.c
File metadata and controls
40 lines (32 loc) · 890 Bytes
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
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdio.h>
#define row_size 128
#define N row_size*row_size
#define block_size 8
//Matrix multiply: prod = m1 x m2
float m1[N];
float m2[N];
float prod[N];
void mm() {
//source machsuite
int i, k, j, jj, kk;
int i_row, k_row;
for (jj = 0; jj < row_size; jj += block_size){
for (kk = 0; kk < row_size; kk += block_size){
for ( i = 0; i < row_size; ++i){
for (k = 0; k < block_size; ++k){
i_row = i * row_size;
k_row = (k + kk) * row_size;
for (j = 0; j < block_size; ++j){
prod[i_row + j + jj] += m1[i_row + k + kk] * m2[k_row + j + jj];
}
}
}
}
}
}
int main(int argc, char**argv) {
mm();
if(argc>=2) {
printf("random result:%f, %s\n", prod[argc],argv[0]);
}
}