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>
49 #include <blaze/util/mpl/And.h>
51 #include <blaze/util/Types.h>
54 
55 
56 namespace blaze {
57 
58 //=================================================================================================
59 //
60 // INTRINSIC LOADU FUNCTIONS
61 //
62 //=================================================================================================
63 
64 //*************************************************************************************************
74 template< typename T > // Type of the integral value
75 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,2UL> >, sse_int16_t >::Type
76  loadu( const T* address )
77 {
78 #if BLAZE_AVX2_MODE
79  return _mm256_loadu_si256( reinterpret_cast<const __m256i*>( address ) );
80 #elif BLAZE_SSE2_MODE
81  return _mm_loadu_si128( reinterpret_cast<const __m128i*>( address ) );
82 #else
83  return *address;
84 #endif
85 }
86 //*************************************************************************************************
87 
88 
89 //*************************************************************************************************
99 template< typename T > // Type of the integral value
100 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,4UL> >, sse_int32_t >::Type
101  loadu( const T* address )
102 {
103 #if BLAZE_MIC_MODE
104  __m512i v1 = _mm512_setzero_epi32();
105  v1 = _mm512_loadunpacklo_epi32( v1, address );
106  v1 = _mm512_loadunpackhi_epi32( v1, address+16UL );
107  return v1;
108 #elif BLAZE_AVX2_MODE
109  return _mm256_loadu_si256( reinterpret_cast<const __m256i*>( address ) );
110 #elif BLAZE_SSE2_MODE
111  return _mm_loadu_si128( reinterpret_cast<const __m128i*>( address ) );
112 #else
113  return *address;
114 #endif
115 }
116 //*************************************************************************************************
117 
118 
119 //*************************************************************************************************
129 template< typename T > // Type of the integral value
130 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,8UL> >, sse_int64_t >::Type
131  loadu( const T* address )
132 {
133 #if BLAZE_MIC_MODE
134  __m512i v1 = _mm512_setzero_epi32();
135  v1 = _mm512_loadunpacklo_epi64( v1, address );
136  v1 = _mm512_loadunpackhi_epi64( v1, address+8UL );
137  return v1;
138 #elif BLAZE_AVX2_MODE
139  return _mm256_loadu_si256( reinterpret_cast<const __m256i*>( address ) );
140 #elif BLAZE_SSE2_MODE
141  return _mm_loadu_si128( reinterpret_cast<const __m128i*>( address ) );
142 #else
143  return *address;
144 #endif
145 }
146 //*************************************************************************************************
147 
148 
149 //*************************************************************************************************
159 BLAZE_ALWAYS_INLINE sse_float_t loadu( const float* address )
160 {
161 #if BLAZE_MIC_MODE
162  __m512 v1 = _mm512_setzero_ps();
163  v1 = _mm512_loadunpacklo_ps( v1, address );
164  v1 = _mm512_loadunpackhi_ps( v1, address+16UL );
165  return v1;
166 #elif BLAZE_AVX_MODE
167  return _mm256_loadu_ps( address );
168 #elif BLAZE_SSE_MODE
169  return _mm_loadu_ps( address );
170 #else
171  return *address;
172 #endif
173 }
174 //*************************************************************************************************
175 
176 
177 //*************************************************************************************************
187 BLAZE_ALWAYS_INLINE sse_double_t loadu( const double* address )
188 {
189 #if BLAZE_MIC_MODE
190  __m512d v1 = _mm512_setzero_pd();
191  v1 = _mm512_loadunpacklo_pd( v1, address );
192  v1 = _mm512_loadunpackhi_pd( v1, address+8UL );
193  return v1;
194 #elif BLAZE_AVX_MODE
195  return _mm256_loadu_pd( address );
196 #elif BLAZE_SSE2_MODE
197  return _mm_loadu_pd( address );
198 #else
199  return *address;
200 #endif
201 }
202 //*************************************************************************************************
203 
204 
205 //*************************************************************************************************
215 BLAZE_ALWAYS_INLINE sse_cfloat_t loadu( const complex<float>* address )
216 {
217  BLAZE_STATIC_ASSERT( sizeof( complex<float> ) == 2UL*sizeof( float ) );
218 
219 #if BLAZE_MIC_MODE
220  __m512 v1 = _mm512_setzero_ps();
221  v1 = _mm512_loadunpacklo_ps( v1, reinterpret_cast<const float*>( address ) );
222  v1 = _mm512_loadunpackhi_ps( v1, reinterpret_cast<const float*>( address+8UL ) );
223  return v1;
224 #elif BLAZE_AVX_MODE
225  return _mm256_loadu_ps( reinterpret_cast<const float*>( address ) );
226 #elif BLAZE_SSE_MODE
227  return _mm_loadu_ps( reinterpret_cast<const float*>( address ) );
228 #else
229  return *address;
230 #endif
231 }
232 //*************************************************************************************************
233 
234 
235 //*************************************************************************************************
245 BLAZE_ALWAYS_INLINE sse_cdouble_t loadu( const complex<double>* address )
246 {
247  BLAZE_STATIC_ASSERT( sizeof( complex<double> ) == 2UL*sizeof( double ) );
248 
249 #if BLAZE_MIC_MODE
250  __m512d v1 = _mm512_setzero_pd();
251  v1 = _mm512_loadunpacklo_pd( v1, reinterpret_cast<const double*>( address ) );
252  v1 = _mm512_loadunpackhi_pd( v1, reinterpret_cast<const double*>( address+4UL ) );
253  return v1;
254 #elif BLAZE_AVX_MODE
255  return _mm256_loadu_pd( reinterpret_cast<const double*>( address ) );
256 #elif BLAZE_SSE2_MODE
257  return _mm_loadu_pd( reinterpret_cast<const double*>( address ) );
258 #else
259  return *address;
260 #endif
261 }
262 //*************************************************************************************************
263 
264 } // namespace blaze
265 
266 #endif
Intrinsic type for 32-bit single precision complex values.
Header file for basic type definitions.
Header file for the IsIntegral type trait.
Header file for the And class template.
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
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, sse_int16_t >::Type loadu(const T *address)
Loads a vector of 2-byte integral values.
Definition: Loadu.h:76
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 the HasSize type trait.
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.