All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Load.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_INTRINSICS_LOAD_H_
36 #define _BLAZE_MATH_INTRINSICS_LOAD_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
44 #include <blaze/system/Inline.h>
47 #include <blaze/util/Assert.h>
48 #include <blaze/util/Complex.h>
50 #include <blaze/util/EnableIf.h>
52 #include <blaze/util/Types.h>
53 
54 
55 namespace blaze {
56 
57 //=================================================================================================
58 //
59 // CLASS DEFINITION
60 //
61 //=================================================================================================
62 
63 //*************************************************************************************************
73 template< typename T // Type of the integral
74  , size_t N > // Size of the integral
75 struct Load;
77 //*************************************************************************************************
78 
79 
80 
81 
82 //=================================================================================================
83 //
84 // SPECIALIZATIONS OF THE LOAD CLASS TEMPLATE
85 //
86 //=================================================================================================
87 
88 //*************************************************************************************************
93 template< typename T > // Type of the integral
94 struct Load<T,2UL>
95 {
96  public:
97  //**Type definitions****************************************************************************
98  typedef sse_int16_t Type;
99  //**********************************************************************************************
100 
101  //**Set function********************************************************************************
102  static BLAZE_ALWAYS_INLINE Type load( const T* address )
103  {
104  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
105 
106 #if BLAZE_AVX2_MODE
107  return _mm256_load_si256( reinterpret_cast<const __m256i*>( address ) );
108 #elif BLAZE_SSE2_MODE
109  return _mm_load_si128( reinterpret_cast<const __m128i*>( address ) );
110 #else
111  return *address;
112 #endif
113  }
114  //**********************************************************************************************
115 
116  private:
117  //**Compile time checks*************************************************************************
119  //**********************************************************************************************
120 };
122 //*************************************************************************************************
123 
124 
125 //*************************************************************************************************
130 template< typename T > // Type of the integral
131 struct Load<T,4UL>
132 {
133  public:
134  //**Type definitions****************************************************************************
135  typedef sse_int32_t Type;
136  //**********************************************************************************************
137 
138  //**Set function********************************************************************************
139  static BLAZE_ALWAYS_INLINE Type load( const T* address )
140  {
141  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
142 
143 #if BLAZE_MIC_MODE
144  return _mm512_load_epi32( address );
145 #elif BLAZE_AVX2_MODE
146  return _mm256_load_si256( reinterpret_cast<const __m256i*>( address ) );
147 #elif BLAZE_SSE2_MODE
148  return _mm_load_si128( reinterpret_cast<const __m128i*>( address ) );
149 #else
150  return *address;
151 #endif
152  }
153  //**********************************************************************************************
154 
155  private:
156  //**Compile time checks*************************************************************************
158  //**********************************************************************************************
159 };
161 //*************************************************************************************************
162 
163 
164 //*************************************************************************************************
169 template< typename T > // Type of the integral
170 struct Load<T,8UL>
171 {
172  public:
173  //**Type definitions****************************************************************************
174  typedef sse_int64_t Type;
175  //**********************************************************************************************
176 
177  //**Set function********************************************************************************
178  static BLAZE_ALWAYS_INLINE Type load( const T* address )
179  {
180  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
181 
182 #if BLAZE_MIC_MODE
183  return _mm512_load_epi64( address );
184 #elif BLAZE_AVX2_MODE
185  return _mm256_load_si256( reinterpret_cast<const __m256i*>( address ) );
186 #elif BLAZE_SSE2_MODE
187  return _mm_load_si128( reinterpret_cast<const __m128i*>( address ) );
188 #else
189  return *address;
190 #endif
191  }
192  //**********************************************************************************************
193 
194  private:
195  //**Compile time checks*************************************************************************
197  //**********************************************************************************************
198 };
200 //*************************************************************************************************
201 
202 
203 
204 
205 //=================================================================================================
206 //
207 // INTRINSIC LOAD FUNCTIONS
208 //
209 //=================================================================================================
210 
211 //*************************************************************************************************
222 template< typename T > // Type of the integral value
223 BLAZE_ALWAYS_INLINE typename EnableIf< IsIntegral<T>, Load<T,sizeof(T)> >::Type::Type
224  load( const T* address )
225 {
226  return Load<T,sizeof(T)>::load( address );
227 }
228 //*************************************************************************************************
229 
230 
231 //*************************************************************************************************
242 BLAZE_ALWAYS_INLINE sse_float_t load( const float* address )
243 {
244  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
245 
246 #if BLAZE_MIC_MODE
247  return _mm512_load_ps( address );
248 #elif BLAZE_AVX_MODE
249  return _mm256_load_ps( address );
250 #elif BLAZE_SSE_MODE
251  return _mm_load_ps( address );
252 #else
253  return *address;
254 #endif
255 }
256 //*************************************************************************************************
257 
258 
259 //*************************************************************************************************
270 BLAZE_ALWAYS_INLINE sse_double_t load( const double* address )
271 {
272  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
273 
274 #if BLAZE_MIC_MODE
275  return _mm512_load_pd( address );
276 #elif BLAZE_AVX_MODE
277  return _mm256_load_pd( address );
278 #elif BLAZE_SSE2_MODE
279  return _mm_load_pd( address );
280 #else
281  return *address;
282 #endif
283 }
284 //*************************************************************************************************
285 
286 
287 //*************************************************************************************************
298 BLAZE_ALWAYS_INLINE sse_cfloat_t load( const complex<float>* address )
299 {
300  BLAZE_STATIC_ASSERT ( sizeof( complex<float> ) == 2UL*sizeof( float ) );
301  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
302 
303 #if BLAZE_MIC_MODE
304  return _mm512_load_ps( reinterpret_cast<const float*>( address ) );
305 #elif BLAZE_AVX_MODE
306  return _mm256_load_ps( reinterpret_cast<const float*>( address ) );
307 #elif BLAZE_SSE_MODE
308  return _mm_load_ps( reinterpret_cast<const float*>( address ) );
309 #else
310  return *address;
311 #endif
312 }
313 //*************************************************************************************************
314 
315 
316 //*************************************************************************************************
327 BLAZE_ALWAYS_INLINE sse_cdouble_t load( const complex<double>* address )
328 {
329  BLAZE_STATIC_ASSERT ( sizeof( complex<double> ) == 2UL*sizeof( double ) );
330  BLAZE_INTERNAL_ASSERT( checkAlignment( address ), "Invalid alignment detected" );
331 
332 #if BLAZE_MIC_MODE
333  return _mm512_load_pd( reinterpret_cast<const double*>( address ) );
334 #elif BLAZE_AVX_MODE
335  return _mm256_load_pd( reinterpret_cast<const double*>( address ) );
336 #elif BLAZE_SSE2_MODE
337  return _mm_load_pd( reinterpret_cast<const double*>( address ) );
338 #else
339  return *address;
340 #endif
341 }
342 //*************************************************************************************************
343 
344 } // namespace blaze
345 
346 #endif
Intrinsic type for 32-bit single precision complex values.
BLAZE_ALWAYS_INLINE sse_cdouble_t load(const complex< double > *address)
Loads a vector of 'complex' values.
Definition: Load.h:327
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:224
#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.
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 run time assertion macros.
bool checkAlignment(const T *address)
Checks the alignment of the given.
Definition: AlignmentCheck.h:68
Header file for the alignment check function.
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.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101