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 
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 //*************************************************************************************************
71 template< typename T // Type of the integral
72  , size_t N > // Size of the integral
73 struct Store;
75 //*************************************************************************************************
76 
77 
78 
79 
80 //=================================================================================================
81 //
82 // SPECIALIZATIONS OF THE STORE CLASS TEMPLATE
83 //
84 //=================================================================================================
85 
86 //*************************************************************************************************
91 template< typename T > // Type of the integral
92 struct Store<T,2UL>
93 {
94  public:
95  //**Type definitions****************************************************************************
96  typedef sse_int16_t Type;
97  //**********************************************************************************************
98 
99  //**Set function********************************************************************************
100  static inline void store( T* address, const Type& value )
101  {
102  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
103 
104 #if BLAZE_AVX2_MODE
105  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), value.value );
106 #elif BLAZE_SSE2_MODE
107  _mm_store_si128( reinterpret_cast<__m128i*>( address ), value.value );
108 #else
109  *address = value.value;
110 #endif
111  }
112  //**********************************************************************************************
113 
114  private:
115  //**Compile time checks*************************************************************************
117  //**********************************************************************************************
118 };
120 //*************************************************************************************************
121 
122 
123 //*************************************************************************************************
128 template< typename T > // Type of the integral
129 struct Store<T,4UL>
130 {
131  public:
132  //**Type definitions****************************************************************************
133  typedef sse_int32_t Type;
134  //**********************************************************************************************
135 
136  //**Set function********************************************************************************
137  static inline void store( T* address, const Type& value )
138  {
139  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
140 
141 #if BLAZE_MIC_MODE
142  _mm512_store_epi32( address, value.value );
143 #elif BLAZE_AVX2_MODE
144  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), value.value );
145 #elif BLAZE_SSE2_MODE
146  _mm_store_si128( reinterpret_cast<__m128i*>( address ), value.value );
147 #else
148  *address = value.value;
149 #endif
150  }
151  //**********************************************************************************************
152 
153  private:
154  //**Compile time checks*************************************************************************
156  //**********************************************************************************************
157 };
159 //*************************************************************************************************
160 
161 
162 //*************************************************************************************************
167 template< typename T > // Type of the integral
168 struct Store<T,8UL>
169 {
170  public:
171  //**Type definitions****************************************************************************
172  typedef sse_int64_t Type;
173  //**********************************************************************************************
174 
175  //**Set function********************************************************************************
176  static inline void store( T* address, const Type& value )
177  {
178  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
179 
180 #if BLAZE_MIC_MODE
181  _mm512_store_epi64( address, value.value );
182 #elif BLAZE_AVX2_MODE
183  _mm256_store_si256( reinterpret_cast<__m256i*>( address ), value.value );
184 #elif BLAZE_SSE2_MODE
185  _mm_store_si128( reinterpret_cast<__m128i*>( address ), value.value );
186 #else
187  *address = value.value;
188 #endif
189  }
190  //**********************************************************************************************
191 
192  private:
193  //**Compile time checks*************************************************************************
195  //**********************************************************************************************
196 };
198 //*************************************************************************************************
199 
200 
201 
202 
203 //=================================================================================================
204 //
205 // INTRINSIC STORE FUNCTIONS
206 //
207 //=================================================================================================
208 
209 //*************************************************************************************************
221 template< typename T > // Type of the integral value
222 inline typename EnableIf< IsIntegral<T> >::Type
223  store( T* address, const typename Store<T,sizeof(T)>::Type& value )
224 {
225  Store<T,sizeof(T)>::store( address, value );
226 }
227 //*************************************************************************************************
228 
229 
230 //*************************************************************************************************
242 inline void store( float* address, const sse_float_t& value )
243 {
244  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
245 
246 #if BLAZE_MIC_MODE
247  _mm512_store_ps( address, value.value );
248 #elif BLAZE_AVX_MODE
249  _mm256_store_ps( address, value.value );
250 #elif BLAZE_SSE_MODE
251  _mm_store_ps( address, value.value );
252 #else
253  *address = value.value;
254 #endif
255 }
256 //*************************************************************************************************
257 
258 
259 //*************************************************************************************************
271 inline void store( double* address, const sse_double_t& value )
272 {
273  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
274 
275 #if BLAZE_MIC_MODE
276  _mm512_store_pd( address, value.value );
277 #elif BLAZE_AVX_MODE
278  _mm256_store_pd( address, value.value );
279 #elif BLAZE_SSE2_MODE
280  _mm_store_pd( address, value.value );
281 #else
282  *address = value.value;
283 #endif
284 }
285 //*************************************************************************************************
286 
287 
288 //*************************************************************************************************
300 inline void store( complex<float>* address, const sse_cfloat_t& value )
301 {
302  BLAZE_STATIC_ASSERT ( sizeof( complex<float> ) == 2UL*sizeof( float ) );
303  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
304 
305 #if BLAZE_MIC_MODE
306  _mm512_store_ps( reinterpret_cast<float*>( address ), value.value );
307 #elif BLAZE_AVX_MODE
308  _mm256_store_ps( reinterpret_cast<float*>( address ), value.value );
309 #elif BLAZE_SSE_MODE
310  _mm_store_ps( reinterpret_cast<float*>( address ), value.value );
311 #else
312  *address = value.value;
313 #endif
314 }
315 //*************************************************************************************************
316 
317 
318 //*************************************************************************************************
330 inline void store( complex<double>* address, const sse_cdouble_t& value )
331 {
332  BLAZE_STATIC_ASSERT ( sizeof( complex<double> ) == 2UL*sizeof( double ) );
333  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
334 
335 #if BLAZE_MIC_MODE
336  _mm512_store_pd( reinterpret_cast<double*>( address ), value.value );
337 #elif BLAZE_AVX_MODE
338  _mm256_store_pd( reinterpret_cast<double*>( address ), value.value );
339 #elif BLAZE_SSE2_MODE
340  _mm_store_pd( reinterpret_cast<double*>( address ), value.value );
341 #else
342  *address = value.value;
343 #endif
344 }
345 //*************************************************************************************************
346 
347 } // namespace blaze
348 
349 #endif
Intrinsic type for 32-bit single precision complex values.
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:223
void store(complex< double > *address, const sse_cdouble_t &value)
Aligned store of a vector of 'complex' values.
Definition: Store.h:330
#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