• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2015 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifdef EIGEN_TEST_PART_1
11 #define EIGEN_UNALIGNED_VECTORIZE 1
12 #endif
13 
14 #ifdef EIGEN_TEST_PART_2
15 #define EIGEN_UNALIGNED_VECTORIZE 0
16 #endif
17 
18 #ifdef EIGEN_DEFAULT_TO_ROW_MAJOR
19 #undef EIGEN_DEFAULT_TO_ROW_MAJOR
20 #endif
21 #define EIGEN_DEBUG_ASSIGN
22 #include "main.h"
23 #include <typeinfo>
24 
25 // Disable "ignoring attributes on template argument"
26 // for packet_traits<Packet*>
27 // => The only workaround would be to wrap _m128 and the likes
28 //    within wrappers.
29 #if EIGEN_GNUC_AT_LEAST(6,0)
30     #pragma GCC diagnostic ignored "-Wignored-attributes"
31 #endif
32 
33 using internal::demangle_flags;
34 using internal::demangle_traversal;
35 using internal::demangle_unrolling;
36 
37 template<typename Dst, typename Src>
test_assign(const Dst &,const Src &,int traversal,int unrolling)38 bool test_assign(const Dst&, const Src&, int traversal, int unrolling)
39 {
40   EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Dst,Src);
41   typedef internal::copy_using_evaluator_traits<internal::evaluator<Dst>,internal::evaluator<Src>, internal::assign_op<typename Dst::Scalar,typename Src::Scalar> > traits;
42   bool res = traits::Traversal==traversal;
43   if(unrolling==InnerUnrolling+CompleteUnrolling)
44     res = res && (int(traits::Unrolling)==InnerUnrolling || int(traits::Unrolling)==CompleteUnrolling);
45   else
46     res = res && int(traits::Unrolling)==unrolling;
47   if(!res)
48   {
49     std::cerr << "Src: " << demangle_flags(Src::Flags) << std::endl;
50     std::cerr << "     " << demangle_flags(internal::evaluator<Src>::Flags) << std::endl;
51     std::cerr << "Dst: " << demangle_flags(Dst::Flags) << std::endl;
52     std::cerr << "     " << demangle_flags(internal::evaluator<Dst>::Flags) << std::endl;
53     traits::debug();
54     std::cerr << " Expected Traversal == " << demangle_traversal(traversal)
55               << " got " << demangle_traversal(traits::Traversal) << "\n";
56     std::cerr << " Expected Unrolling == " << demangle_unrolling(unrolling)
57               << " got " << demangle_unrolling(traits::Unrolling) << "\n";
58   }
59   return res;
60 }
61 
62 template<typename Dst, typename Src>
test_assign(int traversal,int unrolling)63 bool test_assign(int traversal, int unrolling)
64 {
65   EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Dst,Src);
66   typedef internal::copy_using_evaluator_traits<internal::evaluator<Dst>,internal::evaluator<Src>, internal::assign_op<typename Dst::Scalar,typename Src::Scalar> > traits;
67   bool res = traits::Traversal==traversal && traits::Unrolling==unrolling;
68   if(!res)
69   {
70     std::cerr << "Src: " << demangle_flags(Src::Flags) << std::endl;
71     std::cerr << "     " << demangle_flags(internal::evaluator<Src>::Flags) << std::endl;
72     std::cerr << "Dst: " << demangle_flags(Dst::Flags) << std::endl;
73     std::cerr << "     " << demangle_flags(internal::evaluator<Dst>::Flags) << std::endl;
74     traits::debug();
75     std::cerr << " Expected Traversal == " << demangle_traversal(traversal)
76               << " got " << demangle_traversal(traits::Traversal) << "\n";
77     std::cerr << " Expected Unrolling == " << demangle_unrolling(unrolling)
78               << " got " << demangle_unrolling(traits::Unrolling) << "\n";
79   }
80   return res;
81 }
82 
83 template<typename Xpr>
test_redux(const Xpr &,int traversal,int unrolling)84 bool test_redux(const Xpr&, int traversal, int unrolling)
85 {
86   typedef typename Xpr::Scalar Scalar;
87   typedef internal::redux_traits<internal::scalar_sum_op<Scalar,Scalar>,internal::redux_evaluator<Xpr> > traits;
88 
89   bool res = traits::Traversal==traversal && traits::Unrolling==unrolling;
90   if(!res)
91   {
92     std::cerr << demangle_flags(Xpr::Flags) << std::endl;
93     std::cerr << demangle_flags(internal::evaluator<Xpr>::Flags) << std::endl;
94     traits::debug();
95 
96     std::cerr << " Expected Traversal == " << demangle_traversal(traversal)
97               << " got " << demangle_traversal(traits::Traversal) << "\n";
98     std::cerr << " Expected Unrolling == " << demangle_unrolling(unrolling)
99               << " got " << demangle_unrolling(traits::Unrolling) << "\n";
100   }
101   return res;
102 }
103 
104 template<typename Scalar, bool Enable = internal::packet_traits<Scalar>::Vectorizable>
105 struct vectorization_logic
106 {
107   typedef internal::packet_traits<Scalar> PacketTraits;
108 
109   typedef typename internal::packet_traits<Scalar>::type PacketType;
110   typedef typename internal::unpacket_traits<PacketType>::half HalfPacketType;
111   enum {
112     PacketSize = internal::unpacket_traits<PacketType>::size,
113     HalfPacketSize = internal::unpacket_traits<HalfPacketType>::size
114   };
runvectorization_logic115   static void run()
116   {
117 
118     typedef Matrix<Scalar,PacketSize,1> Vector1;
119     typedef Matrix<Scalar,Dynamic,1> VectorX;
120     typedef Matrix<Scalar,Dynamic,Dynamic> MatrixXX;
121     typedef Matrix<Scalar,PacketSize,PacketSize> Matrix11;
122     typedef Matrix<Scalar,(Matrix11::Flags&RowMajorBit)?8:2*PacketSize,(Matrix11::Flags&RowMajorBit)?2*PacketSize:8>   Matrix22;
123     typedef Matrix<Scalar,(Matrix11::Flags&RowMajorBit)?16:4*PacketSize,(Matrix11::Flags&RowMajorBit)?4*PacketSize:16> Matrix44;
124     typedef Matrix<Scalar,(Matrix11::Flags&RowMajorBit)?16:4*PacketSize,(Matrix11::Flags&RowMajorBit)?4*PacketSize:16,DontAlign|EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION> Matrix44u;
125     typedef Matrix<Scalar,4*PacketSize,4*PacketSize,ColMajor> Matrix44c;
126     typedef Matrix<Scalar,4*PacketSize,4*PacketSize,RowMajor> Matrix44r;
127 
128     typedef Matrix<Scalar,
129         (PacketSize==16 ? 8 : PacketSize==8 ? 4 : PacketSize==4 ? 2 : PacketSize==2 ? 1 : /*PacketSize==1 ?*/ 1),
130         (PacketSize==16 ? 2 : PacketSize==8 ? 2 : PacketSize==4 ? 2 : PacketSize==2 ? 2 : /*PacketSize==1 ?*/ 1)
131       > Matrix1;
132 
133     typedef Matrix<Scalar,
134         (PacketSize==16 ? 8 : PacketSize==8 ? 4 : PacketSize==4 ? 2 : PacketSize==2 ? 1 : /*PacketSize==1 ?*/ 1),
135         (PacketSize==16 ? 2 : PacketSize==8 ? 2 : PacketSize==4 ? 2 : PacketSize==2 ? 2 : /*PacketSize==1 ?*/ 1),
136       DontAlign|((Matrix1::Flags&RowMajorBit)?RowMajor:ColMajor)> Matrix1u;
137 
138     // this type is made such that it can only be vectorized when viewed as a linear 1D vector
139     typedef Matrix<Scalar,
140         (PacketSize==16 ?  4 : PacketSize==8 ? 4 : PacketSize==4 ? 6 : PacketSize==2 ? ((Matrix11::Flags&RowMajorBit)?2:3) : /*PacketSize==1 ?*/ 1),
141         (PacketSize==16 ? 12 : PacketSize==8 ? 6 : PacketSize==4 ? 2 : PacketSize==2 ? ((Matrix11::Flags&RowMajorBit)?3:2) : /*PacketSize==1 ?*/ 3)
142       > Matrix3;
143 
144     #if !EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT
145     VERIFY(test_assign(Vector1(),Vector1(),
146       InnerVectorizedTraversal,CompleteUnrolling));
147     VERIFY(test_assign(Vector1(),Vector1()+Vector1(),
148       InnerVectorizedTraversal,CompleteUnrolling));
149     VERIFY(test_assign(Vector1(),Vector1().cwiseProduct(Vector1()),
150       InnerVectorizedTraversal,CompleteUnrolling));
151     VERIFY(test_assign(Vector1(),Vector1().template cast<Scalar>(),
152       InnerVectorizedTraversal,CompleteUnrolling));
153 
154     VERIFY(test_assign(Matrix44(),Matrix44()+Matrix44(),
155       InnerVectorizedTraversal,InnerUnrolling));
156 
157     VERIFY(test_assign(Matrix44u(),Matrix44()+Matrix44(),
158       EIGEN_UNALIGNED_VECTORIZE ? InnerVectorizedTraversal : LinearTraversal,
159       EIGEN_UNALIGNED_VECTORIZE ? InnerUnrolling : NoUnrolling));
160 
161     VERIFY(test_assign(Matrix1(),Matrix1()+Matrix1(),
162       (int(Matrix1::InnerSizeAtCompileTime) % int(PacketSize))==0 ? InnerVectorizedTraversal : LinearVectorizedTraversal,
163       CompleteUnrolling));
164 
165     VERIFY(test_assign(Matrix1u(),Matrix1()+Matrix1(),
166       EIGEN_UNALIGNED_VECTORIZE ? ((int(Matrix1::InnerSizeAtCompileTime) % int(PacketSize))==0 ? InnerVectorizedTraversal : LinearVectorizedTraversal)
167                                 : LinearTraversal, CompleteUnrolling));
168 
169     VERIFY(test_assign(Matrix44c().col(1),Matrix44c().col(2)+Matrix44c().col(3),
170       InnerVectorizedTraversal,CompleteUnrolling));
171 
172     VERIFY(test_assign(Matrix44r().row(2),Matrix44r().row(1)+Matrix44r().row(1),
173       InnerVectorizedTraversal,CompleteUnrolling));
174 
175     if(PacketSize>1)
176     {
177       typedef Matrix<Scalar,3,3,ColMajor> Matrix33c;
178       typedef Matrix<Scalar,3,1,ColMajor> Vector3;
179       VERIFY(test_assign(Matrix33c().row(2),Matrix33c().row(1)+Matrix33c().row(1),
180         LinearTraversal,CompleteUnrolling));
181       VERIFY(test_assign(Vector3(),Vector3()+Vector3(),
182         sizeof(Scalar)==16 ? InnerVectorizedTraversal : (EIGEN_UNALIGNED_VECTORIZE ? LinearVectorizedTraversal : LinearTraversal), CompleteUnrolling));
183       VERIFY(test_assign(Matrix33c().col(0),Matrix33c().col(1)+Matrix33c().col(1),
184         EIGEN_UNALIGNED_VECTORIZE ? (sizeof(Scalar)==16 ? InnerVectorizedTraversal : LinearVectorizedTraversal)
185                                   : (sizeof(Scalar)==16 ? SliceVectorizedTraversal : LinearTraversal),
186         ((!EIGEN_UNALIGNED_VECTORIZE) && (sizeof(Scalar)==16)) ? NoUnrolling : CompleteUnrolling));
187 
188       VERIFY(test_assign(Matrix3(),Matrix3().cwiseProduct(Matrix3()),
189         LinearVectorizedTraversal,CompleteUnrolling));
190 
191       VERIFY(test_assign(Matrix<Scalar,17,17>(),Matrix<Scalar,17,17>()+Matrix<Scalar,17,17>(),
192         sizeof(Scalar)==16        ? InnerVectorizedTraversal  :
193         EIGEN_UNALIGNED_VECTORIZE ? LinearVectorizedTraversal :
194                                     LinearTraversal,
195         NoUnrolling));
196 
197       VERIFY(test_assign(Matrix11(), Matrix11()+Matrix11(),InnerVectorizedTraversal,CompleteUnrolling));
198 
199 
200       VERIFY(test_assign(Matrix11(),Matrix<Scalar,21,21>().template block<PacketSize,PacketSize>(2,3)+Matrix<Scalar,21,21>().template block<PacketSize,PacketSize>(3,2),
201         (EIGEN_UNALIGNED_VECTORIZE) ? InnerVectorizedTraversal : DefaultTraversal, CompleteUnrolling|InnerUnrolling));
202 
203       VERIFY(test_assign(Vector1(),Matrix11()*Vector1(),
204                          InnerVectorizedTraversal,CompleteUnrolling));
205 
206       VERIFY(test_assign(Matrix11(),Matrix11().lazyProduct(Matrix11()),
207                          InnerVectorizedTraversal,InnerUnrolling+CompleteUnrolling));
208     }
209 
210     VERIFY(test_redux(Vector1(),
211       LinearVectorizedTraversal,CompleteUnrolling));
212 
213     VERIFY(test_redux(Vector1().array()*Vector1().array(),
214       LinearVectorizedTraversal,CompleteUnrolling));
215 
216     VERIFY(test_redux((Vector1().array()*Vector1().array()).col(0),
217       LinearVectorizedTraversal,CompleteUnrolling));
218 
219     VERIFY(test_redux(Matrix<Scalar,PacketSize,3>(),
220       LinearVectorizedTraversal,CompleteUnrolling));
221 
222     VERIFY(test_redux(Matrix3(),
223       LinearVectorizedTraversal,CompleteUnrolling));
224 
225     VERIFY(test_redux(Matrix44(),
226       LinearVectorizedTraversal,NoUnrolling));
227 
228     if(PacketSize>1) {
229       VERIFY(test_redux(Matrix44().template block<(Matrix1::Flags&RowMajorBit)?4:PacketSize,(Matrix1::Flags&RowMajorBit)?PacketSize:4>(1,2),
230         SliceVectorizedTraversal,CompleteUnrolling));
231 
232       VERIFY(test_redux(Matrix44().template block<(Matrix1::Flags&RowMajorBit)?2:PacketSize,(Matrix1::Flags&RowMajorBit)?PacketSize:2>(1,2),
233         DefaultTraversal,CompleteUnrolling));
234     }
235 
236     VERIFY(test_redux(Matrix44c().template block<2*PacketSize,1>(1,2),
237       LinearVectorizedTraversal,CompleteUnrolling));
238 
239     VERIFY(test_redux(Matrix44r().template block<1,2*PacketSize>(2,1),
240       LinearVectorizedTraversal,CompleteUnrolling));
241 
242     VERIFY((test_assign<
243             Map<Matrix22, AlignedMax, OuterStride<3*PacketSize> >,
244             Matrix22
245             >(InnerVectorizedTraversal,CompleteUnrolling)));
246 
247     VERIFY((test_assign<
248             Map<Matrix<Scalar,EIGEN_PLAIN_ENUM_MAX(2,PacketSize),EIGEN_PLAIN_ENUM_MAX(2,PacketSize)>, AlignedMax, InnerStride<3*PacketSize> >,
249             Matrix<Scalar,EIGEN_PLAIN_ENUM_MAX(2,PacketSize),EIGEN_PLAIN_ENUM_MAX(2,PacketSize)>
250             >(DefaultTraversal,PacketSize>=8?InnerUnrolling:CompleteUnrolling)));
251 
252     VERIFY((test_assign(Matrix11(), Matrix<Scalar,PacketSize,EIGEN_PLAIN_ENUM_MIN(2,PacketSize)>()*Matrix<Scalar,EIGEN_PLAIN_ENUM_MIN(2,PacketSize),PacketSize>(),
253                         InnerVectorizedTraversal, CompleteUnrolling)));
254     #endif
255 
256     VERIFY(test_assign(MatrixXX(10,10),MatrixXX(20,20).block(10,10,2,3),
257       SliceVectorizedTraversal,NoUnrolling));
258 
259     VERIFY(test_redux(VectorX(10),
260       LinearVectorizedTraversal,NoUnrolling));
261   }
262 };
263 
264 template<typename Scalar> struct vectorization_logic<Scalar,false>
265 {
runvectorization_logic266   static void run() {}
267 };
268 
269 template<typename Scalar, bool Enable = !internal::is_same<typename internal::unpacket_traits<typename internal::packet_traits<Scalar>::type>::half,
270                                                            typename internal::packet_traits<Scalar>::type>::value >
271 struct vectorization_logic_half
272 {
273   typedef internal::packet_traits<Scalar> PacketTraits;
274   typedef typename internal::unpacket_traits<typename internal::packet_traits<Scalar>::type>::half PacketType;
275   enum {
276     PacketSize = internal::unpacket_traits<PacketType>::size
277   };
runvectorization_logic_half278   static void run()
279   {
280 
281     typedef Matrix<Scalar,PacketSize,1> Vector1;
282     typedef Matrix<Scalar,PacketSize,PacketSize> Matrix11;
283     typedef Matrix<Scalar,5*PacketSize,7,ColMajor> Matrix57;
284     typedef Matrix<Scalar,3*PacketSize,5,ColMajor> Matrix35;
285     typedef Matrix<Scalar,5*PacketSize,7,DontAlign|ColMajor> Matrix57u;
286 
287     typedef Matrix<Scalar,
288         (PacketSize==16 ? 8 : PacketSize==8 ? 4 : PacketSize==4 ? 2 : PacketSize==2 ? 1 : /*PacketSize==1 ?*/ 1),
289         (PacketSize==16 ? 2 : PacketSize==8 ? 2 : PacketSize==4 ? 2 : PacketSize==2 ? 2 : /*PacketSize==1 ?*/ 1)
290       > Matrix1;
291 
292     typedef Matrix<Scalar,
293         (PacketSize==16 ? 8 : PacketSize==8 ? 4 : PacketSize==4 ? 2 : PacketSize==2 ? 1 : /*PacketSize==1 ?*/ 1),
294         (PacketSize==16 ? 2 : PacketSize==8 ? 2 : PacketSize==4 ? 2 : PacketSize==2 ? 2 : /*PacketSize==1 ?*/ 1),
295       DontAlign|((Matrix1::Flags&RowMajorBit)?RowMajor:ColMajor)> Matrix1u;
296 
297     // this type is made such that it can only be vectorized when viewed as a linear 1D vector
298     typedef Matrix<Scalar,
299         (PacketSize==16 ?  4 : PacketSize==8 ? 4 : PacketSize==4 ? 6 : PacketSize==2 ? ((Matrix11::Flags&RowMajorBit)?2:3) : /*PacketSize==1 ?*/ 1),
300         (PacketSize==16 ? 12 : PacketSize==8 ? 6 : PacketSize==4 ? 2 : PacketSize==2 ? ((Matrix11::Flags&RowMajorBit)?3:2) : /*PacketSize==1 ?*/ 3)
301       > Matrix3;
302 
303     #if !EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT
304     VERIFY(test_assign(Vector1(),Vector1(),
305       InnerVectorizedTraversal,CompleteUnrolling));
306     VERIFY(test_assign(Vector1(),Vector1()+Vector1(),
307       InnerVectorizedTraversal,CompleteUnrolling));
308     VERIFY(test_assign(Vector1(),Vector1().template segment<PacketSize>(0).derived(),
309       EIGEN_UNALIGNED_VECTORIZE ? InnerVectorizedTraversal : LinearVectorizedTraversal,CompleteUnrolling));
310     VERIFY(test_assign(Vector1(),Scalar(2.1)*Vector1()-Vector1(),
311       InnerVectorizedTraversal,CompleteUnrolling));
312     VERIFY(test_assign(Vector1(),(Scalar(2.1)*Vector1().template segment<PacketSize>(0)-Vector1().template segment<PacketSize>(0)).derived(),
313       EIGEN_UNALIGNED_VECTORIZE ? InnerVectorizedTraversal : LinearVectorizedTraversal,CompleteUnrolling));
314     VERIFY(test_assign(Vector1(),Vector1().cwiseProduct(Vector1()),
315       InnerVectorizedTraversal,CompleteUnrolling));
316     VERIFY(test_assign(Vector1(),Vector1().template cast<Scalar>(),
317       InnerVectorizedTraversal,CompleteUnrolling));
318 
319     VERIFY(test_assign(Matrix57(),Matrix57()+Matrix57(),
320       InnerVectorizedTraversal,InnerUnrolling));
321 
322     VERIFY(test_assign(Matrix57u(),Matrix57()+Matrix57(),
323       EIGEN_UNALIGNED_VECTORIZE ? InnerVectorizedTraversal : LinearTraversal,
324       EIGEN_UNALIGNED_VECTORIZE ? InnerUnrolling : NoUnrolling));
325 
326     VERIFY(test_assign(Matrix1u(),Matrix1()+Matrix1(),
327       EIGEN_UNALIGNED_VECTORIZE ? ((int(Matrix1::InnerSizeAtCompileTime) % int(PacketSize))==0 ? InnerVectorizedTraversal : LinearVectorizedTraversal) : LinearTraversal,CompleteUnrolling));
328 
329     if(PacketSize>1)
330     {
331       typedef Matrix<Scalar,3,3,ColMajor> Matrix33c;
332       VERIFY(test_assign(Matrix33c().row(2),Matrix33c().row(1)+Matrix33c().row(1),
333         LinearTraversal,CompleteUnrolling));
334       VERIFY(test_assign(Matrix33c().col(0),Matrix33c().col(1)+Matrix33c().col(1),
335         EIGEN_UNALIGNED_VECTORIZE ? (sizeof(Scalar)==16 ? InnerVectorizedTraversal : LinearVectorizedTraversal)
336                                   : (sizeof(Scalar)==16 ? SliceVectorizedTraversal : LinearTraversal),
337         ((!EIGEN_UNALIGNED_VECTORIZE) && (sizeof(Scalar)==16)) ? NoUnrolling : CompleteUnrolling));
338 
339       VERIFY(test_assign(Matrix3(),Matrix3().cwiseQuotient(Matrix3()),
340         PacketTraits::HasDiv ? LinearVectorizedTraversal : LinearTraversal,CompleteUnrolling));
341 
342       VERIFY(test_assign(Matrix<Scalar,17,17>(),Matrix<Scalar,17,17>()+Matrix<Scalar,17,17>(),
343         sizeof(Scalar)==16 ? InnerVectorizedTraversal : (EIGEN_UNALIGNED_VECTORIZE ? LinearVectorizedTraversal : LinearTraversal),
344         NoUnrolling));
345 
346       VERIFY(test_assign(Matrix11(),Matrix<Scalar,17,17>().template block<PacketSize,PacketSize>(2,3)+Matrix<Scalar,17,17>().template block<PacketSize,PacketSize>(8,4),
347         EIGEN_UNALIGNED_VECTORIZE ? InnerVectorizedTraversal : DefaultTraversal,InnerUnrolling+CompleteUnrolling));
348 
349 
350       VERIFY(test_assign(Vector1(),Matrix11()*Vector1(),
351                          InnerVectorizedTraversal,CompleteUnrolling));
352 
353       VERIFY(test_assign(Matrix11(),Matrix11().lazyProduct(Matrix11()),
354                          InnerVectorizedTraversal,InnerUnrolling+CompleteUnrolling));
355     }
356 
357     VERIFY(test_redux(Vector1(),
358       LinearVectorizedTraversal,CompleteUnrolling));
359 
360     VERIFY(test_redux(Matrix<Scalar,PacketSize,3>(),
361       LinearVectorizedTraversal,CompleteUnrolling));
362 
363     VERIFY(test_redux(Matrix3(),
364       LinearVectorizedTraversal,CompleteUnrolling));
365 
366     VERIFY(test_redux(Matrix35(),
367       LinearVectorizedTraversal,CompleteUnrolling));
368 
369     VERIFY(test_redux(Matrix57().template block<PacketSize==1?2:PacketSize,3>(1,0),
370       SliceVectorizedTraversal,CompleteUnrolling));
371 
372     if(PacketSize>1) {
373       VERIFY(test_redux(Matrix57().template block<PacketSize,2>(1,0),
374         DefaultTraversal,CompleteUnrolling));
375     }
376 
377     VERIFY((test_assign<
378             Map<Matrix<Scalar,EIGEN_PLAIN_ENUM_MAX(2,PacketSize),EIGEN_PLAIN_ENUM_MAX(2,PacketSize)>, AlignedMax, InnerStride<3*PacketSize> >,
379             Matrix<Scalar,EIGEN_PLAIN_ENUM_MAX(2,PacketSize),EIGEN_PLAIN_ENUM_MAX(2,PacketSize)>
380             >(DefaultTraversal,PacketSize>4?InnerUnrolling:CompleteUnrolling)));
381 
382     VERIFY((test_assign(Matrix57(), Matrix<Scalar,5*PacketSize,3>()*Matrix<Scalar,3,7>(),
383                         InnerVectorizedTraversal, InnerUnrolling+CompleteUnrolling)));
384     #endif
385   }
386 };
387 
388 template<typename Scalar> struct vectorization_logic_half<Scalar,false>
389 {
runvectorization_logic_half390   static void run() {}
391 };
392 
EIGEN_DECLARE_TEST(vectorization_logic)393 EIGEN_DECLARE_TEST(vectorization_logic)
394 {
395 
396 #ifdef EIGEN_VECTORIZE
397 
398   CALL_SUBTEST( vectorization_logic<int>::run() );
399   CALL_SUBTEST( vectorization_logic<float>::run() );
400   CALL_SUBTEST( vectorization_logic<double>::run() );
401   CALL_SUBTEST( vectorization_logic<std::complex<float> >::run() );
402   CALL_SUBTEST( vectorization_logic<std::complex<double> >::run() );
403 
404   CALL_SUBTEST( vectorization_logic_half<int>::run() );
405   CALL_SUBTEST( vectorization_logic_half<float>::run() );
406   CALL_SUBTEST( vectorization_logic_half<double>::run() );
407   CALL_SUBTEST( vectorization_logic_half<std::complex<float> >::run() );
408   CALL_SUBTEST( vectorization_logic_half<std::complex<double> >::run() );
409 
410   if(internal::packet_traits<float>::Vectorizable)
411   {
412     VERIFY(test_assign(Matrix<float,3,3>(),Matrix<float,3,3>()+Matrix<float,3,3>(),
413       EIGEN_UNALIGNED_VECTORIZE ? LinearVectorizedTraversal : LinearTraversal,CompleteUnrolling));
414 
415     VERIFY(test_redux(Matrix<float,5,2>(),
416       EIGEN_UNALIGNED_VECTORIZE ? LinearVectorizedTraversal : DefaultTraversal,CompleteUnrolling));
417   }
418 
419   if(internal::packet_traits<double>::Vectorizable)
420   {
421     VERIFY(test_assign(Matrix<double,3,3>(),Matrix<double,3,3>()+Matrix<double,3,3>(),
422       EIGEN_UNALIGNED_VECTORIZE ? LinearVectorizedTraversal : LinearTraversal,CompleteUnrolling));
423 
424     VERIFY(test_redux(Matrix<double,7,3>(),
425       EIGEN_UNALIGNED_VECTORIZE ? LinearVectorizedTraversal : DefaultTraversal,CompleteUnrolling));
426   }
427 #endif // EIGEN_VECTORIZE
428 
429 }
430