TR-mbed 1.0
Loading...
Searching...
No Matches
basicbenchmark.h
Go to the documentation of this file.
1
2#ifndef EIGEN_BENCH_BASICBENCH_H
3#define EIGEN_BENCH_BASICBENCH_H
4
6
7template<int Mode, typename MatrixType>
8void benchBasic_loop(const MatrixType& I, MatrixType& m, int iterations) __attribute__((noinline));
9
10template<int Mode, typename MatrixType>
11void benchBasic_loop(const MatrixType& I, MatrixType& m, int iterations)
12{
13 for(int a = 0; a < iterations; a++)
14 {
15 if (Mode==LazyEval)
16 {
17 asm("#begin_bench_loop LazyEval");
18 if (MatrixType::SizeAtCompileTime!=Eigen::Dynamic) asm("#fixedsize");
19 m = (I + 0.00005 * (m + m.lazyProduct(m))).eval();
20 }
21 else if (Mode==OmpEval)
22 {
23 asm("#begin_bench_loop OmpEval");
24 if (MatrixType::SizeAtCompileTime!=Eigen::Dynamic) asm("#fixedsize");
25 m = (I + 0.00005 * (m + m.lazyProduct(m))).eval();
26 }
27 else
28 {
29 asm("#begin_bench_loop EarlyEval");
30 if (MatrixType::SizeAtCompileTime!=Eigen::Dynamic) asm("#fixedsize");
31 m = I + 0.00005 * (m + m * m);
32 }
33 asm("#end_bench_loop");
34 }
35}
36
37template<int Mode, typename MatrixType>
38double benchBasic(const MatrixType& mat, int size, int tries) __attribute__((noinline));
39
40template<int Mode, typename MatrixType>
41double benchBasic(const MatrixType& mat, int iterations, int tries)
42{
43 const int rows = mat.rows();
44 const int cols = mat.cols();
45
48
50
52 for(uint t=0; t<tries; ++t)
53 {
55 timer.start();
56 benchBasic_loop<Mode>(I, m, iterations);
57 timer.stop();
58 cerr << m;
59 }
60 return timer.value();
61};
62
63#endif // EIGEN_BENCH_BASICBENCH_H
Matrix3f m
Definition AngleAxis_mimic_euler.cpp:1
ArrayXXi a
Definition Array_initializer_list_23_cxx11.cpp:1
void initMatrix_identity(MatrixType &mat) __attribute__((noinline))
Definition BenchUtil.h:28
void initMatrix_random(MatrixType &mat) __attribute__((noinline))
Definition BenchUtil.h:22
MatrixXf mat
Definition Tutorial_AdvancedInitialization_CommaTemporary.cpp:1
int rows
Definition Tutorial_commainit_02.cpp:1
int cols
Definition Tutorial_commainit_02.cpp:1
@ LazyEval
Definition basicbenchmark.h:5
@ EarlyEval
Definition basicbenchmark.h:5
@ OmpEval
Definition basicbenchmark.h:5
double benchBasic(const MatrixType &mat, int size, int tries) __attribute__((noinline))
Definition basicbenchmark.h:41
void benchBasic_loop(const MatrixType &I, MatrixType &m, int iterations) __attribute__((noinline))
Definition basicbenchmark.h:11
Scalar Scalar int size
Definition benchVecAdd.cpp:17
__attribute__((noinline)) void bench_reverse(const MatrixType &m)
Definition bench_reverse.cpp:18
MatrixXf MatrixType
Definition benchmark-blocking-sizes.cpp:52
Definition BenchTimer.h:60
double value(int TIMER=CPU_TIMER) const
Definition BenchTimer.h:104
void stop()
Definition BenchTimer.h:86
void start()
Definition BenchTimer.h:81
#define I
Definition main.h:112
const int Dynamic
Definition Constants.h:22