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 
46 #include <blaze/util/Assert.h>
47 #include <blaze/util/Complex.h>
49 #include <blaze/util/EnableIf.h>
51 
52 
53 namespace blaze {
54 
55 //=================================================================================================
56 //
57 // CLASS DEFINITION
58 //
59 //=================================================================================================
60 
61 //*************************************************************************************************
70 template< typename T // Type of the integral
71  , size_t N > // Size of the integral
72 struct Stream;
74 //*************************************************************************************************
75 
76 
77 
78 
79 //=================================================================================================
80 //
81 // SPECIALIZATIONS OF THE STREAM CLASS TEMPLATE
82 //
83 //=================================================================================================
84 
85 //*************************************************************************************************
90 template< typename T > // Type of the integral
91 struct Stream<T,2UL>
92 {
93  public:
94  //**Type definitions****************************************************************************
95  typedef sse_int16_t Type;
96  //**********************************************************************************************
97 
98  //**Set function********************************************************************************
99  static inline void stream( T* address, const Type& value )
100  {
101  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
102 
103 #if BLAZE_AVX2_MODE
104  _mm256_stream_si256( reinterpret_cast<__m256i*>( address ), value.value );
105 #elif BLAZE_SSE2_MODE
106  _mm_stream_si128( reinterpret_cast<__m128i*>( address ), value.value );
107 #else
108  *address = value.value;
109 #endif
110  }
111  //**********************************************************************************************
112 
113  private:
114  //**Compile time checks*************************************************************************
116  //**********************************************************************************************
117 };
119 //*************************************************************************************************
120 
121 
122 //*************************************************************************************************
127 template< typename T > // Type of the integral
128 struct Stream<T,4UL>
129 {
130  public:
131  //**Type definitions****************************************************************************
132  typedef sse_int32_t Type;
133  //**********************************************************************************************
134 
135  //**Set function********************************************************************************
136  static inline void stream( T* address, const Type& value )
137  {
138  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
139 
140 #if BLAZE_MIC_MODE
141  _mm512_store_epi32( address, value.value );
142 #elif BLAZE_AVX2_MODE
143  _mm256_stream_si256( reinterpret_cast<__m256i*>( address ), value.value );
144 #elif BLAZE_SSE2_MODE
145  _mm_stream_si128( reinterpret_cast<__m128i*>( address ), value.value );
146 #else
147  *address = value.value;
148 #endif
149  }
150  //**********************************************************************************************
151 
152  private:
153  //**Compile time checks*************************************************************************
155  //**********************************************************************************************
156 };
158 //*************************************************************************************************
159 
160 
161 //*************************************************************************************************
166 template< typename T > // Type of the integral
167 struct Stream<T,8UL>
168 {
169  public:
170  //**Type definitions****************************************************************************
171  typedef sse_int64_t Type;
172  //**********************************************************************************************
173 
174  //**Set function********************************************************************************
175  static inline void stream( T* address, const Type& value )
176  {
177  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
178 
179 #if BLAZE_MIC_MODE
180  _mm512_store_epi64( address, value.value );
181 #elif BLAZE_AVX2_MODE
182  _mm256_stream_si256( reinterpret_cast<__m256i*>( address ), value.value );
183 #elif BLAZE_SSE2_MODE
184  _mm_stream_si128( reinterpret_cast<__m128i*>( address ), value.value );
185 #else
186  *address = value.value;
187 #endif
188  }
189  //**********************************************************************************************
190 
191  private:
192  //**Compile time checks*************************************************************************
194  //**********************************************************************************************
195 };
197 //*************************************************************************************************
198 
199 
200 
201 
202 //=================================================================================================
203 //
204 // INTRINSIC STREAM FUNCTIONS
205 //
206 //=================================================================================================
207 
208 //*************************************************************************************************
216 template< typename T > // Type of the integral value
217 inline typename EnableIf< IsIntegral<T> >::Type
218  stream( T* address, const typename Stream<T,sizeof(T)>::Type& value )
219 {
220  Stream<T,sizeof(T)>::stream( address, value );
221 }
222 //*************************************************************************************************
223 
224 
225 //*************************************************************************************************
233 inline void stream( float* address, const sse_float_t& value )
234 {
235  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
236 
237 #if BLAZE_MIC_MODE
238  _mm512_storenr_ps( address, value.value );
239 #elif BLAZE_AVX_MODE
240  _mm256_stream_ps( address, value.value );
241 #elif BLAZE_SSE_MODE
242  _mm_stream_ps( address, value.value );
243 #else
244  *address = value.value;
245 #endif
246 }
247 //*************************************************************************************************
248 
249 
250 //*************************************************************************************************
258 inline void stream( double* address, const sse_double_t& value )
259 {
260  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
261 
262 #if BLAZE_MIC_MODE
263  _mm512_storenr_pd( address, value.value );
264 #elif BLAZE_AVX_MODE
265  _mm256_stream_pd( address, value.value );
266 #elif BLAZE_SSE2_MODE
267  _mm_stream_pd( address, value.value );
268 #else
269  *address = value.value;
270 #endif
271 }
272 //*************************************************************************************************
273 
274 
275 //*************************************************************************************************
283 inline void stream( complex<float>* address, const sse_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 inline void stream( complex<double>* address, const sse_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 32-bit single precision complex values.
void stream(float *address, const sse_float_t &value)
Aligned, non-temporal store of a vector of &#39;float&#39; values.
Definition: Stream.h:233
#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
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.
bool checkAlignment(const T *address)
Checks the alignment of the given.
Definition: AlignmentCheck.h:68
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
#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