Gentoo Archives: gentoo-commits

From: Andrea Arteaga <andyspiros@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/auto-numerical-bench:newinterfaces commit in: btl/actions/, btl/libs/BLAS/
Date: Sun, 30 Sep 2012 20:32:45
Message-Id: 1349037108.c70b1444190f2f57d24c88b2f9f189c3d4be316a.spiros@gentoo
1 commit: c70b1444190f2f57d24c88b2f9f189c3d4be316a
2 Author: Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
3 AuthorDate: Sun Sep 30 20:31:48 2012 +0000
4 Commit: Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
5 CommitDate: Sun Sep 30 20:31:48 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=c70b1444
7
8 Added and tested actions for BLAS level 3.
9
10 ---
11 ...on_MatrixVector.hpp => action_MatrixMatrix.hpp} | 33 ++++++++--------
12 ...n_MatrixVector.hpp => action_MatrixTMatrix.hpp} | 33 ++++++++--------
13 btl/actions/action_MatrixVector.hpp | 11 ++---
14 ...MatrixVector.hpp => action_TriMatrixMatrix.hpp} | 32 +++++++--------
15 ...riSolveVector.hpp => action_TriSolveMatrix.hpp} | 41 ++++++++++----------
16 btl/actions/action_TriSolveVector.hpp | 2 +-
17 btl/actions/actionsBLAS.hpp | 2 -
18 btl/libs/BLAS/main.cpp | 22 +++++------
19 8 files changed, 84 insertions(+), 92 deletions(-)
20
21 diff --git a/btl/actions/action_MatrixVector.hpp b/btl/actions/action_MatrixMatrix.hpp
22 similarity index 64%
23 copy from btl/actions/action_MatrixVector.hpp
24 copy to btl/actions/action_MatrixMatrix.hpp
25 index 923dc7b..a69a7f0 100644
26 --- a/btl/actions/action_MatrixVector.hpp
27 +++ b/btl/actions/action_MatrixMatrix.hpp
28 @@ -15,52 +15,51 @@
29 // along with this program; if not, write to the Free Software
30 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 //
32 -#ifndef ACTION_MATRIXVECTOR
33 -#define ACTION_MATRIXVECTOR
34 +#ifndef ACTION_MATRIXMATRIX
35 +#define ACTION_MATRIXMATRIX
36
37 #include "LinearCongruential.hpp"
38 #include <vector>
39 #include <algorithm>
40
41 template<class Interface>
42 -class Action_MatrixVector {
43 +class Action_MatrixMatrix {
44
45 typedef typename Interface::Scalar Scalar;
46 typedef std::vector<Scalar> vector_t;
47
48 private:
49 // Invalidate copy constructor
50 - Action_MatrixVector(const Action_MatrixVector&);
51 + Action_MatrixMatrix(const Action_MatrixMatrix&);
52
53 public:
54
55 // Constructor
56 - Action_MatrixVector(int size)
57 + Action_MatrixMatrix(int size)
58 : _size(size), lc(10),
59 - A(lc.fillVector<Scalar>(size*size)), x(lc.fillVector<Scalar>(size)),
60 - A_work(size*size), x_work(size), y_work(size)
61 + A(lc.fillVector<Scalar>(size*size)), B(lc.fillVector<Scalar>(size*size)),
62 + C(size*size), C_work(size*size)
63 {
64 - MESSAGE("Action_MatrixVector Constructor");
65 + MESSAGE("Action_MatrixMatrix Constructor");
66 }
67
68 // Action name
69 static std::string name()
70 {
71 - return "MatrixVector_" + Interface::name();
72 + return "MatrixMatrix_" + Interface::name();
73 }
74
75 double fpo() {
76 - return 2*double(_size)*double(_size) - double(_size);
77 + return double(_size)*double(_size)*(2*double(_size) - 1);
78 }
79
80 inline void initialize(){
81 - std::copy(A.begin(), A.end(), A_work.begin());
82 - std::copy(x.begin(), x.end(), x_work.begin());
83 + std::copy(C.begin(), C.end(), C_work.begin());
84 }
85
86 inline void calculate() {
87 - Interface::MatrixVector(false, _size, _size, 1., &A_work[0], &x_work[0],
88 - 0., &y_work[0]);
89 + Interface::MatrixMatrix(false, false, _size, _size, _size,
90 + 1., &A[0], &B[0], 0., &C_work[0]);
91 }
92
93 Scalar getResidual() {
94 @@ -71,9 +70,9 @@ private:
95 const int _size;
96 LinearCongruential<> lc;
97
98 - const vector_t A, x;
99 - vector_t A_work, x_work, y_work;
100 + const vector_t A, B, C;
101 + vector_t C_work;
102
103 };
104
105 -#endif // ACTION_MATRIXVECTOR
106 +#endif // ACTION_MATRIXMATRIX
107
108 diff --git a/btl/actions/action_MatrixVector.hpp b/btl/actions/action_MatrixTMatrix.hpp
109 similarity index 64%
110 copy from btl/actions/action_MatrixVector.hpp
111 copy to btl/actions/action_MatrixTMatrix.hpp
112 index 923dc7b..43aaf74 100644
113 --- a/btl/actions/action_MatrixVector.hpp
114 +++ b/btl/actions/action_MatrixTMatrix.hpp
115 @@ -15,52 +15,51 @@
116 // along with this program; if not, write to the Free Software
117 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
118 //
119 -#ifndef ACTION_MATRIXVECTOR
120 -#define ACTION_MATRIXVECTOR
121 +#ifndef ACTION_MATRIXTMATRIX
122 +#define ACTION_MATRIXTMATRIX
123
124 #include "LinearCongruential.hpp"
125 #include <vector>
126 #include <algorithm>
127
128 template<class Interface>
129 -class Action_MatrixVector {
130 +class Action_MatrixTMatrix {
131
132 typedef typename Interface::Scalar Scalar;
133 typedef std::vector<Scalar> vector_t;
134
135 private:
136 // Invalidate copy constructor
137 - Action_MatrixVector(const Action_MatrixVector&);
138 + Action_MatrixTMatrix(const Action_MatrixTMatrix&);
139
140 public:
141
142 // Constructor
143 - Action_MatrixVector(int size)
144 + Action_MatrixTMatrix(int size)
145 : _size(size), lc(10),
146 - A(lc.fillVector<Scalar>(size*size)), x(lc.fillVector<Scalar>(size)),
147 - A_work(size*size), x_work(size), y_work(size)
148 + A(lc.fillVector<Scalar>(size*size)), B(lc.fillVector<Scalar>(size*size)),
149 + C(size*size), C_work(size*size)
150 {
151 - MESSAGE("Action_MatrixVector Constructor");
152 + MESSAGE("Action_MatrixTMatrix Constructor");
153 }
154
155 // Action name
156 static std::string name()
157 {
158 - return "MatrixVector_" + Interface::name();
159 + return "MatrixTMatrix_" + Interface::name();
160 }
161
162 double fpo() {
163 - return 2*double(_size)*double(_size) - double(_size);
164 + return double(_size)*double(_size)*(2*double(_size) - 1);
165 }
166
167 inline void initialize(){
168 - std::copy(A.begin(), A.end(), A_work.begin());
169 - std::copy(x.begin(), x.end(), x_work.begin());
170 + std::copy(C.begin(), C.end(), C_work.begin());
171 }
172
173 inline void calculate() {
174 - Interface::MatrixVector(false, _size, _size, 1., &A_work[0], &x_work[0],
175 - 0., &y_work[0]);
176 + Interface::MatrixMatrix(true, false, _size, _size, _size,
177 + 1., &A[0], &B[0], 0., &C_work[0]);
178 }
179
180 Scalar getResidual() {
181 @@ -71,9 +70,9 @@ private:
182 const int _size;
183 LinearCongruential<> lc;
184
185 - const vector_t A, x;
186 - vector_t A_work, x_work, y_work;
187 + const vector_t A, B, C;
188 + vector_t C_work;
189
190 };
191
192 -#endif // ACTION_MATRIXVECTOR
193 +#endif // ACTION_MATRIXTMATRIX
194
195 diff --git a/btl/actions/action_MatrixVector.hpp b/btl/actions/action_MatrixVector.hpp
196 index 923dc7b..b1a37d0 100644
197 --- a/btl/actions/action_MatrixVector.hpp
198 +++ b/btl/actions/action_MatrixVector.hpp
199 @@ -38,7 +38,7 @@ public:
200 Action_MatrixVector(int size)
201 : _size(size), lc(10),
202 A(lc.fillVector<Scalar>(size*size)), x(lc.fillVector<Scalar>(size)),
203 - A_work(size*size), x_work(size), y_work(size)
204 + y(size), y_work(size)
205 {
206 MESSAGE("Action_MatrixVector Constructor");
207 }
208 @@ -54,12 +54,11 @@ public:
209 }
210
211 inline void initialize(){
212 - std::copy(A.begin(), A.end(), A_work.begin());
213 - std::copy(x.begin(), x.end(), x_work.begin());
214 + std::copy(y.begin(), y.end(), y_work.begin());
215 }
216
217 inline void calculate() {
218 - Interface::MatrixVector(false, _size, _size, 1., &A_work[0], &x_work[0],
219 + Interface::MatrixVector(false, _size, _size, 1., &A[0], &x[0],
220 0., &y_work[0]);
221 }
222
223 @@ -71,8 +70,8 @@ private:
224 const int _size;
225 LinearCongruential<> lc;
226
227 - const vector_t A, x;
228 - vector_t A_work, x_work, y_work;
229 + const vector_t A, x, y;
230 + vector_t y_work;
231
232 };
233
234
235 diff --git a/btl/actions/action_MatrixVector.hpp b/btl/actions/action_TriMatrixMatrix.hpp
236 similarity index 64%
237 copy from btl/actions/action_MatrixVector.hpp
238 copy to btl/actions/action_TriMatrixMatrix.hpp
239 index 923dc7b..2b8a7c1 100644
240 --- a/btl/actions/action_MatrixVector.hpp
241 +++ b/btl/actions/action_TriMatrixMatrix.hpp
242 @@ -15,52 +15,50 @@
243 // along with this program; if not, write to the Free Software
244 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
245 //
246 -#ifndef ACTION_MATRIXVECTOR
247 -#define ACTION_MATRIXVECTOR
248 +#ifndef ACTION_TRIMATRIXMATRIX
249 +#define ACTION_TRIMATRIXMATRIX
250
251 #include "LinearCongruential.hpp"
252 #include <vector>
253 #include <algorithm>
254
255 template<class Interface>
256 -class Action_MatrixVector {
257 +class Action_TriMatrixMatrix {
258
259 typedef typename Interface::Scalar Scalar;
260 typedef std::vector<Scalar> vector_t;
261
262 private:
263 // Invalidate copy constructor
264 - Action_MatrixVector(const Action_MatrixVector&);
265 + Action_TriMatrixMatrix(const Action_TriMatrixMatrix&);
266
267 public:
268
269 // Constructor
270 - Action_MatrixVector(int size)
271 + Action_TriMatrixMatrix(int size)
272 : _size(size), lc(10),
273 - A(lc.fillVector<Scalar>(size*size)), x(lc.fillVector<Scalar>(size)),
274 - A_work(size*size), x_work(size), y_work(size)
275 + A(lc.fillVector<Scalar>(size*size)), B(lc.fillVector<Scalar>(size*size)),
276 + B_work(size*size)
277 {
278 - MESSAGE("Action_MatrixVector Constructor");
279 + MESSAGE("Action_TriMatrixMatrix Constructor");
280 }
281
282 // Action name
283 static std::string name()
284 {
285 - return "MatrixVector_" + Interface::name();
286 + return "TriMatrixMatrix_" + Interface::name();
287 }
288
289 double fpo() {
290 - return 2*double(_size)*double(_size) - double(_size);
291 + return double(_size)*double(_size)*(double(_size) - 1);
292 }
293
294 inline void initialize(){
295 - std::copy(A.begin(), A.end(), A_work.begin());
296 - std::copy(x.begin(), x.end(), x_work.begin());
297 + std::copy(B.begin(), B.end(), B_work.begin());
298 }
299
300 inline void calculate() {
301 - Interface::MatrixVector(false, _size, _size, 1., &A_work[0], &x_work[0],
302 - 0., &y_work[0]);
303 + Interface::TriMatrixMatrix('U', _size, _size, &A[0], &B_work[0]);
304 }
305
306 Scalar getResidual() {
307 @@ -71,9 +69,9 @@ private:
308 const int _size;
309 LinearCongruential<> lc;
310
311 - const vector_t A, x;
312 - vector_t A_work, x_work, y_work;
313 + const vector_t A, B;
314 + vector_t B_work;
315
316 };
317
318 -#endif // ACTION_MATRIXVECTOR
319 +#endif // ACTION_TRIMATRIXMATRIX
320
321 diff --git a/btl/actions/action_TriSolveVector.hpp b/btl/actions/action_TriSolveMatrix.hpp
322 similarity index 62%
323 copy from btl/actions/action_TriSolveVector.hpp
324 copy to btl/actions/action_TriSolveMatrix.hpp
325 index 6be18b0..f2f8879 100644
326 --- a/btl/actions/action_TriSolveVector.hpp
327 +++ b/btl/actions/action_TriSolveMatrix.hpp
328 @@ -15,34 +15,34 @@
329 // along with this program; if not, write to the Free Software
330 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
331 //
332 -#ifndef ACTION_TRISOLVEVECTOR
333 -#define ACTION_TRISOLVEVECTOR
334 +#ifndef ACTION_TRISOLVEMATRIX
335 +#define ACTION_TRISOLVEMATRIX
336
337 #include "LinearCongruential.hpp"
338 #include <vector>
339 #include <algorithm>
340
341 template<class Interface>
342 -class Action_TriSolveVector {
343 +class Action_TriSolveMatrix {
344
345 typedef typename Interface::Scalar Scalar;
346 typedef std::vector<Scalar> vector_t;
347
348 private:
349 // Invalidate copy constructor
350 - Action_TriSolveVector(const Action_TriSolveVector&);
351 + Action_TriSolveMatrix(const Action_TriSolveMatrix&);
352
353 public:
354
355 // Constructor
356 - Action_TriSolveVector(int size)
357 + Action_TriSolveMatrix(int size)
358 : _size(size), lc(10),
359 - A(lc.fillVector<Scalar>(size*size)), b(lc.fillVector<Scalar>(size)),
360 - x_work(size)
361 + A(lc.fillVector<Scalar>(size*size)), B(lc.fillVector<Scalar>(size*size)),
362 + X_work(size*size)
363 {
364 - MESSAGE("Action_TriSolveVector Constructor");
365 + MESSAGE("Action_TriSolveMatrix Constructor");
366
367 - // Adding size to the diagonal of A to make it invertible
368 + // Adding size to the diagonal of A to ensure it is invertible
369 for (int i = 0; i < size; ++i)
370 A[i+size*i] += size;
371 }
372 @@ -50,36 +50,37 @@ public:
373 // Action name
374 static std::string name()
375 {
376 - return "TriSolveVector_" + Interface::name();
377 + return "TriSolveMatrix_" + Interface::name();
378 }
379
380 double fpo() {
381 - return double(_size)*double(_size) - 2*double(_size);
382 + return double(_size)*double(_size)*(double(_size) - 2);
383 }
384
385 inline void initialize(){
386 - std::copy(b.begin(), b.end(), x_work.begin());
387 + std::copy(B.begin(), B.end(), X_work.begin());
388 }
389
390 inline void calculate() {
391 - Interface::TriSolveVector('U', _size, &A[0], &x_work[0]);
392 + Interface::TriSolveMatrix('U', _size, _size, &A[0], &X_work[0]);
393 }
394
395 Scalar getResidual() {
396 initialize();
397 calculate();
398 - Interface::TriMatrixVector('U', _size, &A[0], &x_work[0]);
399 - Interface::axpy(_size, -1., &b[0], &x_work[0]);
400 - return Interface::norm(_size, &x_work[0]);
401 + Interface::TriMatrixMatrix('U', _size, &A[0], &X_work[0]);
402 + Interface::axpy(_size*_size, -1., &B[0], &X_work[0]);
403 + return Interface::norm(_size*_size, &X_work[0]);
404 }
405
406 -//private:
407 +private:
408 const int _size;
409 LinearCongruential<> lc;
410
411 - vector_t A, b;
412 - vector_t x_work;
413 + vector_t A;
414 + const vector_t B;
415 + vector_t X_work;
416
417 };
418
419 -#endif // ACTION_TRISOLVEVECTOR
420 +#endif // ACTION_TRISOLVEMATRIX
421
422 diff --git a/btl/actions/action_TriSolveVector.hpp b/btl/actions/action_TriSolveVector.hpp
423 index 6be18b0..6cac6f1 100644
424 --- a/btl/actions/action_TriSolveVector.hpp
425 +++ b/btl/actions/action_TriSolveVector.hpp
426 @@ -42,7 +42,7 @@ public:
427 {
428 MESSAGE("Action_TriSolveVector Constructor");
429
430 - // Adding size to the diagonal of A to make it invertible
431 + // Adding size to the diagonal of A to ensure it is invertible
432 for (int i = 0; i < size; ++i)
433 A[i+size*i] += size;
434 }
435
436 diff --git a/btl/actions/actionsBLAS.hpp b/btl/actions/actionsBLAS.hpp
437 index 0a63675..1ac4b12 100644
438 --- a/btl/actions/actionsBLAS.hpp
439 +++ b/btl/actions/actionsBLAS.hpp
440 @@ -8,9 +8,7 @@
441 #include "action_Rank1Update.hpp"
442 #include "action_Rank2Update.hpp"
443
444 -/*
445 #include "action_MatrixMatrix.hpp"
446 #include "action_MatrixTMatrix.hpp"
447 #include "action_TriMatrixMatrix.hpp"
448 #include "action_TriSolveMatrix.hpp"
449 -*/
450
451 diff --git a/btl/libs/BLAS/main.cpp b/btl/libs/BLAS/main.cpp
452 index 9f43464..f4dc8fa 100644
453 --- a/btl/libs/BLAS/main.cpp
454 +++ b/btl/libs/BLAS/main.cpp
455 @@ -57,7 +57,7 @@ int main(int argv, char **argc)
456 for (int i = 1; i < argv; ++i) {
457 std::string arg = argc[i];
458
459 - if (arg == "axpy") do_axpy = true;
460 + if (arg == "axpy") do_axpy = true;
461 else if (arg == "rot") do_rot = true;
462
463 else if (arg == "MatrixVector") do_MatrixVector = true;
464 @@ -70,7 +70,7 @@ int main(int argv, char **argc)
465 else if (arg == "MatrixMatrix") do_MatrixMatrix = true;
466 else if (arg == "MatrixTMatrix") do_MatrixTMatrix = true;
467 else if (arg == "TriMatrixMatrix") do_TriMatrixMatrix = true;
468 - else if (arg == "TrisolveMatrix") do_TriSolveMatrix = true;
469 + else if (arg == "TriSolveMatrix") do_TriSolveMatrix = true;
470
471 // Check switch -N
472 else if (arg[0] == '-' && arg[1] == 'N') {
473 @@ -99,16 +99,14 @@ int main(int argv, char **argc)
474 if (do_TriSolveVector)
475 bench<Action_TriSolveVector<Interface> >(MIN_MM,MAX_MM, N);
476
477 - /*
478 - if (matrix_matrix)
479 - bench<Action_matrix_matrix_product<Interface> >(MIN_MM,MAX_MM, N);
480 - if (aat)
481 - bench<Action_aat_product<Interface> >(MIN_MM,MAX_MM, N);
482 - if (trisolve_matrix)
483 - bench<Action_trisolve_matrix<Interface> >(MIN_MM,MAX_MM, N);
484 - if (trmm)
485 - bench<Action_trmm<Interface> >(MIN_MM,MAX_MM, N);
486 - */
487 + if (do_MatrixMatrix)
488 + bench<Action_MatrixMatrix<Interface> >(MIN_MM,MAX_MM, N);
489 + if (do_MatrixTMatrix)
490 + bench<Action_MatrixTMatrix<Interface> >(MIN_MM,MAX_MM, N);
491 + if (do_TriMatrixMatrix)
492 + bench<Action_TriMatrixMatrix<Interface> >(MIN_MM,MAX_MM, N);
493 + if (do_TriSolveMatrix)
494 + bench<Action_TriSolveMatrix<Interface> >(MIN_MM,MAX_MM, N);
495
496
497 return 0;