All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
52 #include <blaze/util/Types.h>
53 
54 
55 namespace blaze {
56 
57 //=================================================================================================
58 //
59 // CLASS DEFINITION
60 //
61 //=================================================================================================
62 
63 //*************************************************************************************************
73 template< typename T // Type of the integral
74  , size_t N > // Size of the integral
75 struct Store;
77 //*************************************************************************************************
78 
79 
80 
81 
82 //=================================================================================================
83 //
84 // SPECIALIZATIONS OF THE STORE CLASS TEMPLATE
85 //
86 //=================================================================================================
87 
88 //*************************************************************************************************
93 template< typename T > // Type of the integral
94 struct Store<T,2UL>
95 {
96  public:
97  //**Type definitions****************************************************************************
98  typedef sse_int16_t Type;
99  //**********************************************************************************************
100 
101  //**Set function********************************************************************************
102  static BLAZE_ALWAYS_INLINE void store( T* address, const Type& value )
103  {
104  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
105 
106 #if BLAZE_AVX2_MODE
107  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), value.value );
108 #elif BLAZE_SSE2_MODE
109  _mm_store_si128( reinterpret_cast<__m128i*>( address ), value.value );
110 #else
111  *address = value.value;
112 #endif
113  }
114  //**********************************************************************************************
115 
116  private:
117  //**Compile time checks*************************************************************************
119  //**********************************************************************************************
120 };
122 //*************************************************************************************************
123 
124 
125 //*************************************************************************************************
130 template< typename T > // Type of the integral
131 struct Store<T,4UL>
132 {
133  public:
134  //**Type definitions****************************************************************************
135  typedef sse_int32_t Type;
136  //**********************************************************************************************
137 
138  //**Set function********************************************************************************
139  static BLAZE_ALWAYS_INLINE void store( T* address, const Type& value )
140  {
141  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
142 
143 #if BLAZE_MIC_MODE
144  _mm512_store_epi32( address, value.value );
145 #elif BLAZE_AVX2_MODE
146  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), value.value );
147 #elif BLAZE_SSE2_MODE
148  _mm_store_si128( reinterpret_cast<__m128i*>( address ), value.value );
149 #else
150  *address = value.value;
151 #endif
152  }
153  //**********************************************************************************************
154 
155  private:
156  //**Compile time checks*************************************************************************
158  //**********************************************************************************************
159 };
161 //*************************************************************************************************
162 
163 
164 //*************************************************************************************************
169 template< typename T > // Type of the integral
170 struct Store<T,8UL>
171 {
172  public:
173  //**Type definitions****************************************************************************
174  typedef sse_int64_t Type;
175  //**********************************************************************************************
176 
177  //**Set function********************************************************************************
178  static BLAZE_ALWAYS_INLINE void store( T* address, const Type& value )
179  {
180  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
181 
182 #if BLAZE_MIC_MODE
183  _mm512_store_epi64( address, value.value );
184 #elif BLAZE_AVX2_MODE
185  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), value.value );
186 #elif BLAZE_SSE2_MODE
187  _mm_store_si128( reinterpret_cast<__m128i*>( address ), value.value );
188 #else
189  *address = value.value;
190 #endif
191  }
192  //**********************************************************************************************
193 
194  private:
195  //**Compile time checks*************************************************************************
197  //**********************************************************************************************
198 };
200 //*************************************************************************************************
201 
202 
203 
204 
205 //=================================================================================================
206 //
207 // INTRINSIC STORE FUNCTIONS
208 //
209 //=================================================================================================
210 
211 //*************************************************************************************************
223 template< typename T > // Type of the integral value
224 BLAZE_ALWAYS_INLINE typename EnableIf< IsIntegral<T> >::Type
225  store( T* address, const typename Store<T,sizeof(T)>::Type& value )
226 {
227  Store<T,sizeof(T)>::store( address, value );
228 }
229 //*************************************************************************************************
230 
231 
232 //*************************************************************************************************
244 BLAZE_ALWAYS_INLINE void store( float* address, const sse_float_t& value )
245 {
246  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
247 
248 #if BLAZE_MIC_MODE
249  _mm512_store_ps( address, value.value );
250 #elif BLAZE_AVX_MODE
251  _mm256_store_ps( address, value.value );
252 #elif BLAZE_SSE_MODE
253  _mm_store_ps( address, value.value );
254 #else
255  *address = value.value;
256 #endif
257 }
258 //*************************************************************************************************
259 
260 
261 //*************************************************************************************************
273 BLAZE_ALWAYS_INLINE void store( double* address, const sse_double_t& value )
274 {
275  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
276 
277 #if BLAZE_MIC_MODE
278  _mm512_store_pd( address, value.value );
279 #elif BLAZE_AVX_MODE
280  _mm256_store_pd( address, value.value );
281 #elif BLAZE_SSE2_MODE
282  _mm_store_pd( address, value.value );
283 #else
284  *address = value.value;
285 #endif
286 }
287 //*************************************************************************************************
288 
289 
290 //*************************************************************************************************
302 BLAZE_ALWAYS_INLINE void store( complex<float>* address, const sse_cfloat_t& value )
303 {
304  BLAZE_STATIC_ASSERT ( sizeof( complex<float> ) == 2UL*sizeof( float ) );
305  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
306 
307 #if BLAZE_MIC_MODE
308  _mm512_store_ps( reinterpret_cast<float*>( address ), value.value );
309 #elif BLAZE_AVX_MODE
310  _mm256_store_ps( reinterpret_cast<float*>( address ), value.value );
311 #elif BLAZE_SSE_MODE
312  _mm_store_ps( reinterpret_cast<float*>( address ), value.value );
313 #else
314  *address = value.value;
315 #endif
316 }
317 //*************************************************************************************************
318 
319 
320 //*************************************************************************************************
332 BLAZE_ALWAYS_INLINE void store( complex<double>* address, const sse_cdouble_t& value )
333 {
334  BLAZE_STATIC_ASSERT ( sizeof( complex<double> ) == 2UL*sizeof( double ) );
335  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
336 
337 #if BLAZE_MIC_MODE
338  _mm512_store_pd( reinterpret_cast<double*>( address ), value.value );
339 #elif BLAZE_AVX_MODE
340  _mm256_store_pd( reinterpret_cast<double*>( address ), value.value );
341 #elif BLAZE_SSE2_MODE
342  _mm_store_pd( reinterpret_cast<double*>( address ), value.value );
343 #else
344  *address = value.value;
345 #endif
346 }
347 //*************************************************************************************************
348 
349 } // namespace blaze
350 
351 #endif
Intrinsic type for 32-bit single precision complex values.
#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.
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.
BLAZE_ALWAYS_INLINE void store(complex< double > *address, const sse_cdouble_t &value)
Aligned store of a vector of 'complex' values.
Definition: Store.h:332
#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
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type store(T *address, const typename Store< T, sizeof(T)>::Type &value)
Aligned store of a vector of integral values.
Definition: Store.h:225
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