BasicTypes.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_INTRINSICS_BASICTYPES_H_
36 #define _BLAZE_MATH_INTRINSICS_BASICTYPES_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/system/Inline.h>
45 #include <blaze/util/Complex.h>
46 #include <blaze/util/Types.h>
47 
48 
49 namespace blaze {
50 
51 //=================================================================================================
52 //
53 // BASIC INTRINSIC TYPES
54 //
55 //=================================================================================================
56 
57 //*************************************************************************************************
63 #if BLAZE_AVX2_MODE
64 struct sse_int8_t {
65  BLAZE_ALWAYS_INLINE sse_int8_t() : value( _mm256_setzero_si256() ) {}
66  BLAZE_ALWAYS_INLINE sse_int8_t( __m256i v ) : value( v ) {}
67  BLAZE_ALWAYS_INLINE int8_t operator[]( size_t i ) const { return reinterpret_cast<const int8_t*>( &value )[i]; }
68  __m256i value; // Contains 32 8-bit integral data values
69 };
70 #elif BLAZE_SSE2_MODE
71 struct sse_int8_t {
72  BLAZE_ALWAYS_INLINE sse_int8_t() : value( _mm_setzero_si128() ) {}
73  BLAZE_ALWAYS_INLINE sse_int8_t( __m128i v ) : value( v ) {}
74  BLAZE_ALWAYS_INLINE int8_t operator[]( size_t i ) const { return reinterpret_cast<const int8_t*>( &value )[i]; }
75  __m128i value; // Contains 16 8-bit integral data values
76 };
77 #else
78 struct sse_int8_t {
79  BLAZE_ALWAYS_INLINE sse_int8_t() : value( 0 ) {}
80  BLAZE_ALWAYS_INLINE sse_int8_t( int8_t v ) : value( v ) {}
81  BLAZE_ALWAYS_INLINE int8_t operator[]( size_t /*i*/ ) const { return value; }
82  int8_t value;
83 };
84 #endif
85 
86 //*************************************************************************************************
87 
88 
89 //*************************************************************************************************
95 #if BLAZE_AVX2_MODE
96 struct sse_int16_t {
97  BLAZE_ALWAYS_INLINE sse_int16_t() : value( _mm256_setzero_si256() ) {}
98  BLAZE_ALWAYS_INLINE sse_int16_t( __m256i v ) : value( v ) {}
99  BLAZE_ALWAYS_INLINE int16_t operator[]( size_t i ) const { return reinterpret_cast<const int16_t*>( &value )[i]; }
100  __m256i value; // Contains 16 16-bit integral data values
101 };
102 #elif BLAZE_SSE2_MODE
103 struct sse_int16_t {
104  BLAZE_ALWAYS_INLINE sse_int16_t() : value( _mm_setzero_si128() ) {}
105  BLAZE_ALWAYS_INLINE sse_int16_t( __m128i v ) : value( v ) {}
106  BLAZE_ALWAYS_INLINE int16_t operator[]( size_t i ) const { return reinterpret_cast<const int16_t*>( &value )[i]; }
107  __m128i value; // Contains 8 16-bit integral data values
108 };
109 #else
110 struct sse_int16_t {
111  BLAZE_ALWAYS_INLINE sse_int16_t() : value( 0 ) {}
112  BLAZE_ALWAYS_INLINE sse_int16_t( int16_t v ) : value( v ) {}
113  BLAZE_ALWAYS_INLINE int16_t operator[]( size_t /*i*/ ) const { return value; }
114  int16_t value;
115 };
116 #endif
117 
118 //*************************************************************************************************
119 
120 
121 //*************************************************************************************************
127 #if BLAZE_MIC_MODE
128 struct sse_int32_t {
129  BLAZE_ALWAYS_INLINE sse_int32_t() : value( _mm512_setzero_epi32() ) {}
130  BLAZE_ALWAYS_INLINE sse_int32_t( __m512i v ) : value( v ) {}
131  BLAZE_ALWAYS_INLINE int32_t operator[]( size_t i ) const { return reinterpret_cast<const int32_t*>( &value )[i]; }
132  __m512i value; // Contains 16 32-bit integral data values
133 };
134 #elif BLAZE_AVX2_MODE
135 struct sse_int32_t {
136  BLAZE_ALWAYS_INLINE sse_int32_t() : value( _mm256_setzero_si256() ) {}
137  BLAZE_ALWAYS_INLINE sse_int32_t( __m256i v ) : value( v ) {}
138  BLAZE_ALWAYS_INLINE int32_t operator[]( size_t i ) const { return reinterpret_cast<const int32_t*>( &value )[i]; }
139  __m256i value; // Contains 8 32-bit integral data values
140 };
141 #elif BLAZE_SSE2_MODE
142 struct sse_int32_t {
143  BLAZE_ALWAYS_INLINE sse_int32_t() : value( _mm_setzero_si128() ) {}
144  BLAZE_ALWAYS_INLINE sse_int32_t( __m128i v ) : value( v ) {}
145  BLAZE_ALWAYS_INLINE int32_t operator[]( size_t i ) const { return reinterpret_cast<const int32_t*>( &value )[i]; }
146  __m128i value; // Contains 4 32-bit integral data values
147 };
148 #else
149 struct sse_int32_t {
150  BLAZE_ALWAYS_INLINE sse_int32_t() : value( 0 ) {}
151  BLAZE_ALWAYS_INLINE sse_int32_t( int32_t v ) : value( v ) {}
152  BLAZE_ALWAYS_INLINE int32_t operator[]( size_t /*i*/ ) const { return value; }
153  int32_t value;
154 };
155 #endif
156 
157 //*************************************************************************************************
158 
159 
160 //*************************************************************************************************
166 #if BLAZE_MIC_MODE
167 struct sse_int64_t {
168  BLAZE_ALWAYS_INLINE sse_int64_t() : value( _mm512_setzero_epi32() ) {}
169  BLAZE_ALWAYS_INLINE sse_int64_t( __m512i v ) : value( v ) {}
170  BLAZE_ALWAYS_INLINE int64_t operator[]( size_t i ) const { return reinterpret_cast<const int64_t*>( &value )[i]; }
171  __m512i value; // Contains 8 64-bit integral data values
172 };
173 #elif BLAZE_AVX2_MODE
174 struct sse_int64_t {
175  BLAZE_ALWAYS_INLINE sse_int64_t() : value( _mm256_setzero_si256() ) {}
176  BLAZE_ALWAYS_INLINE sse_int64_t( __m256i v ) : value( v ) {}
177  BLAZE_ALWAYS_INLINE int64_t operator[]( size_t i ) const { return reinterpret_cast<const int64_t*>( &value )[i]; }
178  __m256i value; // Contains 4 64-bit integral data values
179 };
180 #elif BLAZE_SSE2_MODE
181 struct sse_int64_t {
182  BLAZE_ALWAYS_INLINE sse_int64_t() : value( _mm_setzero_si128() ) {}
183  BLAZE_ALWAYS_INLINE sse_int64_t( __m128i v ) : value( v ) {}
184  BLAZE_ALWAYS_INLINE int64_t operator[]( size_t i ) const { return reinterpret_cast<const int64_t*>( &value )[i]; }
185  __m128i value; // Contains 2 64-bit integral data values
186 };
187 #else
188 struct sse_int64_t {
189  BLAZE_ALWAYS_INLINE sse_int64_t() : value( 0 ) {}
190  BLAZE_ALWAYS_INLINE sse_int64_t( int64_t v ) : value( v ) {}
191  BLAZE_ALWAYS_INLINE int64_t operator[]( size_t /*i*/ ) const { return value; }
192  int64_t value;
193 };
194 #endif
195 
196 //*************************************************************************************************
197 
198 
199 //*************************************************************************************************
205 #if BLAZE_MIC_MODE
206 struct sse_float_t {
207  BLAZE_ALWAYS_INLINE sse_float_t() : value( _mm512_setzero_ps() ) {}
208  BLAZE_ALWAYS_INLINE sse_float_t( __m512 v ) : value( v ) {}
209  BLAZE_ALWAYS_INLINE float operator[]( size_t i ) const { return reinterpret_cast<const float*>( &value )[i]; }
210  __m512 value; // Contains 16 32-bit single precision floating point values
211 };
212 #elif BLAZE_AVX_MODE
213 struct sse_float_t {
214  BLAZE_ALWAYS_INLINE sse_float_t() : value( _mm256_setzero_ps() ) {}
215  BLAZE_ALWAYS_INLINE sse_float_t( __m256 v ) : value( v ) {}
216  BLAZE_ALWAYS_INLINE float operator[]( size_t i ) const { return reinterpret_cast<const float*>( &value )[i]; }
217  __m256 value; // Contains 8 32-bit single precision floating point values
218 };
219 #elif BLAZE_SSE_MODE
220 struct sse_float_t {
221  BLAZE_ALWAYS_INLINE sse_float_t() : value( _mm_setzero_ps() ) {}
222  BLAZE_ALWAYS_INLINE sse_float_t( __m128 v ) : value( v ) {}
223  BLAZE_ALWAYS_INLINE float operator[]( size_t i ) const { return reinterpret_cast<const float*>( &value )[i]; }
224  __m128 value; // Contains 4 32-bit single precision floating point values
225 };
226 #else
227 struct sse_float_t {
228  BLAZE_ALWAYS_INLINE sse_float_t() : value( 0.0F ) {}
229  BLAZE_ALWAYS_INLINE sse_float_t( float v ) : value( v ) {}
230  BLAZE_ALWAYS_INLINE float operator[]( size_t /*i*/ ) const { return value; }
231  float value;
232 };
233 #endif
234 
235 //*************************************************************************************************
236 
237 
238 //*************************************************************************************************
244 #if BLAZE_MIC_MODE
245 struct sse_double_t {
246  BLAZE_ALWAYS_INLINE sse_double_t() : value( _mm512_setzero_pd() ) {}
247  BLAZE_ALWAYS_INLINE sse_double_t( __m512d v ) : value( v ) {}
248  BLAZE_ALWAYS_INLINE double operator[]( size_t i ) const { return reinterpret_cast<const double*>( &value )[i]; }
249  __m512d value; // Contains 8 64-bit double precision floating point values
250 };
251 #elif BLAZE_AVX_MODE
252 struct sse_double_t {
253  BLAZE_ALWAYS_INLINE sse_double_t() : value( _mm256_setzero_pd() ) {}
254  BLAZE_ALWAYS_INLINE sse_double_t( __m256d v ) : value( v ) {}
255  BLAZE_ALWAYS_INLINE double operator[]( size_t i ) const { return reinterpret_cast<const double*>( &value )[i]; }
256  __m256d value; // Contains 4 64-bit double precision floating point values
257 };
258 #elif BLAZE_SSE2_MODE
259 struct sse_double_t {
260  BLAZE_ALWAYS_INLINE sse_double_t() : value( _mm_setzero_pd() ) {}
261  BLAZE_ALWAYS_INLINE sse_double_t( __m128d v ) : value( v ) {}
262  BLAZE_ALWAYS_INLINE double operator[]( size_t i ) const { return reinterpret_cast<const double*>( &value )[i]; }
263  __m128d value; // Contains 2 64-bit double precision floating point values
264 };
265 #else
266 struct sse_double_t {
267  BLAZE_ALWAYS_INLINE sse_double_t() : value( 0.0 ) {}
268  BLAZE_ALWAYS_INLINE sse_double_t( double v ) : value( v ) {}
269  BLAZE_ALWAYS_INLINE double operator[]( size_t /*i*/ ) const { return value; }
270  double value;
271 };
272 #endif
273 
274 //*************************************************************************************************
275 
276 
277 //*************************************************************************************************
283 #if BLAZE_MIC_MODE
284 struct sse_cfloat_t {
285  BLAZE_ALWAYS_INLINE sse_cfloat_t() : value( _mm512_setzero_ps() ) {}
286  BLAZE_ALWAYS_INLINE sse_cfloat_t( __m512 v ) : value( v ) {}
287  BLAZE_ALWAYS_INLINE complex<float> operator[]( size_t i ) const { return reinterpret_cast<const complex<float>*>( &value )[i]; }
288  __m512 value; // Contains 8 32-bit single precision complex values
289 };
290 #elif BLAZE_AVX_MODE
291 struct sse_cfloat_t {
292  BLAZE_ALWAYS_INLINE sse_cfloat_t() : value( _mm256_setzero_ps() ) {}
293  BLAZE_ALWAYS_INLINE sse_cfloat_t( __m256 v ) : value( v ) {}
294  BLAZE_ALWAYS_INLINE complex<float> operator[]( size_t i ) const { return reinterpret_cast<const complex<float>*>( &value )[i]; }
295  __m256 value; // Contains 4 32-bit single precision complex values
296 };
297 #elif BLAZE_SSE_MODE
298 struct sse_cfloat_t {
299  BLAZE_ALWAYS_INLINE sse_cfloat_t() : value( _mm_setzero_ps() ) {}
300  BLAZE_ALWAYS_INLINE sse_cfloat_t( __m128 v ) : value( v ) {}
301  BLAZE_ALWAYS_INLINE complex<float> operator[]( size_t i ) const { return reinterpret_cast<const complex<float>*>( &value )[i]; }
302  __m128 value; // Contains 2 32-bit single precision complex values
303 };
304 #else
305 struct sse_cfloat_t {
306  BLAZE_ALWAYS_INLINE sse_cfloat_t() : value( 0.0F, 0.0F ) {}
307  BLAZE_ALWAYS_INLINE sse_cfloat_t( complex<float> v ) : value( v ) {}
308  BLAZE_ALWAYS_INLINE complex<float> operator[]( size_t /*i*/ ) const { return value; }
309  complex<float> value;
310 };
311 #endif
312 
313 //*************************************************************************************************
314 
315 
316 //*************************************************************************************************
322 #if BLAZE_MIC_MODE
323 struct sse_cdouble_t {
324  BLAZE_ALWAYS_INLINE sse_cdouble_t() : value( _mm512_setzero_pd() ) {}
325  BLAZE_ALWAYS_INLINE sse_cdouble_t( __m512d v ) : value( v ) {}
326  BLAZE_ALWAYS_INLINE complex<double> operator[]( size_t i ) const { return reinterpret_cast<const complex<double>*>( &value )[i]; }
327  __m512d value; // Contains 4 64-bit double precision complex value
328 };
329 #elif BLAZE_AVX_MODE
330 struct sse_cdouble_t {
331  BLAZE_ALWAYS_INLINE sse_cdouble_t() : value( _mm256_setzero_pd() ) {}
332  BLAZE_ALWAYS_INLINE sse_cdouble_t( __m256d v ) : value( v ) {}
333  BLAZE_ALWAYS_INLINE complex<double> operator[]( size_t i ) const { return reinterpret_cast<const complex<double>*>( &value )[i]; }
334  __m256d value; // Contains 2 64-bit double precision complex value
335 };
336 #elif BLAZE_SSE2_MODE
337 struct sse_cdouble_t {
338  BLAZE_ALWAYS_INLINE sse_cdouble_t() : value( _mm_setzero_pd() ) {}
339  BLAZE_ALWAYS_INLINE sse_cdouble_t( __m128d v ) : value( v ) {}
340  BLAZE_ALWAYS_INLINE complex<double> operator[]( size_t i ) const { return reinterpret_cast<const complex<double>*>( &value )[i]; }
341  __m128d value; // Contains 1 64-bit double precision complex value
342 };
343 #else
344 struct sse_cdouble_t {
345  BLAZE_ALWAYS_INLINE sse_cdouble_t() : value( 0.0, 0.0 ) {}
346  BLAZE_ALWAYS_INLINE sse_cdouble_t( complex<double> v ) : value( v ) {}
347  BLAZE_ALWAYS_INLINE complex<double> operator[]( size_t /*i*/ ) const { return value; }
348  complex<double> value;
349 };
350 #endif
351 
352 //*************************************************************************************************
353 
354 } // namespace blaze
355 
356 #endif
Header file for basic type definitions.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
System settings for the SSE mode.
Header file for the complex data type.
System settings for the inline keywords.