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 #if BLAZE_MIC_MODE
73  static constexpr size_t value = ( IsVectorizable<T>::value )?( 64UL ):( defaultAlignment );
74 #elif BLAZE_AVX2_MODE
75  static constexpr size_t value = ( IsVectorizable<T>::value )?( 32UL ):( defaultAlignment );
76 #elif BLAZE_SSE2_MODE
77  static constexpr size_t value = ( IsVectorizable<T>::value )?( 16UL ):( defaultAlignment );
78 #else
79  static constexpr size_t value = defaultAlignment;
80 #endif
81  //**********************************************************************************************
82 };
84 //*************************************************************************************************
85 
86 
87 //*************************************************************************************************
92 template<>
93 struct AlignmentOfHelper<float>
94 {
95  public:
96  //**********************************************************************************************
97 #if BLAZE_MIC_MODE
98  static constexpr size_t value = 64UL;
99 #elif BLAZE_AVX_MODE
100  static constexpr size_t value = 32UL;
101 #elif BLAZE_SSE_MODE
102  static constexpr size_t value = 16UL;
103 #else
104  static constexpr size_t value = std::alignment_of<float>::value;
105 #endif
106  //**********************************************************************************************
107 };
109 //*************************************************************************************************
110 
111 
112 //*************************************************************************************************
117 template<>
118 struct AlignmentOfHelper<double>
119 {
120  public:
121  //**********************************************************************************************
122 #if BLAZE_MIC_MODE
123  static constexpr size_t value = 64UL;
124 #elif BLAZE_AVX_MODE
125  static constexpr size_t value = 32UL;
126 #elif BLAZE_SSE_MODE
127  static constexpr size_t value = 16UL;
128 #else
129  static constexpr size_t value = std::alignment_of<double>::value;
130 #endif
131  //**********************************************************************************************
132 };
134 //*************************************************************************************************
135 
136 
137 //*************************************************************************************************
142 template<>
143 struct AlignmentOfHelper< complex<float> >
144 {
145  public:
146  //**********************************************************************************************
147 #if BLAZE_MIC_MODE
148  static constexpr size_t value = 64UL;
149 #elif BLAZE_AVX_MODE
150  static constexpr size_t value = 32UL;
151 #elif BLAZE_SSE_MODE
152  static constexpr size_t value = 16UL;
153 #else
154  static constexpr size_t value = std::alignment_of< complex<float> >::value;
155 #endif
156  //**********************************************************************************************
157 };
159 //*************************************************************************************************
160 
161 
162 //*************************************************************************************************
167 template<>
168 struct AlignmentOfHelper< complex<double> >
169 {
170  public:
171  //**********************************************************************************************
172 #if BLAZE_MIC_MODE
173  static constexpr size_t value = 64UL;
174 #elif BLAZE_AVX_MODE
175  static constexpr size_t value = 32UL;
176 #elif BLAZE_SSE_MODE
177  static constexpr size_t value = 16UL;
178 #else
179  static constexpr size_t value = std::alignment_of< complex<double> >::value;
180 #endif
181  //**********************************************************************************************
182 };
184 //*************************************************************************************************
185 
186 
187 //*************************************************************************************************
206 template< typename T >
207 struct AlignmentOf : IntegralConstant<size_t,AlignmentOfHelper<T>::value>
208 {};
209 //*************************************************************************************************
210 
211 
212 //*************************************************************************************************
217 template< typename T >
218 struct AlignmentOf< const T > : IntegralConstant<size_t,AlignmentOfHelper<T>::value>
219 {};
221 //*************************************************************************************************
222 
223 
224 //*************************************************************************************************
229 template< typename T >
230 struct AlignmentOf< volatile T > : IntegralConstant<size_t,AlignmentOfHelper<T>::value>
231 {};
233 //*************************************************************************************************
234 
235 
236 //*************************************************************************************************
241 template< typename T >
242 struct AlignmentOf< const volatile T > : IntegralConstant<size_t,AlignmentOfHelper<T>::value>
243 {};
245 //*************************************************************************************************
246 
247 } // namespace blaze
248 
249 #endif
Generic wrapper for a compile time constant integral value.The IntegralConstant class template repres...
Definition: IntegralConstant.h:71
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
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:207