File: FlopsSampler.m

package info (click to toggle)
papi 5.7.0+dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 9,856 kB
  • sloc: ansic: 93,265; fortran: 3,338; xml: 2,460; makefile: 815; sh: 290
file content (135 lines) | stat: -rw-r--r-- 2,848 bytes parent folder | download | duplicates (4)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
function FlopsSampler(n) 

% A Sampler of Matlab functions that consume Floating Point Operations
% in increasing order of floating point intensity.
%
%        FlopsSampler(n) - where n == array or vector size
%

fprintf(1,'\nCounts Using PAPI\n');
fprintf(1,'\n%24s %12s %14s %12s\n',  'Operations', 'n', 'fl pt ops', 'Mflop/s' )
s1=rand(1,1);s2=rand(1,1);
x=rand(n,1);y=rand(n,1);
a=rand(n); 
b=a;
c=a*a';

fprintf(1,'%25s', 'calling PAPI flops')
flops(0);
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )

fprintf(1,'%25s', 'dot product')
flops(0);
x'*y; 
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )

fprintf(1,'%25s', 'matrix vector')
flops(0);
a*x; 
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )

fprintf(1,'%25s', 'random matrix')
flops(0);
a=rand(n);
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )

fprintf(1,'%25s', 'chol(a)')
flops(0);
chol(c); 
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )

fprintf(1,'%25s', 'lu(a)')
flops(0);
lu(a); 
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )

fprintf(1,'%25s', 'x=a\y')
flops(0);
x=a\y; 
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )

fprintf(1,'%25s', 'condest(a)')
flops(0);
condest(a); 
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )

fprintf(1,'%25s', 'qr(a)')
flops(0);
qr(a); 
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )

fprintf(1,'%25s', 'matrix multiply')
flops(0);
a*b; 
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )

fprintf(1,'%25s', 'inv(a)')
flops(0);
inv(a); 
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )

fprintf(1,'%25s', 'svd(a)')
flops(0);
svd(a); 
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )

fprintf(1,'%25s', 'cond(a)')
flops(0);
cond(a); 
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )

fprintf(1,'%25s', 'hess(a)')
flops(0);
hess(a); 
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )

fprintf(1,'%25s', 'eig(a)')
flops(0);
eig(a); 
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )

fprintf(1,'%25s', '[u,s,v]=svd(a)')
flops(0);
[u,s,v]=svd(a); 
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )

fprintf(1,'%25s', 'pinv(a)')
flops(0);
pinv(a);
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )

fprintf(1,'%25s', 's=gsvd(a)')
flops(0);
s=gsvd(a,b);
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )

fprintf(1,'%25s', '[x,e]=eig(a)')
flops(0);
[x,e]=eig(a); 
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )

fprintf(1,'%25s', ' [u,v,x,c,s]=gsvd(a,b)')
flops(0);
[u,v,x,c,s]=gsvd(a,b);
[ops,mflops]=flops;
fprintf(1,'%12d %14d %12.2f\n', n, ops, mflops )