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>
51 #include <blaze/util/mpl/And.h>
53 #include <blaze/util/Types.h>
56 
57 
58 namespace blaze {
59 
60 //=================================================================================================
61 //
62 // INTRINSIC STREAM FUNCTIONS
63 //
64 //=================================================================================================
65 
66 //*************************************************************************************************
74 template< typename T > // Type of the integral value
75 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,2UL> > >::Type
76  stream( T* address, const sse_int16_t& value )
77 {
78  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
79 
80 #if BLAZE_AVX2_MODE
81  _mm256_stream_si256( reinterpret_cast<__m256i*>( address ), value.value );
82 #elif BLAZE_SSE2_MODE
83  _mm_stream_si128( reinterpret_cast<__m128i*>( address ), value.value );
84 #else
85  *address = value.value;
86 #endif
87 }
88 //*************************************************************************************************
89 
90 
91 //*************************************************************************************************
99 template< typename T > // Type of the integral value
100 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,4UL> > >::Type
101  stream( T* address, const sse_int32_t& value )
102 {
103  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
104 
105 #if BLAZE_MIC_MODE
106  _mm512_store_epi32( address, value.value );
107 #elif BLAZE_AVX2_MODE
108  _mm256_stream_si256( reinterpret_cast<__m256i*>( address ), value.value );
109 #elif BLAZE_SSE2_MODE
110  _mm_stream_si128( reinterpret_cast<__m128i*>( address ), value.value );
111 #else
112  *address = value.value;
113 #endif
114 }
115 //*************************************************************************************************
116 
117 
118 //*************************************************************************************************
126 template< typename T > // Type of the integral value
127 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,8UL> > >::Type
128  stream( T* address, const sse_int64_t& value )
129 {
130  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
131 
132 #if BLAZE_MIC_MODE
133  _mm512_store_epi64( address, value.value );
134 #elif BLAZE_AVX2_MODE
135  _mm256_stream_si256( reinterpret_cast<__m256i*>( address ), value.value );
136 #elif BLAZE_SSE2_MODE
137  _mm_stream_si128( reinterpret_cast<__m128i*>( address ), value.value );
138 #else
139  *address = value.value;
140 #endif
141 }
142 //*************************************************************************************************
143 
144 
145 //*************************************************************************************************
153 BLAZE_ALWAYS_INLINE void stream( float* address, const sse_float_t& value )
154 {
155  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
156 
157 #if BLAZE_MIC_MODE
158  _mm512_storenr_ps( address, value.value );
159 #elif BLAZE_AVX_MODE
160  _mm256_stream_ps( address, value.value );
161 #elif BLAZE_SSE_MODE
162  _mm_stream_ps( address, value.value );
163 #else
164  *address = value.value;
165 #endif
166 }
167 //*************************************************************************************************
168 
169 
170 //*************************************************************************************************
178 BLAZE_ALWAYS_INLINE void stream( double* address, const sse_double_t& value )
179 {
180  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
181 
182 #if BLAZE_MIC_MODE
183  _mm512_storenr_pd( address, value.value );
184 #elif BLAZE_AVX_MODE
185  _mm256_stream_pd( address, value.value );
186 #elif BLAZE_SSE2_MODE
187  _mm_stream_pd( address, value.value );
188 #else
189  *address = value.value;
190 #endif
191 }
192 //*************************************************************************************************
193 
194 
195 //*************************************************************************************************
203 BLAZE_ALWAYS_INLINE void stream( complex<float>* address, const sse_cfloat_t& value )
204 {
205  BLAZE_STATIC_ASSERT ( sizeof( complex<float> ) == 2UL*sizeof( float ) );
206  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
207 
208 #if BLAZE_MIC_MODE
209  _mm512_storenr_ps( reinterpret_cast<float*>( address ), value.value );
210 #elif BLAZE_AVX_MODE
211  _mm256_stream_ps( reinterpret_cast<float*>( address ), value.value );
212 #elif BLAZE_SSE_MODE
213  _mm_stream_ps( reinterpret_cast<float*>( address ), value.value );
214 #else
215  *address = value.value;
216 #endif
217 }
218 //*************************************************************************************************
219 
220 
221 //*************************************************************************************************
229 BLAZE_ALWAYS_INLINE void stream( complex<double>* address, const sse_cdouble_t& value )
230 {
231  BLAZE_STATIC_ASSERT ( sizeof( complex<double> ) == 2UL*sizeof( double ) );
232  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
233 
234 #if BLAZE_MIC_MODE
235  _mm512_storenr_pd( reinterpret_cast<double*>( address ), value.value );
236 #elif BLAZE_AVX_MODE
237  _mm256_stream_pd( reinterpret_cast<double*>( address ), value.value );
238 #elif BLAZE_SSE2_MODE
239  _mm_stream_pd( reinterpret_cast<double*>( address ), value.value );
240 #else
241  *address = value.value;
242 #endif
243 }
244 //*************************************************************************************************
245 
246 } // namespace blaze
247 
248 #endif
Intrinsic type for 32-bit single precision complex values.
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type stream(T *address, const sse_int16_t &value)
Aligned, non-temporal store of a vector of 2-byte integral values.
Definition: Stream.h:76
Header file for the IsIntegral type trait.
Header file for the And class template.
Intrinsic type for 64-bit integral 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.
Intrinsic type for 16-bit integral data values.
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.
Header file for the HasSize type trait.
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.
Intrinsic type for 32-bit integral data values.
#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