All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
50 #include <blaze/util/EnableIf.h>
52 #include <blaze/util/Types.h>
53 
54 
55 namespace blaze {
56 
57 //=================================================================================================
58 //
59 // CLASS DEFINITION
60 //
61 //=================================================================================================
62 
63 //*************************************************************************************************
72 template< typename T // Type of the integral
73  , size_t N > // Size of the integral
74 struct Stream;
76 //*************************************************************************************************
77 
78 
79 
80 
81 //=================================================================================================
82 //
83 // SPECIALIZATIONS OF THE STREAM CLASS TEMPLATE
84 //
85 //=================================================================================================
86 
87 //*************************************************************************************************
92 template< typename T > // Type of the integral
93 struct Stream<T,2UL>
94 {
95  public:
96  //**Type definitions****************************************************************************
97  typedef sse_int16_t Type;
98  //**********************************************************************************************
99 
100  //**Set function********************************************************************************
101  static BLAZE_ALWAYS_INLINE void stream( T* address, const Type& value )
102  {
103  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
104 
105 #if 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  private:
116  //**Compile time checks*************************************************************************
118  //**********************************************************************************************
119 };
121 //*************************************************************************************************
122 
123 
124 //*************************************************************************************************
129 template< typename T > // Type of the integral
130 struct Stream<T,4UL>
131 {
132  public:
133  //**Type definitions****************************************************************************
134  typedef sse_int32_t Type;
135  //**********************************************************************************************
136 
137  //**Set function********************************************************************************
138  static BLAZE_ALWAYS_INLINE void stream( T* address, const Type& value )
139  {
140  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
141 
142 #if BLAZE_MIC_MODE
143  _mm512_store_epi32( address, value.value );
144 #elif BLAZE_AVX2_MODE
145  _mm256_stream_si256( reinterpret_cast<__m256i*>( address ), value.value );
146 #elif BLAZE_SSE2_MODE
147  _mm_stream_si128( reinterpret_cast<__m128i*>( address ), value.value );
148 #else
149  *address = value.value;
150 #endif
151  }
152  //**********************************************************************************************
153 
154  private:
155  //**Compile time checks*************************************************************************
157  //**********************************************************************************************
158 };
160 //*************************************************************************************************
161 
162 
163 //*************************************************************************************************
168 template< typename T > // Type of the integral
169 struct Stream<T,8UL>
170 {
171  public:
172  //**Type definitions****************************************************************************
173  typedef sse_int64_t Type;
174  //**********************************************************************************************
175 
176  //**Set function********************************************************************************
177  static BLAZE_ALWAYS_INLINE void stream( T* address, const Type& value )
178  {
179  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
180 
181 #if BLAZE_MIC_MODE
182  _mm512_store_epi64( address, value.value );
183 #elif BLAZE_AVX2_MODE
184  _mm256_stream_si256( reinterpret_cast<__m256i*>( address ), value.value );
185 #elif BLAZE_SSE2_MODE
186  _mm_stream_si128( reinterpret_cast<__m128i*>( address ), value.value );
187 #else
188  *address = value.value;
189 #endif
190  }
191  //**********************************************************************************************
192 
193  private:
194  //**Compile time checks*************************************************************************
196  //**********************************************************************************************
197 };
199 //*************************************************************************************************
200 
201 
202 
203 
204 //=================================================================================================
205 //
206 // INTRINSIC STREAM FUNCTIONS
207 //
208 //=================================================================================================
209 
210 //*************************************************************************************************
218 template< typename T > // Type of the integral value
219 BLAZE_ALWAYS_INLINE typename EnableIf< IsIntegral<T> >::Type
220  stream( T* address, const typename Stream<T,sizeof(T)>::Type& value )
221 {
222  Stream<T,sizeof(T)>::stream( address, value );
223 }
224 //*************************************************************************************************
225 
226 
227 //*************************************************************************************************
235 BLAZE_ALWAYS_INLINE void stream( float* address, const sse_float_t& value )
236 {
237  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
238 
239 #if BLAZE_MIC_MODE
240  _mm512_storenr_ps( address, value.value );
241 #elif BLAZE_AVX_MODE
242  _mm256_stream_ps( address, value.value );
243 #elif BLAZE_SSE_MODE
244  _mm_stream_ps( address, value.value );
245 #else
246  *address = value.value;
247 #endif
248 }
249 //*************************************************************************************************
250 
251 
252 //*************************************************************************************************
260 BLAZE_ALWAYS_INLINE void stream( double* address, const sse_double_t& value )
261 {
262  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
263 
264 #if BLAZE_MIC_MODE
265  _mm512_storenr_pd( address, value.value );
266 #elif BLAZE_AVX_MODE
267  _mm256_stream_pd( address, value.value );
268 #elif BLAZE_SSE2_MODE
269  _mm_stream_pd( address, value.value );
270 #else
271  *address = value.value;
272 #endif
273 }
274 //*************************************************************************************************
275 
276 
277 //*************************************************************************************************
285 BLAZE_ALWAYS_INLINE void stream( complex<float>* address, const sse_cfloat_t& value )
286 {
287  BLAZE_STATIC_ASSERT ( sizeof( complex<float> ) == 2UL*sizeof( float ) );
288  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
289 
290 #if BLAZE_MIC_MODE
291  _mm512_storenr_ps( reinterpret_cast<float*>( address ), value.value );
292 #elif BLAZE_AVX_MODE
293  _mm256_stream_ps( reinterpret_cast<float*>( address ), value.value );
294 #elif BLAZE_SSE_MODE
295  _mm_stream_ps( reinterpret_cast<float*>( address ), value.value );
296 #else
297  *address = value.value;
298 #endif
299 }
300 //*************************************************************************************************
301 
302 
303 //*************************************************************************************************
311 BLAZE_ALWAYS_INLINE void stream( complex<double>* address, const sse_cdouble_t& value )
312 {
313  BLAZE_STATIC_ASSERT ( sizeof( complex<double> ) == 2UL*sizeof( double ) );
314  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
315 
316 #if BLAZE_MIC_MODE
317  _mm512_storenr_pd( reinterpret_cast<double*>( address ), value.value );
318 #elif BLAZE_AVX_MODE
319  _mm256_stream_pd( reinterpret_cast<double*>( address ), value.value );
320 #elif BLAZE_SSE2_MODE
321  _mm_stream_pd( reinterpret_cast<double*>( address ), value.value );
322 #else
323  *address = value.value;
324 #endif
325 }
326 //*************************************************************************************************
327 
328 } // namespace blaze
329 
330 #endif
Intrinsic type for 32-bit single precision complex values.
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type stream(T *address, const typename Stream< T, sizeof(T)>::Type &value)
Aligned, non-temporal store of a vector of integral values.
Definition: Stream.h:220
#define BLAZE_CONSTRAINT_MUST_BE_INTEGRAL_TYPE(T)
Constraint on the data type.In case the given data type T is not an integral data type...
Definition: Integral.h:78
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Compile time assertion.
Intrinsic type for 32-bit single precision floating point data values.
Intrinsic type for 64-bit double precision complex values.
Constraint on the data type.
Header file for the EnableIf class template.
Intrinsic type for 64-bit double precision floating point data values.
Header file for the basic intrinsic types.
Header file for run time assertion macros.
BLAZE_ALWAYS_INLINE void stream(complex< double > *address, const sse_cdouble_t &value)
Aligned, non-temporal store of a vector of 'complex' values.
Definition: Stream.h:311
bool checkAlignment(const T *address)
Checks the alignment of the given.
Definition: AlignmentCheck.h:68
Header file for the alignment check function.
Header file for basic type definitions.
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