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 
44 #include <blaze/system/Inline.h>
46 #include <blaze/util/Complex.h>
48 #include <blaze/util/EnableIf.h>
50 #include <blaze/util/Types.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 Loadu;
75 //*************************************************************************************************
76 
77 
78 
79 
80 //=================================================================================================
81 //
82 // SPECIALIZATIONS OF THE LOADU CLASS TEMPLATE
83 //
84 //=================================================================================================
85 
86 //*************************************************************************************************
91 template< typename T > // Type of the integral
92 struct Loadu<T,2UL>
93 {
94  public:
95  //**Type definitions****************************************************************************
96  typedef sse_int16_t Type;
97  //**********************************************************************************************
98 
99  //**Set function********************************************************************************
100  static BLAZE_ALWAYS_INLINE Type loadu( const T* address )
101  {
102 #if BLAZE_AVX2_MODE
103  return _mm256_loadu_si256( reinterpret_cast<const __m256i*>( address ) );
104 #elif BLAZE_SSE2_MODE
105  return _mm_loadu_si128( reinterpret_cast<const __m128i*>( address ) );
106 #else
107  return *address;
108 #endif
109  }
110  //**********************************************************************************************
111 
112  private:
113  //**Compile time checks*************************************************************************
115  //**********************************************************************************************
116 };
118 //*************************************************************************************************
119 
120 
121 //*************************************************************************************************
126 template< typename T > // Type of the integral
127 struct Loadu<T,4UL>
128 {
129  public:
130  //**Type definitions****************************************************************************
131  typedef sse_int32_t Type;
132  //**********************************************************************************************
133 
134  //**Set function********************************************************************************
135  static BLAZE_ALWAYS_INLINE Type loadu( const T* address )
136  {
137 #if BLAZE_MIC_MODE
138  __m512i v1 = _mm512_setzero_epi32();
139  v1 = _mm512_loadunpacklo_epi32( v1, address );
140  v1 = _mm512_loadunpackhi_epi32( v1, address+16UL );
141  return v1;
142 #elif BLAZE_AVX2_MODE
143  return _mm256_loadu_si256( reinterpret_cast<const __m256i*>( address ) );
144 #elif BLAZE_SSE2_MODE
145  return _mm_loadu_si128( reinterpret_cast<const __m128i*>( address ) );
146 #else
147  return *address;
148 #endif
149  }
150  //**********************************************************************************************
151 
152  private:
153  //**Compile time checks*************************************************************************
155  //**********************************************************************************************
156 };
158 //*************************************************************************************************
159 
160 
161 //*************************************************************************************************
166 template< typename T > // Type of the integral
167 struct Loadu<T,8UL>
168 {
169  public:
170  //**Type definitions****************************************************************************
171  typedef sse_int64_t Type;
172  //**********************************************************************************************
173 
174  //**Set function********************************************************************************
175  static BLAZE_ALWAYS_INLINE Type loadu( const T* address )
176  {
177 #if BLAZE_MIC_MODE
178  __m512i v1 = _mm512_setzero_epi32();
179  v1 = _mm512_loadunpacklo_epi64( v1, address );
180  v1 = _mm512_loadunpackhi_epi64( v1, address+8UL );
181  return v1;
182 #elif BLAZE_AVX2_MODE
183  return _mm256_loadu_si256( reinterpret_cast<const __m256i*>( address ) );
184 #elif BLAZE_SSE2_MODE
185  return _mm_loadu_si128( reinterpret_cast<const __m128i*>( address ) );
186 #else
187  return *address;
188 #endif
189  }
190  //**********************************************************************************************
191 
192  private:
193  //**Compile time checks*************************************************************************
195  //**********************************************************************************************
196 };
198 //*************************************************************************************************
199 
200 
201 
202 
203 //=================================================================================================
204 //
205 // INTRINSIC LOADU FUNCTIONS
206 //
207 //=================================================================================================
208 
209 //*************************************************************************************************
219 template< typename T > // Type of the integral value
220 BLAZE_ALWAYS_INLINE typename EnableIf< IsIntegral<T>, Loadu<T,sizeof(T)> >::Type::Type
221  loadu( const T* address )
222 {
223  return Loadu<T,sizeof(T)>::loadu( address );
224 }
225 //*************************************************************************************************
226 
227 
228 //*************************************************************************************************
238 BLAZE_ALWAYS_INLINE sse_float_t loadu( const float* address )
239 {
240 #if BLAZE_MIC_MODE
241  __m512 v1 = _mm512_setzero_ps();
242  v1 = _mm512_loadunpacklo_ps( v1, address );
243  v1 = _mm512_loadunpackhi_ps( v1, address+16UL );
244  return v1;
245 #elif BLAZE_AVX_MODE
246  return _mm256_loadu_ps( address );
247 #elif BLAZE_SSE_MODE
248  return _mm_loadu_ps( address );
249 #else
250  return *address;
251 #endif
252 }
253 //*************************************************************************************************
254 
255 
256 //*************************************************************************************************
266 BLAZE_ALWAYS_INLINE sse_double_t loadu( const double* address )
267 {
268 #if BLAZE_MIC_MODE
269  __m512d v1 = _mm512_setzero_pd();
270  v1 = _mm512_loadunpacklo_pd( v1, address );
271  v1 = _mm512_loadunpackhi_pd( v1, address+8UL );
272  return v1;
273 #elif BLAZE_AVX_MODE
274  return _mm256_loadu_pd( address );
275 #elif BLAZE_SSE2_MODE
276  return _mm_loadu_pd( address );
277 #else
278  return *address;
279 #endif
280 }
281 //*************************************************************************************************
282 
283 
284 //*************************************************************************************************
294 BLAZE_ALWAYS_INLINE sse_cfloat_t loadu( const complex<float>* address )
295 {
296  BLAZE_STATIC_ASSERT( sizeof( complex<float> ) == 2UL*sizeof( float ) );
297 
298 #if BLAZE_MIC_MODE
299  __m512 v1 = _mm512_setzero_ps();
300  v1 = _mm512_loadunpacklo_ps( v1, reinterpret_cast<const float*>( address ) );
301  v1 = _mm512_loadunpackhi_ps( v1, reinterpret_cast<const float*>( address+8UL ) );
302  return v1;
303 #elif BLAZE_AVX_MODE
304  return _mm256_loadu_ps( reinterpret_cast<const float*>( address ) );
305 #elif BLAZE_SSE_MODE
306  return _mm_loadu_ps( reinterpret_cast<const float*>( address ) );
307 #else
308  return *address;
309 #endif
310 }
311 //*************************************************************************************************
312 
313 
314 //*************************************************************************************************
324 BLAZE_ALWAYS_INLINE sse_cdouble_t loadu( const complex<double>* address )
325 {
326  BLAZE_STATIC_ASSERT( sizeof( complex<double> ) == 2UL*sizeof( double ) );
327 
328 #if BLAZE_MIC_MODE
329  __m512d v1 = _mm512_setzero_pd();
330  v1 = _mm512_loadunpacklo_pd( v1, reinterpret_cast<const double*>( address ) );
331  v1 = _mm512_loadunpackhi_pd( v1, reinterpret_cast<const double*>( address+4UL ) );
332  return v1;
333 #elif BLAZE_AVX_MODE
334  return _mm256_loadu_pd( reinterpret_cast<const double*>( address ) );
335 #elif BLAZE_SSE2_MODE
336  return _mm_loadu_pd( reinterpret_cast<const double*>( address ) );
337 #else
338  return *address;
339 #endif
340 }
341 //*************************************************************************************************
342 
343 } // namespace blaze
344 
345 #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.
BLAZE_ALWAYS_INLINE sse_cdouble_t loadu(const complex< double > *address)
Loads a vector of 'complex' values.
Definition: Loadu.h:324
Intrinsic type for 64-bit double precision complex values.
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Loadu< T, sizeof(T)> >::Type::Type loadu(const T *address)
Loads a vector of integral values.
Definition: Loadu.h:221
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 basic type definitions.
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
System settings for the inline keywords.