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_AVX2_MODE
79  _mm256_storeu_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
80 #elif BLAZE_SSE2_MODE
81  _mm_storeu_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
82 #else
83  *address = (~value).value;
84 #endif
85 }
86 //*************************************************************************************************
87 
88 
89 //*************************************************************************************************
100 template< typename T1 // Type of the integral value
101  , typename T2 > // Type of the SIMD data type
102 BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral<T1>, HasSize<T1,1UL> > >
103  storeu( complex<T1>* address, const SIMDci8<T2>& value ) noexcept
104 {
105  BLAZE_STATIC_ASSERT( sizeof( complex<T1> ) == 2UL*sizeof( T1 ) );
106 
107 #if BLAZE_AVX2_MODE
108  _mm256_storeu_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
109 #elif BLAZE_SSE2_MODE
110  _mm_storeu_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
111 #else
112  *address = (~value).value;
113 #endif
114 }
115 //*************************************************************************************************
116 
117 
118 
119 
120 //=================================================================================================
121 //
122 // 16-BIT INTEGRAL SIMD TYPES
123 //
124 //=================================================================================================
125 
126 //*************************************************************************************************
137 template< typename T1 // Type of the integral value
138  , typename T2 > // Type of the SIMD data type
139 BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral<T1>, HasSize<T1,2UL> > >
140  storeu( T1* address, const SIMDi16<T2>& value ) noexcept
141 {
142 #if BLAZE_AVX2_MODE
143  _mm256_storeu_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
144 #elif BLAZE_SSE2_MODE
145  _mm_storeu_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
146 #else
147  *address = (~value).value;
148 #endif
149 }
150 //*************************************************************************************************
151 
152 
153 //*************************************************************************************************
164 template< typename T1 // Type of the integral value
165  , typename T2 > // Type of the SIMD data type
166 BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral<T1>, HasSize<T1,2UL> > >
167  storeu( complex<T1>* address, const SIMDci16<T2>& value ) noexcept
168 {
169  BLAZE_STATIC_ASSERT( sizeof( complex<T1> ) == 2UL*sizeof( T1 ) );
170 
171 #if BLAZE_AVX2_MODE
172  _mm256_storeu_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
173 #elif BLAZE_SSE2_MODE
174  _mm_storeu_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
175 #else
176  *address = (~value).value;
177 #endif
178 }
179 //*************************************************************************************************
180 
181 
182 
183 
184 //=================================================================================================
185 //
186 // 32-BIT INTEGRAL SIMD TYPES
187 //
188 //=================================================================================================
189 
190 //*************************************************************************************************
201 template< typename T1 // Type of the integral value
202  , typename T2 > // Type of the SIMD data type
203 BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral<T1>, HasSize<T1,4UL> > >
204  storeu( T1* address, const SIMDi32<T2>& value ) noexcept
205 {
206 #if BLAZE_MIC_MODE
207  _mm512_packstorelo_epi32( address , (~value).value );
208  _mm512_packstorehi_epi32( address+16UL, (~value).value );
209 #elif BLAZE_AVX2_MODE
210  _mm256_storeu_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
211 #elif BLAZE_SSE2_MODE
212  _mm_storeu_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
213 #else
214  *address = (~value).value;
215 #endif
216 }
217 //*************************************************************************************************
218 
219 
220 //*************************************************************************************************
231 template< typename T1 // Type of the integral value
232  , typename T2 > // Type of the SIMD data type
233 BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral<T1>, HasSize<T1,4UL> > >
234  storeu( complex<T1>* address, const SIMDci32<T2>& value ) noexcept
235 {
236  BLAZE_STATIC_ASSERT( sizeof( complex<T1> ) == 2UL*sizeof( T1 ) );
237 
238 #if BLAZE_MIC_MODE
239  _mm512_packstorelo_epi32( address , (~value).value );
240  _mm512_packstorehi_epi32( address+8UL, (~value).value );
241 #elif BLAZE_AVX2_MODE
242  _mm256_storeu_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
243 #elif BLAZE_SSE2_MODE
244  _mm_storeu_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
245 #else
246  *address = (~value).value;
247 #endif
248 }
249 //*************************************************************************************************
250 
251 
252 
253 
254 //=================================================================================================
255 //
256 // 64-BIT INTEGRAL SIMD TYPES
257 //
258 //=================================================================================================
259 
260 //*************************************************************************************************
271 template< typename T1 // Type of the integral value
272  , typename T2 > // Type of the SIMD data type
273 BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral<T1>, HasSize<T1,8UL> > >
274  storeu( T1* address, const SIMDi64<T2>& value ) noexcept
275 {
276 #if BLAZE_MIC_MODE
277  _mm512_packstorelo_epi64( address , (~value).value );
278  _mm512_packstorehi_epi64( address+8UL, (~value).value );
279 #elif BLAZE_AVX2_MODE
280  _mm256_storeu_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
281 #elif BLAZE_SSE2_MODE
282  _mm_storeu_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
283 #else
284  *address = (~value).value;
285 #endif
286 }
287 //*************************************************************************************************
288 
289 
290 //*************************************************************************************************
301 template< typename T1 // Type of the integral value
302  , typename T2 > // Type of the SIMD data type
303 BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral<T1>, HasSize<T1,8UL> > >
304  storeu( complex<T1>* address, const SIMDci64<T2>& value ) noexcept
305 {
306  BLAZE_STATIC_ASSERT( sizeof( complex<T1> ) == 2UL*sizeof( T1 ) );
307 
308 #if BLAZE_MIC_MODE
309  _mm512_packstorelo_epi64( address , (~value).value );
310  _mm512_packstorehi_epi64( address+4UL, (~value).value );
311 #elif BLAZE_AVX2_MODE
312  _mm256_storeu_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
313 #elif BLAZE_SSE2_MODE
314  _mm_storeu_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
315 #else
316  *address = (~value).value;
317 #endif
318 }
319 //*************************************************************************************************
320 
321 
322 
323 
324 //=================================================================================================
325 //
326 // 32-BIT FLOATING POINT SIMD TYPES
327 //
328 //=================================================================================================
329 
330 //*************************************************************************************************
341 template< typename T > // Type of the operand
342 BLAZE_ALWAYS_INLINE void storeu( float* address, const SIMDf32<T>& value ) noexcept
343 {
344 #if BLAZE_MIC_MODE
345  const SIMDfloat( (~value).eval().value );
346  _mm512_packstorelo_ps( address , tmp );
347  _mm512_packstorehi_ps( address+16UL, tmp );
348 #elif BLAZE_AVX_MODE
349  _mm256_storeu_ps( address, (~value).eval().value );
350 #elif BLAZE_SSE_MODE
351  _mm_storeu_ps( address, (~value).eval().value );
352 #else
353  *address = (~value).eval().value;
354 #endif
355 }
356 //*************************************************************************************************
357 
358 
359 //*************************************************************************************************
370 BLAZE_ALWAYS_INLINE void storeu( complex<float>* address, const SIMDcfloat& value ) noexcept
371 {
372  BLAZE_STATIC_ASSERT( sizeof( complex<float> ) == 2UL*sizeof( float ) );
373 
374 #if BLAZE_MIC_MODE
375  _mm512_packstorelo_ps( reinterpret_cast<float*>( address ), value.value );
376  _mm512_packstorehi_ps( reinterpret_cast<float*>( address+8UL ), value.value );
377 #elif BLAZE_AVX_MODE
378  _mm256_storeu_ps( reinterpret_cast<float*>( address ), value.value );
379 #elif BLAZE_SSE_MODE
380  _mm_storeu_ps( reinterpret_cast<float*>( address ), value.value );
381 #else
382  *address = value.value;
383 #endif
384 }
385 //*************************************************************************************************
386 
387 
388 
389 
390 //=================================================================================================
391 //
392 // 64-BIT FLOATING POINT SIMD TYPES
393 //
394 //=================================================================================================
395 
396 //*************************************************************************************************
407 template< typename T > // Type of the operand
408 BLAZE_ALWAYS_INLINE void storeu( double* address, const SIMDf64<T>& value ) noexcept
409 {
410 #if BLAZE_MIC_MODE
411  const SIMDdouble tmp( (~value).eval().value );
412  _mm512_packstorelo_pd( address , tmp );
413  _mm512_packstorehi_pd( address+8UL, tmp );
414 #elif BLAZE_AVX_MODE
415  _mm256_storeu_pd( address, (~value).eval().value );
416 #elif BLAZE_SSE2_MODE
417  _mm_storeu_pd( address, (~value).eval().value );
418 #else
419  *address = (~value).eval().value;
420 #endif
421 }
422 //*************************************************************************************************
423 
424 
425 //*************************************************************************************************
436 BLAZE_ALWAYS_INLINE void storeu( complex<double>* address, const SIMDcdouble& value ) noexcept
437 {
438  BLAZE_STATIC_ASSERT( sizeof( complex<double> ) == 2UL*sizeof( double ) );
439 
440 #if BLAZE_MIC_MODE
441  _mm512_packstorelo_pd( reinterpret_cast<double*>( address ), value.value );
442  _mm512_packstorehi_pd( reinterpret_cast<double*>( address+4UL ), value.value );
443 #elif BLAZE_AVX_MODE
444  _mm256_storeu_pd( reinterpret_cast<double*>( address ), value.value );
445 #elif BLAZE_SSE2_MODE
446  _mm_storeu_pd( reinterpret_cast<double*>( address ), value.value );
447 #else
448  *address = value.value;
449 #endif
450 }
451 //*************************************************************************************************
452 
453 } // namespace blaze
454 
455 #endif
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.
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.
const DMatEvalExpr< MT, SO > eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition: DMatEvalExpr.h:705
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.