Blaze 3.9
Loading...
Searching...
No Matches
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
57namespace blaze {
58
59//=================================================================================================
60//
61// CLASS SIMDTRAITBASE
62//
63//=================================================================================================
64
65//*************************************************************************************************
70template< typename T
71 , typename = void >
72struct SIMDTraitBase
73{
74 using Type = T;
75 static constexpr size_t size = 1UL;
76};
78//*************************************************************************************************
79
80
81//*************************************************************************************************
86template< typename T >
87struct 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//*************************************************************************************************
101template< typename T >
102struct 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//*************************************************************************************************
118template< typename T >
119struct 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//*************************************************************************************************
133template< typename T >
134struct 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//*************************************************************************************************
150template< typename T >
151struct 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//*************************************************************************************************
165template< typename T >
166struct 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//*************************************************************************************************
182template< typename T >
183struct 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//*************************************************************************************************
197template< typename T >
198struct 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//*************************************************************************************************
214template<>
215struct SIMDTraitBase<float>
216{
217 using Type = SIMDfloat;
218 static constexpr size_t size = Type::size;
219};
221//*************************************************************************************************
222
223
224//*************************************************************************************************
229template<>
230struct 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//*************************************************************************************************
246template<>
247struct SIMDTraitBase<double>
248{
249 using Type = SIMDdouble;
250 static constexpr size_t size = Type::size;
251};
253//*************************************************************************************************
254
255
256//*************************************************************************************************
261template<>
262struct 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//*************************************************************************************************
294template< typename T >
296 : public SIMDTraitBase< RemoveCV_t<T> >
297{};
298//*************************************************************************************************
299
300
301//*************************************************************************************************
314template< typename T >
316//*************************************************************************************************
317
318} // namespace blaze
319
320#endif
Header file for the basic SIMD types.
Header file for the complex data type.
Header file for the EnableIf class template.
Header file for the HasSize type trait.
Header file for the If class template.
Header file for the IsIntegral type trait.
Header file for the IsNumeric type trait.
Header file for the IsSigned type trait.
Header file for the RemoveCV type trait.
Compile time assertion.
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition Matrix.h:676
typename SIMDTrait< T >::Type SIMDTrait_t
Auxiliary alias declaration for the SIMDTrait class template.
Definition SIMDTrait.h:315
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.
Definition StaticAssert.h:112
constexpr bool Has1Byte_v
Auxiliary variable template for the Has1Byte type trait.
Definition HasSize.h:223
constexpr bool IsNumeric_v
Auxiliary variable template for the IsNumeric type trait.
Definition IsNumeric.h:132
constexpr bool Has2Bytes_v
Auxiliary variable template for the Has2Bytes type trait.
Definition HasSize.h:275
constexpr bool Has8Bytes_v
Auxiliary variable template for the Has8Bytes type trait.
Definition HasSize.h:379
constexpr bool IsIntegral_v
Auxiliary variable template for the IsIntegral type trait.
Definition IsIntegral.h:95
constexpr bool Has4Bytes_v
Auxiliary variable template for the Has4Bytes type trait.
Definition HasSize.h:327
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:138
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition If.h:108
System settings for the SSE mode.
Header file for basic type definitions.