Storea.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_INTRINSICS_STOREA_H_
36 #define _BLAZE_MATH_INTRINSICS_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>
50 #include <blaze/util/mpl/And.h>
54 
55 
56 namespace blaze {
57 
58 //=================================================================================================
59 //
60 // INTRINSIC STORE FUNCTIONS
61 //
62 //=================================================================================================
63 
64 //*************************************************************************************************
76 template< typename T > // Type of the integral value
77 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,2UL> > >::Type
78  storea( T* address, const simd_int16_t& value )
79 {
80  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
81 
82 #if BLAZE_AVX2_MODE
83  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), value.value );
84 #elif BLAZE_SSE2_MODE
85  _mm_store_si128( reinterpret_cast<__m128i*>( address ), value.value );
86 #else
87  *address = value.value;
88 #endif
89 }
90 //*************************************************************************************************
91 
92 
93 //*************************************************************************************************
105 template< typename T > // Type of the integral value
106 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,4UL> > >::Type
107  storea( T* address, const simd_int32_t& value )
108 {
109  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
110 
111 #if BLAZE_MIC_MODE
112  _mm512_store_epi32( address, value.value );
113 #elif BLAZE_AVX2_MODE
114  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), value.value );
115 #elif BLAZE_SSE2_MODE
116  _mm_store_si128( reinterpret_cast<__m128i*>( address ), value.value );
117 #else
118  *address = value.value;
119 #endif
120 }
121 //*************************************************************************************************
122 
123 
124 //*************************************************************************************************
136 template< typename T > // Type of the integral value
137 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,8UL> > >::Type
138  storea( T* address, const simd_int64_t& value )
139 {
140  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
141 
142 #if BLAZE_MIC_MODE
143  _mm512_store_epi64( address, value.value );
144 #elif BLAZE_AVX2_MODE
145  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), value.value );
146 #elif BLAZE_SSE2_MODE
147  _mm_store_si128( reinterpret_cast<__m128i*>( address ), value.value );
148 #else
149  *address = value.value;
150 #endif
151 }
152 //*************************************************************************************************
153 
154 
155 //*************************************************************************************************
167 BLAZE_ALWAYS_INLINE void storea( float* address, const simd_float_t& value )
168 {
169  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
170 
171 #if BLAZE_MIC_MODE
172  _mm512_store_ps( address, value.value );
173 #elif BLAZE_AVX_MODE
174  _mm256_store_ps( address, value.value );
175 #elif BLAZE_SSE_MODE
176  _mm_store_ps( address, value.value );
177 #else
178  *address = value.value;
179 #endif
180 }
181 //*************************************************************************************************
182 
183 
184 //*************************************************************************************************
196 BLAZE_ALWAYS_INLINE void storea( double* address, const simd_double_t& value )
197 {
198  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
199 
200 #if BLAZE_MIC_MODE
201  _mm512_store_pd( address, value.value );
202 #elif BLAZE_AVX_MODE
203  _mm256_store_pd( address, value.value );
204 #elif BLAZE_SSE2_MODE
205  _mm_store_pd( address, value.value );
206 #else
207  *address = value.value;
208 #endif
209 }
210 //*************************************************************************************************
211 
212 
213 //*************************************************************************************************
225 template< typename T > // Type of the integral value
226 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,2UL> > >::Type
227  storea( complex<T>* address, const simd_cint16_t& value )
228 {
229  BLAZE_STATIC_ASSERT( sizeof( complex<T> ) == 2UL*sizeof( T ) );
230  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
231 
232 #if BLAZE_AVX2_MODE
233  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), value.value );
234 #elif BLAZE_SSE2_MODE
235  _mm_store_si128( reinterpret_cast<__m128i*>( address ), value.value );
236 #else
237  *address = value.value;
238 #endif
239 }
240 //*************************************************************************************************
241 
242 
243 //*************************************************************************************************
255 template< typename T > // Type of the integral value
256 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,4UL> > >::Type
257  storea( complex<T>* address, const simd_cint32_t& value )
258 {
259  BLAZE_STATIC_ASSERT( sizeof( complex<T> ) == 2UL*sizeof( T ) );
260  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
261 
262 #if BLAZE_MIC_MODE
263  _mm512_store_epi32( address, value.value );
264 #elif BLAZE_AVX2_MODE
265  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), value.value );
266 #elif BLAZE_SSE2_MODE
267  _mm_store_si128( reinterpret_cast<__m128i*>( address ), value.value );
268 #else
269  *address = value.value;
270 #endif
271 }
272 //*************************************************************************************************
273 
274 
275 //*************************************************************************************************
287 template< typename T > // Type of the integral value
288 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,8UL> > >::Type
289  storea( complex<T>* address, const simd_cint64_t& value )
290 {
291  BLAZE_STATIC_ASSERT( sizeof( complex<T> ) == 2UL*sizeof( T ) );
292  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
293 
294 #if BLAZE_MIC_MODE
295  _mm512_store_epi64( address, value.value );
296 #elif BLAZE_AVX2_MODE
297  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), value.value );
298 #elif BLAZE_SSE2_MODE
299  _mm_store_si128( reinterpret_cast<__m128i*>( address ), value.value );
300 #else
301  *address = value.value;
302 #endif
303 }
304 //*************************************************************************************************
305 
306 
307 //*************************************************************************************************
319 BLAZE_ALWAYS_INLINE void storea( complex<float>* address, const simd_cfloat_t& value )
320 {
321  BLAZE_STATIC_ASSERT ( sizeof( complex<float> ) == 2UL*sizeof( float ) );
322  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
323 
324 #if BLAZE_MIC_MODE
325  _mm512_store_ps( reinterpret_cast<float*>( address ), value.value );
326 #elif BLAZE_AVX_MODE
327  _mm256_store_ps( reinterpret_cast<float*>( address ), value.value );
328 #elif BLAZE_SSE_MODE
329  _mm_store_ps( reinterpret_cast<float*>( address ), value.value );
330 #else
331  *address = value.value;
332 #endif
333 }
334 //*************************************************************************************************
335 
336 
337 //*************************************************************************************************
349 BLAZE_ALWAYS_INLINE void storea( complex<double>* address, const simd_cdouble_t& value )
350 {
351  BLAZE_STATIC_ASSERT ( sizeof( complex<double> ) == 2UL*sizeof( double ) );
352  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
353 
354 #if BLAZE_MIC_MODE
355  _mm512_store_pd( reinterpret_cast<double*>( address ), value.value );
356 #elif BLAZE_AVX_MODE
357  _mm256_store_pd( reinterpret_cast<double*>( address ), value.value );
358 #elif BLAZE_SSE2_MODE
359  _mm_store_pd( reinterpret_cast<double*>( address ), value.value );
360 #else
361  *address = value.value;
362 #endif
363 }
364 //*************************************************************************************************
365 
366 } // namespace blaze
367 
368 #endif
Intrinsic type for 16-bit integral data values.
Header file for the IsIntegral type trait.
Header file for the And class template.
Intrinsic 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 intrinsic types.
Intrinsic type for 64-bit integral complex values.
Intrinsic type for 32-bit single precision floating point data values.
Header file for run time assertion macros.
Header file for the HasSize type trait.
Intrinsic type for 64-bit integral data values.
Intrinsic type for 32-bit integral complex values.
Intrinsic type for 64-bit double precision complex values.
BLAZE_ALWAYS_INLINE bool checkAlignment(const T *address)
Checks the alignment of the given address.
Definition: AlignmentCheck.h:68
Intrinsic type for 32-bit single precision complex values.
Intrinsic type for 16-bit integral complex values.
Header file for the alignment check function.
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:143
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, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type storea(T *address, const simd_int16_t &value)
Aligned store of a vector of 2-byte integral values.
Definition: Storea.h:78
Intrinsic type for 32-bit integral data values.