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>
47 #include <blaze/util/EnableIf.h>
48 #include <blaze/util/mpl/And.h>
52 
53 
54 namespace blaze {
55 
56 //=================================================================================================
57 //
58 // INTRINSIC LOADU FUNCTIONS
59 //
60 //=================================================================================================
61 
62 //*************************************************************************************************
72 template< typename T > // Type of the integral value
73 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,2UL> >, simd_int16_t >::Type
74  loadu( const T* address )
75 {
76 #if BLAZE_AVX2_MODE
77  return _mm256_loadu_si256( reinterpret_cast<const __m256i*>( address ) );
78 #elif BLAZE_SSE2_MODE
79  return _mm_loadu_si128( reinterpret_cast<const __m128i*>( address ) );
80 #else
81  return *address;
82 #endif
83 }
84 //*************************************************************************************************
85 
86 
87 //*************************************************************************************************
97 template< typename T > // Type of the integral value
98 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,4UL> >, simd_int32_t >::Type
99  loadu( const T* address )
100 {
101 #if BLAZE_MIC_MODE
102  __m512i v1 = _mm512_setzero_epi32();
103  v1 = _mm512_loadunpacklo_epi32( v1, address );
104  v1 = _mm512_loadunpackhi_epi32( v1, address+16UL );
105  return v1;
106 #elif BLAZE_AVX2_MODE
107  return _mm256_loadu_si256( reinterpret_cast<const __m256i*>( address ) );
108 #elif BLAZE_SSE2_MODE
109  return _mm_loadu_si128( reinterpret_cast<const __m128i*>( address ) );
110 #else
111  return *address;
112 #endif
113 }
114 //*************************************************************************************************
115 
116 
117 //*************************************************************************************************
127 template< typename T > // Type of the integral value
128 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,8UL> >, simd_int64_t >::Type
129  loadu( const T* address )
130 {
131 #if BLAZE_MIC_MODE
132  __m512i v1 = _mm512_setzero_epi32();
133  v1 = _mm512_loadunpacklo_epi64( v1, address );
134  v1 = _mm512_loadunpackhi_epi64( v1, address+8UL );
135  return v1;
136 #elif BLAZE_AVX2_MODE
137  return _mm256_loadu_si256( reinterpret_cast<const __m256i*>( address ) );
138 #elif BLAZE_SSE2_MODE
139  return _mm_loadu_si128( reinterpret_cast<const __m128i*>( address ) );
140 #else
141  return *address;
142 #endif
143 }
144 //*************************************************************************************************
145 
146 
147 //*************************************************************************************************
157 BLAZE_ALWAYS_INLINE simd_float_t loadu( const float* address )
158 {
159 #if BLAZE_MIC_MODE
160  __m512 v1 = _mm512_setzero_ps();
161  v1 = _mm512_loadunpacklo_ps( v1, address );
162  v1 = _mm512_loadunpackhi_ps( v1, address+16UL );
163  return v1;
164 #elif BLAZE_AVX_MODE
165  return _mm256_loadu_ps( address );
166 #elif BLAZE_SSE_MODE
167  return _mm_loadu_ps( address );
168 #else
169  return *address;
170 #endif
171 }
172 //*************************************************************************************************
173 
174 
175 //*************************************************************************************************
185 BLAZE_ALWAYS_INLINE simd_double_t loadu( const double* address )
186 {
187 #if BLAZE_MIC_MODE
188  __m512d v1 = _mm512_setzero_pd();
189  v1 = _mm512_loadunpacklo_pd( v1, address );
190  v1 = _mm512_loadunpackhi_pd( v1, address+8UL );
191  return v1;
192 #elif BLAZE_AVX_MODE
193  return _mm256_loadu_pd( address );
194 #elif BLAZE_SSE2_MODE
195  return _mm_loadu_pd( address );
196 #else
197  return *address;
198 #endif
199 }
200 //*************************************************************************************************
201 
202 
203 //*************************************************************************************************
213 template< typename T > // Type of the integral value
214 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,2UL> >, simd_cint16_t >::Type
215  loadu( const complex<T>* address )
216 {
217  BLAZE_STATIC_ASSERT( sizeof( complex<T> ) == 2UL*sizeof( T ) );
218 
219 #if BLAZE_AVX2_MODE
220  return _mm256_loadu_si256( reinterpret_cast<const __m256i*>( address ) );
221 #elif BLAZE_SSE2_MODE
222  return _mm_loadu_si128( reinterpret_cast<const __m128i*>( address ) );
223 #else
224  return *address;
225 #endif
226 }
227 //*************************************************************************************************
228 
229 
230 //*************************************************************************************************
240 template< typename T > // Type of the integral value
241 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,4UL> >, simd_cint32_t >::Type
242  loadu( const complex<T>* address )
243 {
244  BLAZE_STATIC_ASSERT( sizeof( complex<T> ) == 2UL*sizeof( T ) );
245 
246 #if BLAZE_MIC_MODE
247  __m512i v1 = _mm512_setzero_epi32();
248  v1 = _mm512_loadunpacklo_epi32( v1, address );
249  v1 = _mm512_loadunpackhi_epi32( v1, address+16UL );
250  return v1;
251 #elif BLAZE_AVX2_MODE
252  return _mm256_loadu_si256( reinterpret_cast<const __m256i*>( address ) );
253 #elif BLAZE_SSE2_MODE
254  return _mm_loadu_si128( reinterpret_cast<const __m128i*>( address ) );
255 #else
256  return *address;
257 #endif
258 }
259 //*************************************************************************************************
260 
261 
262 //*************************************************************************************************
272 template< typename T > // Type of the integral value
273 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,8UL> >, simd_cint64_t >::Type
274  loadu( const complex<T>* address )
275 {
276  BLAZE_STATIC_ASSERT( sizeof( complex<T> ) == 2UL*sizeof( T ) );
277 
278 #if BLAZE_MIC_MODE
279  __m512i v1 = _mm512_setzero_epi32();
280  v1 = _mm512_loadunpacklo_epi64( v1, address );
281  v1 = _mm512_loadunpackhi_epi64( v1, address+8UL );
282  return v1;
283 #elif BLAZE_AVX2_MODE
284  return _mm256_loadu_si256( reinterpret_cast<const __m256i*>( address ) );
285 #elif BLAZE_SSE2_MODE
286  return _mm_loadu_si128( reinterpret_cast<const __m128i*>( address ) );
287 #else
288  return *address;
289 #endif
290 }
291 //*************************************************************************************************
292 
293 
294 //*************************************************************************************************
304 BLAZE_ALWAYS_INLINE simd_cfloat_t loadu( const complex<float>* address )
305 {
306  BLAZE_STATIC_ASSERT( sizeof( complex<float> ) == 2UL*sizeof( float ) );
307 
308 #if BLAZE_MIC_MODE
309  __m512 v1 = _mm512_setzero_ps();
310  v1 = _mm512_loadunpacklo_ps( v1, reinterpret_cast<const float*>( address ) );
311  v1 = _mm512_loadunpackhi_ps( v1, reinterpret_cast<const float*>( address+8UL ) );
312  return v1;
313 #elif BLAZE_AVX_MODE
314  return _mm256_loadu_ps( reinterpret_cast<const float*>( address ) );
315 #elif BLAZE_SSE_MODE
316  return _mm_loadu_ps( reinterpret_cast<const float*>( address ) );
317 #else
318  return *address;
319 #endif
320 }
321 //*************************************************************************************************
322 
323 
324 //*************************************************************************************************
334 BLAZE_ALWAYS_INLINE simd_cdouble_t loadu( const complex<double>* address )
335 {
336  BLAZE_STATIC_ASSERT( sizeof( complex<double> ) == 2UL*sizeof( double ) );
337 
338 #if BLAZE_MIC_MODE
339  __m512d v1 = _mm512_setzero_pd();
340  v1 = _mm512_loadunpacklo_pd( v1, reinterpret_cast<const double*>( address ) );
341  v1 = _mm512_loadunpackhi_pd( v1, reinterpret_cast<const double*>( address+4UL ) );
342  return v1;
343 #elif BLAZE_AVX_MODE
344  return _mm256_loadu_pd( reinterpret_cast<const double*>( address ) );
345 #elif BLAZE_SSE2_MODE
346  return _mm_loadu_pd( reinterpret_cast<const double*>( address ) );
347 #else
348  return *address;
349 #endif
350 }
351 //*************************************************************************************************
352 
353 } // namespace blaze
354 
355 #endif
Header file for the IsIntegral type trait.
Header file for the And class template.
Intrinsic type for 64-bit double precision floating point data values.
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, simd_int16_t >::Type loadu(const T *address)
Loads a vector of 2-byte integral values.
Definition: Loadu.h:74
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Compile time assertion.
Header file for the EnableIf class template.
Header file for the basic intrinsic types.
Intrinsic type for 32-bit single precision floating point data values.
Header file for the HasSize type trait.
Intrinsic type for 64-bit double precision complex values.
Intrinsic type for 32-bit single precision complex values.
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.