Revision 123, 0.8 kB
(checked in by smidl, 16 years ago)
|
blas
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Rev Author Date
|
Line | |
---|
1 | function test |
---|
2 | |
---|
3 | vn = [5,50,200,500] |
---|
4 | if 0 |
---|
5 | et =zeros(1,4); |
---|
6 | et2 =zeros(1,4); |
---|
7 | |
---|
8 | idn = 1; |
---|
9 | vn = [5,50,200,500] |
---|
10 | for n= vn |
---|
11 | A=rand(n);B=rand(n);C=rand(n); |
---|
12 | tic; |
---|
13 | for i=1:10 |
---|
14 | C=matmult(A,B); |
---|
15 | end |
---|
16 | et(idn) = toc; |
---|
17 | |
---|
18 | tic; |
---|
19 | for i=1:10 |
---|
20 | C=A*B; |
---|
21 | end |
---|
22 | et2(idn) = toc; |
---|
23 | |
---|
24 | idn =idn+1; |
---|
25 | end |
---|
26 | save blas_test |
---|
27 | else |
---|
28 | load blas_test |
---|
29 | end |
---|
30 | |
---|
31 | itload('../blas_test.it') |
---|
32 | |
---|
33 | figure |
---|
34 | plot(vn,et) |
---|
35 | hold on |
---|
36 | plot(vn,et2,'r'); |
---|
37 | plot(vn,exec_times,'--') |
---|
38 | plot(vn,exec_times_b,'r--') |
---|
39 | plot(vn,exec_times_c,'g--') |
---|
40 | title('For cycle vs. BLAS'); |
---|
41 | ylabel('execution time'); |
---|
42 | xlabel('matrix size'); |
---|
43 | set(gca,'YScale','log') |
---|
44 | set(gca,'XScale','log') |
---|
45 | set(gcf,'PaperPositionMode','auto'); |
---|
46 | |
---|
47 | legend('matlab for','matlab blas','IT++ for','IT++ blas','C array') |
---|
48 | |
---|
49 | |
---|
50 | function C=matmult(A,B) |
---|
51 | for i=1:size(A,1) |
---|
52 | for j=1:size(A,2) |
---|
53 | sum=0; |
---|
54 | for k=1:size(A,2) |
---|
55 | sum=sum+A(i,k)*B(k,j); |
---|
56 | end |
---|
57 | C(i,j)=sum; |
---|
58 | end |
---|
59 | end |
---|