Multiplication.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_INTRINSICS_MULTIPLICATION_H_
36 #define _BLAZE_MATH_INTRINSICS_MULTIPLICATION_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
44 #include <blaze/system/Inline.h>
46 
47 
48 namespace blaze {
49 
50 //=================================================================================================
51 //
52 // INTRINSIC MULTIPLICATION OPERATORS
53 //
54 //=================================================================================================
55 
56 //*************************************************************************************************
65 #if BLAZE_AVX2_MODE
66 BLAZE_ALWAYS_INLINE sse_int16_t operator*( const sse_int16_t& a, const sse_int16_t& b )
67 {
68  return _mm256_mullo_epi16( a.value, b.value );
69 }
70 #elif BLAZE_SSE2_MODE
71 BLAZE_ALWAYS_INLINE sse_int16_t operator*( const sse_int16_t& a, const sse_int16_t& b )
72 {
73  return _mm_mullo_epi16( a.value, b.value );
74 }
75 #endif
76 //*************************************************************************************************
77 
78 
79 //*************************************************************************************************
88 #if BLAZE_MIC_MODE
89 BLAZE_ALWAYS_INLINE sse_int32_t operator*( const sse_int32_t& a, const sse_int32_t& b )
90 {
91  return _mm512_mullo_epi32( a.value, b.value );
92 }
93 #elif BLAZE_AVX2_MODE
94 BLAZE_ALWAYS_INLINE sse_int32_t operator*( const sse_int32_t& a, const sse_int32_t& b )
95 {
96  return _mm256_mullo_epi32( a.value, b.value );
97 }
98 #elif BLAZE_SSE4_MODE
99 BLAZE_ALWAYS_INLINE sse_int32_t operator*( const sse_int32_t& a, const sse_int32_t& b )
100 {
101  return _mm_mullo_epi32( a.value, b.value );
102 }
103 #endif
104 //*************************************************************************************************
105 
106 
107 //*************************************************************************************************
116 #if BLAZE_MIC_MODE
117 BLAZE_ALWAYS_INLINE sse_float_t operator*( const sse_float_t& a, const sse_float_t& b )
118 {
119  return _mm512_mul_ps( a.value, b.value );
120 }
121 #elif BLAZE_AVX_MODE
122 BLAZE_ALWAYS_INLINE sse_float_t operator*( const sse_float_t& a, const sse_float_t& b )
123 {
124  return _mm256_mul_ps( a.value, b.value );
125 }
126 #elif BLAZE_SSE_MODE
127 BLAZE_ALWAYS_INLINE sse_float_t operator*( const sse_float_t& a, const sse_float_t& b )
128 {
129  return _mm_mul_ps( a.value, b.value );
130 }
131 #endif
132 //*************************************************************************************************
133 
134 
135 //*************************************************************************************************
144 #if BLAZE_MIC_MODE
145 BLAZE_ALWAYS_INLINE sse_double_t operator*( const sse_double_t& a, const sse_double_t& b )
146 {
147  return _mm512_mul_pd( a.value, b.value );
148 }
149 #elif BLAZE_AVX_MODE
150 BLAZE_ALWAYS_INLINE sse_double_t operator*( const sse_double_t& a, const sse_double_t& b )
151 {
152  return _mm256_mul_pd( a.value, b.value );
153 }
154 #elif BLAZE_SSE2_MODE
155 BLAZE_ALWAYS_INLINE sse_double_t operator*( const sse_double_t& a, const sse_double_t& b )
156 {
157  return _mm_mul_pd( a.value, b.value );
158 }
159 #endif
160 //*************************************************************************************************
161 
162 
163 //*************************************************************************************************
172 #if BLAZE_AVX_MODE
173 BLAZE_ALWAYS_INLINE sse_cfloat_t operator*( const sse_cfloat_t& a, const sse_cfloat_t& b )
174 {
175  __m256 x, y, z;
176 
177  x = _mm256_shuffle_ps( a.value, a.value, 0xA0 );
178  z = _mm256_mul_ps( x, b.value );
179  x = _mm256_shuffle_ps( a.value, a.value, 0xF5 );
180  y = _mm256_shuffle_ps( b.value, b.value, 0xB1 );
181  y = _mm256_mul_ps( x, y );
182  return _mm256_addsub_ps( z, y );
183 }
184 #elif BLAZE_SSE3_MODE
185 BLAZE_ALWAYS_INLINE sse_cfloat_t operator*( const sse_cfloat_t& a, const sse_cfloat_t& b )
186 {
187  __m128 x, y, z;
188 
189  x = _mm_shuffle_ps( a.value, a.value, 0xA0 );
190  z = _mm_mul_ps( x, b.value );
191  x = _mm_shuffle_ps( a.value, a.value, 0xF5 );
192  y = _mm_shuffle_ps( b.value, b.value, 0xB1 );
193  y = _mm_mul_ps( x, y );
194  return _mm_addsub_ps( z, y );
195 }
196 #endif
197 //*************************************************************************************************
198 
199 
200 //*************************************************************************************************
209 #if BLAZE_AVX_MODE
210 BLAZE_ALWAYS_INLINE sse_cdouble_t operator*( const sse_cdouble_t& a, const sse_cdouble_t& b )
211 {
212  __m256d x, y, z;
213 
214  x = _mm256_shuffle_pd( a.value, a.value, 0 );
215  z = _mm256_mul_pd( x, b.value );
216  x = _mm256_shuffle_pd( a.value, a.value, 15 );
217  y = _mm256_shuffle_pd( b.value, b.value, 5 );
218  y = _mm256_mul_pd( x, y );
219  return _mm256_addsub_pd( z, y );
220 }
221 #elif BLAZE_SSE3_MODE
222 BLAZE_ALWAYS_INLINE sse_cdouble_t operator*( const sse_cdouble_t& a, const sse_cdouble_t& b )
223 {
224  __m128d x, y, z;
225 
226  x = _mm_shuffle_pd( a.value, a.value, 0 );
227  z = _mm_mul_pd( x, b.value );
228  x = _mm_shuffle_pd( a.value, a.value, 3 );
229  y = _mm_shuffle_pd( b.value, b.value, 1 );
230  y = _mm_mul_pd( x, y );
231  return _mm_addsub_pd( z, y );
232 }
233 #endif
234 //*************************************************************************************************
235 
236 } // namespace blaze
237 
238 #endif
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:8247
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
Header file for the basic intrinsic types.
System settings for the SSE mode.
System settings for the inline keywords.