Bugzilla – Attachment 164 Details for
Bug 256
Assigning a vectorizable expression to an unaligned destination loses vectorization
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
a benchmark for unaligned vectorization of small fixed size objects
bench_fixed_unaligned.cpp (text/plain), 2.51 KB, created by
Gael Guennebaud
on 2011-04-26 22:13:16 UTC
(
hide
)
Description:
a benchmark for unaligned vectorization of small fixed size objects
Filename:
MIME Type:
Creator:
Gael Guennebaud
Created:
2011-04-26 22:13:16 UTC
Size:
2.51 KB
patch
obsolete
>#define EIGEN_UNROLLING_LIMIT 100000 > >#include <iostream> >#include <Eigen/Core> >#include <bench/BenchTimer.h> > >using namespace Eigen; > >template<typename Derived1, typename Derived2, int Index, int Stop> >struct assign_enforcedvec_CompleteUnrolling >{ > enum { > outer = Index / Derived1::InnerSizeAtCompileTime, > inner = Index % Derived1::InnerSizeAtCompileTime, > }; > > EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src) > { > dst.template writePacket<(Derived1::Flags&AlignedBit)?Aligned:Unaligned>(inner,outer, > src.template packet<(Derived2::Flags&AlignedBit)?Aligned:Unaligned>(inner,outer)); > assign_enforcedvec_CompleteUnrolling<Derived1, Derived2, > Index+internal::packet_traits<typename Derived1::Scalar>::size, Stop>::run(dst, src); > } >}; > >template<typename Derived1, typename Derived2, int Stop> >struct assign_enforcedvec_CompleteUnrolling<Derived1, Derived2, Stop, Stop> >{ > EIGEN_STRONG_INLINE static void run(Derived1 &, const Derived2 &) {} >}; > >template<typename Dest,typename Src> void assign_packet_unrolling(Dest& dst, const Src& src) >{ > assign_enforcedvec_CompleteUnrolling<Dest, Src, 0, Dest::SizeAtCompileTime>::run(dst, src); >} > >typedef float Scalar; >const int N = 16; >const int B = 8; >const int K = 1; >typedef Matrix<Scalar,N,1> VectorA; >typedef Matrix<Scalar,B,1> VectorB; > >EIGEN_DONT_INLINE void foo_unaligned(const VectorA& v0, const VectorA& v1, VectorA& v2) >{ > EIGEN_ASM_COMMENT("my foo_unaligned"); > VectorBlock<VectorA,B> dest = v2.segment<B>(2); > for(int k=0;k<K;++k) > assign_packet_unrolling(dest, 2 * v0.segment<B>(1) - v1.segment<B>(3)); >} > >EIGEN_DONT_INLINE void foo_default(const VectorA& v0, const VectorA& v1, VectorA& v2) >{ > EIGEN_ASM_COMMENT("my foo_default"); > for(int k=0;k<K;++k) > v2.segment<B>(2) = 2 * v0.segment<B>(1) - v1.segment<B>(3); >} > >EIGEN_DONT_INLINE void foo_aligned(const VectorB& v0, const VectorB& v1, VectorB& v2) >{ > EIGEN_ASM_COMMENT("my foo_aligned"); > for(int k=0;k<K;++k) > v2 = 2 * v0 - v1; >} > >int main() >{ > VectorA a0(VectorA::Random()), a1(VectorA::Random()), a2(VectorA::Random()); > VectorB b0(VectorB::Random()), b1(VectorB::Random()), b2(VectorB::Random()); > > int rep = 100000; > int tries = 100; > BenchTimer t0, t1, t2; > BENCH(t0,tries,rep,foo_unaligned(a0,a1,a0)); > BENCH(t1,tries,rep,foo_default(a0,a1,a0)); > BENCH(t2,tries,rep,foo_aligned(b0,b1,b2)); > > std::cout << "unaligned" << " \t" << "default" << " \t" << "aligned" << "\n"; > std::cout << t0.best() << " \t" << t1.best() << " \t" << t2.best() << "\n"; > return 0; >}
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 256
:
163
| 164 |
709