Blaze  3.6
BasicTypes.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_SIMD_BASICTYPES_H_
36 #define _BLAZE_MATH_SIMD_BASICTYPES_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
44 #include <blaze/system/Inline.h>
46 #include <blaze/util/Complex.h>
47 #include <blaze/util/Types.h>
48 
49 
50 namespace blaze {
51 
52 //=================================================================================================
53 //
54 // 8-BIT INTEGRAL SIMD TYPES
55 //
56 //=================================================================================================
57 
58 //*************************************************************************************************
59 /*\class blaze::SIMDi8
60 // \brief Base class for all 8-bit integral SIMD data types.
61 // \ingroup simd
62 */
64 template< typename T > // Type of the SIMD element
65 struct SIMDi8
66  : public SIMDPack< T >
67 {};
69 //*************************************************************************************************
70 
71 
72 //*************************************************************************************************
78 struct SIMDint8
79  : public SIMDi8< SIMDint8 >
80 {
81  using This = SIMDint8;
82  using BaseType = SIMDi8<This>;
83  using ValueType = int8_t;
84 
85 #if BLAZE_AVX512BW_MODE
86  using IntrinsicType = __m512i;
87  BLAZE_ALWAYS_INLINE SIMDint8() noexcept : value( _mm512_setzero_si512() ) {}
88  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
89  static constexpr size_t size = 64UL;
90 #elif BLAZE_MIC_MODE
91  using IntrinsicType = ValueType;
92  BLAZE_ALWAYS_INLINE SIMDint8() noexcept : value( 0 ) {}
93  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
94  static constexpr size_t size = 1UL;
95 #elif BLAZE_AVX2_MODE
96  using IntrinsicType = __m256i;
97  BLAZE_ALWAYS_INLINE SIMDint8() noexcept : value( _mm256_setzero_si256() ) {}
98  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
99  static constexpr size_t size = 32UL;
100 #elif BLAZE_SSE2_MODE
101  using IntrinsicType = __m128i;
102  BLAZE_ALWAYS_INLINE SIMDint8() noexcept : value( _mm_setzero_si128() ) {}
103  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
104  static constexpr size_t size = 16UL;
105 #else
106  using IntrinsicType = ValueType;
107  BLAZE_ALWAYS_INLINE SIMDint8() noexcept : value( 0 ) {}
108  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
109  static constexpr size_t size = 1UL;
110 #endif
111 
112  BLAZE_ALWAYS_INLINE SIMDint8( IntrinsicType v ) noexcept : value( v ) {}
113 
114  template< typename T >
115  BLAZE_ALWAYS_INLINE SIMDint8( const SIMDi8<T>& v ) noexcept : value( (~v).value ) {}
116 
117  template< typename T >
118  BLAZE_ALWAYS_INLINE SIMDint8& operator=( const SIMDi8<T>& v ) noexcept { value = (~v).value; return *this; }
119 
120  IntrinsicType value;
121 };
123 //*************************************************************************************************
124 
125 
126 //*************************************************************************************************
132 struct SIMDuint8
133  : public SIMDi8< SIMDuint8 >
134 {
135  using This = SIMDuint8;
136  using BaseType = SIMDi8<This>;
137  using ValueType = uint8_t;
138 
139 #if BLAZE_AVX512BW_MODE
140  using IntrinsicType = __m512i;
141  BLAZE_ALWAYS_INLINE SIMDuint8() noexcept : value( _mm512_setzero_si512() ) {}
142  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
143  static constexpr size_t size = 64UL;
144 #elif BLAZE_MIC_MODE
145  using IntrinsicType = ValueType;
146  BLAZE_ALWAYS_INLINE SIMDuint8() noexcept : value( 0 ) {}
147  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
148  static constexpr size_t size = 1UL;
149 #elif BLAZE_AVX2_MODE
150  using IntrinsicType = __m256i;
151  BLAZE_ALWAYS_INLINE SIMDuint8() noexcept : value( _mm256_setzero_si256() ) {}
152  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
153  static constexpr size_t size = 32UL;
154 #elif BLAZE_SSE2_MODE
155  using IntrinsicType = __m128i;
156  BLAZE_ALWAYS_INLINE SIMDuint8() noexcept : value( _mm_setzero_si128() ) {}
157  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
158  static constexpr size_t size = 16UL;
159 #else
160  using IntrinsicType = ValueType;
161  BLAZE_ALWAYS_INLINE SIMDuint8() noexcept : value( 0 ) {}
162  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
163  static constexpr size_t size = 1UL;
164 #endif
165 
166  BLAZE_ALWAYS_INLINE SIMDuint8( IntrinsicType v ) noexcept : value( v ) {}
167 
168  template< typename T >
169  BLAZE_ALWAYS_INLINE SIMDuint8( const SIMDi8<T>& v ) noexcept : value( (~v).value ) {}
170 
171  template< typename T >
172  BLAZE_ALWAYS_INLINE SIMDuint8& operator=( const SIMDi8<T>& v ) noexcept { value = (~v).value; return *this; }
173 
174  IntrinsicType value;
175 };
177 //*************************************************************************************************
178 
179 
180 
181 
182 //=================================================================================================
183 //
184 // 8-BIT INTEGRAL COMPLEX SIMD TYPES
185 //
186 //=================================================================================================
187 
188 //*************************************************************************************************
189 /*\class blaze::SIMDci8
190 // \brief Base class for all 8-bit integral complex SIMD data types.
191 // \ingroup simd
192 */
194 template< typename T > // Type of the SIMD element
195 struct SIMDci8
196  : public SIMDPack< T >
197 {};
199 //*************************************************************************************************
200 
201 
202 //*************************************************************************************************
208 struct SIMDcint8
209  : public SIMDci8< SIMDcint8 >
210 {
211  using This = SIMDcint8;
212  using BaseType = SIMDci8<This>;
213  using ValueType = complex<int8_t>;
214 
215 #if BLAZE_AVX512BW_MODE
216  using IntrinsicType = __m512i;
217  BLAZE_ALWAYS_INLINE SIMDcint8() noexcept : value( _mm512_setzero_si512() ) {}
218  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
219  static constexpr size_t size = 32UL;
220 #elif BLAZE_MIC_MODE
221  using IntrinsicType = ValueType;
222  BLAZE_ALWAYS_INLINE SIMDcint8() noexcept : value( 0, 0 ) {}
223  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
224  static constexpr size_t size = 1UL;
225 #elif BLAZE_AVX2_MODE
226  using IntrinsicType = __m256i;
227  BLAZE_ALWAYS_INLINE SIMDcint8() noexcept : value( _mm256_setzero_si256() ) {}
228  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
229  static constexpr size_t size = 16UL;
230 #elif BLAZE_SSE2_MODE
231  using IntrinsicType = __m128i;
232  BLAZE_ALWAYS_INLINE SIMDcint8() noexcept : value( _mm_setzero_si128() ) {}
233  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
234  static constexpr size_t size = 8UL;
235 #else
236  using IntrinsicType = ValueType;
237  BLAZE_ALWAYS_INLINE SIMDcint8() noexcept : value( 0, 0 ) {}
238  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
239  static constexpr size_t size = 1UL;
240 #endif
241 
242  BLAZE_ALWAYS_INLINE SIMDcint8( IntrinsicType v ) noexcept : value( v ) {}
243 
244  template< typename T >
245  BLAZE_ALWAYS_INLINE SIMDcint8( const SIMDci8<T>& v ) noexcept : value( (~v).value ) {}
246 
247  template< typename T >
248  BLAZE_ALWAYS_INLINE SIMDcint8& operator=( const SIMDci8<T>& v ) noexcept { value = (~v).value; return *this; }
249 
250  IntrinsicType value;
251 };
253 //*************************************************************************************************
254 
255 
256 //*************************************************************************************************
262 struct SIMDcuint8
263  : public SIMDci8< SIMDcuint8 >
264 {
265  using This = SIMDcuint8;
266  using BaseType = SIMDci8<This>;
267  using ValueType = complex<uint8_t>;
268 
269 #if BLAZE_AVX512BW_MODE
270  using IntrinsicType = __m512i;
271  BLAZE_ALWAYS_INLINE SIMDcuint8() noexcept : value( _mm512_setzero_si512() ) {}
272  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
273  static constexpr size_t size = 32UL;
274 #elif BLAZE_MIC_MODE
275  using IntrinsicType = ValueType;
276  BLAZE_ALWAYS_INLINE SIMDcuint8() noexcept : value( 0, 0 ) {}
277  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
278  static constexpr size_t size = 1UL;
279 #elif BLAZE_AVX2_MODE
280  using IntrinsicType = __m256i;
281  BLAZE_ALWAYS_INLINE SIMDcuint8() noexcept : value( _mm256_setzero_si256() ) {}
282  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
283  static constexpr size_t size = 16UL;
284 #elif BLAZE_SSE2_MODE
285  using IntrinsicType = __m128i;
286  BLAZE_ALWAYS_INLINE SIMDcuint8() noexcept : value( _mm_setzero_si128() ) {}
287  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
288  static constexpr size_t size = 8UL;
289 #else
290  using IntrinsicType = ValueType;
291  BLAZE_ALWAYS_INLINE SIMDcuint8() noexcept : value( 0, 0 ) {}
292  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
293  static constexpr size_t size = 1UL;
294 #endif
295 
296  BLAZE_ALWAYS_INLINE SIMDcuint8( IntrinsicType v ) noexcept : value( v ) {}
297 
298  template< typename T >
299  BLAZE_ALWAYS_INLINE SIMDcuint8( const SIMDci8<T>& v ) noexcept : value( (~v).value ) {}
300 
301  template< typename T >
302  BLAZE_ALWAYS_INLINE SIMDcuint8& operator=( const SIMDci8<T>& v ) noexcept { value = (~v).value; return *this; }
303 
304  IntrinsicType value;
305 };
307 //*************************************************************************************************
308 
309 
310 
311 
312 //=================================================================================================
313 //
314 // 16-BIT INTEGRAL SIMD TYPES
315 //
316 //=================================================================================================
317 
318 //*************************************************************************************************
319 /*\class blaze::SIMDi16
320 // \brief Base class for all 16-bit integral SIMD data types.
321 // \ingroup simd
322 */
324 template< typename T > // Type of the SIMD element
325 struct SIMDi16
326  : public SIMDPack< T >
327 {};
329 //*************************************************************************************************
330 
331 
332 //*************************************************************************************************
338 struct SIMDint16
339  : public SIMDi16< SIMDint16 >
340 {
341  using This = SIMDint16;
342  using BaseType = SIMDi16<This>;
343  using ValueType = int16_t;
344 
345 #if BLAZE_AVX512BW_MODE
346  using IntrinsicType = __m512i;
347  BLAZE_ALWAYS_INLINE SIMDint16() noexcept : value( _mm512_setzero_si512() ) {}
348  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
349  static constexpr size_t size = 32UL;
350 #elif BLAZE_MIC_MODE
351  using IntrinsicType = ValueType;
352  BLAZE_ALWAYS_INLINE SIMDint16() noexcept : value( 0 ) {}
353  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
354  static constexpr size_t size = 1UL;
355 #elif BLAZE_AVX2_MODE
356  using IntrinsicType = __m256i;
357  BLAZE_ALWAYS_INLINE SIMDint16() noexcept : value( _mm256_setzero_si256() ) {}
358  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
359  static constexpr size_t size = 16UL;
360 #elif BLAZE_SSE2_MODE
361  using IntrinsicType = __m128i;
362  BLAZE_ALWAYS_INLINE SIMDint16() noexcept : value( _mm_setzero_si128() ) {}
363  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
364  static constexpr size_t size = 8UL;
365 #else
366  using IntrinsicType = ValueType;
367  BLAZE_ALWAYS_INLINE SIMDint16() noexcept : value( 0 ) {}
368  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
369  static constexpr size_t size = 1UL;
370 #endif
371 
372  BLAZE_ALWAYS_INLINE SIMDint16( IntrinsicType v ) noexcept : value( v ) {}
373 
374  template< typename T >
375  BLAZE_ALWAYS_INLINE SIMDint16( const SIMDi16<T>& v ) noexcept : value( (~v).value ) {}
376 
377  template< typename T >
378  BLAZE_ALWAYS_INLINE SIMDint16& operator=( const SIMDi16<T>& v ) noexcept { value = (~v).value; return *this; }
379 
380  IntrinsicType value;
381 };
383 //*************************************************************************************************
384 
385 
386 //*************************************************************************************************
392 struct SIMDuint16
393  : public SIMDi16< SIMDuint16 >
394 {
395  using This = SIMDuint16;
396  using BaseType = SIMDi16<This>;
397  using ValueType = uint16_t;
398 
399 #if BLAZE_AVX512BW_MODE
400  using IntrinsicType = __m512i;
401  BLAZE_ALWAYS_INLINE SIMDuint16() noexcept : value( _mm512_setzero_si512() ) {}
402  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
403  static constexpr size_t size = 32UL;
404 #elif BLAZE_MIC_MODE
405  using IntrinsicType = ValueType;
406  BLAZE_ALWAYS_INLINE SIMDuint16() noexcept : value( 0 ) {}
407  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
408  static constexpr size_t size = 1UL;
409 #elif BLAZE_AVX2_MODE
410  using IntrinsicType = __m256i;
411  BLAZE_ALWAYS_INLINE SIMDuint16() noexcept : value( _mm256_setzero_si256() ) {}
412  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
413  static constexpr size_t size = 16UL;
414 #elif BLAZE_SSE2_MODE
415  using IntrinsicType = __m128i;
416  BLAZE_ALWAYS_INLINE SIMDuint16() noexcept : value( _mm_setzero_si128() ) {}
417  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
418  static constexpr size_t size = 8UL;
419 #else
420  using IntrinsicType = ValueType;
421  BLAZE_ALWAYS_INLINE SIMDuint16() noexcept : value( 0 ) {}
422  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
423  static constexpr size_t size = 1UL;
424 #endif
425 
426  BLAZE_ALWAYS_INLINE SIMDuint16( IntrinsicType v ) noexcept : value( v ) {}
427 
428  template< typename T >
429  BLAZE_ALWAYS_INLINE SIMDuint16( const SIMDi16<T>& v ) noexcept : value( (~v).value ) {}
430 
431  template< typename T >
432  BLAZE_ALWAYS_INLINE SIMDuint16& operator=( const SIMDi16<T>& v ) noexcept { value = (~v).value; return *this; }
433 
434  IntrinsicType value;
435 };
437 //*************************************************************************************************
438 
439 
440 
441 
442 //=================================================================================================
443 //
444 // 16-BIT INTEGRAL COMPLEX SIMD TYPES
445 //
446 //=================================================================================================
447 
448 //*************************************************************************************************
449 /*\class blaze::SIMDci16
450 // \brief Base class for all 16-bit integral complex SIMD data types.
451 // \ingroup simd
452 */
454 template< typename T > // Type of the SIMD element
455 struct SIMDci16
456  : public SIMDPack< T >
457 {};
459 //*************************************************************************************************
460 
461 
462 //*************************************************************************************************
468 struct SIMDcint16
469  : public SIMDci16< SIMDcint16 >
470 {
471  using This = SIMDcint16;
472  using BaseType = SIMDci16<This>;
473  using ValueType = complex<int16_t>;
474 
475 #if BLAZE_AVX512BW_MODE
476  using IntrinsicType = __m512i;
477  BLAZE_ALWAYS_INLINE SIMDcint16() noexcept : value( _mm512_setzero_si512() ) {}
478  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
479  static constexpr size_t size = 16UL;
480 #elif BLAZE_MIC_MODE
481  using IntrinsicType = ValueType;
482  BLAZE_ALWAYS_INLINE SIMDcint16() noexcept : value( 0, 0 ) {}
483  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
484  static constexpr size_t size = 1UL;
485 #elif BLAZE_AVX2_MODE
486  using IntrinsicType = __m256i;
487  BLAZE_ALWAYS_INLINE SIMDcint16() noexcept : value( _mm256_setzero_si256() ) {}
488  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
489  static constexpr size_t size = 8UL;
490 #elif BLAZE_SSE2_MODE
491  using IntrinsicType = __m128i;
492  BLAZE_ALWAYS_INLINE SIMDcint16() noexcept : value( _mm_setzero_si128() ) {}
493  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
494  static constexpr size_t size = 4UL;
495 #else
496  using IntrinsicType = ValueType;
497  BLAZE_ALWAYS_INLINE SIMDcint16() noexcept : value( 0, 0 ) {}
498  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
499  static constexpr size_t size = 1UL;
500 #endif
501 
502  BLAZE_ALWAYS_INLINE SIMDcint16( IntrinsicType v ) noexcept : value( v ) {}
503 
504  template< typename T >
505  BLAZE_ALWAYS_INLINE SIMDcint16( const SIMDci16<T>& v ) noexcept : value( (~v).value ) {}
506 
507  template< typename T >
508  BLAZE_ALWAYS_INLINE SIMDcint16& operator=( const SIMDci16<T>& v ) noexcept { value = (~v).value; return *this; }
509 
510  IntrinsicType value;
511 };
513 //*************************************************************************************************
514 
515 
516 //*************************************************************************************************
522 struct SIMDcuint16
523  : public SIMDci16< SIMDcuint16 >
524 {
525  using This = SIMDcuint16;
526  using BaseType = SIMDci16<This>;
527  using ValueType = complex<uint16_t>;
528 
529 #if BLAZE_AVX512BW_MODE
530  using IntrinsicType = __m512i;
531  BLAZE_ALWAYS_INLINE SIMDcuint16() noexcept : value( _mm512_setzero_si512() ) {}
532  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
533  static constexpr size_t size = 16UL;
534 #elif BLAZE_MIC_MODE
535  using IntrinsicType = ValueType;
536  BLAZE_ALWAYS_INLINE SIMDcuint16() noexcept : value( 0, 0 ) {}
537  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
538  static constexpr size_t size = 1UL;
539 #elif BLAZE_AVX2_MODE
540  using IntrinsicType = __m256i;
541  BLAZE_ALWAYS_INLINE SIMDcuint16() noexcept : value( _mm256_setzero_si256() ) {}
542  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
543  static constexpr size_t size = 8UL;
544 #elif BLAZE_SSE2_MODE
545  using IntrinsicType = __m128i;
546  BLAZE_ALWAYS_INLINE SIMDcuint16() noexcept : value( _mm_setzero_si128() ) {}
547  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
548  static constexpr size_t size = 4UL;
549 #else
550  using IntrinsicType = ValueType;
551  BLAZE_ALWAYS_INLINE SIMDcuint16() noexcept : value( 0, 0 ) {}
552  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
553  static constexpr size_t size = 1UL;
554 #endif
555 
556  BLAZE_ALWAYS_INLINE SIMDcuint16( IntrinsicType v ) noexcept : value( v ) {}
557 
558  template< typename T >
559  BLAZE_ALWAYS_INLINE SIMDcuint16( const SIMDci16<T>& v ) noexcept : value( (~v).value ) {}
560 
561  template< typename T >
562  BLAZE_ALWAYS_INLINE SIMDcuint16& operator=( const SIMDci16<T>& v ) noexcept { value = (~v).value; return *this; }
563 
564  IntrinsicType value;
565 };
567 //*************************************************************************************************
568 
569 
570 
571 
572 //=================================================================================================
573 //
574 // 32-BIT INTEGRAL SIMD TYPES
575 //
576 //=================================================================================================
577 
578 //*************************************************************************************************
579 /*\class blaze::SIMDi32
580 // \brief Base class for all 32-bit integral SIMD data types.
581 // \ingroup simd
582 */
584 template< typename T > // Type of the SIMD element
585 struct SIMDi32
586  : public SIMDPack< T >
587 {};
589 //*************************************************************************************************
590 
591 
592 //*************************************************************************************************
598 struct SIMDint32
599  : public SIMDi32< SIMDint32 >
600 {
601  using This = SIMDint32;
602  using BaseType = SIMDi32<This>;
603  using ValueType = int32_t;
604 
605 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
606  using IntrinsicType = __m512i;
607  BLAZE_ALWAYS_INLINE SIMDint32() noexcept : value( _mm512_setzero_si512() ) {}
608  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
609  static constexpr size_t size = 16UL;
610 #elif BLAZE_AVX2_MODE
611  using IntrinsicType = __m256i;
612  BLAZE_ALWAYS_INLINE SIMDint32() noexcept : value( _mm256_setzero_si256() ) {}
613  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
614  static constexpr size_t size = 8UL;
615 #elif BLAZE_SSE2_MODE
616  using IntrinsicType = __m128i;
617  BLAZE_ALWAYS_INLINE SIMDint32() noexcept : value( _mm_setzero_si128() ) {}
618  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
619  static constexpr size_t size = 4UL;
620 #else
621  using IntrinsicType = ValueType;
622  BLAZE_ALWAYS_INLINE SIMDint32() noexcept : value( 0 ) {}
623  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
624  static constexpr size_t size = 1UL;
625 #endif
626 
627  BLAZE_ALWAYS_INLINE SIMDint32( IntrinsicType v ) noexcept : value( v ) {}
628 
629  template< typename T >
630  BLAZE_ALWAYS_INLINE SIMDint32( const SIMDi32<T>& v ) noexcept : value( (~v).value ) {}
631 
632  template< typename T >
633  BLAZE_ALWAYS_INLINE SIMDint32& operator=( const SIMDi32<T>& v ) noexcept { value = (~v).value; return *this; }
634 
635  IntrinsicType value;
636 };
638 //*************************************************************************************************
639 
640 
641 //*************************************************************************************************
647 struct SIMDuint32
648  : public SIMDi32< SIMDuint32 >
649 {
650  using This = SIMDuint32;
651  using BaseType = SIMDi32<This>;
652  using ValueType = uint32_t;
653 
654 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
655  using IntrinsicType = __m512i;
656  BLAZE_ALWAYS_INLINE SIMDuint32() noexcept : value( _mm512_setzero_si512() ) {}
657  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
658  static constexpr size_t size = 16UL;
659 #elif BLAZE_AVX2_MODE
660  using IntrinsicType = __m256i;
661  BLAZE_ALWAYS_INLINE SIMDuint32() noexcept : value( _mm256_setzero_si256() ) {}
662  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
663  static constexpr size_t size = 8UL;
664 #elif BLAZE_SSE2_MODE
665  using IntrinsicType = __m128i;
666  BLAZE_ALWAYS_INLINE SIMDuint32() noexcept : value( _mm_setzero_si128() ) {}
667  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
668  static constexpr size_t size = 4UL;
669 #else
670  using IntrinsicType = ValueType;
671  BLAZE_ALWAYS_INLINE SIMDuint32() noexcept : value( 0 ) {}
672  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
673  static constexpr size_t size = 1UL;
674 #endif
675 
676  BLAZE_ALWAYS_INLINE SIMDuint32( IntrinsicType v ) noexcept : value( v ) {}
677 
678  template< typename T >
679  BLAZE_ALWAYS_INLINE SIMDuint32( const SIMDi32<T>& v ) noexcept : value( (~v).value ) {}
680 
681  template< typename T >
682  BLAZE_ALWAYS_INLINE SIMDuint32& operator=( const SIMDi32<T>& v ) noexcept { value = (~v).value; return *this; }
683 
684  IntrinsicType value;
685 };
687 //*************************************************************************************************
688 
689 
690 
691 
692 //=================================================================================================
693 //
694 // 32-BIT INTEGRAL COMPLEX SIMD TYPES
695 //
696 //=================================================================================================
697 
698 //*************************************************************************************************
699 /*\class blaze::SIMDci32
700 // \brief Base class for all 32-bit integral complex SIMD data types.
701 // \ingroup simd
702 */
704 template< typename T > // Type of the SIMD element
705 struct SIMDci32
706  : public SIMDPack< T >
707 {};
709 //*************************************************************************************************
710 
711 
712 //*************************************************************************************************
718 struct SIMDcint32
719  : public SIMDci32< SIMDcint32 >
720 {
721  using This = SIMDcint32;
722  using BaseType = SIMDci32<This>;
723  using ValueType = complex<int32_t>;
724 
725 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
726  using IntrinsicType = __m512i;
727  BLAZE_ALWAYS_INLINE SIMDcint32() noexcept : value( _mm512_setzero_si512() ) {}
728  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
729  static constexpr size_t size = 8UL;
730 #elif BLAZE_AVX2_MODE
731  using IntrinsicType = __m256i;
732  BLAZE_ALWAYS_INLINE SIMDcint32() noexcept : value( _mm256_setzero_si256() ) {}
733  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
734  static constexpr size_t size = 4UL;
735 #elif BLAZE_SSE2_MODE
736  using IntrinsicType = __m128i;
737  BLAZE_ALWAYS_INLINE SIMDcint32() noexcept : value( _mm_setzero_si128() ) {}
738  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
739  static constexpr size_t size = 2UL;
740 #else
741  using IntrinsicType = ValueType;
742  BLAZE_ALWAYS_INLINE SIMDcint32() noexcept : value( 0, 0 ) {}
743  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
744  static constexpr size_t size = 1UL;
745 #endif
746 
747  BLAZE_ALWAYS_INLINE SIMDcint32( IntrinsicType v ) noexcept : value( v ) {}
748 
749  template< typename T >
750  BLAZE_ALWAYS_INLINE SIMDcint32( const SIMDci32<T>& v ) noexcept : value( (~v).value ) {}
751 
752  template< typename T >
753  BLAZE_ALWAYS_INLINE SIMDcint32& operator=( const SIMDci32<T>& v ) noexcept { value = (~v).value; return *this; }
754 
755  IntrinsicType value;
756 };
758 //*************************************************************************************************
759 
760 
761 //*************************************************************************************************
767 struct SIMDcuint32
768  : public SIMDci32< SIMDcuint32 >
769 {
770  using This = SIMDcuint32;
771  using BaseType = SIMDci32<This>;
772  using ValueType = complex<uint32_t>;
773 
774 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
775  using IntrinsicType = __m512i;
776  BLAZE_ALWAYS_INLINE SIMDcuint32() noexcept : value( _mm512_setzero_si512() ) {}
777  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
778  static constexpr size_t size = 8UL;
779 #elif BLAZE_AVX2_MODE
780  using IntrinsicType = __m256i;
781  BLAZE_ALWAYS_INLINE SIMDcuint32() noexcept : value( _mm256_setzero_si256() ) {}
782  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
783  static constexpr size_t size = 4UL;
784 #elif BLAZE_SSE2_MODE
785  using IntrinsicType = __m128i;
786  BLAZE_ALWAYS_INLINE SIMDcuint32() noexcept : value( _mm_setzero_si128() ) {}
787  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
788  static constexpr size_t size = 2UL;
789 #else
790  using IntrinsicType = ValueType;
791  BLAZE_ALWAYS_INLINE SIMDcuint32() noexcept : value( 0, 0 ) {}
792  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
793  static constexpr size_t size = 1UL;
794 #endif
795 
796  BLAZE_ALWAYS_INLINE SIMDcuint32( IntrinsicType v ) noexcept : value( v ) {}
797 
798  template< typename T >
799  BLAZE_ALWAYS_INLINE SIMDcuint32( const SIMDci32<T>& v ) noexcept : value( (~v).value ) {}
800 
801  template< typename T >
802  BLAZE_ALWAYS_INLINE SIMDcuint32& operator=( const SIMDci32<T>& v ) noexcept { value = (~v).value; return *this; }
803 
804  IntrinsicType value;
805 };
807 //*************************************************************************************************
808 
809 
810 
811 
812 //=================================================================================================
813 //
814 // 64-BIT INTEGRAL SIMD TYPES
815 //
816 //=================================================================================================
817 
818 //*************************************************************************************************
819 /*\class blaze::SIMDi64
820 // \brief Base class for all 64-bit integral SIMD data types.
821 // \ingroup simd
822 */
824 template< typename T > // Type of the SIMD element
825 struct SIMDi64
826  : public SIMDPack< T >
827 {};
829 //*************************************************************************************************
830 
831 
832 //*************************************************************************************************
838 struct SIMDint64
839  : public SIMDi64< SIMDint64 >
840 {
841  using This = SIMDint64;
842  using BaseType = SIMDi64<This>;
843  using ValueType = int64_t;
844 
845 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
846  using IntrinsicType = __m512i;
847  BLAZE_ALWAYS_INLINE SIMDint64() noexcept : value( _mm512_setzero_si512() ) {}
848  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
849  static constexpr size_t size = 8UL;
850 #elif BLAZE_AVX2_MODE
851  using IntrinsicType = __m256i;
852  BLAZE_ALWAYS_INLINE SIMDint64() noexcept : value( _mm256_setzero_si256() ) {}
853  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
854  static constexpr size_t size = 4UL;
855 #elif BLAZE_SSE2_MODE
856  using IntrinsicType = __m128i;
857  BLAZE_ALWAYS_INLINE SIMDint64() noexcept : value( _mm_setzero_si128() ) {}
858  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
859  static constexpr size_t size = 2UL;
860 #else
861  using IntrinsicType = ValueType;
862  BLAZE_ALWAYS_INLINE SIMDint64() noexcept : value( 0L ) {}
863  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
864  static constexpr size_t size = 1UL;
865 #endif
866 
867  BLAZE_ALWAYS_INLINE SIMDint64( IntrinsicType v ) noexcept : value( v ) {}
868 
869  template< typename T >
870  BLAZE_ALWAYS_INLINE SIMDint64( const SIMDi64<T>& v ) noexcept : value( (~v).value ) {}
871 
872  template< typename T >
873  BLAZE_ALWAYS_INLINE SIMDint64& operator=( const SIMDi64<T>& v ) noexcept { value = (~v).value; return *this; }
874 
875  IntrinsicType value;
876 };
878 //*************************************************************************************************
879 
880 
881 //*************************************************************************************************
887 struct SIMDuint64
888  : public SIMDi64< SIMDuint64 >
889 {
890  using This = SIMDuint64;
891  using BaseType = SIMDi64<This>;
892  using ValueType = uint64_t;
893 
894 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
895  using IntrinsicType = __m512i;
896  BLAZE_ALWAYS_INLINE SIMDuint64() noexcept : value( _mm512_setzero_si512() ) {}
897  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
898  static constexpr size_t size = 8UL;
899 #elif BLAZE_AVX2_MODE
900  using IntrinsicType = __m256i;
901  BLAZE_ALWAYS_INLINE SIMDuint64() noexcept : value( _mm256_setzero_si256() ) {}
902  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
903  static constexpr size_t size = 4UL;
904 #elif BLAZE_SSE2_MODE
905  using IntrinsicType = __m128i;
906  BLAZE_ALWAYS_INLINE SIMDuint64() noexcept : value( _mm_setzero_si128() ) {}
907  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
908  static constexpr size_t size = 2UL;
909 #else
910  using IntrinsicType = ValueType;
911  BLAZE_ALWAYS_INLINE SIMDuint64() noexcept : value( 0L ) {}
912  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
913  static constexpr size_t size = 1UL;
914 #endif
915 
916  BLAZE_ALWAYS_INLINE SIMDuint64( IntrinsicType v ) noexcept : value( v ) {}
917 
918  template< typename T >
919  BLAZE_ALWAYS_INLINE SIMDuint64( const SIMDi64<T>& v ) noexcept : value( (~v).value ) {}
920 
921  template< typename T >
922  BLAZE_ALWAYS_INLINE SIMDuint64& operator=( const SIMDi64<T>& v ) noexcept { value = (~v).value; return *this; }
923 
924  IntrinsicType value;
925 };
927 //*************************************************************************************************
928 
929 
930 
931 
932 //=================================================================================================
933 //
934 // 64-BIT INTEGRAL COMPLEX SIMD TYPES
935 //
936 //=================================================================================================
937 
938 //*************************************************************************************************
939 /*\class blaze::SIMDci64
940 // \brief Base class for all 64-bit integral complex SIMD data types.
941 // \ingroup simd
942 */
944 template< typename T > // Type of the SIMD element
945 struct SIMDci64
946  : public SIMDPack< T >
947 {};
949 //*************************************************************************************************
950 
951 
952 //*************************************************************************************************
958 struct SIMDcint64
959  : public SIMDci64< SIMDcint64 >
960 {
961  using This = SIMDcint64;
962  using BaseType = SIMDci64<This>;
963  using ValueType = complex<int64_t>;
964 
965 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
966  using IntrinsicType = __m512i;
967  BLAZE_ALWAYS_INLINE SIMDcint64() noexcept : value( _mm512_setzero_si512() ) {}
968  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
969  static constexpr size_t size = 4UL;
970 #elif BLAZE_AVX2_MODE
971  using IntrinsicType = __m256i;
972  BLAZE_ALWAYS_INLINE SIMDcint64() noexcept : value( _mm256_setzero_si256() ) {}
973  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
974  static constexpr size_t size = 2UL;
975 #elif BLAZE_SSE2_MODE
976  using IntrinsicType = __m128i;
977  BLAZE_ALWAYS_INLINE SIMDcint64() noexcept : value( _mm_setzero_si128() ) {}
978  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
979  static constexpr size_t size = 1UL;
980 #else
981  using IntrinsicType = ValueType;
982  BLAZE_ALWAYS_INLINE SIMDcint64() noexcept : value( 0L, 0L ) {}
983  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
984  static constexpr size_t size = 1UL;
985 #endif
986 
987  BLAZE_ALWAYS_INLINE SIMDcint64( IntrinsicType v ) noexcept : value( v ) {}
988 
989  template< typename T >
990  BLAZE_ALWAYS_INLINE SIMDcint64( const SIMDci64<T>& v ) noexcept : value( (~v).value ) {}
991 
992  template< typename T >
993  BLAZE_ALWAYS_INLINE SIMDcint64& operator=( const SIMDci64<T>& v ) noexcept { value = (~v).value; return *this; }
994 
995  IntrinsicType value;
996 };
998 //*************************************************************************************************
999 
1000 
1001 //*************************************************************************************************
1007 struct SIMDcuint64
1008  : public SIMDci64< SIMDcuint64 >
1009 {
1010  using This = SIMDcuint64;
1011  using BaseType = SIMDci64<This>;
1012  using ValueType = complex<uint64_t>;
1013 
1014 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
1015  using IntrinsicType = __m512i;
1016  BLAZE_ALWAYS_INLINE SIMDcuint64() noexcept : value( _mm512_setzero_si512() ) {}
1017  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
1018  static constexpr size_t size = 4UL;
1019 #elif BLAZE_AVX2_MODE
1020  using IntrinsicType = __m256i;
1021  BLAZE_ALWAYS_INLINE SIMDcuint64() noexcept : value( _mm256_setzero_si256() ) {}
1022  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
1023  static constexpr size_t size = 2UL;
1024 #elif BLAZE_SSE2_MODE
1025  using IntrinsicType = __m128i;
1026  BLAZE_ALWAYS_INLINE SIMDcuint64() noexcept : value( _mm_setzero_si128() ) {}
1027  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
1028  static constexpr size_t size = 1UL;
1029 #else
1030  using IntrinsicType = ValueType;
1031  BLAZE_ALWAYS_INLINE SIMDcuint64() noexcept : value( 0L, 0L ) {}
1032  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
1033  static constexpr size_t size = 1UL;
1034 #endif
1035 
1036  BLAZE_ALWAYS_INLINE SIMDcuint64( IntrinsicType v ) noexcept : value( v ) {}
1037 
1038  template< typename T >
1039  BLAZE_ALWAYS_INLINE SIMDcuint64( const SIMDci64<T>& v ) noexcept : value( (~v).value ) {}
1040 
1041  template< typename T >
1042  BLAZE_ALWAYS_INLINE SIMDcuint64& operator=( const SIMDci64<T>& v ) noexcept { value = (~v).value; return *this; }
1043 
1044  IntrinsicType value;
1045 };
1047 //*************************************************************************************************
1048 
1049 
1050 
1051 
1052 //=================================================================================================
1053 //
1054 // SINGLE PRECISION FLOATING POINT SIMD TYPES
1055 //
1056 //=================================================================================================
1057 
1058 //*************************************************************************************************
1059 /*\class blaze::SIMDf32
1060 // \brief Base class for all single precision floating point SIMD data types.
1061 // \ingroup simd
1062 */
1064 template< typename T > // Type of the SIMD element
1065 struct SIMDf32
1066  : public SIMDPack< T >
1067 {};
1069 //*************************************************************************************************
1070 
1071 
1072 //*************************************************************************************************
1078 struct SIMDfloat
1079  : public SIMDf32< SIMDfloat >
1080 {
1081  using This = SIMDfloat;
1082  using BaseType = SIMDf32<This>;
1083  using ValueType = float;
1084 
1085 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
1086  using IntrinsicType = __m512;
1087  BLAZE_ALWAYS_INLINE SIMDfloat() noexcept : value( _mm512_setzero_ps() ) {}
1088  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
1089  static constexpr size_t size = 16UL;
1090 #elif BLAZE_AVX_MODE
1091  using IntrinsicType = __m256;
1092  BLAZE_ALWAYS_INLINE SIMDfloat() noexcept : value( _mm256_setzero_ps() ) {}
1093  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
1094  static constexpr size_t size = 8UL;
1095 #elif BLAZE_SSE_MODE
1096  using IntrinsicType = __m128;
1097  BLAZE_ALWAYS_INLINE SIMDfloat() noexcept : value( _mm_setzero_ps() ) {}
1098  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
1099  static constexpr size_t size = 4UL;
1100 #else
1101  using IntrinsicType = ValueType;
1102  BLAZE_ALWAYS_INLINE SIMDfloat() noexcept : value( 0.0F ) {}
1103  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
1104  static constexpr size_t size = 1UL;
1105 #endif
1106 
1107  BLAZE_ALWAYS_INLINE SIMDfloat( IntrinsicType v ) noexcept : value( v ) {}
1108 
1109  template< typename T >
1110  BLAZE_ALWAYS_INLINE SIMDfloat( const SIMDf32<T>& v ) noexcept : value( (~v).eval().value ) {}
1111 
1112  template< typename T >
1113  BLAZE_ALWAYS_INLINE SIMDfloat& operator=( const SIMDf32<T>& v ) noexcept { value = (~v).eval().value; return *this; }
1114 
1115  BLAZE_ALWAYS_INLINE const This& eval() const { return *this; }
1116 
1117  IntrinsicType value;
1118 };
1120 //*************************************************************************************************
1121 
1122 
1123 
1124 
1125 //=================================================================================================
1126 //
1127 // SINGLE PRECISION FLOATING POINT COMPLEX SIMD TYPES
1128 //
1129 //=================================================================================================
1130 
1131 //*************************************************************************************************
1132 /*\class blaze::SIMDcf32
1133 // \brief Base class for all single precision floating point complex SIMD data types.
1134 // \ingroup simd
1135 */
1137 template< typename T > // Type of the SIMD element
1138 struct SIMDcf32
1139  : public SIMDPack< T >
1140 {};
1142 //*************************************************************************************************
1143 
1144 
1145 //*************************************************************************************************
1151 struct SIMDcfloat
1152  : public SIMDcf32< SIMDcfloat >
1153 {
1154  using This = SIMDcfloat;
1155  using BaseType = SIMDcf32<This>;
1156  using ValueType = complex<float>;
1157 
1158 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
1159  using IntrinsicType = __m512;
1160  BLAZE_ALWAYS_INLINE SIMDcfloat() noexcept : value( _mm512_setzero_ps() ) {}
1161  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
1162  static constexpr size_t size = 8UL;
1163 #elif BLAZE_AVX_MODE
1164  using IntrinsicType = __m256;
1165  BLAZE_ALWAYS_INLINE SIMDcfloat() noexcept : value( _mm256_setzero_ps() ) {}
1166  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
1167  static constexpr size_t size = 4UL;
1168 #elif BLAZE_SSE_MODE
1169  using IntrinsicType = __m128;
1170  BLAZE_ALWAYS_INLINE SIMDcfloat() noexcept : value( _mm_setzero_ps() ) {}
1171  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
1172  static constexpr size_t size = 2UL;
1173 #else
1174  using IntrinsicType = ValueType;
1175  BLAZE_ALWAYS_INLINE SIMDcfloat() noexcept : value( 0.0F, 0.0F ) {}
1176  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
1177  static constexpr size_t size = 1UL;
1178 #endif
1179 
1180  BLAZE_ALWAYS_INLINE SIMDcfloat( IntrinsicType v ) noexcept : value( v ) {}
1181 
1182  template< typename T >
1183  BLAZE_ALWAYS_INLINE SIMDcfloat( const SIMDcf32<T>& v ) noexcept : value( (~v).value ) {}
1184 
1185  template< typename T >
1186  BLAZE_ALWAYS_INLINE SIMDcfloat& operator=( const SIMDcf32<T>& v ) noexcept { value = (~v).value; return *this; }
1187 
1188  IntrinsicType value;
1189 };
1191 //*************************************************************************************************
1192 
1193 
1194 
1195 
1196 //=================================================================================================
1197 //
1198 // DOUBLE PRECISION FLOATING POINT SIMD TYPES
1199 //
1200 //=================================================================================================
1201 
1202 //*************************************************************************************************
1203 /*\class blaze::SIMDf64
1204 // \brief Base class for all double precision floating point SIMD data types.
1205 // \ingroup simd
1206 */
1208 template< typename T > // Type of the SIMD element
1209 struct SIMDf64
1210  : public SIMDPack< T >
1211 {};
1213 //*************************************************************************************************
1214 
1215 
1216 //*************************************************************************************************
1222 struct SIMDdouble
1223  : public SIMDf64< SIMDdouble >
1224 {
1225  using This = SIMDdouble;
1226  using BaseType = SIMDf64<This>;
1227  using ValueType = double;
1228 
1229 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
1230  using IntrinsicType = __m512d;
1231  BLAZE_ALWAYS_INLINE SIMDdouble() noexcept : value( _mm512_setzero_pd() ) {}
1232  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
1233  static constexpr size_t size = 8UL;
1234 #elif BLAZE_AVX_MODE
1235  using IntrinsicType = __m256d;
1236  BLAZE_ALWAYS_INLINE SIMDdouble() noexcept : value( _mm256_setzero_pd() ) {}
1237  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
1238  static constexpr size_t size = 4UL;
1239 #elif BLAZE_SSE2_MODE
1240  using IntrinsicType = __m128d;
1241  BLAZE_ALWAYS_INLINE SIMDdouble() noexcept : value( _mm_setzero_pd() ) {}
1242  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
1243  static constexpr size_t size = 2UL;
1244 #else
1245  using IntrinsicType = ValueType;
1246  BLAZE_ALWAYS_INLINE SIMDdouble() noexcept : value( 0.0 ) {}
1247  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
1248  static constexpr size_t size = 1UL;
1249 #endif
1250 
1251  BLAZE_ALWAYS_INLINE SIMDdouble( IntrinsicType v ) noexcept : value( v ) {}
1252 
1253  template< typename T >
1254  BLAZE_ALWAYS_INLINE SIMDdouble( const SIMDf64<T>& v ) noexcept : value( (~v).eval().value ) {}
1255 
1256  template< typename T >
1257  BLAZE_ALWAYS_INLINE SIMDdouble& operator=( const SIMDf64<T>& v ) noexcept { value = (~v).eval().value; return *this; }
1258 
1259  BLAZE_ALWAYS_INLINE const This& eval() const { return *this; }
1260 
1261  IntrinsicType value;
1262 };
1264 //*************************************************************************************************
1265 
1266 
1267 
1268 
1269 //=================================================================================================
1270 //
1271 // DOUBLE PRECISION FLOATING POINT COMPLEX SIMD TYPES
1272 //
1273 //=================================================================================================
1274 
1275 //*************************************************************************************************
1276 /*\class blaze::SIMDcf64
1277 // \brief Base class for all double precision floating point complex SIMD data types.
1278 // \ingroup simd
1279 */
1281 template< typename T > // Type of the SIMD element
1282 struct SIMDcf64
1283  : public SIMDPack< T >
1284 {};
1286 //*************************************************************************************************
1287 
1288 
1289 //*************************************************************************************************
1295 struct SIMDcdouble
1296  : public SIMDcf64< SIMDcdouble >
1297 {
1298  using This = SIMDcdouble;
1299  using BaseType = SIMDcf64<This>;
1300  using ValueType = complex<double>;
1301 
1302 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
1303  using IntrinsicType = __m512d;
1304  BLAZE_ALWAYS_INLINE SIMDcdouble() noexcept : value( _mm512_setzero_pd() ) {}
1305  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
1306  static constexpr size_t size = 4UL;
1307 #elif BLAZE_AVX_MODE
1308  using IntrinsicType = __m256d;
1309  BLAZE_ALWAYS_INLINE SIMDcdouble() noexcept : value( _mm256_setzero_pd() ) {}
1310  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
1311  static constexpr size_t size = 2UL;
1312 #elif BLAZE_SSE2_MODE
1313  using IntrinsicType = __m128d;
1314  BLAZE_ALWAYS_INLINE SIMDcdouble() noexcept : value( _mm_setzero_pd() ) {}
1315  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t i ) const noexcept { return reinterpret_cast<const ValueType*>( &value )[i]; }
1316  static constexpr size_t size = 1UL;
1317 #else
1318  using IntrinsicType = ValueType;
1319  BLAZE_ALWAYS_INLINE SIMDcdouble() noexcept : value( 0.0, 0.0 ) {}
1320  BLAZE_ALWAYS_INLINE ValueType operator[]( size_t /*i*/ ) const noexcept { return value; }
1321  static constexpr size_t size = 1UL;
1322 #endif
1323 
1324  BLAZE_ALWAYS_INLINE SIMDcdouble( IntrinsicType v ) noexcept : value( v ) {}
1325 
1326  template< typename T >
1327  BLAZE_ALWAYS_INLINE SIMDcdouble( const SIMDcf64<T>& v ) noexcept : value( (~v).value ) {}
1328 
1329  template< typename T >
1330  BLAZE_ALWAYS_INLINE SIMDcdouble& operator=( const SIMDcf64<T>& v ) noexcept { value = (~v).value; return *this; }
1331 
1332  IntrinsicType value;
1333 };
1335 //*************************************************************************************************
1336 
1337 
1338 
1339 
1340 //=================================================================================================
1341 //
1342 // SIMD OPERATORS
1343 //
1344 //=================================================================================================
1345 
1346 //*************************************************************************************************
1354 template< typename T1 // Type of the left-hand side SIMD operand
1355  , typename T2 > // Type of the right-hand side SIMD operand
1357 {
1358  (~lhs) = (~lhs) + (~rhs);
1359  return ~lhs;
1360 }
1361 //*************************************************************************************************
1362 
1363 
1364 //*************************************************************************************************
1372 template< typename T1 // Type of the left-hand side SIMD operand
1373  , typename T2 > // Type of the right-hand side SIMD operand
1375 {
1376  (~lhs) = (~lhs) - (~rhs);
1377  return ~lhs;
1378 }
1379 //*************************************************************************************************
1380 
1381 
1382 //*************************************************************************************************
1390 template< typename T1 // Type of the left-hand side SIMD operand
1391  , typename T2 > // Type of the right-hand side SIMD operand
1393 {
1394  (~lhs) = (~lhs) * (~rhs);
1395  return ~lhs;
1396 }
1397 //*************************************************************************************************
1398 
1399 
1400 //*************************************************************************************************
1408 template< typename T1 // Type of the left-hand side SIMD operand
1409  , typename T2 > // Type of the right-hand side SIMD operand
1411 {
1412  (~lhs) = (~lhs) / (~rhs);
1413  return ~lhs;
1414 }
1415 //*************************************************************************************************
1416 
1417 } // namespace blaze
1418 
1419 #endif
auto operator-=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Subtraction assignment operator for the subtraction of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:432
Header file for basic type definitions.
Header file for the SIMDPack base class.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
auto operator+=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Addition assignment operator for the addition of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:370
Base class for all SIMD data types.The SIMDPack class template is a base class for all SIMD data type...
Definition: SIMDPack.h:63
decltype(auto) eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition: DMatEvalExpr.h:786
auto operator/=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Division assignment operator for the division of a dense matrix by a scalar value ( ).
Definition: DenseMatrix.h:558
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
System settings for the SSE mode.
auto operator *=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:494
Header file for the complex data type.
System settings for the inline keywords.