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