Store.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_INTRINSICS_STORE_H_
36 #define _BLAZE_MATH_INTRINSICS_STORE_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 STORE FUNCTIONS
63 //
64 //=================================================================================================
65 
66 //*************************************************************************************************
78 template< typename T > // Type of the integral value
79 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,2UL> > >::Type
80  store( T* address, const sse_int16_t& value )
81 {
82  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
83 
84 #if BLAZE_AVX2_MODE
85  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), value.value );
86 #elif BLAZE_SSE2_MODE
87  _mm_store_si128( reinterpret_cast<__m128i*>( address ), value.value );
88 #else
89  *address = value.value;
90 #endif
91 }
92 //*************************************************************************************************
93 
94 
95 //*************************************************************************************************
107 template< typename T > // Type of the integral value
108 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,4UL> > >::Type
109  store( T* address, const sse_int32_t& value )
110 {
111  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
112 
113 #if BLAZE_MIC_MODE
114  _mm512_store_epi32( address, value.value );
115 #elif BLAZE_AVX2_MODE
116  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), value.value );
117 #elif BLAZE_SSE2_MODE
118  _mm_store_si128( reinterpret_cast<__m128i*>( address ), value.value );
119 #else
120  *address = value.value;
121 #endif
122 }
123 //*************************************************************************************************
124 
125 
126 //*************************************************************************************************
138 template< typename T > // Type of the integral value
139 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,8UL> > >::Type
140  store( T* address, const sse_int64_t& value )
141 {
142  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
143 
144 #if BLAZE_MIC_MODE
145  _mm512_store_epi64( address, value.value );
146 #elif BLAZE_AVX2_MODE
147  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), value.value );
148 #elif BLAZE_SSE2_MODE
149  _mm_store_si128( reinterpret_cast<__m128i*>( address ), value.value );
150 #else
151  *address = value.value;
152 #endif
153 }
154 //*************************************************************************************************
155 
156 
157 //*************************************************************************************************
169 BLAZE_ALWAYS_INLINE void store( float* address, const sse_float_t& value )
170 {
171  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
172 
173 #if BLAZE_MIC_MODE
174  _mm512_store_ps( address, value.value );
175 #elif BLAZE_AVX_MODE
176  _mm256_store_ps( address, value.value );
177 #elif BLAZE_SSE_MODE
178  _mm_store_ps( address, value.value );
179 #else
180  *address = value.value;
181 #endif
182 }
183 //*************************************************************************************************
184 
185 
186 //*************************************************************************************************
198 BLAZE_ALWAYS_INLINE void store( double* address, const sse_double_t& value )
199 {
200  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
201 
202 #if BLAZE_MIC_MODE
203  _mm512_store_pd( address, value.value );
204 #elif BLAZE_AVX_MODE
205  _mm256_store_pd( address, value.value );
206 #elif BLAZE_SSE2_MODE
207  _mm_store_pd( address, value.value );
208 #else
209  *address = value.value;
210 #endif
211 }
212 //*************************************************************************************************
213 
214 
215 //*************************************************************************************************
227 BLAZE_ALWAYS_INLINE void store( complex<float>* address, const sse_cfloat_t& value )
228 {
229  BLAZE_STATIC_ASSERT ( sizeof( complex<float> ) == 2UL*sizeof( float ) );
230  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
231 
232 #if BLAZE_MIC_MODE
233  _mm512_store_ps( reinterpret_cast<float*>( address ), value.value );
234 #elif BLAZE_AVX_MODE
235  _mm256_store_ps( reinterpret_cast<float*>( address ), value.value );
236 #elif BLAZE_SSE_MODE
237  _mm_store_ps( reinterpret_cast<float*>( address ), value.value );
238 #else
239  *address = value.value;
240 #endif
241 }
242 //*************************************************************************************************
243 
244 
245 //*************************************************************************************************
257 BLAZE_ALWAYS_INLINE void store( complex<double>* address, const sse_cdouble_t& value )
258 {
259  BLAZE_STATIC_ASSERT ( sizeof( complex<double> ) == 2UL*sizeof( double ) );
260  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
261 
262 #if BLAZE_MIC_MODE
263  _mm512_store_pd( reinterpret_cast<double*>( address ), value.value );
264 #elif BLAZE_AVX_MODE
265  _mm256_store_pd( reinterpret_cast<double*>( address ), value.value );
266 #elif BLAZE_SSE2_MODE
267  _mm_store_pd( reinterpret_cast<double*>( address ), value.value );
268 #else
269  *address = value.value;
270 #endif
271 }
272 //*************************************************************************************************
273 
274 } // namespace blaze
275 
276 #endif
Intrinsic type for 32-bit single precision complex values.
Header file for basic type definitions.
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.
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type store(T *address, const sse_int16_t &value)
Aligned store of a vector of 2-byte integral values.
Definition: Store.h:80
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