bench_reverse.cpp
Go to the documentation of this file.
1 
2 #include <iostream>
3 #include <Eigen/Core>
4 #include <bench/BenchUtil.h>
5 using namespace Eigen;
6 
7 #ifndef REPEAT
8 #define REPEAT 100000
9 #endif
10 
11 #ifndef TRIES
12 #define TRIES 20
13 #endif
14 
15 typedef double Scalar;
16 
17 template <typename MatrixType>
18 __attribute__ ((noinline)) void bench_reverse(const MatrixType& m)
19 {
20  int rows = m.rows();
21  int cols = m.cols();
22  int size = m.size();
23 
24  int repeats = (REPEAT*1000)/size;
25  MatrixType a = MatrixType::Random(rows,cols);
26  MatrixType b = MatrixType::Random(rows,cols);
27 
28  BenchTimer timerB, timerH, timerV;
29 
30  Scalar acc = 0;
31  int r = internal::random<int>(0,rows-1);
32  int c = internal::random<int>(0,cols-1);
33  for (int t=0; t<TRIES; ++t)
34  {
35  timerB.start();
36  for (int k=0; k<repeats; ++k)
37  {
38  asm("#begin foo");
39  b = a.reverse();
40  asm("#end foo");
41  acc += b.coeff(r,c);
42  }
43  timerB.stop();
44  }
45 
46  if (MatrixType::RowsAtCompileTime==Dynamic)
47  std::cout << "dyn ";
48  else
49  std::cout << "fixed ";
50  std::cout << rows << " x " << cols << " \t"
51  << (timerB.value() * REPEAT) / repeats << "s "
52  << "(" << 1e-6 * size*repeats/timerB.value() << " MFLOPS)\t";
53 
54  std::cout << "\n";
55  // make sure the compiler does not optimize too much
56  if (acc==123)
57  std::cout << acc;
58 }
59 
60 int main(int argc, char* argv[])
61 {
62  const int dynsizes[] = {4,6,8,16,24,32,49,64,128,256,512,900,0};
63  std::cout << "size no sqrt standard";
64 // #ifdef BENCH_GSL
65 // std::cout << " GSL (standard + double + ATLAS) ";
66 // #endif
67  std::cout << "\n";
68  for (uint i=0; dynsizes[i]>0; ++i)
69  {
70  bench_reverse(Matrix<Scalar,Dynamic,Dynamic>(dynsizes[i],dynsizes[i]));
71  bench_reverse(Matrix<Scalar,Dynamic,1>(dynsizes[i]*dynsizes[i]));
72  }
73 // bench_reverse(Matrix<Scalar,2,2>());
74 // bench_reverse(Matrix<Scalar,3,3>());
75 // bench_reverse(Matrix<Scalar,4,4>());
76 // bench_reverse(Matrix<Scalar,5,5>());
77 // bench_reverse(Matrix<Scalar,6,6>());
78 // bench_reverse(Matrix<Scalar,7,7>());
79 // bench_reverse(Matrix<Scalar,8,8>());
80 // bench_reverse(Matrix<Scalar,12,12>());
81 // bench_reverse(Matrix<Scalar,16,16>());
82  return 0;
83 }
84 
Matrix3f m
SCALAR Scalar
Definition: bench_gemm.cpp:46
#define TRIES
Scalar * b
Definition: benchVecAdd.cpp:17
double Scalar
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
double value(int TIMER=CPU_TIMER) const
Definition: BenchTimer.h:104
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
MatrixXf MatrixType
#define REPEAT
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
int main(int argc, char *argv[])
Array< double, 1, 3 > e(1./3., 0.5, 2.)
const int Dynamic
Definition: Constants.h:22
Point2 t(10, 10)
__attribute__((noinline)) void bench_reverse(const MatrixType &m)


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:33:57