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 
EIGEN_DONT_INLINE void quatmul_default(const Quat &a, const Quat &b, Quat &c)
Definition: quatmul.cpp:9
Scalar * b
Definition: benchVecAdd.cpp:17
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
#define EIGEN_DONT_INLINE
Definition: Macros.h:940
double best(int TIMER=CPU_TIMER) const
Definition: BenchTimer.h:111
int main()
Definition: quatmul.cpp:39
Array< double, 1, 3 > e(1./3., 0.5, 2.)
void bench(const std::string &label)
Definition: quatmul.cpp:20
EIGEN_DONT_INLINE void quatmul_novec(const Quat &a, const Quat &b, Quat &c)
Definition: quatmul.cpp:15
#define BENCH(TIMER, TRIES, REP, CODE)
Definition: BenchTimer.h:174
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion< Scalar > run(const QuaternionBase< Derived1 > &a, const QuaternionBase< Derived2 > &b)
Point2 t(10, 10)


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:35:29