AlignmentOf.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_UTIL_TYPETRAITS_ALIGNMENTOF_H_
36 #define _BLAZE_UTIL_TYPETRAITS_ALIGNMENTOF_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <type_traits>
45 #include <blaze/util/Complex.h>
47 
48 
49 namespace blaze {
50 
51 //=================================================================================================
52 //
53 // CLASS DEFINITION
54 //
55 //=================================================================================================
56 
57 //*************************************************************************************************
62 template< typename T >
63 struct AlignmentOfHelper
64 {
65  private:
66  //**********************************************************************************************
67  static constexpr size_t defaultAlignment = std::alignment_of<T>::value;
68  //**********************************************************************************************
69 
70  public:
71  //**********************************************************************************************
72  enum : size_t {
73 #if BLAZE_AVX512BW_MODE
74  value = ( IsVectorizable<T>::value )?( 64UL ):( defaultAlignment )
76  value = ( IsVectorizable<T>::value )?( sizeof(T) >= 4UL ? 64UL : 32UL ):( defaultAlignment )
77 #elif BLAZE_AVX2_MODE
78  value = ( IsVectorizable<T>::value )?( 32UL ):( defaultAlignment )
79 #elif BLAZE_SSE2_MODE
80  value = ( IsVectorizable<T>::value )?( 16UL ):( defaultAlignment )
81 #else
82  value = defaultAlignment
83 #endif
84  };
85  //**********************************************************************************************
86 };
88 //*************************************************************************************************
89 
90 
91 //*************************************************************************************************
96 template<>
97 struct AlignmentOfHelper<float>
98 {
99  public:
100  //**********************************************************************************************
101  enum : size_t {
102 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
103  value = 64UL
104 #elif BLAZE_AVX_MODE
105  value = 32UL
106 #elif BLAZE_SSE_MODE
107  value = 16UL
108 #else
109  value = std::alignment_of<float>::value
110 #endif
111  };
112  //**********************************************************************************************
113 };
115 //*************************************************************************************************
116 
117 
118 //*************************************************************************************************
123 template<>
124 struct AlignmentOfHelper<double>
125 {
126  public:
127  //**********************************************************************************************
128  enum : size_t {
129 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
130  value = 64UL
131 #elif BLAZE_AVX_MODE
132  value = 32UL
133 #elif BLAZE_SSE2_MODE
134  value = 16UL
135 #else
136  value = std::alignment_of<double>::value
137 #endif
138  };
139  //**********************************************************************************************
140 };
142 //*************************************************************************************************
143 
144 
145 //*************************************************************************************************
150 template<>
151 struct AlignmentOfHelper< complex<float> >
152 {
153  public:
154  //**********************************************************************************************
155  enum : size_t {
156 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
157  value = 64UL
158 #elif BLAZE_AVX_MODE
159  value = 32UL
160 #elif BLAZE_SSE_MODE
161  value = 16UL
162 #else
163  value = std::alignment_of< complex<float> >::value
164 #endif
165  };
166  //**********************************************************************************************
167 };
169 //*************************************************************************************************
170 
171 
172 //*************************************************************************************************
177 template<>
178 struct AlignmentOfHelper< complex<double> >
179 {
180  public:
181  //**********************************************************************************************
182  enum : size_t {
183 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
184  value = 64UL
185 #elif BLAZE_AVX_MODE
186  value = 32UL
187 #elif BLAZE_SSE2_MODE
188  value = 16UL
189 #else
190  value = std::alignment_of< complex<double> >::value
191 #endif
192  };
193  //**********************************************************************************************
194 };
196 //*************************************************************************************************
197 
198 
199 //*************************************************************************************************
218 template< typename T >
220  : public IntegralConstant<size_t,AlignmentOfHelper<T>::value>
221 {};
222 //*************************************************************************************************
223 
224 
225 //*************************************************************************************************
230 template< typename T >
231 struct AlignmentOf< const T >
232  : public IntegralConstant<size_t,AlignmentOfHelper<T>::value>
233 {};
235 //*************************************************************************************************
236 
237 
238 //*************************************************************************************************
243 template< typename T >
244 struct AlignmentOf< volatile T >
245  : public IntegralConstant<size_t,AlignmentOfHelper<T>::value>
246 {};
248 //*************************************************************************************************
249 
250 
251 //*************************************************************************************************
256 template< typename T >
257 struct AlignmentOf< const volatile T >
258  : public IntegralConstant<size_t,AlignmentOfHelper<T>::value>
259 {};
261 //*************************************************************************************************
262 
263 } // namespace blaze
264 
265 #endif
#define BLAZE_AVX512F_MODE
Compilation switch for the AVX512F mode.This compilation switch enables/disables the AVX512F mode...
Definition: Vectorization.h:246
Generic wrapper for a compile time constant integral value.The IntegralConstant class template repres...
Definition: IntegralConstant.h:71
#define BLAZE_MIC_MODE
Compilation switch for the MIC mode.This compilation switch enables/disables the MIC mode...
Definition: Vectorization.h:299
#define BLAZE_AVX2_MODE
Compilation switch for the AVX2 mode.This compilation switch enables/disables the AVX2 mode...
Definition: Vectorization.h:228
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the IsVectorizable type trait.
System settings for the SSE mode.
Header file for the complex data type.
Evaluation of the required alignment of the given data type.The AlignmentOf type trait template evalu...
Definition: AlignmentOf.h:219