All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Storeu.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_INTRINSICS_STOREU_H_
36 #define _BLAZE_MATH_INTRINSICS_STOREU_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
45 #include <blaze/util/Complex.h>
47 #include <blaze/util/EnableIf.h>
49 
50 
51 namespace blaze {
52 
53 //=================================================================================================
54 //
55 // CLASS DEFINITION
56 //
57 //=================================================================================================
58 
59 //*************************************************************************************************
69 template< typename T // Type of the integral
70  , size_t N > // Size of the integral
71 struct Storeu;
73 //*************************************************************************************************
74 
75 
76 
77 
78 //=================================================================================================
79 //
80 // SPECIALIZATIONS OF THE STOREU CLASS TEMPLATE
81 //
82 //=================================================================================================
83 
84 //*************************************************************************************************
89 template< typename T > // Type of the integral
90 struct Storeu<T,2UL>
91 {
92  public:
93  //**Type definitions****************************************************************************
94  typedef sse_int16_t Type;
95  //**********************************************************************************************
96 
97  //**Set function********************************************************************************
98  static inline void storeu( T* address, const Type& value )
99  {
100 #if BLAZE_AVX2_MODE
101  _mm256_storeu_si256( reinterpret_cast<__m256i*>( address ), value.value );
102 #elif BLAZE_SSE2_MODE
103  _mm_storeu_si128( reinterpret_cast<__m128i*>( address ), value.value );
104 #else
105  *address = value.value;
106 #endif
107  }
108  //**********************************************************************************************
109 
110  private:
111  //**Compile time checks*************************************************************************
113  //**********************************************************************************************
114 };
116 //*************************************************************************************************
117 
118 
119 //*************************************************************************************************
124 template< typename T > // Type of the integral
125 struct Storeu<T,4UL>
126 {
127  public:
128  //**Type definitions****************************************************************************
129  typedef sse_int32_t Type;
130  //**********************************************************************************************
131 
132  //**Set function********************************************************************************
133  static inline void storeu( T* address, const Type& value )
134  {
135 #if BLAZE_MIC_MODE
136  _mm512_packstorelo_epi32( address, value.value );
137  _mm512_packstorehi_epi32( address+16UL, value.value );
138 #elif BLAZE_AVX2_MODE
139  _mm256_storeu_si256( reinterpret_cast<__m256i*>( address ), value.value );
140 #elif BLAZE_SSE2_MODE
141  _mm_storeu_si128( reinterpret_cast<__m128i*>( address ), value.value );
142 #else
143  *address = value.value;
144 #endif
145  }
146  //**********************************************************************************************
147 
148  private:
149  //**Compile time checks*************************************************************************
151  //**********************************************************************************************
152 };
154 //*************************************************************************************************
155 
156 
157 //*************************************************************************************************
162 template< typename T > // Type of the integral
163 struct Storeu<T,8UL>
164 {
165  public:
166  //**Type definitions****************************************************************************
167  typedef sse_int64_t Type;
168  //**********************************************************************************************
169 
170  //**Set function********************************************************************************
171  static inline void storeu( T* address, const Type& value )
172  {
173 #if BLAZE_MIC_MODE
174  _mm512_packstorelo_epi64( address, value.value );
175  _mm512_packstorehi_epi64( address+8UL, value.value );
176 #elif BLAZE_AVX2_MODE
177  _mm256_storeu_si256( reinterpret_cast<__m256i*>( address ), value.value );
178 #elif BLAZE_SSE2_MODE
179  _mm_storeu_si128( reinterpret_cast<__m128i*>( address ), value.value );
180 #else
181  *address = value.value;
182 #endif
183  }
184  //**********************************************************************************************
185 
186  private:
187  //**Compile time checks*************************************************************************
189  //**********************************************************************************************
190 };
192 //*************************************************************************************************
193 
194 
195 
196 
197 //=================================================================================================
198 //
199 // INTRINSIC STOREU FUNCTIONS
200 //
201 //=================================================================================================
202 
203 //*************************************************************************************************
214 template< typename T > // Type of the integral value
215 inline typename EnableIf< IsIntegral<T> >::Type
216  storeu( T* address, const typename Storeu<T,sizeof(T)>::Type& value )
217 {
218  Storeu<T,sizeof(T)>::storeu( address, value );
219 }
220 //*************************************************************************************************
221 
222 
223 //*************************************************************************************************
234 inline void storeu( float* address, const sse_float_t& value )
235 {
236 #if BLAZE_MIC_MODE
237  _mm512_packstorelo_ps( address , value.value );
238  _mm512_packstorehi_ps( address+16UL, value.value );
239 #elif BLAZE_AVX_MODE
240  _mm256_storeu_ps( address, value.value );
241 #elif BLAZE_SSE_MODE
242  _mm_storeu_ps( address, value.value );
243 #else
244  *address = value.value;
245 #endif
246 }
247 //*************************************************************************************************
248 
249 
250 //*************************************************************************************************
261 inline void storeu( double* address, const sse_double_t& value )
262 {
263 #if BLAZE_MIC_MODE
264  _mm512_packstorelo_pd( address , value.value );
265  _mm512_packstorehi_pd( address+8UL, value.value );
266 #elif BLAZE_AVX_MODE
267  _mm256_storeu_pd( address, value.value );
268 #elif BLAZE_SSE2_MODE
269  _mm_storeu_pd( address, value.value );
270 #else
271  *address = value.value;
272 #endif
273 }
274 //*************************************************************************************************
275 
276 
277 //*************************************************************************************************
288 inline void storeu( complex<float>* address, const sse_cfloat_t& value )
289 {
290  BLAZE_STATIC_ASSERT( sizeof( complex<float> ) == 2UL*sizeof( float ) );
291 
292 #if BLAZE_MIC_MODE
293  _mm512_packstorelo_ps( reinterpret_cast<float*>( address ), value.value );
294  _mm512_packstorehi_ps( reinterpret_cast<float*>( address+8UL ), value.value );
295 #elif BLAZE_AVX_MODE
296  _mm256_storeu_ps( reinterpret_cast<float*>( address ), value.value );
297 #elif BLAZE_SSE_MODE
298  _mm_storeu_ps( reinterpret_cast<float*>( address ), value.value );
299 #else
300  *address = value.value;
301 #endif
302 }
303 //*************************************************************************************************
304 
305 
306 //*************************************************************************************************
317 inline void storeu( complex<double>* address, const sse_cdouble_t& value )
318 {
319  BLAZE_STATIC_ASSERT( sizeof( complex<double> ) == 2UL*sizeof( double ) );
320 
321 #if BLAZE_MIC_MODE
322  _mm512_packstorelo_pd( reinterpret_cast<double*>( address ), value.value );
323  _mm512_packstorehi_pd( reinterpret_cast<double*>( address+4UL ), value.value );
324 #elif BLAZE_AVX_MODE
325  _mm256_storeu_pd( reinterpret_cast<double*>( address ), value.value );
326 #elif BLAZE_SSE2_MODE
327  _mm_storeu_pd( reinterpret_cast<double*>( address ), value.value );
328 #else
329  *address = value.value;
330 #endif
331 }
332 //*************************************************************************************************
333 
334 } // namespace blaze
335 
336 #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
Compile time assertion.
Intrinsic type for 32-bit single precision floating point data values.
Intrinsic type for 64-bit double precision complex values.
void storeu(complex< double > *address, const sse_cdouble_t &value)
Unaligned store of a vector of 'complex' values.
Definition: Storeu.h:317
Constraint on the data type.
Header file for the EnableIf class template.
EnableIf< IsIntegral< T > >::Type storeu(T *address, const typename Storeu< T, sizeof(T)>::Type &value)
Unaligned store of a vector of integral values.
Definition: Storeu.h:216
Intrinsic type for 64-bit double precision floating point data values.
Header file for the basic intrinsic types.
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