All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Loadu.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_INTRINSICS_LOADU_H_
36 #define _BLAZE_MATH_INTRINSICS_LOADU_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 Loadu;
73 //*************************************************************************************************
74 
75 
76 
77 
78 //=================================================================================================
79 //
80 // SPECIALIZATIONS OF THE LOADU CLASS TEMPLATE
81 //
82 //=================================================================================================
83 
84 //*************************************************************************************************
89 template< typename T > // Type of the integral
90 struct Loadu<T,2UL>
91 {
92  public:
93  //**Type definitions****************************************************************************
94  typedef sse_int16_t Type;
95  //**********************************************************************************************
96 
97  //**Set function********************************************************************************
98  static inline Type loadu( const T* address )
99  {
100 #if BLAZE_AVX2_MODE
101  return _mm256_loadu_si256( reinterpret_cast<const __m256i*>( address ) );
102 #elif BLAZE_SSE2_MODE
103  return _mm_loadu_si128( reinterpret_cast<const __m128i*>( address ) );
104 #else
105  return *address;
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 Loadu<T,4UL>
126 {
127  public:
128  //**Type definitions****************************************************************************
129  typedef sse_int32_t Type;
130  //**********************************************************************************************
131 
132  //**Set function********************************************************************************
133  static inline Type loadu( const T* address )
134  {
135 #if BLAZE_MIC_MODE
136  __m512i v1 = _mm512_setzero_epi32();
137  v1 = _mm512_loadunpacklo_epi32( v1, address );
138  v1 = _mm512_loadunpackhi_epi32( v1, address+16UL );
139  return v1;
140 #elif BLAZE_AVX2_MODE
141  return _mm256_loadu_si256( reinterpret_cast<const __m256i*>( address ) );
142 #elif BLAZE_SSE2_MODE
143  return _mm_loadu_si128( reinterpret_cast<const __m128i*>( address ) );
144 #else
145  return *address;
146 #endif
147  }
148  //**********************************************************************************************
149 
150  private:
151  //**Compile time checks*************************************************************************
153  //**********************************************************************************************
154 };
156 //*************************************************************************************************
157 
158 
159 //*************************************************************************************************
164 template< typename T > // Type of the integral
165 struct Loadu<T,8UL>
166 {
167  public:
168  //**Type definitions****************************************************************************
169  typedef sse_int64_t Type;
170  //**********************************************************************************************
171 
172  //**Set function********************************************************************************
173  static inline Type loadu( const T* address )
174  {
175 #if BLAZE_MIC_MODE
176  __m512i v1 = _mm512_setzero_epi32();
177  v1 = _mm512_loadunpacklo_epi64( v1, address );
178  v1 = _mm512_loadunpackhi_epi64( v1, address+8UL );
179  return v1;
180 #elif BLAZE_AVX2_MODE
181  return _mm256_loadu_si256( reinterpret_cast<const __m256i*>( address ) );
182 #elif BLAZE_SSE2_MODE
183  return _mm_loadu_si128( reinterpret_cast<const __m128i*>( address ) );
184 #else
185  return *address;
186 #endif
187  }
188  //**********************************************************************************************
189 
190  private:
191  //**Compile time checks*************************************************************************
193  //**********************************************************************************************
194 };
196 //*************************************************************************************************
197 
198 
199 
200 
201 //=================================================================================================
202 //
203 // INTRINSIC LOADU FUNCTIONS
204 //
205 //=================================================================================================
206 
207 //*************************************************************************************************
217 template< typename T > // Type of the integral value
218 inline typename EnableIf< IsIntegral<T>, Loadu<T,sizeof(T)> >::Type::Type
219  loadu( const T* address )
220 {
221  return Loadu<T,sizeof(T)>::loadu( address );
222 }
223 //*************************************************************************************************
224 
225 
226 //*************************************************************************************************
236 inline sse_float_t loadu( const float* address )
237 {
238 #if BLAZE_MIC_MODE
239  __m512 v1 = _mm512_setzero_ps();
240  v1 = _mm512_loadunpacklo_ps( v1, address );
241  v1 = _mm512_loadunpackhi_ps( v1, address+16UL );
242  return v1;
243 #elif BLAZE_AVX_MODE
244  return _mm256_loadu_ps( address );
245 #elif BLAZE_SSE_MODE
246  return _mm_loadu_ps( address );
247 #else
248  return *address;
249 #endif
250 }
251 //*************************************************************************************************
252 
253 
254 //*************************************************************************************************
264 inline sse_double_t loadu( const double* address )
265 {
266 #if BLAZE_MIC_MODE
267  __m512d v1 = _mm512_setzero_pd();
268  v1 = _mm512_loadunpacklo_pd( v1, address );
269  v1 = _mm512_loadunpackhi_pd( v1, address+8UL );
270  return v1;
271 #elif BLAZE_AVX_MODE
272  return _mm256_loadu_pd( address );
273 #elif BLAZE_SSE2_MODE
274  return _mm_loadu_pd( address );
275 #else
276  return *address;
277 #endif
278 }
279 //*************************************************************************************************
280 
281 
282 //*************************************************************************************************
292 inline sse_cfloat_t loadu( const complex<float>* address )
293 {
294  BLAZE_STATIC_ASSERT( sizeof( complex<float> ) == 2UL*sizeof( float ) );
295 
296 #if BLAZE_MIC_MODE
297  __m512 v1 = _mm512_setzero_ps();
298  v1 = _mm512_loadunpacklo_ps( v1, reinterpret_cast<const float*>( address ) );
299  v1 = _mm512_loadunpackhi_ps( v1, reinterpret_cast<const float*>( address+8UL ) );
300  return v1;
301 #elif BLAZE_AVX_MODE
302  return _mm256_loadu_ps( reinterpret_cast<const float*>( address ) );
303 #elif BLAZE_SSE_MODE
304  return _mm_loadu_ps( reinterpret_cast<const float*>( address ) );
305 #else
306  return *address;
307 #endif
308 }
309 //*************************************************************************************************
310 
311 
312 //*************************************************************************************************
322 inline sse_cdouble_t loadu( const complex<double>* address )
323 {
324  BLAZE_STATIC_ASSERT( sizeof( complex<double> ) == 2UL*sizeof( double ) );
325 
326 #if BLAZE_MIC_MODE
327  __m512d v1 = _mm512_setzero_pd();
328  v1 = _mm512_loadunpacklo_pd( v1, reinterpret_cast<const double*>( address ) );
329  v1 = _mm512_loadunpackhi_pd( v1, reinterpret_cast<const double*>( address+4UL ) );
330  return v1;
331 #elif BLAZE_AVX_MODE
332  return _mm256_loadu_pd( reinterpret_cast<const double*>( address ) );
333 #elif BLAZE_SSE2_MODE
334  return _mm_loadu_pd( reinterpret_cast<const double*>( address ) );
335 #else
336  return *address;
337 #endif
338 }
339 //*************************************************************************************************
340 
341 } // namespace blaze
342 
343 #endif
Intrinsic type for 32-bit single precision complex values.
EnableIf< IsIntegral< T >, Loadu< T, sizeof(T)> >::Type::Type loadu(const T *address)
Loads a vector of integral values.
Definition: Loadu.h:219
#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.
sse_cdouble_t loadu(const complex< double > *address)
Loads a vector of 'complex' values.
Definition: Loadu.h:322
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