Storeu.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_SIMD_STOREU_H_
36 #define _BLAZE_MATH_SIMD_STOREU_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
44 #include <blaze/system/Inline.h>
46 #include <blaze/util/Complex.h>
47 #include <blaze/util/EnableIf.h>
48 #include <blaze/util/mpl/And.h>
52 
53 
54 namespace blaze {
55 
56 //=================================================================================================
57 //
58 // 8-BIT INTEGRAL SIMD TYPES
59 //
60 //=================================================================================================
61 
62 //*************************************************************************************************
73 template< typename T1 // Type of the integral value
74  , typename T2 > // Type of the SIMD data type
75 BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral<T1>, HasSize<T1,1UL> > >
76  storeu( T1* address, const SIMDi8<T2>& value ) noexcept
77 {
78 #if BLAZE_AVX512BW_MODE
79  _mm512_storeu_si512( address, (~value).value );
80 #elif BLAZE_AVX2_MODE
81  _mm256_storeu_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
82 #elif BLAZE_SSE2_MODE
83  _mm_storeu_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
84 #else
85  *address = (~value).value;
86 #endif
87 }
88 //*************************************************************************************************
89 
90 
91 //*************************************************************************************************
102 template< typename T1 // Type of the integral value
103  , typename T2 > // Type of the SIMD data type
104 BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral<T1>, HasSize<T1,1UL> > >
105  storeu( complex<T1>* address, const SIMDci8<T2>& value ) noexcept
106 {
107  BLAZE_STATIC_ASSERT( sizeof( complex<T1> ) == 2UL*sizeof( T1 ) );
108 
109 #if BLAZE_AVX512BW_MODE
110  _mm512_storeu_si512( address, (~value).value );
111 #elif BLAZE_AVX2_MODE
112  _mm256_storeu_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
113 #elif BLAZE_SSE2_MODE
114  _mm_storeu_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
115 #else
116  *address = (~value).value;
117 #endif
118 }
119 //*************************************************************************************************
120 
121 
122 
123 
124 //=================================================================================================
125 //
126 // 16-BIT INTEGRAL SIMD TYPES
127 //
128 //=================================================================================================
129 
130 //*************************************************************************************************
141 template< typename T1 // Type of the integral value
142  , typename T2 > // Type of the SIMD data type
143 BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral<T1>, HasSize<T1,2UL> > >
144  storeu( T1* address, const SIMDi16<T2>& value ) noexcept
145 {
146 #if BLAZE_AVX512BW_MODE
147  _mm512_storeu_si512( address, (~value).value );
148 #elif BLAZE_AVX2_MODE
149  _mm256_storeu_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
150 #elif BLAZE_SSE2_MODE
151  _mm_storeu_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
152 #else
153  *address = (~value).value;
154 #endif
155 }
156 //*************************************************************************************************
157 
158 
159 //*************************************************************************************************
170 template< typename T1 // Type of the integral value
171  , typename T2 > // Type of the SIMD data type
172 BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral<T1>, HasSize<T1,2UL> > >
173  storeu( complex<T1>* address, const SIMDci16<T2>& value ) noexcept
174 {
175  BLAZE_STATIC_ASSERT( sizeof( complex<T1> ) == 2UL*sizeof( T1 ) );
176 
177 #if BLAZE_AVX512BW_MODE
178  _mm512_storeu_si512( address, (~value).value );
179 #elif BLAZE_AVX2_MODE
180  _mm256_storeu_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
181 #elif BLAZE_SSE2_MODE
182  _mm_storeu_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
183 #else
184  *address = (~value).value;
185 #endif
186 }
187 //*************************************************************************************************
188 
189 
190 
191 
192 //=================================================================================================
193 //
194 // 32-BIT INTEGRAL SIMD TYPES
195 //
196 //=================================================================================================
197 
198 //*************************************************************************************************
209 template< typename T1 // Type of the integral value
210  , typename T2 > // Type of the SIMD data type
211 BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral<T1>, HasSize<T1,4UL> > >
212  storeu( T1* address, const SIMDi32<T2>& value ) noexcept
213 {
214 #if BLAZE_AVX512F_MODE
215  _mm512_mask_storeu_epi32( address, 0xFFFF, (~value).value );
216 #elif BLAZE_MIC_MODE
217  _mm512_packstorelo_epi32( address , (~value).value );
218  _mm512_packstorehi_epi32( address+16UL, (~value).value );
219 #elif BLAZE_AVX2_MODE
220  _mm256_storeu_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
221 #elif BLAZE_SSE2_MODE
222  _mm_storeu_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
223 #else
224  *address = (~value).value;
225 #endif
226 }
227 //*************************************************************************************************
228 
229 
230 //*************************************************************************************************
241 template< typename T1 // Type of the integral value
242  , typename T2 > // Type of the SIMD data type
243 BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral<T1>, HasSize<T1,4UL> > >
244  storeu( complex<T1>* address, const SIMDci32<T2>& value ) noexcept
245 {
246  BLAZE_STATIC_ASSERT( sizeof( complex<T1> ) == 2UL*sizeof( T1 ) );
247 
248 #if BLAZE_AVX512F_MODE
249  _mm512_mask_storeu_epi32( address, 0xFFFF, (~value).value );
250 #elif BLAZE_MIC_MODE
251  _mm512_packstorelo_epi32( address , (~value).value );
252  _mm512_packstorehi_epi32( address+8UL, (~value).value );
253 #elif BLAZE_AVX2_MODE
254  _mm256_storeu_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
255 #elif BLAZE_SSE2_MODE
256  _mm_storeu_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
257 #else
258  *address = (~value).value;
259 #endif
260 }
261 //*************************************************************************************************
262 
263 
264 
265 
266 //=================================================================================================
267 //
268 // 64-BIT INTEGRAL SIMD TYPES
269 //
270 //=================================================================================================
271 
272 //*************************************************************************************************
283 template< typename T1 // Type of the integral value
284  , typename T2 > // Type of the SIMD data type
285 BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral<T1>, HasSize<T1,8UL> > >
286  storeu( T1* address, const SIMDi64<T2>& value ) noexcept
287 {
288 #if BLAZE_AVX512F_MODE
289  _mm512_mask_storeu_epi64( address, 0xFF, (~value).value );
290 #elif BLAZE_MIC_MODE
291  _mm512_packstorelo_epi64( address , (~value).value );
292  _mm512_packstorehi_epi64( address+8UL, (~value).value );
293 #elif BLAZE_AVX2_MODE
294  _mm256_storeu_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
295 #elif BLAZE_SSE2_MODE
296  _mm_storeu_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
297 #else
298  *address = (~value).value;
299 #endif
300 }
301 //*************************************************************************************************
302 
303 
304 //*************************************************************************************************
315 template< typename T1 // Type of the integral value
316  , typename T2 > // Type of the SIMD data type
317 BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral<T1>, HasSize<T1,8UL> > >
318  storeu( complex<T1>* address, const SIMDci64<T2>& value ) noexcept
319 {
320  BLAZE_STATIC_ASSERT( sizeof( complex<T1> ) == 2UL*sizeof( T1 ) );
321 
322 #if BLAZE_AVX512F_MODE
323  _mm512_mask_storeu_epi64( address, 0xFF, (~value).value );
324 #elif BLAZE_MIC_MODE
325  _mm512_packstorelo_epi64( address , (~value).value );
326  _mm512_packstorehi_epi64( address+4UL, (~value).value );
327 #elif BLAZE_AVX2_MODE
328  _mm256_storeu_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
329 #elif BLAZE_SSE2_MODE
330  _mm_storeu_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
331 #else
332  *address = (~value).value;
333 #endif
334 }
335 //*************************************************************************************************
336 
337 
338 
339 
340 //=================================================================================================
341 //
342 // 32-BIT FLOATING POINT SIMD TYPES
343 //
344 //=================================================================================================
345 
346 //*************************************************************************************************
357 template< typename T > // Type of the operand
358 BLAZE_ALWAYS_INLINE void storeu( float* address, const SIMDf32<T>& value ) noexcept
359 {
360 #if BLAZE_AVX512F_MODE
361  _mm512_storeu_ps( address, (~value).value );
362 #elif BLAZE_MIC_MODE
363  const SIMDfloat tmp( (~value).eval().value );
364  _mm512_packstorelo_ps( address , tmp.value );
365  _mm512_packstorehi_ps( address+16UL, tmp.value );
366 #elif BLAZE_AVX_MODE
367  _mm256_storeu_ps( address, (~value).eval().value );
368 #elif BLAZE_SSE_MODE
369  _mm_storeu_ps( address, (~value).eval().value );
370 #else
371  *address = (~value).eval().value;
372 #endif
373 }
374 //*************************************************************************************************
375 
376 
377 //*************************************************************************************************
388 BLAZE_ALWAYS_INLINE void storeu( complex<float>* address, const SIMDcfloat& value ) noexcept
389 {
390  BLAZE_STATIC_ASSERT( sizeof( complex<float> ) == 2UL*sizeof( float ) );
391 
392 #if BLAZE_AVX512F_MODE
393  _mm512_storeu_ps( address, (~value).value );
394 #elif BLAZE_MIC_MODE
395  _mm512_packstorelo_ps( reinterpret_cast<float*>( address ), value.value );
396  _mm512_packstorehi_ps( reinterpret_cast<float*>( address+8UL ), value.value );
397 #elif BLAZE_AVX_MODE
398  _mm256_storeu_ps( reinterpret_cast<float*>( address ), value.value );
399 #elif BLAZE_SSE_MODE
400  _mm_storeu_ps( reinterpret_cast<float*>( address ), value.value );
401 #else
402  *address = value.value;
403 #endif
404 }
405 //*************************************************************************************************
406 
407 
408 
409 
410 //=================================================================================================
411 //
412 // 64-BIT FLOATING POINT SIMD TYPES
413 //
414 //=================================================================================================
415 
416 //*************************************************************************************************
427 template< typename T > // Type of the operand
428 BLAZE_ALWAYS_INLINE void storeu( double* address, const SIMDf64<T>& value ) noexcept
429 {
430 #if BLAZE_AVX512F_MODE
431  _mm512_storeu_pd( address, (~value).value );
432 #elif BLAZE_MIC_MODE
433  const SIMDdouble tmp( (~value).eval().value );
434  _mm512_packstorelo_pd( address , tmp.value );
435  _mm512_packstorehi_pd( address+8UL, tmp.value );
436 #elif BLAZE_AVX_MODE
437  _mm256_storeu_pd( address, (~value).eval().value );
438 #elif BLAZE_SSE2_MODE
439  _mm_storeu_pd( address, (~value).eval().value );
440 #else
441  *address = (~value).eval().value;
442 #endif
443 }
444 //*************************************************************************************************
445 
446 
447 //*************************************************************************************************
458 BLAZE_ALWAYS_INLINE void storeu( complex<double>* address, const SIMDcdouble& value ) noexcept
459 {
460  BLAZE_STATIC_ASSERT( sizeof( complex<double> ) == 2UL*sizeof( double ) );
461 
462 #if BLAZE_AVX512F_MODE
463  _mm512_storeu_pd( address, (~value).value );
464 #elif BLAZE_MIC_MODE
465  _mm512_packstorelo_pd( reinterpret_cast<double*>( address ), value.value );
466  _mm512_packstorehi_pd( reinterpret_cast<double*>( address+4UL ), value.value );
467 #elif BLAZE_AVX_MODE
468  _mm256_storeu_pd( reinterpret_cast<double*>( address ), value.value );
469 #elif BLAZE_SSE2_MODE
470  _mm_storeu_pd( reinterpret_cast<double*>( address ), value.value );
471 #else
472  *address = value.value;
473 #endif
474 }
475 //*************************************************************************************************
476 
477 } // namespace blaze
478 
479 #endif
Compile time size check.This class offers the possibility to test the size of a type at compile time...
Definition: HasSize.h:75
Header file for the IsIntegral type trait.
Header file for the And class template.
SIMD type for 64-bit double precision floating point data values.
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
Compile time assertion.
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 EnableIf class template.
Header file for the basic SIMD types.
Header file for the HasSize type trait.
SIMD type for 32-bit single precision complex values.
SIMD type for 32-bit single precision floating point data values.
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > storeu(T1 *address, const SIMDi8< T2 > &value) noexcept
Unaligned store of a vector of 1-byte integral values.
Definition: Storeu.h:76
SIMD type for 64-bit double precision complex values.
System settings for the SSE mode.
Header file for the complex data type.
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:112
System settings for the inline keywords.