Blaze  3.6
Storea.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_SIMD_STOREA_H_
36 #define _BLAZE_MATH_SIMD_STOREA_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
44 #include <blaze/system/Inline.h>
47 #include <blaze/util/Assert.h>
48 #include <blaze/util/Complex.h>
49 #include <blaze/util/EnableIf.h>
53 
54 
55 namespace blaze {
56 
57 //=================================================================================================
58 //
59 // 8-BIT INTEGRAL SIMD TYPES
60 //
61 //=================================================================================================
62 
63 //*************************************************************************************************
75 template< typename T1 // Type of the integral value
76  , typename T2 > // Type of the SIMD data type
77 BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v<T1> && HasSize_v<T1,1UL> >
78  storea( T1* address, const SIMDi8<T2>& value ) noexcept
79 {
80  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
81 
82 #if BLAZE_AVX512BW_MODE
83  _mm512_store_si512( address, (~value).value );
84 #elif BLAZE_AVX2_MODE
85  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
86 #elif BLAZE_SSE2_MODE
87  _mm_store_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
88 #else
89  *address = (~value).value;
90 #endif
91 }
92 //*************************************************************************************************
93 
94 
95 //*************************************************************************************************
107 template< typename T1 // Type of the integral value
108  , typename T2 > // Type of the SIMD data type
109 BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v<T1> && HasSize_v<T1,1UL> >
110  storea( complex<T1>* address, const SIMDci8<T2>& value ) noexcept
111 {
112  BLAZE_STATIC_ASSERT( sizeof( complex<T1> ) == 2UL*sizeof( T1 ) );
113  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
114 
115 #if BLAZE_AVX512BW_MODE
116  _mm512_store_si512( address, (~value).value );
117 #elif BLAZE_AVX2_MODE
118  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
119 #elif BLAZE_SSE2_MODE
120  _mm_store_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
121 #else
122  *address = (~value).value;
123 #endif
124 }
125 //*************************************************************************************************
126 
127 
128 
129 
130 //=================================================================================================
131 //
132 // 16-BIT INTEGRAL SIMD TYPES
133 //
134 //=================================================================================================
135 
136 //*************************************************************************************************
148 template< typename T1 // Type of the integral value
149  , typename T2 > // Type of the SIMD data type
150 BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v<T1> && HasSize_v<T1,2UL> >
151  storea( T1* address, const SIMDi16<T2>& value ) noexcept
152 {
153  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
154 
155 #if BLAZE_AVX512BW_MODE
156  _mm512_store_si512( address, (~value).value );
157 #elif BLAZE_AVX2_MODE
158  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
159 #elif BLAZE_SSE2_MODE
160  _mm_store_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
161 #else
162  *address = (~value).value;
163 #endif
164 }
165 //*************************************************************************************************
166 
167 
168 //*************************************************************************************************
180 template< typename T1 // Type of the integral value
181  , typename T2 > // Type of the SIMD data type
182 BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v<T1> && HasSize_v<T1,2UL> >
183  storea( complex<T1>* address, const SIMDci16<T2>& value ) noexcept
184 {
185  BLAZE_STATIC_ASSERT( sizeof( complex<T1> ) == 2UL*sizeof( T1 ) );
186  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
187 
188 #if BLAZE_AVX512BW_MODE
189  _mm512_store_si512( address, (~value).value );
190 #elif BLAZE_AVX2_MODE
191  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
192 #elif BLAZE_SSE2_MODE
193  _mm_store_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
194 #else
195  *address = (~value).value;
196 #endif
197 }
198 //*************************************************************************************************
199 
200 
201 
202 
203 //=================================================================================================
204 //
205 // 32-BIT INTEGRAL SIMD TYPES
206 //
207 //=================================================================================================
208 
209 //*************************************************************************************************
221 template< typename T1 // Type of the integral value
222  , typename T2 > // Type of the SIMD data type
223 BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v<T1> && HasSize_v<T1,4UL> >
224  storea( T1* address, const SIMDi32<T2>& value ) noexcept
225 {
226  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
227 
228 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
229  _mm512_store_epi32( address, (~value).value );
230 #elif BLAZE_AVX2_MODE
231  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
232 #elif BLAZE_SSE2_MODE
233  _mm_store_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
234 #else
235  *address = (~value).value;
236 #endif
237 }
238 //*************************************************************************************************
239 
240 
241 //*************************************************************************************************
253 template< typename T1 // Type of the integral value
254  , typename T2 > // Type of the SIMD data type
255 BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v<T1> && HasSize_v<T1,4UL> >
256  storea( complex<T1>* address, const SIMDci32<T2>& value ) noexcept
257 {
258  BLAZE_STATIC_ASSERT( sizeof( complex<T1> ) == 2UL*sizeof( T1 ) );
259  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
260 
261 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
262  _mm512_store_epi32( address, (~value).value );
263 #elif BLAZE_AVX2_MODE
264  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
265 #elif BLAZE_SSE2_MODE
266  _mm_store_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
267 #else
268  *address = (~value).value;
269 #endif
270 }
271 //*************************************************************************************************
272 
273 
274 
275 
276 //=================================================================================================
277 //
278 // 64-BIT INTEGRAL SIMD TYPES
279 //
280 //=================================================================================================
281 
282 //*************************************************************************************************
294 template< typename T1 // Type of the integral value
295  , typename T2 > // Type of the SIMD data type
296 BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v<T1> && HasSize_v<T1,8UL> >
297  storea( T1* address, const SIMDi64<T2>& value ) noexcept
298 {
299  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
300 
301 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
302  _mm512_store_epi64( address, (~value).value );
303 #elif BLAZE_AVX2_MODE
304  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
305 #elif BLAZE_SSE2_MODE
306  _mm_store_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
307 #else
308  *address = (~value).value;
309 #endif
310 }
311 //*************************************************************************************************
312 
313 
314 //*************************************************************************************************
326 template< typename T1 // Type of the integral value
327  , typename T2 > // Type of the SIMD data type
328 BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v<T1> && HasSize_v<T1,8UL> >
329  storea( complex<T1>* address, const SIMDci64<T2>& value ) noexcept
330 {
331  BLAZE_STATIC_ASSERT( sizeof( complex<T1> ) == 2UL*sizeof( T1 ) );
332  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
333 
334 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
335  _mm512_store_epi64( address, (~value).value );
336 #elif BLAZE_AVX2_MODE
337  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), (~value).value );
338 #elif BLAZE_SSE2_MODE
339  _mm_store_si128( reinterpret_cast<__m128i*>( address ), (~value).value );
340 #else
341  *address = (~value).value;
342 #endif
343 }
344 //*************************************************************************************************
345 
346 
347 
348 
349 //=================================================================================================
350 //
351 // 32-BIT FLOATING POINT SIMD TYPES
352 //
353 //=================================================================================================
354 
355 //*************************************************************************************************
367 template< typename T > // Type of the operand
368 BLAZE_ALWAYS_INLINE void storea( float* address, const SIMDf32<T>& value ) noexcept
369 {
370  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
371 
372 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
373  _mm512_store_ps( address, (~value).eval().value );
374 #elif BLAZE_AVX_MODE
375  _mm256_store_ps( address, (~value).eval().value );
376 #elif BLAZE_SSE_MODE
377  _mm_store_ps( address, (~value).eval().value );
378 #else
379  *address = (~value).eval().value;
380 #endif
381 }
382 //*************************************************************************************************
383 
384 
385 //*************************************************************************************************
397 BLAZE_ALWAYS_INLINE void storea( complex<float>* address, const SIMDcfloat& value ) noexcept
398 {
399  BLAZE_STATIC_ASSERT ( sizeof( complex<float> ) == 2UL*sizeof( float ) );
400  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
401 
402 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
403  _mm512_store_ps( reinterpret_cast<float*>( address ), value.value );
404 #elif BLAZE_AVX_MODE
405  _mm256_store_ps( reinterpret_cast<float*>( address ), value.value );
406 #elif BLAZE_SSE_MODE
407  _mm_store_ps( reinterpret_cast<float*>( address ), value.value );
408 #else
409  *address = value.value;
410 #endif
411 }
412 //*************************************************************************************************
413 
414 
415 
416 
417 //=================================================================================================
418 //
419 // 64-BIT FLOATING POINT SIMD TYPES
420 //
421 //=================================================================================================
422 
423 //*************************************************************************************************
435 template< typename T > // Type of the operand
436 BLAZE_ALWAYS_INLINE void storea( double* address, const SIMDf64<T>& value ) noexcept
437 {
438  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
439 
440 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
441  _mm512_store_pd( address, (~value).eval().value );
442 #elif BLAZE_AVX_MODE
443  _mm256_store_pd( address, (~value).eval().value );
444 #elif BLAZE_SSE2_MODE
445  _mm_store_pd( address, (~value).eval().value );
446 #else
447  *address = (~value).eval().value;
448 #endif
449 }
450 //*************************************************************************************************
451 
452 
453 //*************************************************************************************************
465 BLAZE_ALWAYS_INLINE void storea( complex<double>* address, const SIMDcdouble& value ) noexcept
466 {
467  BLAZE_STATIC_ASSERT ( sizeof( complex<double> ) == 2UL*sizeof( double ) );
468  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
469 
470 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
471  _mm512_store_pd( reinterpret_cast<double*>( address ), value.value );
472 #elif BLAZE_AVX_MODE
473  _mm256_store_pd( reinterpret_cast<double*>( address ), value.value );
474 #elif BLAZE_SSE2_MODE
475  _mm_store_pd( reinterpret_cast<double*>( address ), value.value );
476 #else
477  *address = value.value;
478 #endif
479 }
480 //*************************************************************************************************
481 
482 } // namespace blaze
483 
484 #endif
Header file for the IsIntegral type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Compile time assertion.
BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v< T1 > &&HasSize_v< T1, 1UL > > storea(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned store of a vector of 1-byte integral values.
Definition: Storea.h:78
decltype(auto) eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition: DMatEvalExpr.h:786
Header file for the EnableIf class template.
Header file for the basic SIMD types.
Header file for run time assertion macros.
Header file for the HasSize type trait.
SIMD type for 32-bit single precision complex values.
BLAZE_ALWAYS_INLINE bool checkAlignment(const T *address)
Checks the alignment of the given address.
Definition: AlignmentCheck.h:68
Header file for the alignment check function.
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.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression,...
Definition: Assert.h:101