// g++ -DNDEBUG -O3 -I.. benchLLT.cpp -o benchLLT && ./benchLLT // options: // -DBENCH_GSL -lgsl /usr/lib/libcblas.so.3 // -DSTORMEIGEN_DONT_VECTORIZE // -msse2 // -DREPEAT=100 // -DTRIES=10 // -DSCALAR=double #include #include #include #include using namespace StormEigen; #ifndef REPEAT #define REPEAT 10000 #endif #ifndef TRIES #define TRIES 10 #endif typedef float Scalar; template __attribute__ ((noinline)) void benchLLT(const MatrixType& m) { int rows = m.rows(); int cols = m.cols(); int cost = 0; for (int j=0; j SquareMatrixType; MatrixType a = MatrixType::Random(rows,cols); SquareMatrixType covMat = a * a.adjoint(); BenchTimer timerNoSqrt, timerSqrt; Scalar acc = 0; int r = internal::random(0,covMat.rows()-1); int c = internal::random(0,covMat.cols()-1); for (int t=0; t cholnosqrt(covMat); acc += cholnosqrt.matrixL().coeff(r,c); } timerNoSqrt.stop(); } for (int t=0; t chol(covMat); acc += chol.matrixL().coeff(r,c); } timerSqrt.stop(); } if (MatrixType::RowsAtCompileTime==Dynamic) std::cout << "dyn "; else std::cout << "fixed "; std::cout << covMat.rows() << " \t" << (timerNoSqrt.value() * REPEAT) / repeats << "s " << "(" << 1e-6 * cost*repeats/timerNoSqrt.value() << " MFLOPS)\t" << (timerSqrt.value() * REPEAT) / repeats << "s " << "(" << 1e-6 * cost*repeats/timerSqrt.value() << " MFLOPS)\n"; #ifdef BENCH_GSL if (MatrixType::RowsAtCompileTime==Dynamic) { timerSqrt.reset(); gsl_matrix* gslCovMat = gsl_matrix_alloc(covMat.rows(),covMat.cols()); gsl_matrix* gslCopy = gsl_matrix_alloc(covMat.rows(),covMat.cols()); eiToGsl(covMat, &gslCovMat); for (int t=0; t0; ++i) benchLLT(Matrix(dynsizes[i],dynsizes[i])); benchLLT(Matrix()); benchLLT(Matrix()); benchLLT(Matrix()); benchLLT(Matrix()); benchLLT(Matrix()); benchLLT(Matrix()); benchLLT(Matrix()); benchLLT(Matrix()); benchLLT(Matrix()); return 0; }