From 77a622f2bb3356ee005a9413f6436373ec06efc2 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 8 Jul 2008 17:20:17 +0000 Subject: add Cholesky and eigensolver benchmark --- bench/benchEigenSolver.cpp | 210 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 bench/benchEigenSolver.cpp (limited to 'bench/benchEigenSolver.cpp') diff --git a/bench/benchEigenSolver.cpp b/bench/benchEigenSolver.cpp new file mode 100644 index 000000000..a62ee41f4 --- /dev/null +++ b/bench/benchEigenSolver.cpp @@ -0,0 +1,210 @@ + +// g++ -DNDEBUG -O3 -I.. benchEigenSolver.cpp -o benchEigenSolver && ./benchEigenSolver +// options: +// -DBENCH_GMM +// -DBENCH_GSL -lgsl /usr/lib/libcblas.so.3 +// -DEIGEN_DONT_VECTORIZE +// -msse2 +// -DREPEAT=100 +// -DTRIES=10 +// -DSCALAR=double + +#include +#include +#include +using namespace Eigen; + +#ifndef REPEAT +#define REPEAT 1000 +#endif + +#ifndef TRIES +#define TRIES 4 +#endif + +#ifndef SCALAR +#define SCALAR float +#endif + +typedef SCALAR Scalar; + +template +__attribute__ ((noinline)) void benchEigenSolver(const MatrixType& m) +{ + int rows = m.rows(); + int cols = m.cols(); + + int stdRepeats = std::max(1,int((REPEAT*1000)/(rows*rows*sqrt(rows)))); + int saRepeats = stdRepeats * 4; + + typedef typename MatrixType::Scalar Scalar; + typedef Matrix SquareMatrixType; + + MatrixType a = MatrixType::random(rows,cols); + SquareMatrixType covMat = a * a.adjoint(); + + BenchTimer timerSa, timerStd; + + Scalar acc = 0; + int r = ei_random(0,covMat.rows()-1); + int c = ei_random(0,covMat.cols()-1); + { + SelfAdjointEigenSolver ei(covMat); + for (int t=0; t ei(covMat); + for (int t=0; t gmmCovMat(covMat.rows(),covMat.cols()); + gmm::dense_matrix eigvect(covMat.rows(),covMat.cols()); + std::vector eigval(covMat.rows()); + eiToGmm(covMat, gmmCovMat); + for (int t=0; t0; ++i) + benchEigenSolver(Matrix(dynsizes[i],dynsizes[i])); + + benchEigenSolver(Matrix()); + benchEigenSolver(Matrix()); + benchEigenSolver(Matrix()); + benchEigenSolver(Matrix()); + benchEigenSolver(Matrix()); + benchEigenSolver(Matrix()); + benchEigenSolver(Matrix()); + return 0; +} + -- cgit v1.2.3