blob: d1b5b49160b4c7ca5b701c081372e1b7c0ae6d78 [file] [log] [blame]
Gael Guennebaudcb71dc42009-01-07 22:20:03 +00001// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra. Eigen itself is part of the KDE project.
3//
4// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
5//
6// Eigen is free software; you can redistribute it and/or
7// modify it under the terms of the GNU Lesser General Public
8// License as published by the Free Software Foundation; either
9// version 3 of the License, or (at your option) any later version.
10//
11// Alternatively, you can redistribute it and/or
12// modify it under the terms of the GNU General Public License as
13// published by the Free Software Foundation; either version 2 of
14// the License, or (at your option) any later version.
15//
16// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
17// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
19// GNU General Public License for more details.
20//
21// You should have received a copy of the GNU Lesser General Public
22// License and a copy of the GNU General Public License along with
23// Eigen. If not, see <http://www.gnu.org/licenses/>.
24
25#include "main.h"
26#include <typeinfo>
27
28template<typename Dst, typename Src>
29bool test_assign(const Dst&, const Src&, int vectorization, int unrolling)
30{
31 return ei_assign_traits<Dst,Src>::Vectorization==vectorization
32 && ei_assign_traits<Dst,Src>::Unrolling==unrolling;
33}
34
35template<typename Xpr>
36bool test_sum(const Xpr&, int vectorization, int unrolling)
37{
38 return ei_sum_traits<Xpr>::Vectorization==vectorization
39 && ei_sum_traits<Xpr>::Unrolling==unrolling;
40}
41
42void test_vectorization_logic()
43{
44
45#ifdef EIGEN_VECTORIZE
46
47 VERIFY(test_assign(Vector4f(),Vector4f(),
48 InnerVectorization,CompleteUnrolling));
49 VERIFY(test_assign(Vector4f(),Vector4f()+Vector4f(),
50 InnerVectorization,CompleteUnrolling));
51 VERIFY(test_assign(Vector4f(),Vector4f().cwise() * Vector4f(),
52 InnerVectorization,CompleteUnrolling));
53
54 VERIFY(test_assign(Matrix4f(),Matrix4f(),
55 InnerVectorization,CompleteUnrolling));
56 VERIFY(test_assign(Matrix4f(),Matrix4f()+Matrix4f(),
57 InnerVectorization,CompleteUnrolling));
58 VERIFY(test_assign(Matrix4f(),Matrix4f().cwise() * Matrix4f(),
59 InnerVectorization,CompleteUnrolling));
60
61 VERIFY(test_assign(Matrix<float,16,16>(),Matrix<float,16,16>()+Matrix<float,16,16>(),
62 InnerVectorization,InnerUnrolling));
63
64 VERIFY(test_assign(Matrix<float,16,16,DontAlign>(),Matrix<float,16,16>()+Matrix<float,16,16>(),
65 NoVectorization,InnerUnrolling));
66
67 VERIFY(test_assign(Matrix<float,6,2>(),Matrix<float,6,2>().cwise() / Matrix<float,6,2>(),
68 LinearVectorization,CompleteUnrolling));
69
70 VERIFY(test_assign(Matrix<float,17,17>(),Matrix<float,17,17>()+Matrix<float,17,17>(),
71 NoVectorization,InnerUnrolling));
72
73 VERIFY(test_assign(Matrix<float,4,4>(),Matrix<float,17,17>().block<4,4>(2,3)+Matrix<float,17,17>().block<4,4>(10,4),
74 NoVectorization,CompleteUnrolling));
75
76 VERIFY(test_assign(MatrixXf(10,10),MatrixXf(20,20).block(10,10,2,3),
77 SliceVectorization,NoUnrolling));
78
79
80 VERIFY(test_sum(VectorXf(10),
81 LinearVectorization,NoUnrolling));
82
83 VERIFY(test_sum(Matrix<float,5,2>(),
Gael Guennebaudaf27fb72009-01-08 11:53:21 +000084 NoVectorization,CompleteUnrolling));
85
86 VERIFY(test_sum(Matrix<float,6,2>(),
Gael Guennebaudcb71dc42009-01-07 22:20:03 +000087 LinearVectorization,CompleteUnrolling));
88
89 VERIFY(test_sum(Matrix<float,16,16>(),
90 LinearVectorization,NoUnrolling));
91
92 VERIFY(test_sum(Matrix<float,16,16>().block<4,4>(1,2),
93 NoVectorization,CompleteUnrolling));
94
95 VERIFY(test_sum(Matrix<float,16,16>().block<8,1>(1,2),
96 LinearVectorization,CompleteUnrolling));
97
98 VERIFY(test_sum(Matrix<double,7,3>(),
99 NoVectorization,CompleteUnrolling));
100
101#endif // EIGEN_VECTORIZE
102
103}