Stream.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_INTRINSICS_STREAM_H_
36 #define _BLAZE_MATH_INTRINSICS_STREAM_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 STREAM FUNCTIONS
61 //
62 //=================================================================================================
63 
64 //*************************************************************************************************
72 template< typename T > // Type of the integral value
73 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,2UL> > >::Type
74  stream( T* address, const simd_int16_t& value )
75 {
76  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
77 
78 #if BLAZE_AVX2_MODE
79  _mm256_stream_si256( reinterpret_cast<__m256i*>( address ), value.value );
80 #elif BLAZE_SSE2_MODE
81  _mm_stream_si128( reinterpret_cast<__m128i*>( address ), value.value );
82 #else
83  *address = value.value;
84 #endif
85 }
86 //*************************************************************************************************
87 
88 
89 //*************************************************************************************************
97 template< typename T > // Type of the integral value
98 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,4UL> > >::Type
99  stream( T* address, const simd_int32_t& value )
100 {
101  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
102 
103 #if BLAZE_MIC_MODE
104  _mm512_store_epi32( address, value.value );
105 #elif BLAZE_AVX2_MODE
106  _mm256_stream_si256( reinterpret_cast<__m256i*>( address ), value.value );
107 #elif BLAZE_SSE2_MODE
108  _mm_stream_si128( reinterpret_cast<__m128i*>( address ), value.value );
109 #else
110  *address = value.value;
111 #endif
112 }
113 //*************************************************************************************************
114 
115 
116 //*************************************************************************************************
124 template< typename T > // Type of the integral value
125 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,8UL> > >::Type
126  stream( T* address, const simd_int64_t& value )
127 {
128  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
129 
130 #if BLAZE_MIC_MODE
131  _mm512_store_epi64( address, value.value );
132 #elif BLAZE_AVX2_MODE
133  _mm256_stream_si256( reinterpret_cast<__m256i*>( address ), value.value );
134 #elif BLAZE_SSE2_MODE
135  _mm_stream_si128( reinterpret_cast<__m128i*>( address ), value.value );
136 #else
137  *address = value.value;
138 #endif
139 }
140 //*************************************************************************************************
141 
142 
143 //*************************************************************************************************
151 BLAZE_ALWAYS_INLINE void stream( float* address, const simd_float_t& value )
152 {
153  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
154 
155 #if BLAZE_MIC_MODE
156  _mm512_storenr_ps( address, value.value );
157 #elif BLAZE_AVX_MODE
158  _mm256_stream_ps( address, value.value );
159 #elif BLAZE_SSE_MODE
160  _mm_stream_ps( address, value.value );
161 #else
162  *address = value.value;
163 #endif
164 }
165 //*************************************************************************************************
166 
167 
168 //*************************************************************************************************
176 BLAZE_ALWAYS_INLINE void stream( double* address, const simd_double_t& value )
177 {
178  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
179 
180 #if BLAZE_MIC_MODE
181  _mm512_storenr_pd( address, value.value );
182 #elif BLAZE_AVX_MODE
183  _mm256_stream_pd( address, value.value );
184 #elif BLAZE_SSE2_MODE
185  _mm_stream_pd( address, value.value );
186 #else
187  *address = value.value;
188 #endif
189 }
190 //*************************************************************************************************
191 
192 
193 //*************************************************************************************************
201 template< typename T > // Type of the integral value
202 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,2UL> > >::Type
203  stream( complex<T>* address, const simd_cint16_t& value )
204 {
205  BLAZE_STATIC_ASSERT( sizeof( complex<T> ) == 2UL*sizeof( T ) );
206  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
207 
208 #if BLAZE_AVX2_MODE
209  _mm256_stream_si256( reinterpret_cast<__m256i*>( address ), value.value );
210 #elif BLAZE_SSE2_MODE
211  _mm_stream_si128( reinterpret_cast<__m128i*>( address ), value.value );
212 #else
213  *address = value.value;
214 #endif
215 }
216 //*************************************************************************************************
217 
218 
219 //*************************************************************************************************
227 template< typename T > // Type of the integral value
228 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,4UL> > >::Type
229  stream( complex<T>* address, const simd_cint32_t& value )
230 {
231  BLAZE_STATIC_ASSERT( sizeof( complex<T> ) == 2UL*sizeof( T ) );
232  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
233 
234 #if BLAZE_MIC_MODE
235  _mm512_store_epi32( address, value.value );
236 #elif BLAZE_AVX2_MODE
237  _mm256_stream_si256( reinterpret_cast<__m256i*>( address ), value.value );
238 #elif BLAZE_SSE2_MODE
239  _mm_stream_si128( reinterpret_cast<__m128i*>( address ), value.value );
240 #else
241  *address = value.value;
242 #endif
243 }
244 //*************************************************************************************************
245 
246 
247 //*************************************************************************************************
255 template< typename T > // Type of the integral value
256 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,8UL> > >::Type
257  stream( complex<T>* address, const simd_cint64_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_epi64( address, value.value );
264 #elif BLAZE_AVX2_MODE
265  _mm256_stream_si256( reinterpret_cast<__m256i*>( address ), value.value );
266 #elif BLAZE_SSE2_MODE
267  _mm_stream_si128( reinterpret_cast<__m128i*>( address ), value.value );
268 #else
269  *address = value.value;
270 #endif
271 }
272 //*************************************************************************************************
273 
274 
275 //*************************************************************************************************
283 BLAZE_ALWAYS_INLINE void stream( complex<float>* address, const simd_cfloat_t& value )
284 {
285  BLAZE_STATIC_ASSERT ( sizeof( complex<float> ) == 2UL*sizeof( float ) );
286  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
287 
288 #if BLAZE_MIC_MODE
289  _mm512_storenr_ps( reinterpret_cast<float*>( address ), value.value );
290 #elif BLAZE_AVX_MODE
291  _mm256_stream_ps( reinterpret_cast<float*>( address ), value.value );
292 #elif BLAZE_SSE_MODE
293  _mm_stream_ps( reinterpret_cast<float*>( address ), value.value );
294 #else
295  *address = value.value;
296 #endif
297 }
298 //*************************************************************************************************
299 
300 
301 //*************************************************************************************************
309 BLAZE_ALWAYS_INLINE void stream( complex<double>* address, const simd_cdouble_t& value )
310 {
311  BLAZE_STATIC_ASSERT ( sizeof( complex<double> ) == 2UL*sizeof( double ) );
312  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
313 
314 #if BLAZE_MIC_MODE
315  _mm512_storenr_pd( reinterpret_cast<double*>( address ), value.value );
316 #elif BLAZE_AVX_MODE
317  _mm256_stream_pd( reinterpret_cast<double*>( address ), value.value );
318 #elif BLAZE_SSE2_MODE
319  _mm_stream_pd( reinterpret_cast<double*>( address ), value.value );
320 #else
321  *address = value.value;
322 #endif
323 }
324 //*************************************************************************************************
325 
326 } // namespace blaze
327 
328 #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.
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type stream(T *address, const simd_int16_t &value)
Aligned, non-temporal store of a vector of 2-byte integral values.
Definition: Stream.h:74
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
Intrinsic type for 32-bit integral data values.