bench_reverse.cpp File Reference
#include <iostream>
#include <Eigen/Core>
#include <bench/BenchUtil.h>

Macros

#define REPEAT   100000
 
#define TRIES   20
 

Typedefs

typedef double Scalar
 

Functions

template<typename MatrixType >
 __attribute__ ((noinline)) void bench_reverse(const MatrixType &m)
 
int main (int argc, char *argv[])
 

Macro Definition Documentation

◆ REPEAT

#define REPEAT   100000

◆ TRIES

#define TRIES   20

Typedef Documentation

◆ Scalar

typedef double Scalar

Function Documentation

◆ __attribute__()

template<typename MatrixType >
__attribute__ ( (noinline)  ) const &
18  {
19  int rows = m.rows();
20  int cols = m.cols();
21  int size = m.size();
22 
23  int repeats = (REPEAT * 1000) / size;
24  MatrixType a = MatrixType::Random(rows, cols);
25  MatrixType b = MatrixType::Random(rows, cols);
26 
27  BenchTimer timerB, timerH, timerV;
28 
29  Scalar acc = 0;
30  int r = internal::random<int>(0, rows - 1);
31  int c = internal::random<int>(0, cols - 1);
32  for (int t = 0; t < TRIES; ++t) {
33  timerB.start();
34  for (int k = 0; k < repeats; ++k) {
35  asm("#begin foo");
36  b = a.reverse();
37  asm("#end foo");
38  acc += b.coeff(r, c);
39  }
40  timerB.stop();
41  }
42 
43  if (MatrixType::RowsAtCompileTime == Dynamic)
44  std::cout << "dyn ";
45  else
46  std::cout << "fixed ";
47  std::cout << rows << " x " << cols << " \t" << (timerB.value() * REPEAT) / repeats << "s "
48  << "(" << 1e-6 * size * repeats / timerB.value() << " MFLOPS)\t";
49 
50  std::cout << "\n";
51  // make sure the compiler does not optimize too much
52  if (acc == 123) std::cout << acc;
53 }
Array< double, 1, 3 > e(1./3., 0.5, 2.)
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
Scalar * b
Definition: benchVecAdd.cpp:17
#define REPEAT
Definition: bench_reverse.cpp:8
double Scalar
Definition: bench_reverse.cpp:15
#define TRIES
Definition: bench_reverse.cpp:12
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
Definition: BenchTimer.h:55
double value(int TIMER=CPU_TIMER) const
Definition: BenchTimer.h:94
void stop()
Definition: BenchTimer.h:77
void start()
Definition: BenchTimer.h:73
const Scalar * a
Definition: level2_cplx_impl.h:32
int * m
Definition: level2_cplx_impl.h:294
char char char int int * k
Definition: level2_impl.h:374
const int Dynamic
Definition: Constants.h:25
r
Definition: UniformPSDSelfTest.py:20
int c
Definition: calibrate.py:100
t
Definition: plotPSD.py:36

References a, b, calibrate::c, cols, Eigen::Dynamic, e(), k, m, UniformPSDSelfTest::r, REPEAT, rows, size, Eigen::BenchTimer::start(), Eigen::BenchTimer::stop(), plotPSD::t, TRIES, and Eigen::BenchTimer::value().

◆ main()

int main ( int argc  ,
char argv[] 
)
55  {
56  const int dynsizes[] = {4, 6, 8, 16, 24, 32, 49, 64, 128, 256, 512, 900, 0};
57  std::cout << "size no sqrt standard";
58  // #ifdef BENCH_GSL
59  // std::cout << " GSL (standard + double + ATLAS) ";
60  // #endif
61  std::cout << "\n";
62  for (uint i = 0; dynsizes[i] > 0; ++i) {
63  bench_reverse(Matrix<Scalar, Dynamic, Dynamic>(dynsizes[i], dynsizes[i]));
64  bench_reverse(Matrix<Scalar, Dynamic, 1>(dynsizes[i] * dynsizes[i]));
65  }
66  // bench_reverse(Matrix<Scalar,2,2>());
67  // bench_reverse(Matrix<Scalar,3,3>());
68  // bench_reverse(Matrix<Scalar,4,4>());
69  // bench_reverse(Matrix<Scalar,5,5>());
70  // bench_reverse(Matrix<Scalar,6,6>());
71  // bench_reverse(Matrix<Scalar,7,7>());
72  // bench_reverse(Matrix<Scalar,8,8>());
73  // bench_reverse(Matrix<Scalar,12,12>());
74  // bench_reverse(Matrix<Scalar,16,16>());
75  return 0;
76 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9

References i.