quatmul.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <Eigen/Core>
3 #include <Eigen/Geometry>
4 #include <bench/BenchTimer.h>
5 
6 using namespace Eigen;
7 
8 template<typename Quat>
9 EIGEN_DONT_INLINE void quatmul_default(const Quat& a, const Quat& b, Quat& c)
10 {
11  c = a * b;
12 }
13 
14 template<typename Quat>
15 EIGEN_DONT_INLINE void quatmul_novec(const Quat& a, const Quat& b, Quat& c)
16 {
18 }
19 
20 template<typename Quat> void bench(const std::string& label)
21 {
22  int tries = 10;
23  int rep = 1000000;
24  BenchTimer t;
25 
26  Quat a(4, 1, 2, 3);
27  Quat b(2, 3, 4, 5);
28  Quat c;
29 
30  std::cout.precision(3);
31 
32  BENCH(t, tries, rep, quatmul_default(a,b,c));
33  std::cout << label << " default " << 1e3*t.best(CPU_TIMER) << "ms \t" << 1e-6*double(rep)/(t.best(CPU_TIMER)) << " M mul/s\n";
34 
35  BENCH(t, tries, rep, quatmul_novec(a,b,c));
36  std::cout << label << " novec " << 1e3*t.best(CPU_TIMER) << "ms \t" << 1e-6*double(rep)/(t.best(CPU_TIMER)) << " M mul/s\n";
37 }
38 
39 int main()
40 {
41  bench<Quaternionf>("float ");
42  bench<Quaterniond>("double");
43 
44  return 0;
45 
46 }
47 
bench
void bench(const std::string &label)
Definition: quatmul.cpp:20
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
b
Scalar * b
Definition: benchVecAdd.cpp:17
quatmul_default
EIGEN_DONT_INLINE void quatmul_default(const Quat &a, const Quat &b, Quat &c)
Definition: quatmul.cpp:9
Eigen::BenchTimer
Definition: BenchTimer.h:59
BENCH
#define BENCH(TIMER, TRIES, REP, CODE)
Definition: BenchTimer.h:174
main
int main()
Definition: quatmul.cpp:39
Eigen::internal::quat_product::run
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion< Scalar > run(const QuaternionBase< Derived1 > &a, const QuaternionBase< Derived2 > &b)
Definition: 3rdparty/Eigen/Eigen/src/Geometry/Quaternion.h:493
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
Eigen::CPU_TIMER
@ CPU_TIMER
Definition: BenchTimer.h:48
BenchTimer.h
align_3::t
Point2 t(10, 10)
quatmul_novec
EIGEN_DONT_INLINE void quatmul_novec(const Quat &a, const Quat &b, Quat &c)
Definition: quatmul.cpp:15
EIGEN_DONT_INLINE
#define EIGEN_DONT_INLINE
Definition: Macros.h:940


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:03:54