Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
Enumerations
a
c
d
e
f
g
i
k
l
m
n
p
q
r
s
t
u
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
z
Classes
Class List
Class Hierarchy
Class Members
All
!
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
!
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
a
b
c
d
f
k
l
m
n
o
p
r
s
t
v
z
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Related Functions
:
a
b
c
d
e
g
h
i
l
m
n
o
p
r
s
t
u
v
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
x
z
Enumerations
Enumerator
b
c
e
f
g
i
l
m
n
o
p
r
s
t
u
v
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Examples
gtsam
3rdparty
Eigen
bench
product_threshold.cpp
Go to the documentation of this file.
1
2
#include <iostream>
3
#include <Eigen/Core>
4
#include <
bench/BenchTimer.h
>
5
6
using namespace
Eigen
;
7
using namespace
std
;
8
9
#define END 9
10
11
template
<
int
S>
struct
map_size
{
enum
{
ret
=
S
}; };
12
template
<>
struct
map_size
<10> {
enum
{
ret
= 20 }; };
13
template
<>
struct
map_size
<11> {
enum
{
ret
= 50 }; };
14
template
<>
struct
map_size
<12> {
enum
{
ret
= 100 }; };
15
template
<>
struct
map_size
<13> {
enum
{
ret
= 300 }; };
16
17
template
<
int
M,
int
N,
int
K>
struct
alt_prod
18
{
19
enum
{
20
ret
=
M
==1 &&
N
==1 ?
InnerProduct
21
:
K
==1 ?
OuterProduct
22
:
M
==1 ?
GemvProduct
23
:
N
==1 ?
GemvProduct
24
:
GemmProduct
25
};
26
};
27
28
void
print_mode
(
int
mode
)
29
{
30
if
(
mode
==
InnerProduct
) std::cout <<
"i"
;
31
if
(
mode
==
OuterProduct
) std::cout <<
"o"
;
32
if
(
mode
==
CoeffBasedProductMode
) std::cout <<
"c"
;
33
if
(
mode
==
LazyCoeffBasedProductMode
) std::cout <<
"l"
;
34
if
(
mode
==
GemvProduct
) std::cout <<
"v"
;
35
if
(
mode
==
GemmProduct
) std::cout <<
"m"
;
36
}
37
38
template
<
int
Mode,
typename
Lhs,
typename
Rhs,
typename
Res>
39
EIGEN_DONT_INLINE
void
prod
(
const
Lhs
&
a
,
const
Rhs
&
b
, Res&
c
)
40
{
41
c
.noalias() +=
typename
ProductReturnType<Lhs,Rhs,Mode>::Type
(
a
,
b
);
42
}
43
44
template
<
int
M,
int
N,
int
K,
typename
Scalar,
int
Mode>
45
EIGEN_DONT_INLINE
void
bench_prod
()
46
{
47
typedef
Matrix<Scalar,M,K>
Lhs
;
Lhs
a
;
a
.setRandom();
48
typedef
Matrix<Scalar,K,N>
Rhs
;
Rhs
b
;
b
.setRandom();
49
typedef
Matrix<Scalar,M,N>
Res; Res
c
;
c
.setRandom();
50
51
BenchTimer
t
;
52
double
n
= 2.*double(
M
)*double(
N
)*double(
K
);
53
int
rep = 100000./
n
;
54
rep /= 2;
55
if
(rep<1) rep = 1;
56
do
{
57
rep *= 2;
58
t
.reset();
59
BENCH
(
t
,1,rep,prod<CoeffBasedProductMode>(
a
,
b
,
c
));
60
}
while
(
t
.best()<0.1);
61
62
t
.reset();
63
BENCH
(
t
,5,rep,prod<Mode>(
a
,
b
,
c
));
64
65
print_mode
(Mode);
66
std::cout <<
int
(1
e
-6*
n
*rep/
t
.best()) <<
"\t"
;
67
}
68
69
template
<
int
N>
struct
print_n
;
70
template
<
int
M,
int
N,
int
K>
struct
loop_on_m
;
71
template
<
int
M,
int
N,
int
K,
typename
Scalar,
int
Mode>
struct
loop_on_n
;
72
73
template
<
int
M,
int
N,
int
K>
74
struct
loop_on_k
75
{
76
static
void
run
()
77
{
78
std::cout <<
"K="
<<
K
<<
"\t"
;
79
print_n<N>::run
();
80
std::cout <<
"\n"
;
81
82
loop_on_m<M,N,K>::run
();
83
std::cout <<
"\n\n"
;
84
85
loop_on_k<M,N,K+1>::run
();
86
}
87
};
88
89
template
<
int
M,
int
N>
90
struct
loop_on_k
<
M
,
N
,
END
> {
static
void
run
(){} };
91
92
93
template
<
int
M,
int
N,
int
K>
94
struct
loop_on_m
95
{
96
static
void
run
()
97
{
98
std::cout <<
M
<<
"f\t"
;
99
loop_on_n<M,N,K,float,CoeffBasedProductMode>::run
();
100
std::cout <<
"\n"
;
101
102
std::cout <<
M
<<
"f\t"
;
103
loop_on_n<M,N,K,float,-1>::run
();
104
std::cout <<
"\n"
;
105
106
loop_on_m<M+1,N,K>::run
();
107
}
108
};
109
110
template
<
int
N,
int
K>
111
struct
loop_on_m
<
END
,
N
,
K
> {
static
void
run
(){} };
112
113
template
<
int
M,
int
N,
int
K,
typename
Scalar,
int
Mode>
114
struct
loop_on_n
115
{
116
static
void
run
()
117
{
118
bench_prod
<
M
,
N
,
K
,
Scalar
,Mode==-1?
alt_prod<M,N,K>::ret
: Mode>();
119
120
loop_on_n<M,N+1,K,Scalar,Mode>::run
();
121
}
122
};
123
124
template
<
int
M,
int
K,
typename
Scalar,
int
Mode>
125
struct
loop_on_n
<
M
,
END
,
K
,
Scalar
,Mode> {
static
void
run
(){} };
126
127
template
<
int
N>
struct
print_n
128
{
129
static
void
run
()
130
{
131
std::cout << map_size<N>::ret
<<
"\t"
;
132
print_n<N+1>::run
();
133
}
134
};
135
136
template
<>
struct
print_n
<
END
> {
static
void
run
(){} };
137
138
int
main
()
139
{
140
loop_on_k<1,1,1>::run
();
141
142
return
0;
143
}
gtsam.examples.DogLegOptimizerExample.int
int
Definition:
DogLegOptimizerExample.py:111
loop_on_k
Definition:
product_threshold.cpp:74
Eigen::internal::Lhs
@ Lhs
Definition:
TensorContractionMapper.h:19
Eigen
Namespace containing all symbols from the Eigen library.
Definition:
jet.h:637
Eigen::CoeffBasedProductMode
@ CoeffBasedProductMode
Definition:
Constants.h:500
Eigen::GemvProduct
@ GemvProduct
Definition:
Constants.h:500
END
#define END
Definition:
product_threshold.cpp:9
loop_on_m::run
static void run()
Definition:
product_threshold.cpp:96
loop_on_k< M, N, END >::run
static void run()
Definition:
product_threshold.cpp:90
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
loop_on_n::run
static void run()
Definition:
product_threshold.cpp:116
c
Scalar Scalar * c
Definition:
benchVecAdd.cpp:17
b
Scalar * b
Definition:
benchVecAdd.cpp:17
ret
DenseIndex ret
Definition:
level1_cplx_impl.h:44
Eigen::LazyCoeffBasedProductMode
@ LazyCoeffBasedProductMode
Definition:
Constants.h:500
loop_on_m< END, N, K >::run
static void run()
Definition:
product_threshold.cpp:111
n
int n
Definition:
BiCGSTAB_simple.cpp:1
map_size
Definition:
product_threshold.cpp:11
loop_on_n< M, END, K, Scalar, Mode >::run
static void run()
Definition:
product_threshold.cpp:125
mode
static const DiscreteKey mode(modeKey, 2)
Eigen::Architecture::Type
Type
Definition:
Constants.h:471
Eigen::BenchTimer
Definition:
BenchTimer.h:59
BENCH
#define BENCH(TIMER, TRIES, REP, CODE)
Definition:
BenchTimer.h:174
bench_prod
EIGEN_DONT_INLINE void bench_prod()
Definition:
product_threshold.cpp:45
Eigen::GemmProduct
@ GemmProduct
Definition:
Constants.h:500
print_n
Definition:
product_threshold.cpp:69
loop_on_m
Definition:
product_threshold.cpp:70
Eigen::InnerProduct
@ InnerProduct
Definition:
Constants.h:500
a
ArrayXXi a
Definition:
Array_initializer_list_23_cxx11.cpp:1
K
#define K
Definition:
igam.h:8
Eigen::internal::Rhs
@ Rhs
Definition:
TensorContractionMapper.h:18
alt_prod
Definition:
product_threshold.cpp:17
print_n< END >::run
static void run()
Definition:
product_threshold.cpp:136
std
Definition:
BFloat16.h:88
print_mode
void print_mode(int mode)
Definition:
product_threshold.cpp:28
BenchTimer.h
print_n::run
static void run()
Definition:
product_threshold.cpp:129
loop_on_n
Definition:
product_threshold.cpp:71
Eigen::Matrix
The matrix class, also used for vectors and row-vectors.
Definition:
3rdparty/Eigen/Eigen/src/Core/Matrix.h:178
N
#define N
Definition:
igam.h:9
loop_on_k::run
static void run()
Definition:
product_threshold.cpp:76
align_3::t
Point2 t(10, 10)
Eigen::OuterProduct
@ OuterProduct
Definition:
Constants.h:500
main
int main()
Definition:
product_threshold.cpp:138
Eigen::prod
const Product< Lhs, Rhs > prod(const Lhs &lhs, const Rhs &rhs)
Definition:
evaluators.cpp:8
S
DiscreteKey S(1, 2)
Scalar
SCALAR Scalar
Definition:
bench_gemm.cpp:46
EIGEN_DONT_INLINE
#define EIGEN_DONT_INLINE
Definition:
Macros.h:940
M
Matrix< RealScalar, Dynamic, Dynamic > M
Definition:
bench_gemm.cpp:51
gtsam
Author(s):
autogenerated on Wed Mar 19 2025 03:03:02