gtsam
3rdparty
Eigen
bench
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
<<
"("
<< 1
e
-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
Eigen
Namespace containing all symbols from the Eigen library.
Definition:
jet.h:637
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
MatrixType
MatrixXf MatrixType
Definition:
benchmark-blocking-sizes.cpp:52
REPEAT
#define REPEAT
Definition:
bench_reverse.cpp:8
c
Scalar Scalar * c
Definition:
benchVecAdd.cpp:17
b
Scalar * b
Definition:
benchVecAdd.cpp:17
rows
int rows
Definition:
Tutorial_commainit_02.cpp:1
Scalar
double Scalar
Definition:
bench_reverse.cpp:15
size
Scalar Scalar int size
Definition:
benchVecAdd.cpp:17
main
int main(int argc, char *argv[])
Definition:
bench_reverse.cpp:60
Eigen::BenchTimer::value
double value(int TIMER=CPU_TIMER) const
Definition:
BenchTimer.h:104
BenchUtil.h
Eigen::BenchTimer::start
void start()
Definition:
BenchTimer.h:81
Eigen::Dynamic
const int Dynamic
Definition:
Constants.h:22
Eigen::BenchTimer
Definition:
BenchTimer.h:59
m
Matrix3f m
Definition:
AngleAxis_mimic_euler.cpp:1
a
ArrayXXi a
Definition:
Array_initializer_list_23_cxx11.cpp:1
__attribute__
__attribute__((noinline)) void bench_reverse(const MatrixType &m)
Definition:
bench_reverse.cpp:18
Eigen::BenchTimer::stop
void stop()
Definition:
BenchTimer.h:86
TRIES
#define TRIES
Definition:
bench_reverse.cpp:12
Eigen::Matrix< Scalar, Dynamic, Dynamic >
cols
int cols
Definition:
Tutorial_commainit_02.cpp:1
align_3::t
Point2 t(10, 10)
i
int i
Definition:
BiCGSTAB_step_by_step.cpp:9
Scalar
SCALAR Scalar
Definition:
bench_gemm.cpp:46
gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:11