Bugzilla – Attachment 696 Details for
Bug 1201
Very slow Affine3f to Vector3f multiplication
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Forgot Password
Login:
[x]
This bugzilla service is closed. All entries have been migrated to
https://gitlab.com/libeigen/eigen
benchmark for affine*vector product
affine.cpp (text/x-csrc), 1.94 KB, created by
Gael Guennebaud
on 2016-04-15 10:16:54 UTC
(
hide
)
Description:
benchmark for affine*vector product
Filename:
MIME Type:
Creator:
Gael Guennebaud
Created:
2016-04-15 10:16:54 UTC
Size:
1.94 KB
patch
obsolete
>#include <iostream> >#include <Eigen/Dense> >#include <Eigen/Geometry> >#include <bench/BenchTimer.h> > > >using namespace Eigen; > >template<typename T1, typename T2, typename T3> >EIGEN_DONT_INLINE >void foo1(T1 &C, const T2 &A, const T3 &B) { > C = A * B; >} > >template<typename T1, typename T2, typename T3> >EIGEN_DONT_INLINE >void foo2(T1 &C, const T2 &A, const T3 &B) { > C = A.matrix() * B; >} > > >template<typename T1, typename T2, typename T3> >EIGEN_DONT_INLINE >void foo3(T1 &C, const T2 &A, const T3 &B) { > typedef Matrix<typename T1::Scalar,T1::SizeAtCompileTime+1,1> Vec1; > Vec1 B4, C4; > B4 << B, 1; > C4 = A.matrix() * B4; > C = C4.template head<T1::SizeAtCompileTime>(); >} > >template<typename T1, typename T2, typename T3> >EIGEN_DONT_INLINE >void foo4(T1 &C, const T2 &A, const T3 &B) { > typedef Matrix<typename T1::Scalar,T1::SizeAtCompileTime+1,1> Vec1; > Vec1 B4, C4; > B4 << B, 1; > C4 = A * B4; > C = C4.template head<T1::SizeAtCompileTime>(); >} > >template<typename Scalar, int Dim> >EIGEN_DONT_INLINE >Scalar bench() >{ > int tries = 10; > int rep = 1000000; > > BenchTimer t1, t2, t3, t4, t5; > Transform<Scalar,Dim,Affine> A; A.matrix().setRandom(); > Matrix<Scalar,Dim,1> v3, res3; v3.setRandom(); > Matrix<Scalar,Dim+1,1> v4, res4; v4.setRandom(); > BENCH(t1,tries,rep,foo1(res3,A,v3)); > BENCH(t2,tries,rep,foo2(res4,A,v4)); > BENCH(t3,tries,rep,foo3(res3,A,v3)); > BENCH(t4,tries,rep,foo4(res3,A,v3)); > BENCH(t5,tries,rep,foo1(res4,A,v4)); > std::cout << Dim << typeid(Scalar).name() << " : " << t1.best() << " - " << t2.best() << " - " << t3.best() << " - " << t4.best() << " - " << t5.best() << std::endl; > return res3.sum() + res4.sum(); >} > >int main(int argc, char *argv[]) >{ > std::cout << " A*v A.mat()*h A.mat()*[v,1] A*[v,1] A*h\n"; > bench<float,1>(); > bench<float,2>(); > bench<float,3>(); > bench<float,4>(); > bench<float,5>(); > > bench<double,1>(); > bench<double,2>(); > bench<double,3>(); > bench<double,4>(); > bench<double,5>(); > > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1201
: 696