Addition.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_SIMD_ADDITION_H_
36 #define _BLAZE_MATH_SIMD_ADDITION_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
44 #include <blaze/system/Inline.h>
46 
47 
48 namespace blaze {
49 
50 //=================================================================================================
51 //
52 // 8-BIT INTEGRAL SIMD TYPES
53 //
54 //=================================================================================================
55 
56 //*************************************************************************************************
66 template< typename T > // Type of both operands
67 BLAZE_ALWAYS_INLINE const T
68  operator+( const SIMDi8<T>& a, const SIMDi8<T>& b ) noexcept
69 #if BLAZE_AVX512BW_MODE
70 {
71  return _mm512_add_epi8( (~a).value, (~b).value );
72 }
73 #elif BLAZE_AVX2_MODE
74 {
75  return _mm256_add_epi8( (~a).value, (~b).value );
76 }
77 #elif BLAZE_SSE2_MODE
78 {
79  return _mm_add_epi8( (~a).value, (~b).value );
80 }
81 #else
82 = delete;
83 #endif
84 //*************************************************************************************************
85 
86 
87 //*************************************************************************************************
97 template< typename T1 // Type of the left-hand side operand
98  , typename T2 > // Type of the right-hand side operand
99 BLAZE_ALWAYS_INLINE const SIMDuint8
100  operator+( const SIMDi8<T1>& a, const SIMDi8<T2>& b ) noexcept
101 #if BLAZE_AVX512BW_MODE
102 {
103  return _mm512_add_epi8( (~a).value, (~b).value );
104 }
105 #elif BLAZE_AVX2_MODE
106 {
107  return _mm256_add_epi8( (~a).value, (~b).value );
108 }
109 #elif BLAZE_SSE2_MODE
110 {
111  return _mm_add_epi8( (~a).value, (~b).value );
112 }
113 #else
114 = delete;
115 #endif
116 //*************************************************************************************************
117 
118 
119 //*************************************************************************************************
129 template< typename T > // Type of both operands
130 BLAZE_ALWAYS_INLINE const T
131  operator+( const SIMDci8<T>& a, const SIMDci8<T>& b ) noexcept
132 #if BLAZE_AVX512BW_MODE
133 {
134  return _mm512_add_epi8( (~a).value, (~b).value );
135 }
136 #elif BLAZE_AVX2_MODE
137 {
138  return _mm256_add_epi8( (~a).value, (~b).value );
139 }
140 #elif BLAZE_SSE2_MODE
141 {
142  return _mm_add_epi8( (~a).value, (~b).value );
143 }
144 #else
145 = delete;
146 #endif
147 //*************************************************************************************************
148 
149 
150 
151 
152 //=================================================================================================
153 //
154 // 16-BIT INTEGRAL SIMD TYPES
155 //
156 //=================================================================================================
157 
158 //*************************************************************************************************
168 template< typename T > // Type of both operands
169 BLAZE_ALWAYS_INLINE const T
170  operator+( const SIMDi16<T>& a, const SIMDi16<T>& b ) noexcept
171 #if BLAZE_AVX512BW_MODE
172 {
173  return _mm512_add_epi16( (~a).value, (~b).value );
174 }
175 #elif BLAZE_AVX2_MODE
176 {
177  return _mm256_add_epi16( (~a).value, (~b).value );
178 }
179 #elif BLAZE_SSE2_MODE
180 {
181  return _mm_add_epi16( (~a).value, (~b).value );
182 }
183 #else
184 = delete;
185 #endif
186 //*************************************************************************************************
187 
188 
189 //*************************************************************************************************
199 template< typename T1 // Type of the left-hand side operand
200  , typename T2 > // Type of the right-hand side operand
201 BLAZE_ALWAYS_INLINE const SIMDuint16
202  operator+( const SIMDi16<T1>& a, const SIMDi16<T2>& b ) noexcept
203 #if BLAZE_AVX512BW_MODE
204 {
205  return _mm512_add_epi16( (~a).value, (~b).value );
206 }
207 #elif BLAZE_AVX2_MODE
208 {
209  return _mm256_add_epi16( (~a).value, (~b).value );
210 }
211 #elif BLAZE_SSE2_MODE
212 {
213  return _mm_add_epi16( (~a).value, (~b).value );
214 }
215 #else
216 = delete;
217 #endif
218 //*************************************************************************************************
219 
220 
221 //*************************************************************************************************
231 template< typename T > // Type of both operands
232 BLAZE_ALWAYS_INLINE const T
233  operator+( const SIMDci16<T>& a, const SIMDci16<T>& b ) noexcept
234 #if BLAZE_AVX512BW_MODE
235 {
236  return _mm512_add_epi16( (~a).value, (~b).value );
237 }
238 #elif BLAZE_AVX2_MODE
239 {
240  return _mm256_add_epi16( (~a).value, (~b).value );
241 }
242 #elif BLAZE_SSE2_MODE
243 {
244  return _mm_add_epi16( (~a).value, (~b).value );
245 }
246 #else
247 = delete;
248 #endif
249 //*************************************************************************************************
250 
251 
252 
253 
254 //=================================================================================================
255 //
256 // 32-BIT INTEGRAL SIMD TYPES
257 //
258 //=================================================================================================
259 
260 //*************************************************************************************************
270 template< typename T > // Type of both operands
271 BLAZE_ALWAYS_INLINE const T
272  operator+( const SIMDi32<T>& a, const SIMDi32<T>& b ) noexcept
273 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
274 {
275  return _mm512_add_epi32( (~a).value, (~b).value );
276 }
277 #elif BLAZE_AVX2_MODE
278 {
279  return _mm256_add_epi32( (~a).value, (~b).value );
280 }
281 #elif BLAZE_SSE2_MODE
282 {
283  return _mm_add_epi32( (~a).value, (~b).value );
284 }
285 #else
286 = delete;
287 #endif
288 //*************************************************************************************************
289 
290 
291 //*************************************************************************************************
301 template< typename T1 // Type of the left-hand side operand
302  , typename T2 > // Type of the right-hand side operand
303 BLAZE_ALWAYS_INLINE const SIMDuint32
304  operator+( const SIMDi32<T1>& a, const SIMDi32<T2>& b ) noexcept
305 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
306 {
307  return _mm512_add_epi32( (~a).value, (~b).value );
308 }
309 #elif BLAZE_AVX2_MODE
310 {
311  return _mm256_add_epi32( (~a).value, (~b).value );
312 }
313 #elif BLAZE_SSE2_MODE
314 {
315  return _mm_add_epi32( (~a).value, (~b).value );
316 }
317 #else
318 = delete;
319 #endif
320 //*************************************************************************************************
321 
322 
323 //*************************************************************************************************
333 template< typename T > // Type of both operands
334 BLAZE_ALWAYS_INLINE const T
335  operator+( const SIMDci32<T>& a, const SIMDci32<T>& b ) noexcept
336 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
337 {
338  return _mm512_add_epi32( (~a).value, (~b).value );
339 }
340 #elif BLAZE_AVX2_MODE
341 {
342  return _mm256_add_epi32( (~a).value, (~b).value );
343 }
344 #elif BLAZE_SSE2_MODE
345 {
346  return _mm_add_epi32( (~a).value, (~b).value );
347 }
348 #else
349 = delete;
350 #endif
351 //*************************************************************************************************
352 
353 
354 
355 
356 //=================================================================================================
357 //
358 // 64 SIMD TYPES INTEGRAL
359 //
360 //=================================================================================================
361 
362 //*************************************************************************************************
372 template< typename T > // Type of the left-hand side operand
373 BLAZE_ALWAYS_INLINE const T
374  operator+( const SIMDi64<T>& a, const SIMDi64<T>& b ) noexcept
375 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
376 {
377  return _mm512_add_epi64( (~a).value, (~b).value );
378 }
379 #elif BLAZE_AVX2_MODE
380 {
381  return _mm256_add_epi64( (~a).value, (~b).value );
382 }
383 #elif BLAZE_SSE2_MODE
384 {
385  return _mm_add_epi64( (~a).value, (~b).value );
386 }
387 #else
388 = delete;
389 #endif
390 //*************************************************************************************************
391 
392 
393 //*************************************************************************************************
403 template< typename T1 // Type of the left-hand side operand
404  , typename T2 > // Type of the right-hand side operand
405 BLAZE_ALWAYS_INLINE const SIMDuint64
406  operator+( const SIMDi64<T1>& a, const SIMDi64<T2>& b ) noexcept
407 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
408 {
409  return _mm512_add_epi64( (~a).value, (~b).value );
410 }
411 #elif BLAZE_AVX2_MODE
412 {
413  return _mm256_add_epi64( (~a).value, (~b).value );
414 }
415 #elif BLAZE_SSE2_MODE
416 {
417  return _mm_add_epi64( (~a).value, (~b).value );
418 }
419 #else
420 = delete;
421 #endif
422 //*************************************************************************************************
423 
424 
425 //*************************************************************************************************
435 template< typename T > // Type of both operands
436 BLAZE_ALWAYS_INLINE const T
437  operator+( const SIMDci64<T>& a, const SIMDci64<T>& b ) noexcept
438 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
439 {
440  return _mm512_add_epi64( (~a).value, (~b).value );
441 }
442 #elif BLAZE_AVX2_MODE
443 {
444  return _mm256_add_epi64( (~a).value, (~b).value );
445 }
446 #elif BLAZE_SSE2_MODE
447 {
448  return _mm_add_epi64( (~a).value, (~b).value );
449 }
450 #else
451 = delete;
452 #endif
453 //*************************************************************************************************
454 
455 
456 
457 
458 //=================================================================================================
459 //
460 // 32-BIT FLOATING POINT SIMD TYPES
461 //
462 //=================================================================================================
463 
464 //*************************************************************************************************
474 template< typename T1 // Type of the left-hand side operand
475  , typename T2 > // Type of the right-hand side operand
476 BLAZE_ALWAYS_INLINE const SIMDfloat
477  operator+( const SIMDf32<T1>& a, const SIMDf32<T2>& b ) noexcept
478 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
479 {
480  return _mm512_add_ps( (~a).eval().value, (~b).eval().value );
481 }
482 #elif BLAZE_AVX_MODE
483 {
484  return _mm256_add_ps( (~a).eval().value, (~b).eval().value );
485 }
486 #elif BLAZE_SSE_MODE
487 {
488  return _mm_add_ps( (~a).eval().value, (~b).eval().value );
489 }
490 #else
491 = delete;
492 #endif
493 //*************************************************************************************************
494 
495 
496 //*************************************************************************************************
506 BLAZE_ALWAYS_INLINE const SIMDcfloat
507  operator+( const SIMDcfloat& a, const SIMDcfloat& b ) noexcept
508 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
509 {
510  return _mm512_add_ps( a.value, b.value );
511 }
512 #elif BLAZE_AVX_MODE
513 {
514  return _mm256_add_ps( a.value, b.value );
515 }
516 #elif BLAZE_SSE_MODE
517 {
518  return _mm_add_ps( a.value, b.value );
519 }
520 #else
521 = delete;
522 #endif
523 //*************************************************************************************************
524 
525 
526 
527 
528 //=================================================================================================
529 //
530 // 64-BIT FLOATING POINT SIMD TYPES
531 //
532 //=================================================================================================
533 
534 //*************************************************************************************************
544 template< typename T1 // Type of the left-hand side operand
545  , typename T2 > // Type of the right-hand side operand
546 BLAZE_ALWAYS_INLINE const SIMDdouble
547  operator+( const SIMDf64<T1>& a, const SIMDf64<T2>& b ) noexcept
548 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
549 {
550  return _mm512_add_pd( (~a).eval().value, (~b).eval().value );
551 }
552 #elif BLAZE_AVX_MODE
553 {
554  return _mm256_add_pd( (~a).eval().value, (~b).eval().value );
555 }
556 #elif BLAZE_SSE2_MODE
557 {
558  return _mm_add_pd( (~a).eval().value, (~b).eval().value );
559 }
560 #else
561 = delete;
562 #endif
563 //*************************************************************************************************
564 
565 
566 //*************************************************************************************************
576 BLAZE_ALWAYS_INLINE const SIMDcdouble
577  operator+( const SIMDcdouble& a, const SIMDcdouble& b ) noexcept
578 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
579 {
580  return _mm512_add_pd( a.value, b.value );
581 }
582 #elif BLAZE_AVX_MODE
583 {
584  return _mm256_add_pd( a.value, b.value );
585 }
586 #elif BLAZE_SSE2_MODE
587 {
588  return _mm_add_pd( a.value, b.value );
589 }
590 #else
591 = delete;
592 #endif
593 //*************************************************************************************************
594 
595 } // namespace blaze
596 
597 #endif
const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:699
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
decltype(auto) eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition: DMatEvalExpr.h:797
Header file for the basic SIMD types.
System settings for the SSE mode.
System settings for the inline keywords.