From 526826e013dd353efeb3eec0f6552de5a4a5a431 Mon Sep 17 00:00:00 2001 From: Andrea Arteaga Date: Tue, 16 Oct 2012 23:55:09 +0200 Subject: Use different seeds. --- btl/actions/BLAS/action_MatrixMatrix.hpp | 4 ++-- btl/actions/BLAS/action_MatrixTMatrix.hpp | 4 ++-- btl/actions/BLAS/action_MatrixTVector.hpp | 4 ++-- btl/actions/BLAS/action_MatrixVector.hpp | 4 ++-- btl/actions/BLAS/action_Rank1Update.hpp | 4 ++-- btl/actions/BLAS/action_Rank2Update.hpp | 4 ++-- btl/actions/BLAS/action_SymMatrixVector.hpp | 4 ++-- btl/actions/BLAS/action_TriMatrixMatrix.hpp | 4 ++-- btl/actions/BLAS/action_TriSolveMatrix.hpp | 4 ++-- btl/actions/BLAS/action_TriSolveVector.hpp | 4 ++-- btl/actions/BLAS/action_axpy.hpp | 4 ++-- btl/actions/BLAS/action_rot.hpp | 4 ++-- btl/actions/LAPACK/action_Choleskydecomp.hpp | 4 ++-- btl/actions/LAPACK/action_GeneralSolve.hpp | 4 ++-- btl/actions/LAPACK/action_LUdecomp.hpp | 4 ++-- btl/actions/LAPACK/action_LeastSquaresSolve.hpp | 4 ++-- btl/actions/LAPACK/action_QRdecomp.hpp | 9 +++++---- btl/generic_bench/accuracy.hpp | 20 ++++++++++++-------- 18 files changed, 49 insertions(+), 44 deletions(-) diff --git a/btl/actions/BLAS/action_MatrixMatrix.hpp b/btl/actions/BLAS/action_MatrixMatrix.hpp index a69a7f0..ef3b54e 100644 --- a/btl/actions/BLAS/action_MatrixMatrix.hpp +++ b/btl/actions/BLAS/action_MatrixMatrix.hpp @@ -35,8 +35,8 @@ private: public: // Constructor - Action_MatrixMatrix(int size) - : _size(size), lc(10), + Action_MatrixMatrix(int size, int seed=10) + : _size(size), lc(seed), A(lc.fillVector(size*size)), B(lc.fillVector(size*size)), C(size*size), C_work(size*size) { diff --git a/btl/actions/BLAS/action_MatrixTMatrix.hpp b/btl/actions/BLAS/action_MatrixTMatrix.hpp index 43aaf74..de983ea 100644 --- a/btl/actions/BLAS/action_MatrixTMatrix.hpp +++ b/btl/actions/BLAS/action_MatrixTMatrix.hpp @@ -35,8 +35,8 @@ private: public: // Constructor - Action_MatrixTMatrix(int size) - : _size(size), lc(10), + Action_MatrixTMatrix(int size, int seed=10) + : _size(size), lc(seed), A(lc.fillVector(size*size)), B(lc.fillVector(size*size)), C(size*size), C_work(size*size) { diff --git a/btl/actions/BLAS/action_MatrixTVector.hpp b/btl/actions/BLAS/action_MatrixTVector.hpp index 20b360a..d7d4df2 100644 --- a/btl/actions/BLAS/action_MatrixTVector.hpp +++ b/btl/actions/BLAS/action_MatrixTVector.hpp @@ -35,8 +35,8 @@ private: public: // Constructor - Action_MatrixTVector(int size) - : _size(size), lc(10), + Action_MatrixTVector(int size, int seed=10) + : _size(size), lc(seed), A(lc.fillVector(size*size)), x(lc.fillVector(size)), A_work(size*size), x_work(size), y_work(size) { diff --git a/btl/actions/BLAS/action_MatrixVector.hpp b/btl/actions/BLAS/action_MatrixVector.hpp index b1a37d0..0ed5c3e 100644 --- a/btl/actions/BLAS/action_MatrixVector.hpp +++ b/btl/actions/BLAS/action_MatrixVector.hpp @@ -35,8 +35,8 @@ private: public: // Constructor - Action_MatrixVector(int size) - : _size(size), lc(10), + Action_MatrixVector(int size, int seed=10) + : _size(size), lc(seed), A(lc.fillVector(size*size)), x(lc.fillVector(size)), y(size), y_work(size) { diff --git a/btl/actions/BLAS/action_Rank1Update.hpp b/btl/actions/BLAS/action_Rank1Update.hpp index bd88ac3..e2ba61a 100644 --- a/btl/actions/BLAS/action_Rank1Update.hpp +++ b/btl/actions/BLAS/action_Rank1Update.hpp @@ -35,8 +35,8 @@ private: public: // Constructor - Action_Rank1Update(int size) - : _size(size), lc(10), + Action_Rank1Update(int size, int seed=10) + : _size(size), lc(seed), A(lc.fillVector(size*size)), A_work(size*size), x(lc.fillVector(size)), y(lc.fillVector(size)) { diff --git a/btl/actions/BLAS/action_Rank2Update.hpp b/btl/actions/BLAS/action_Rank2Update.hpp index b0b1693..a94f4b0 100644 --- a/btl/actions/BLAS/action_Rank2Update.hpp +++ b/btl/actions/BLAS/action_Rank2Update.hpp @@ -35,8 +35,8 @@ private: public: // Constructor - Action_Rank2Update(int size) - : _size(size), lc(10), + Action_Rank2Update(int size, int seed=10) + : _size(size), lc(seed), A(lc.fillVector(size*size)), A_work(size*size), x(lc.fillVector(size)), y(lc.fillVector(size)) { diff --git a/btl/actions/BLAS/action_SymMatrixVector.hpp b/btl/actions/BLAS/action_SymMatrixVector.hpp index e475007..e4f324e 100644 --- a/btl/actions/BLAS/action_SymMatrixVector.hpp +++ b/btl/actions/BLAS/action_SymMatrixVector.hpp @@ -35,8 +35,8 @@ private: public: // Constructor - Action_SymMatrixVector(int size) - : _size(size), lc(10), + Action_SymMatrixVector(int size, int seed=10) + : _size(size), lc(seed), A(lc.fillVector(size*size)), x(lc.fillVector(size)), y(size), y_work(size) { diff --git a/btl/actions/BLAS/action_TriMatrixMatrix.hpp b/btl/actions/BLAS/action_TriMatrixMatrix.hpp index 2b8a7c1..2655413 100644 --- a/btl/actions/BLAS/action_TriMatrixMatrix.hpp +++ b/btl/actions/BLAS/action_TriMatrixMatrix.hpp @@ -35,8 +35,8 @@ private: public: // Constructor - Action_TriMatrixMatrix(int size) - : _size(size), lc(10), + Action_TriMatrixMatrix(int size, int seed=10) + : _size(size), lc(seed), A(lc.fillVector(size*size)), B(lc.fillVector(size*size)), B_work(size*size) { diff --git a/btl/actions/BLAS/action_TriSolveMatrix.hpp b/btl/actions/BLAS/action_TriSolveMatrix.hpp index f2f8879..0e7ddfc 100644 --- a/btl/actions/BLAS/action_TriSolveMatrix.hpp +++ b/btl/actions/BLAS/action_TriSolveMatrix.hpp @@ -35,8 +35,8 @@ private: public: // Constructor - Action_TriSolveMatrix(int size) - : _size(size), lc(10), + Action_TriSolveMatrix(int size, int seed=10) + : _size(size), lc(seed), A(lc.fillVector(size*size)), B(lc.fillVector(size*size)), X_work(size*size) { diff --git a/btl/actions/BLAS/action_TriSolveVector.hpp b/btl/actions/BLAS/action_TriSolveVector.hpp index 6cac6f1..a858c77 100644 --- a/btl/actions/BLAS/action_TriSolveVector.hpp +++ b/btl/actions/BLAS/action_TriSolveVector.hpp @@ -35,8 +35,8 @@ private: public: // Constructor - Action_TriSolveVector(int size) - : _size(size), lc(10), + Action_TriSolveVector(int size, int seed=10) + : _size(size), lc(seed), A(lc.fillVector(size*size)), b(lc.fillVector(size)), x_work(size) { diff --git a/btl/actions/BLAS/action_axpy.hpp b/btl/actions/BLAS/action_axpy.hpp index 85cb40e..2cc8324 100644 --- a/btl/actions/BLAS/action_axpy.hpp +++ b/btl/actions/BLAS/action_axpy.hpp @@ -35,8 +35,8 @@ private: public: // Constructor - Action_axpy(int size) - : _size(size), lc(10), + Action_axpy(int size, int seed=10) + : _size(size), lc(seed), x(lc.fillVector(size)), x_work(size), y_work(size) { diff --git a/btl/actions/BLAS/action_rot.hpp b/btl/actions/BLAS/action_rot.hpp index 574254a..5eca8ba 100644 --- a/btl/actions/BLAS/action_rot.hpp +++ b/btl/actions/BLAS/action_rot.hpp @@ -35,8 +35,8 @@ private: public: // Constructor - Action_rot(int size) - : _size(size), lc(10), + Action_rot(int size, int seed=10) + : _size(size), lc(seed), x(lc.fillVector(size)), y(lc.fillVector(size)), x_work(size), y_work(size) { diff --git a/btl/actions/LAPACK/action_Choleskydecomp.hpp b/btl/actions/LAPACK/action_Choleskydecomp.hpp index b60bac1..ae0a6b0 100644 --- a/btl/actions/LAPACK/action_Choleskydecomp.hpp +++ b/btl/actions/LAPACK/action_Choleskydecomp.hpp @@ -35,8 +35,8 @@ private: public: // Constructor - Action_Choleskydecomp(int size) - : _size(size), lc(10), + Action_Choleskydecomp(int size, int seed=10) + : _size(size), lc(seed), A(lc.fillVector(size*size)), A_work(size*size) { MESSAGE("Action_Choleskydecomp Constructor"); diff --git a/btl/actions/LAPACK/action_GeneralSolve.hpp b/btl/actions/LAPACK/action_GeneralSolve.hpp index c6842b1..b547d82 100644 --- a/btl/actions/LAPACK/action_GeneralSolve.hpp +++ b/btl/actions/LAPACK/action_GeneralSolve.hpp @@ -35,8 +35,8 @@ private: public: // Constructor - Action_GeneralSolve(int size) - : _size(size), lc(10), + Action_GeneralSolve(int size, int seed=10) + : _size(size), lc(seed), A(lc.fillVector(size*size)), b(lc.fillVector(size)), A_work(size*size), x_work(size), b_res(size), ipiv(size) { diff --git a/btl/actions/LAPACK/action_LUdecomp.hpp b/btl/actions/LAPACK/action_LUdecomp.hpp index 1369017..f1e66c2 100644 --- a/btl/actions/LAPACK/action_LUdecomp.hpp +++ b/btl/actions/LAPACK/action_LUdecomp.hpp @@ -35,8 +35,8 @@ private: public: // Constructor - Action_LUdecomp(int size) - : _size(size), lc(10), + Action_LUdecomp(int size, int seed=10) + : _size(size), lc(seed), A(lc.fillVector(size*size)), A_work(size*size), eye_work(size*size), ipiv(size) { diff --git a/btl/actions/LAPACK/action_LeastSquaresSolve.hpp b/btl/actions/LAPACK/action_LeastSquaresSolve.hpp index 4bd7da4..f25c39d 100644 --- a/btl/actions/LAPACK/action_LeastSquaresSolve.hpp +++ b/btl/actions/LAPACK/action_LeastSquaresSolve.hpp @@ -35,8 +35,8 @@ private: public: // Constructor - Action_LeastSquaresSolve(int size) - : _size(size), lc(10), + Action_LeastSquaresSolve(int size, int seed=10) + : _size(size), lc(seed), A(lc.fillVector(size*size)), b(lc.fillVector(size)), A_work(size*size), x_work(size), b_res(size) { diff --git a/btl/actions/LAPACK/action_QRdecomp.hpp b/btl/actions/LAPACK/action_QRdecomp.hpp index a079407..c367f5e 100644 --- a/btl/actions/LAPACK/action_QRdecomp.hpp +++ b/btl/actions/LAPACK/action_QRdecomp.hpp @@ -35,10 +35,11 @@ private: public: // Constructor - Action_QRdecomp(int size) - : _size(size), lc(10), + Action_QRdecomp(int size, int seed=10) + : _size(size), lc(seed), A(lc.fillVector(size*size)), A_work(size*size), - tau_work(size), jpiv(size, 0), jpiv_work(size) + tau_work(size), jpiv(size, 0), jpiv_work(size), + Q_work(size*size), H_work(size*size), v_work(size), eye_work(size*size) { MESSAGE("Action_QRdecomp Constructor"); } @@ -72,7 +73,7 @@ private: LinearCongruential<> lc; const vector_t A; - vector_t A_work, tau_work; + vector_t A_work, tau_work, Q_work, H_work, v_work, eye_work; std::vector jpiv, jpiv_work; }; diff --git a/btl/generic_bench/accuracy.hpp b/btl/generic_bench/accuracy.hpp index eb3265f..eb26990 100644 --- a/btl/generic_bench/accuracy.hpp +++ b/btl/generic_bench/accuracy.hpp @@ -46,11 +46,10 @@ void bench_accuracy (int size_min, int size_max, int nb_point, // Loop on sizes for (int i = nb_point-1; i >= 0; --i) { - if (!silent) - std::cout << " " << "size = " << sizes[i] << ", " << std::flush; + const int size = sizes[i]; - // Initialize action with given size - Action action(sizes[i]); + if (!silent) + std::cout << " " << "size = " << size << ", " << std::flush; int repetitions = 0; double average = 0., stddev = 0., e; @@ -58,17 +57,20 @@ void bench_accuracy (int size_min, int size_max, int nb_point, // Perform time loop and store average and standard deviation timer.start(); do { + // Initialize action with given size and new seed + Action action(size, 15+repetitions); e = action.getResidual(); average += e; stddev += e*e; ++repetitions; - } while(timer.elapsed() < 1.); + } while(timer.elapsed() < 1. || repetitions < 4); // Compute average and standard deviation + // (sometimes strange things happen) average /= repetitions; - stddev = std::sqrt(stddev/repetitions - average*average); + stddev = std::sqrt(std::fabs(stddev/repetitions - average*average)); errors[i] = average; devs[i] = stddev; @@ -76,15 +78,17 @@ void bench_accuracy (int size_min, int size_max, int nb_point, // Output if (!silent) std::cout << "average = " << average << ", stddev = " << stddev - << std::endl; + << " (" << repetitions << " samples)" << std::endl; } // Dump the result if (!silent) { std::ofstream outfile(filename.c_str()); + // Don't dump the stddev for now for (int i = 0; i < nb_point; ++i) - outfile << sizes[i] << " " << errors[i] << " " << devs[i] << "\n"; + //outfile << sizes[i] << " " << errors[i] << " " << devs[i] << "\n"; + outfile << sizes[i] << " " << errors[i] << "\n"; outfile.close(); -- cgit v1.2.3-65-gdbad