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 simd_int8_t {
65  BLAZE_ALWAYS_INLINE simd_int8_t() : value( _mm256_setzero_si256() ) {}
66  BLAZE_ALWAYS_INLINE simd_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 simd_int8_t {
72  BLAZE_ALWAYS_INLINE simd_int8_t() : value( _mm_setzero_si128() ) {}
73  BLAZE_ALWAYS_INLINE simd_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 simd_int8_t {
79  BLAZE_ALWAYS_INLINE simd_int8_t() : value( 0 ) {}
80  BLAZE_ALWAYS_INLINE simd_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 simd_int16_t {
97  BLAZE_ALWAYS_INLINE simd_int16_t() : value( _mm256_setzero_si256() ) {}
98  BLAZE_ALWAYS_INLINE simd_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 simd_int16_t {
104  BLAZE_ALWAYS_INLINE simd_int16_t() : value( _mm_setzero_si128() ) {}
105  BLAZE_ALWAYS_INLINE simd_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 simd_int16_t {
111  BLAZE_ALWAYS_INLINE simd_int16_t() : value( 0 ) {}
112  BLAZE_ALWAYS_INLINE simd_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 simd_int32_t {
129  BLAZE_ALWAYS_INLINE simd_int32_t() : value( _mm512_setzero_epi32() ) {}
130  BLAZE_ALWAYS_INLINE simd_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 simd_int32_t {
136  BLAZE_ALWAYS_INLINE simd_int32_t() : value( _mm256_setzero_si256() ) {}
137  BLAZE_ALWAYS_INLINE simd_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 simd_int32_t {
143  BLAZE_ALWAYS_INLINE simd_int32_t() : value( _mm_setzero_si128() ) {}
144  BLAZE_ALWAYS_INLINE simd_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 simd_int32_t {
150  BLAZE_ALWAYS_INLINE simd_int32_t() : value( 0 ) {}
151  BLAZE_ALWAYS_INLINE simd_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 simd_int64_t {
168  BLAZE_ALWAYS_INLINE simd_int64_t() : value( _mm512_setzero_epi32() ) {}
169  BLAZE_ALWAYS_INLINE simd_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 simd_int64_t {
175  BLAZE_ALWAYS_INLINE simd_int64_t() : value( _mm256_setzero_si256() ) {}
176  BLAZE_ALWAYS_INLINE simd_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 simd_int64_t {
182  BLAZE_ALWAYS_INLINE simd_int64_t() : value( _mm_setzero_si128() ) {}
183  BLAZE_ALWAYS_INLINE simd_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 simd_int64_t {
189  BLAZE_ALWAYS_INLINE simd_int64_t() : value( 0L ) {}
190  BLAZE_ALWAYS_INLINE simd_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 simd_float_t {
207  BLAZE_ALWAYS_INLINE simd_float_t() : value( _mm512_setzero_ps() ) {}
208  BLAZE_ALWAYS_INLINE simd_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 simd_float_t {
214  BLAZE_ALWAYS_INLINE simd_float_t() : value( _mm256_setzero_ps() ) {}
215  BLAZE_ALWAYS_INLINE simd_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 simd_float_t {
221  BLAZE_ALWAYS_INLINE simd_float_t() : value( _mm_setzero_ps() ) {}
222  BLAZE_ALWAYS_INLINE simd_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 simd_float_t {
228  BLAZE_ALWAYS_INLINE simd_float_t() : value( 0.0F ) {}
229  BLAZE_ALWAYS_INLINE simd_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 simd_double_t {
246  BLAZE_ALWAYS_INLINE simd_double_t() : value( _mm512_setzero_pd() ) {}
247  BLAZE_ALWAYS_INLINE simd_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 simd_double_t {
253  BLAZE_ALWAYS_INLINE simd_double_t() : value( _mm256_setzero_pd() ) {}
254  BLAZE_ALWAYS_INLINE simd_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 simd_double_t {
260  BLAZE_ALWAYS_INLINE simd_double_t() : value( _mm_setzero_pd() ) {}
261  BLAZE_ALWAYS_INLINE simd_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 simd_double_t {
267  BLAZE_ALWAYS_INLINE simd_double_t() : value( 0.0 ) {}
268  BLAZE_ALWAYS_INLINE simd_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_AVX2_MODE
284 struct simd_cint8_t {
285  BLAZE_ALWAYS_INLINE simd_cint8_t() : value( _mm256_setzero_si256() ) {}
286  BLAZE_ALWAYS_INLINE simd_cint8_t( __m256i v ) : value( v ) {}
287  BLAZE_ALWAYS_INLINE complex<int8_t> operator[]( size_t i ) const { return reinterpret_cast<const complex<int8_t>*>( &value )[i]; }
288  __m256i value; // Contains 16 8-bit integral complex values
289 };
290 #elif BLAZE_SSE2_MODE
291 struct simd_cint8_t {
292  BLAZE_ALWAYS_INLINE simd_cint8_t() : value( _mm_setzero_si128() ) {}
293  BLAZE_ALWAYS_INLINE simd_cint8_t( __m128i v ) : value( v ) {}
294  BLAZE_ALWAYS_INLINE complex<int8_t> operator[]( size_t i ) const { return reinterpret_cast<const complex<int8_t>*>( &value )[i]; }
295  __m128i value; // Contains 8 8-bit integral complex values
296 };
297 #else
298 struct simd_cint8_t {
299  BLAZE_ALWAYS_INLINE simd_cint8_t() : value( 0, 0 ) {}
300  BLAZE_ALWAYS_INLINE simd_cint8_t( complex<int8_t> v ) : value( v ) {}
301  BLAZE_ALWAYS_INLINE complex<int8_t> operator[]( size_t /*i*/ ) const { return value; }
302  complex<int8_t> value;
303 };
304 #endif
305 
306 //*************************************************************************************************
307 
308 
309 //*************************************************************************************************
315 #if BLAZE_AVX2_MODE
316 struct simd_cint16_t {
317  BLAZE_ALWAYS_INLINE simd_cint16_t() : value( _mm256_setzero_si256() ) {}
318  BLAZE_ALWAYS_INLINE simd_cint16_t( __m256i v ) : value( v ) {}
319  BLAZE_ALWAYS_INLINE complex<int16_t> operator[]( size_t i ) const { return reinterpret_cast<const complex<int16_t>*>( &value )[i]; }
320  __m256i value; // Contains 8 16-bit integral complex values
321 };
322 #elif BLAZE_SSE2_MODE
323 struct simd_cint16_t {
324  BLAZE_ALWAYS_INLINE simd_cint16_t() : value( _mm_setzero_si128() ) {}
325  BLAZE_ALWAYS_INLINE simd_cint16_t( __m128i v ) : value( v ) {}
326  BLAZE_ALWAYS_INLINE complex<int16_t> operator[]( size_t i ) const { return reinterpret_cast<const complex<int16_t>*>( &value )[i]; }
327  __m128i value; // Contains 4 16-bit integral complex values
328 };
329 #else
330 struct simd_cint16_t {
331  BLAZE_ALWAYS_INLINE simd_cint16_t() : value( 0, 0 ) {}
332  BLAZE_ALWAYS_INLINE simd_cint16_t( complex<int16_t> v ) : value( v ) {}
333  BLAZE_ALWAYS_INLINE complex<int16_t> operator[]( size_t /*i*/ ) const { return value; }
334  complex<int16_t> value;
335 };
336 #endif
337 
338 //*************************************************************************************************
339 
340 
341 //*************************************************************************************************
347 #if BLAZE_MIC_MODE
348 struct simd_cint32_t {
349  BLAZE_ALWAYS_INLINE simd_cint32_t() : value( _mm512_setzero_epi32() ) {}
350  BLAZE_ALWAYS_INLINE simd_cint32_t( __m512i v ) : value( v ) {}
351  BLAZE_ALWAYS_INLINE complex<int32_t> operator[]( size_t i ) const { return reinterpret_cast<const complex<int32_t>*>( &value )[i]; }
352  __m512i value; // Contains 8 32-bit integral complex values
353 };
354 #elif BLAZE_AVX2_MODE
355 struct simd_cint32_t {
356  BLAZE_ALWAYS_INLINE simd_cint32_t() : value( _mm256_setzero_si256() ) {}
357  BLAZE_ALWAYS_INLINE simd_cint32_t( __m256i v ) : value( v ) {}
358  BLAZE_ALWAYS_INLINE complex<int32_t> operator[]( size_t i ) const { return reinterpret_cast<const complex<int32_t>*>( &value )[i]; }
359  __m256i value; // Contains 4 32-bit integral complex values
360 };
361 #elif BLAZE_SSE2_MODE
362 struct simd_cint32_t {
363  BLAZE_ALWAYS_INLINE simd_cint32_t() : value( _mm_setzero_si128() ) {}
364  BLAZE_ALWAYS_INLINE simd_cint32_t( __m128i v ) : value( v ) {}
365  BLAZE_ALWAYS_INLINE complex<int32_t> operator[]( size_t i ) const { return reinterpret_cast<const complex<int32_t>*>( &value )[i]; }
366  __m128i value; // Contains 2 32-bit integral complex values
367 };
368 #else
369 struct simd_cint32_t {
370  BLAZE_ALWAYS_INLINE simd_cint32_t() : value( 0, 0 ) {}
371  BLAZE_ALWAYS_INLINE simd_cint32_t( complex<int32_t> v ) : value( v ) {}
372  BLAZE_ALWAYS_INLINE complex<int32_t> operator[]( size_t /*i*/ ) const { return value; }
373  complex<int32_t> value;
374 };
375 #endif
376 
377 //*************************************************************************************************
378 
379 
380 //*************************************************************************************************
386 #if BLAZE_MIC_MODE
387 struct simd_cint64_t {
388  BLAZE_ALWAYS_INLINE simd_cint64_t() : value( _mm512_setzero_epi32() ) {}
389  BLAZE_ALWAYS_INLINE simd_cint64_t( __m512i v ) : value( v ) {}
390  BLAZE_ALWAYS_INLINE complex<int64_t> operator[]( size_t i ) const { return reinterpret_cast<const complex<int64_t>*>( &value )[i]; }
391  __m512i value; // Contains 4 64-bit integral complex values
392 };
393 #elif BLAZE_AVX2_MODE
394 struct simd_cint64_t {
395  BLAZE_ALWAYS_INLINE simd_cint64_t() : value( _mm256_setzero_si256() ) {}
396  BLAZE_ALWAYS_INLINE simd_cint64_t( __m256i v ) : value( v ) {}
397  BLAZE_ALWAYS_INLINE complex<int64_t> operator[]( size_t i ) const { return reinterpret_cast<const complex<int64_t>*>( &value )[i]; }
398  __m256i value; // Contains 2 64-bit integral complex values
399 };
400 #elif BLAZE_SSE2_MODE
401 struct simd_cint64_t {
402  BLAZE_ALWAYS_INLINE simd_cint64_t() : value( _mm_setzero_si128() ) {}
403  BLAZE_ALWAYS_INLINE simd_cint64_t( __m128i v ) : value( v ) {}
404  BLAZE_ALWAYS_INLINE complex<int64_t> operator[]( size_t i ) const { return reinterpret_cast<const complex<int64_t>*>( &value )[i]; }
405  __m128i value; // Contains 1 64-bit integral complex values
406 };
407 #else
408 struct simd_cint64_t {
409  BLAZE_ALWAYS_INLINE simd_cint64_t() : value( 0L, 0L ) {}
410  BLAZE_ALWAYS_INLINE simd_cint64_t( complex<int64_t> v ) : value( v ) {}
411  BLAZE_ALWAYS_INLINE complex<int64_t> operator[]( size_t /*i*/ ) const { return value; }
412  complex<int64_t> value;
413 };
414 #endif
415 
416 //*************************************************************************************************
417 
418 
419 //*************************************************************************************************
425 #if BLAZE_MIC_MODE
426 struct simd_cfloat_t {
427  BLAZE_ALWAYS_INLINE simd_cfloat_t() : value( _mm512_setzero_ps() ) {}
428  BLAZE_ALWAYS_INLINE simd_cfloat_t( __m512 v ) : value( v ) {}
429  BLAZE_ALWAYS_INLINE complex<float> operator[]( size_t i ) const { return reinterpret_cast<const complex<float>*>( &value )[i]; }
430  __m512 value; // Contains 8 32-bit single precision complex values
431 };
432 #elif BLAZE_AVX_MODE
433 struct simd_cfloat_t {
434  BLAZE_ALWAYS_INLINE simd_cfloat_t() : value( _mm256_setzero_ps() ) {}
435  BLAZE_ALWAYS_INLINE simd_cfloat_t( __m256 v ) : value( v ) {}
436  BLAZE_ALWAYS_INLINE complex<float> operator[]( size_t i ) const { return reinterpret_cast<const complex<float>*>( &value )[i]; }
437  __m256 value; // Contains 4 32-bit single precision complex values
438 };
439 #elif BLAZE_SSE_MODE
440 struct simd_cfloat_t {
441  BLAZE_ALWAYS_INLINE simd_cfloat_t() : value( _mm_setzero_ps() ) {}
442  BLAZE_ALWAYS_INLINE simd_cfloat_t( __m128 v ) : value( v ) {}
443  BLAZE_ALWAYS_INLINE complex<float> operator[]( size_t i ) const { return reinterpret_cast<const complex<float>*>( &value )[i]; }
444  __m128 value; // Contains 2 32-bit single precision complex values
445 };
446 #else
447 struct simd_cfloat_t {
448  BLAZE_ALWAYS_INLINE simd_cfloat_t() : value( 0.0F, 0.0F ) {}
449  BLAZE_ALWAYS_INLINE simd_cfloat_t( complex<float> v ) : value( v ) {}
450  BLAZE_ALWAYS_INLINE complex<float> operator[]( size_t /*i*/ ) const { return value; }
451  complex<float> value;
452 };
453 #endif
454 
455 //*************************************************************************************************
456 
457 
458 //*************************************************************************************************
464 #if BLAZE_MIC_MODE
465 struct simd_cdouble_t {
466  BLAZE_ALWAYS_INLINE simd_cdouble_t() : value( _mm512_setzero_pd() ) {}
467  BLAZE_ALWAYS_INLINE simd_cdouble_t( __m512d v ) : value( v ) {}
468  BLAZE_ALWAYS_INLINE complex<double> operator[]( size_t i ) const { return reinterpret_cast<const complex<double>*>( &value )[i]; }
469  __m512d value; // Contains 4 64-bit double precision complex value
470 };
471 #elif BLAZE_AVX_MODE
472 struct simd_cdouble_t {
473  BLAZE_ALWAYS_INLINE simd_cdouble_t() : value( _mm256_setzero_pd() ) {}
474  BLAZE_ALWAYS_INLINE simd_cdouble_t( __m256d v ) : value( v ) {}
475  BLAZE_ALWAYS_INLINE complex<double> operator[]( size_t i ) const { return reinterpret_cast<const complex<double>*>( &value )[i]; }
476  __m256d value; // Contains 2 64-bit double precision complex value
477 };
478 #elif BLAZE_SSE2_MODE
479 struct simd_cdouble_t {
480  BLAZE_ALWAYS_INLINE simd_cdouble_t() : value( _mm_setzero_pd() ) {}
481  BLAZE_ALWAYS_INLINE simd_cdouble_t( __m128d v ) : value( v ) {}
482  BLAZE_ALWAYS_INLINE complex<double> operator[]( size_t i ) const { return reinterpret_cast<const complex<double>*>( &value )[i]; }
483  __m128d value; // Contains 1 64-bit double precision complex value
484 };
485 #else
486 struct simd_cdouble_t {
487  BLAZE_ALWAYS_INLINE simd_cdouble_t() : value( 0.0, 0.0 ) {}
488  BLAZE_ALWAYS_INLINE simd_cdouble_t( complex<double> v ) : value( v ) {}
489  BLAZE_ALWAYS_INLINE complex<double> operator[]( size_t /*i*/ ) const { return value; }
490  complex<double> value;
491 };
492 #endif
493 
494 //*************************************************************************************************
495 
496 } // namespace blaze
497 
498 #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.