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