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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <cblas.h>
extern "C" {
#include "testbed.h"
}
float * A;
float * B;
float * C;
int M;
int N;
int K;
void init_matrix(float * m, int size)
{
int i;
for(i=0;i<size;i+=2)
m[i]=i;
}
void init_data(void)
{
int sizeA;
int sizeB;
int sizeC;
sizeA=M*K;
sizeB=K*N;
sizeC=M*N;
A=(float *)malloc(sizeA*sizeof(float));
B=(float *)malloc(sizeB*sizeof(float));
C=(float *)malloc(sizeC*sizeof(float));
init_matrix(A,sizeA);
init_matrix(B,sizeB);
init_matrix(C,sizeC);
}
void run_sgemm(void * dummy)
{
int i;
for(i=0;i<1;i++)
{
cblas_sgemm(CblasRowMajor,CblasNoTrans,CblasNoTrans,M,N,K,
1.0,A,K,B,N,0,C,N);
}
}
int main(int argc, char * argv[])
{
M=27;
K=9;
N=37632;
init_data();
init_testbed();
run_test(16,1,run_sgemm,NULL);
release_testbed();
return 0;
}
|