All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Multiplication.h
Go to the documentation of this file.
1 //=================================================================================================
20 //=================================================================================================
21 
22 #ifndef _BLAZE_MATH_INTRINSICS_MULTIPLICATION_H_
23 #define _BLAZE_MATH_INTRINSICS_MULTIPLICATION_H_
24 
25 
26 //*************************************************************************************************
27 // Includes
28 //*************************************************************************************************
29 
32 
33 
34 namespace blaze {
35 
36 //=================================================================================================
37 //
38 // INTRINSIC MULTIPLICATION OPERATORS
39 //
40 //=================================================================================================
41 
42 //*************************************************************************************************
51 #if BLAZE_AVX2_MODE
52 inline sse_int16_t operator*( const sse_int16_t& a, const sse_int16_t& b )
53 {
54  return _mm256_mullo_epi16( a.value, b.value );
55 }
56 #elif BLAZE_SSE2_MODE
57 inline sse_int16_t operator*( const sse_int16_t& a, const sse_int16_t& b )
58 {
59  return _mm_mullo_epi16( a.value, b.value );
60 }
61 #endif
62 //*************************************************************************************************
63 
64 
65 //*************************************************************************************************
74 #if BLAZE_MIC_MODE
75 inline sse_int32_t operator*( const sse_int32_t& a, const sse_int32_t& b )
76 {
77  return _mm512_mullo_epi32( a.value, b.value );
78 }
79 #elif BLAZE_AVX2_MODE
80 inline sse_int32_t operator*( const sse_int32_t& a, const sse_int32_t& b )
81 {
82  return _mm256_mullo_epi32( a.value, b.value );
83 }
84 #elif BLAZE_SSE4_MODE
85 inline sse_int32_t operator*( const sse_int32_t& a, const sse_int32_t& b )
86 {
87  return _mm_mullo_epi32( a.value, b.value );
88 }
89 #endif
90 //*************************************************************************************************
91 
92 
93 //*************************************************************************************************
102 #if BLAZE_MIC_MODE
103 inline sse_float_t operator*( const sse_float_t& a, const sse_float_t& b )
104 {
105  return _mm512_mul_ps( a.value, b.value );
106 }
107 #elif BLAZE_AVX_MODE
108 inline sse_float_t operator*( const sse_float_t& a, const sse_float_t& b )
109 {
110  return _mm256_mul_ps( a.value, b.value );
111 }
112 #elif BLAZE_SSE_MODE
113 inline sse_float_t operator*( const sse_float_t& a, const sse_float_t& b )
114 {
115  return _mm_mul_ps( a.value, b.value );
116 }
117 #endif
118 //*************************************************************************************************
119 
120 
121 //*************************************************************************************************
130 #if BLAZE_MIC_MODE
131 inline sse_double_t operator*( const sse_double_t& a, const sse_double_t& b )
132 {
133  return _mm512_mul_pd( a.value, b.value );
134 }
135 #elif BLAZE_AVX_MODE
136 inline sse_double_t operator*( const sse_double_t& a, const sse_double_t& b )
137 {
138  return _mm256_mul_pd( a.value, b.value );
139 }
140 #elif BLAZE_SSE2_MODE
141 inline sse_double_t operator*( const sse_double_t& a, const sse_double_t& b )
142 {
143  return _mm_mul_pd( a.value, b.value );
144 }
145 #endif
146 //*************************************************************************************************
147 
148 
149 //*************************************************************************************************
158 #if BLAZE_AVX_MODE
159 inline sse_cfloat_t operator*( const sse_cfloat_t& a, const sse_cfloat_t& b )
160 {
161  __m256 x, y, z;
162 
163  x = _mm256_shuffle_ps( a.value, a.value, 0xA0A0 );
164  z = _mm256_mul_ps( x, b.value );
165  x = _mm256_shuffle_ps( a.value, a.value, 0xF5F5 );
166  y = _mm256_shuffle_ps( b.value, b.value, 0xB1B1 );
167  y = _mm256_mul_ps( x, y );
168  return _mm256_addsub_ps( z, y );
169 }
170 #elif BLAZE_SSE3_MODE
171 inline sse_cfloat_t operator*( const sse_cfloat_t& a, const sse_cfloat_t& b )
172 {
173  __m128 x, y, z;
174 
175  x = _mm_shuffle_ps( a.value, a.value, 0xA0 );
176  z = _mm_mul_ps( x, b.value );
177  x = _mm_shuffle_ps( a.value, a.value, 0xF5 );
178  y = _mm_shuffle_ps( b.value, b.value, 0xB1 );
179  y = _mm_mul_ps( x, y );
180  return _mm_addsub_ps( z, y );
181 }
182 #endif
183 //*************************************************************************************************
184 
185 
186 //*************************************************************************************************
195 #if BLAZE_AVX_MODE
196 inline sse_cdouble_t operator*( const sse_cdouble_t& a, const sse_cdouble_t& b )
197 {
198  __m256d x, y, z;
199 
200  x = _mm256_shuffle_pd( a.value, a.value, 0 );
201  z = _mm256_mul_pd( x, b.value );
202  x = _mm256_shuffle_pd( a.value, a.value, 15 );
203  y = _mm256_shuffle_pd( b.value, b.value, 5 );
204  y = _mm256_mul_pd( x, y );
205  return _mm256_addsub_pd( z, y );
206 }
207 #elif BLAZE_SSE3_MODE
208 inline sse_cdouble_t operator*( const sse_cdouble_t& a, const sse_cdouble_t& b )
209 {
210  __m128d x, y, z;
211 
212  x = _mm_shuffle_pd( a.value, a.value, 0 );
213  z = _mm_mul_pd( x, b.value );
214  x = _mm_shuffle_pd( a.value, a.value, 3 );
215  y = _mm_shuffle_pd( b.value, b.value, 1 );
216  y = _mm_mul_pd( x, y );
217  return _mm_addsub_pd( z, y );
218 }
219 #endif
220 //*************************************************************************************************
221 
222 } // namespace blaze
223 
224 #endif