-
Notifications
You must be signed in to change notification settings - Fork 11
/
sgemm.c
46 lines (40 loc) · 815 Bytes
/
sgemm.c
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
40
41
42
43
44
45
46
// clang sgemm.c -o sgemm -mavx
/*
$ ./sgemm
1.000 2.000
3.000 4.000
5.000 6.000
x
1.000 2.000 3.000 4.000
5.000 6.000 7.000 8.000
=
11.000 14.000 17.000 20.000
23.000 30.000 37.000 44.000
35.000 46.000 57.000 68.000
*/
#include <stdio.h>
#include "sgemm_sse.h"
void print_matrix(float *data, int row, int col)
{
for (int i=0; i<row; i++) {
for (int j=0; j<col; j++) {
printf("%.3f ", data[i*col + j]);
}
printf("\n");
}
}
int main()
{
float A[6] = {1.0,2.0, 3.0,4.0, 5.0,6.0};
float B[8] = {1.0,2.0,3.0,4.0, 5.0,6.0,7.0,8.0};
float C[12];
int M = 3, N = 4, K = 2;
double alpha = 1.0, beta = 0.0;
print_matrix(A, M, K);
printf("x\n");
print_matrix(B, K, N);
printf("=\n");
sgemm_sse('R', 'N', 'N', M, N, K, alpha, A, K, B, N, beta, C, N);
print_matrix(C, M, N);
return 0;
}