SIMDTrait.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_SIMD_SIMDTRAIT_H_
36 #define _BLAZE_MATH_SIMD_SIMDTRAIT_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
45 #include <blaze/util/Complex.h>
46 #include <blaze/util/EnableIf.h>
47 #include <blaze/util/mpl/And.h>
48 #include <blaze/util/mpl/If.h>
50 #include <blaze/util/Types.h>
56 
57 
58 namespace blaze {
59 
60 //=================================================================================================
61 //
62 // CLASS SIMDTRAITBASE
63 //
64 //=================================================================================================
65 
66 //*************************************************************************************************
71 template< typename T
72  , typename = void >
73 struct SIMDTraitBase
74 {
75  using Type = T;
76  enum : size_t { size = 1UL };
77 };
79 //*************************************************************************************************
80 
81 
82 //*************************************************************************************************
87 template< typename T >
88 struct SIMDTraitBase< T, EnableIf_< And< IsNumeric<T>, IsIntegral<T>, Has1Byte<T> > > >
89 {
90  using Type = If_< IsSigned<T>, SIMDint8, SIMDuint8 >;
91  enum : size_t { size = Type::size };
92 };
94 //*************************************************************************************************
95 
96 
97 //*************************************************************************************************
102 template< typename T >
103 struct SIMDTraitBase< complex<T>, EnableIf_< And< IsNumeric<T>, IsIntegral<T>, Has1Byte<T> > > >
104 {
105  using Type = If_< IsSigned<T>, SIMDcint8, SIMDcuint8 >;
106  enum : size_t { size = Type::size };
107 
108  BLAZE_STATIC_ASSERT( sizeof( complex<T> ) == 2UL*sizeof( T ) );
109 };
111 //*************************************************************************************************
112 
113 
114 //*************************************************************************************************
119 template< typename T >
120 struct SIMDTraitBase< T, EnableIf_< And< IsNumeric<T>, IsIntegral<T>, Has2Bytes<T> > > >
121 {
122  using Type = If_< IsSigned<T>, SIMDint16, SIMDuint16 >;
123  enum : size_t { size = Type::size };
124 };
126 //*************************************************************************************************
127 
128 
129 //*************************************************************************************************
134 template< typename T >
135 struct SIMDTraitBase< complex<T>, EnableIf_< And< IsNumeric<T>, IsIntegral<T>, Has2Bytes<T> > > >
136 {
137  using Type = If_< IsSigned<T>, SIMDcint16, SIMDcuint16 >;
138  enum : size_t { size = Type::size };
139 
140  BLAZE_STATIC_ASSERT( sizeof( complex<T> ) == 2UL*sizeof( T ) );
141 };
143 //*************************************************************************************************
144 
145 
146 //*************************************************************************************************
151 template< typename T >
152 struct SIMDTraitBase< T, EnableIf_< And< IsNumeric<T>, IsIntegral<T>, Has4Bytes<T> > > >
153 {
154  using Type = If_< IsSigned<T>, SIMDint32, SIMDuint32 >;
155  enum : size_t { size = Type::size };
156 };
158 //*************************************************************************************************
159 
160 
161 //*************************************************************************************************
166 template< typename T >
167 struct SIMDTraitBase< complex<T>, EnableIf_< And< IsNumeric<T>, IsIntegral<T>, Has4Bytes<T> > > >
168 {
169  using Type = If_< IsSigned<T>, SIMDcint32, SIMDcuint32 >;
170  enum : size_t { size = Type::size };
171 
172  BLAZE_STATIC_ASSERT( sizeof( complex<T> ) == 2UL*sizeof( T ) );
173 };
175 //*************************************************************************************************
176 
177 
178 //*************************************************************************************************
183 template< typename T >
184 struct SIMDTraitBase< T, EnableIf_< And< IsNumeric<T>, IsIntegral<T>, Has8Bytes<T> > > >
185 {
186  using Type = If_< IsSigned<T>, SIMDint64, SIMDuint64 >;
187  enum : size_t { size = Type::size };
188 };
190 //*************************************************************************************************
191 
192 
193 //*************************************************************************************************
198 template< typename T >
199 struct SIMDTraitBase< complex<T>, EnableIf_< And< IsNumeric<T>, IsIntegral<T>, Has8Bytes<T> > > >
200 {
201  using Type = If_< IsSigned<T>, SIMDcint64, SIMDcuint64 >;
202  enum : size_t { size = Type::size };
203 
204  BLAZE_STATIC_ASSERT( sizeof( complex<T> ) == 2UL*sizeof( T ) );
205 };
207 //*************************************************************************************************
208 
209 
210 //*************************************************************************************************
215 template<>
216 struct SIMDTraitBase<float>
217 {
218  using Type = SIMDfloat;
219  enum : size_t { size = Type::size };
220 };
222 //*************************************************************************************************
223 
224 
225 //*************************************************************************************************
230 template<>
231 struct SIMDTraitBase< complex<float> >
232 {
233  using Type = SIMDcfloat;
234  enum : size_t { size = Type::size };
235 
236  BLAZE_STATIC_ASSERT( sizeof( complex<float> ) == 2UL*sizeof( float ) );
237 };
239 //*************************************************************************************************
240 
241 
242 //*************************************************************************************************
247 template<>
248 struct SIMDTraitBase<double>
249 {
250  using Type = SIMDdouble;
251  enum : size_t { size = Type::size };
252 };
254 //*************************************************************************************************
255 
256 
257 //*************************************************************************************************
262 template<>
263 struct SIMDTraitBase< complex<double> >
264 {
265  using Type = SIMDcdouble;
266  enum : size_t { size = Type::size };
267 
268  BLAZE_STATIC_ASSERT( sizeof( complex<double> ) == 2UL*sizeof( double ) );
269 };
271 //*************************************************************************************************
272 
273 
274 
275 
276 //=================================================================================================
277 //
278 // CLASS SIMDTRAIT
279 //
280 //=================================================================================================
281 
282 //*************************************************************************************************
295 template< typename T >
296 class SIMDTrait : public SIMDTraitBase< RemoveCV_<T> >
297 {};
298 //*************************************************************************************************
299 
300 
301 //*************************************************************************************************
314 template< typename T >
316 //*************************************************************************************************
317 
318 } // namespace blaze
319 
320 #endif
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:258
Header file for the RemoveCV type trait.
typename SIMDTrait< T >::Type SIMDTrait_
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_ alias declaration provide...
Definition: SIMDTrait.h:315
Header file for the IsIntegral type trait.
Header file for the And class template.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
Compile time assertion.
Header file for the EnableIf class template.
Header file for the basic SIMD types.
Header file for the IsNumeric type trait.
Header file for the HasSize type trait.
SIMD characteristics of data types.The SIMDTrait class template provides the SIMD characteristics of ...
Definition: SIMDTrait.h:296
Header file for the IsSigned type trait.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
System settings for the SSE mode.
Header file for the complex data type.
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:112