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/If.h>
49 #include <blaze/util/Types.h>
55 
56 
57 namespace blaze {
58 
59 //=================================================================================================
60 //
61 // CLASS SIMDTRAITBASE
62 //
63 //=================================================================================================
64 
65 //*************************************************************************************************
70 template< typename T
71  , typename = void >
72 struct SIMDTraitBase
73 {
74  using Type = T;
75  static constexpr size_t size = 1UL;
76 };
78 //*************************************************************************************************
79 
80 
81 //*************************************************************************************************
86 template< typename T >
87 struct SIMDTraitBase< T, EnableIf_t< IsNumeric_v<T> && IsIntegral_v<T> && Has1Byte_v<T> > >
88 {
89  using Type = If_t< IsSigned_v<T>, SIMDint8, SIMDuint8 >;
90  static constexpr size_t size = Type::size;
91 };
93 //*************************************************************************************************
94 
95 
96 //*************************************************************************************************
101 template< typename T >
102 struct SIMDTraitBase< complex<T>, EnableIf_t< IsNumeric_v<T> && IsIntegral_v<T> && Has1Byte_v<T> > >
103 {
104  using Type = If_t< IsSigned_v<T>, SIMDcint8, SIMDcuint8 >;
105  static constexpr size_t size = Type::size;
106 
107  BLAZE_STATIC_ASSERT( sizeof( complex<T> ) == 2UL*sizeof( T ) );
108 };
110 //*************************************************************************************************
111 
112 
113 //*************************************************************************************************
118 template< typename T >
119 struct SIMDTraitBase< T, EnableIf_t< IsNumeric_v<T> && IsIntegral_v<T> && Has2Bytes_v<T> > >
120 {
121  using Type = If_t< IsSigned_v<T>, SIMDint16, SIMDuint16 >;
122  static constexpr size_t size = Type::size;
123 };
125 //*************************************************************************************************
126 
127 
128 //*************************************************************************************************
133 template< typename T >
134 struct SIMDTraitBase< complex<T>, EnableIf_t< IsNumeric_v<T> && IsIntegral_v<T> && Has2Bytes_v<T> > >
135 {
136  using Type = If_t< IsSigned_v<T>, SIMDcint16, SIMDcuint16 >;
137  static constexpr size_t size = Type::size;
138 
139  BLAZE_STATIC_ASSERT( sizeof( complex<T> ) == 2UL*sizeof( T ) );
140 };
142 //*************************************************************************************************
143 
144 
145 //*************************************************************************************************
150 template< typename T >
151 struct SIMDTraitBase< T, EnableIf_t< IsNumeric_v<T> && IsIntegral_v<T> && Has4Bytes_v<T> > >
152 {
153  using Type = If_t< IsSigned_v<T>, SIMDint32, SIMDuint32 >;
154  static constexpr size_t size = Type::size;
155 };
157 //*************************************************************************************************
158 
159 
160 //*************************************************************************************************
165 template< typename T >
166 struct SIMDTraitBase< complex<T>, EnableIf_t< IsNumeric_v<T> && IsIntegral_v<T> && Has4Bytes_v<T> > >
167 {
168  using Type = If_t< IsSigned_v<T>, SIMDcint32, SIMDcuint32 >;
169  static constexpr size_t size = Type::size;
170 
171  BLAZE_STATIC_ASSERT( sizeof( complex<T> ) == 2UL*sizeof( T ) );
172 };
174 //*************************************************************************************************
175 
176 
177 //*************************************************************************************************
182 template< typename T >
183 struct SIMDTraitBase< T, EnableIf_t< IsNumeric_v<T> && IsIntegral_v<T> && Has8Bytes_v<T> > >
184 {
185  using Type = If_t< IsSigned_v<T>, SIMDint64, SIMDuint64 >;
186  static constexpr size_t size = Type::size;
187 };
189 //*************************************************************************************************
190 
191 
192 //*************************************************************************************************
197 template< typename T >
198 struct SIMDTraitBase< complex<T>, EnableIf_t< IsNumeric_v<T> && IsIntegral_v<T> && Has8Bytes_v<T> > >
199 {
200  using Type = If_t< IsSigned_v<T>, SIMDcint64, SIMDcuint64 >;
201  static constexpr size_t size = Type::size;
202 
203  BLAZE_STATIC_ASSERT( sizeof( complex<T> ) == 2UL*sizeof( T ) );
204 };
206 //*************************************************************************************************
207 
208 
209 //*************************************************************************************************
214 template<>
215 struct SIMDTraitBase<float>
216 {
217  using Type = SIMDfloat;
218  static constexpr size_t size = Type::size;
219 };
221 //*************************************************************************************************
222 
223 
224 //*************************************************************************************************
229 template<>
230 struct SIMDTraitBase< complex<float> >
231 {
232  using Type = SIMDcfloat;
233  static constexpr size_t size = Type::size;
234 
235  BLAZE_STATIC_ASSERT( sizeof( complex<float> ) == 2UL*sizeof( float ) );
236 };
238 //*************************************************************************************************
239 
240 
241 //*************************************************************************************************
246 template<>
247 struct SIMDTraitBase<double>
248 {
249  using Type = SIMDdouble;
250  static constexpr size_t size = Type::size;
251 };
253 //*************************************************************************************************
254 
255 
256 //*************************************************************************************************
261 template<>
262 struct SIMDTraitBase< complex<double> >
263 {
264  using Type = SIMDcdouble;
265  static constexpr size_t size = Type::size;
266 
267  BLAZE_STATIC_ASSERT( sizeof( complex<double> ) == 2UL*sizeof( double ) );
268 };
270 //*************************************************************************************************
271 
272 
273 
274 
275 //=================================================================================================
276 //
277 // CLASS SIMDTRAIT
278 //
279 //=================================================================================================
280 
281 //*************************************************************************************************
294 template< typename T >
296  : public SIMDTraitBase< RemoveCV_t<T> >
297 {};
298 //*************************************************************************************************
299 
300 
301 //*************************************************************************************************
314 template< typename T >
316 //*************************************************************************************************
317 
318 } // namespace blaze
319 
320 #endif
Header file for basic type definitions.
Header file for the RemoveCV type trait.
Header file for the IsIntegral type trait.
typename SIMDTrait< T >::Type SIMDTrait_t
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_t alias declaration provid...
Definition: SIMDTrait.h:315
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
Compile time assertion.
constexpr bool IsNumeric_v
Auxiliary variable template for the IsNumeric type trait.The IsNumeric_v variable template provides a...
Definition: IsNumeric.h:143
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:295
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
Header file for the IsSigned type trait.
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