]> git.uio.no Git - u/mrichter/AliRoot.git/blob - Vc/include/Vc/avx/types.h
Vc package added (version 0.6.79-dev)
[u/mrichter/AliRoot.git] / Vc / include / Vc / avx / types.h
1 /*  This file is part of the Vc library.
2
3     Copyright (C) 2009-2012 Matthias Kretz <kretz@kde.org>
4
5     Vc is free software: you can redistribute it and/or modify
6     it under the terms of the GNU Lesser General Public License as
7     published by the Free Software Foundation, either version 3 of
8     the License, or (at your option) any later version.
9
10     Vc is distributed in the hope that it will be useful, but
11     WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU Lesser General Public License for more details.
14
15     You should have received a copy of the GNU Lesser General Public
16     License along with Vc.  If not, see <http://www.gnu.org/licenses/>.
17
18 */
19
20 #ifndef AVX_TYPES_H
21 #define AVX_TYPES_H
22
23 #include "intrinsics.h"
24 #include "../common/storage.h"
25 #include "macros.h"
26
27 #define VC_DOUBLE_V_SIZE 4
28 #define VC_FLOAT_V_SIZE 8
29 #define VC_SFLOAT_V_SIZE 8
30 #define VC_INT_V_SIZE 8
31 #define VC_UINT_V_SIZE 8
32 #define VC_SHORT_V_SIZE 8
33 #define VC_USHORT_V_SIZE 8
34
35 #include "../common/types.h"
36
37 namespace Vc
38 {
39 namespace AVX
40 {
41     template<typename T> class Vector;
42
43     template<unsigned int VectorSize, size_t RegisterWidth> class Mask;
44
45     template<typename T> struct VectorHelper {};
46     template<typename T> struct GatherHelper;
47     template<typename T> struct ScatterHelper;
48
49     template<typename T> struct IndexTypeHelper;
50     template<> struct IndexTypeHelper<         char > { typedef unsigned char  Type; };
51     template<> struct IndexTypeHelper<unsigned char > { typedef unsigned char  Type; };
52     template<> struct IndexTypeHelper<         short> { typedef unsigned short Type; };
53     template<> struct IndexTypeHelper<unsigned short> { typedef unsigned short Type; };
54     template<> struct IndexTypeHelper<         int  > { typedef unsigned int   Type; };
55     template<> struct IndexTypeHelper<unsigned int  > { typedef unsigned int   Type; };
56     template<> struct IndexTypeHelper<         float> { typedef unsigned int   Type; };
57     template<> struct IndexTypeHelper<        sfloat> { typedef unsigned short Type; };
58     template<> struct IndexTypeHelper<        double> { typedef unsigned int   Type; }; // _M128I based int32 would be nice
59
60     template<typename T> struct VectorTypeHelper;
61     template<> struct VectorTypeHelper<         char > { typedef __m128i Type; };
62     template<> struct VectorTypeHelper<unsigned char > { typedef __m128i Type; };
63     template<> struct VectorTypeHelper<         short> { typedef __m128i Type; };
64     template<> struct VectorTypeHelper<unsigned short> { typedef __m128i Type; };
65     template<> struct VectorTypeHelper<         int  > { typedef _M256I Type; };
66     template<> struct VectorTypeHelper<unsigned int  > { typedef _M256I Type; };
67     template<> struct VectorTypeHelper<         float> { typedef _M256  Type; };
68     template<> struct VectorTypeHelper<        sfloat> { typedef _M256  Type; };
69     template<> struct VectorTypeHelper<        double> { typedef _M256D Type; };
70
71     template<typename T> struct HasVectorDivisionHelper { enum { Value = 1 }; };
72     //template<> struct HasVectorDivisionHelper<unsigned int> { enum { Value = 0 }; };
73
74     template<typename T> struct VectorHelperSize;
75
76 #ifdef VC_MSVC
77     // MSVC's __declspec(align(#)) only works with numbers, no enums or sizeof allowed ;(
78     template<size_t size> class _VectorAlignedBaseHack;
79     template<> class STRUCT_ALIGN1( 8) _VectorAlignedBaseHack< 8> {} STRUCT_ALIGN2( 8);
80     template<> class STRUCT_ALIGN1(16) _VectorAlignedBaseHack<16> {} STRUCT_ALIGN2(16);
81     template<> class STRUCT_ALIGN1(32) _VectorAlignedBaseHack<32> {} STRUCT_ALIGN2(32);
82     template<> class STRUCT_ALIGN1(64) _VectorAlignedBaseHack<64> {} STRUCT_ALIGN2(64);
83     template<typename V = Vector<float> >
84     class VectorAlignedBaseT : public _VectorAlignedBaseHack<sizeof(V)>
85     {
86         public:
87             FREE_STORE_OPERATORS_ALIGNED(sizeof(V))
88     };
89 #else
90     template<typename V = Vector<float> >
91     class STRUCT_ALIGN1(sizeof(V)) VectorAlignedBaseT
92     {
93         public:
94             FREE_STORE_OPERATORS_ALIGNED(sizeof(V))
95     } STRUCT_ALIGN2(sizeof(V));
96 #endif
97 } // namespace AVX
98 } // namespace Vc
99
100 #endif // AVX_TYPES_H