basicbenchmark.h
Go to the documentation of this file.
00001 
00002 #ifndef EIGEN_BENCH_BASICBENCH_H
00003 #define EIGEN_BENCH_BASICBENCH_H
00004 
00005 enum {LazyEval, EarlyEval, OmpEval};
00006 
00007 template<int Mode, typename MatrixType>
00008 void benchBasic_loop(const MatrixType& I, MatrixType& m, int iterations) __attribute__((noinline));
00009 
00010 template<int Mode, typename MatrixType>
00011 void benchBasic_loop(const MatrixType& I, MatrixType& m, int iterations)
00012 {
00013   for(int a = 0; a < iterations; a++)
00014   {
00015     if (Mode==LazyEval)
00016     {
00017       asm("#begin_bench_loop LazyEval");
00018       if (MatrixType::SizeAtCompileTime!=Eigen::Dynamic) asm("#fixedsize");
00019       m = (I + 0.00005 * (m + m.lazy() * m)).eval();
00020     }
00021     else if (Mode==OmpEval)
00022     {
00023       asm("#begin_bench_loop OmpEval");
00024       if (MatrixType::SizeAtCompileTime!=Eigen::Dynamic) asm("#fixedsize");
00025       m = (I + 0.00005 * (m + m.lazy() * m)).evalOMP();
00026     }
00027     else
00028     {
00029       asm("#begin_bench_loop EarlyEval");
00030       if (MatrixType::SizeAtCompileTime!=Eigen::Dynamic) asm("#fixedsize");
00031       m = I + 0.00005 * (m + m * m);
00032     }
00033     asm("#end_bench_loop");
00034   }
00035 }
00036 
00037 template<int Mode, typename MatrixType>
00038 double benchBasic(const MatrixType& mat, int size, int tries) __attribute__((noinline));
00039 
00040 template<int Mode, typename MatrixType>
00041 double benchBasic(const MatrixType& mat, int iterations, int tries)
00042 {
00043   const int rows = mat.rows();
00044   const int cols = mat.cols();
00045 
00046   MatrixType I(rows,cols);
00047   MatrixType m(rows,cols);
00048 
00049   initMatrix_identity(I);
00050 
00051   Eigen::BenchTimer timer;
00052   for(uint t=0; t<tries; ++t)
00053   {
00054     initMatrix_random(m);
00055     timer.start();
00056     benchBasic_loop<Mode>(I, m, iterations);
00057     timer.stop();
00058     cerr << m;
00059   }
00060   return timer.value();
00061 };
00062 
00063 #endif // EIGEN_BENCH_BASICBENCH_H


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:30:47