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  static constexpr size_t value =
73 #if BLAZE_AVX512BW_MODE
74  ( IsVectorizable_v<T> )?( 64UL ):( defaultAlignment );
75 #elif BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
76  ( IsVectorizable_v<T> )?( sizeof(T) >= 4UL ? 64UL : 32UL ):( defaultAlignment );
77 #elif BLAZE_AVX2_MODE
78  ( IsVectorizable_v<T> )?( 32UL ):( defaultAlignment );
79 #elif BLAZE_SSE2_MODE
80  ( IsVectorizable_v<T> )?( 16UL ):( defaultAlignment );
81 #else
82  defaultAlignment;
83 #endif
84  //**********************************************************************************************
85 };
87 //*************************************************************************************************
88 
89 
90 //*************************************************************************************************
95 template<>
96 struct AlignmentOfHelper<float>
97 {
98  public:
99  //**********************************************************************************************
100  static constexpr size_t value =
101 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
102  64UL;
103 #elif BLAZE_AVX_MODE
104  32UL;
105 #elif BLAZE_SSE_MODE
106  16UL;
107 #else
108  std::alignment_of<float>::value;
109 #endif
110  //**********************************************************************************************
111 };
113 //*************************************************************************************************
114 
115 
116 //*************************************************************************************************
121 template<>
122 struct AlignmentOfHelper<double>
123 {
124  public:
125  //**********************************************************************************************
126  static constexpr size_t value =
127 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
128  64UL;
129 #elif BLAZE_AVX_MODE
130  32UL;
131 #elif BLAZE_SSE2_MODE
132  16UL;
133 #else
134  std::alignment_of<double>::value;
135 #endif
136  //**********************************************************************************************
137 };
139 //*************************************************************************************************
140 
141 
142 //*************************************************************************************************
147 template< typename T >
148 struct AlignmentOfHelper< complex<T> >
149 {
150  public:
151  //**********************************************************************************************
152  static constexpr size_t value = AlignmentOfHelper<T>::value;
153  //**********************************************************************************************
154 };
156 //*************************************************************************************************
157 
158 
159 //*************************************************************************************************
178 template< typename T >
180  : public IntegralConstant<size_t,AlignmentOfHelper<T>::value>
181 {};
182 //*************************************************************************************************
183 
184 
185 //*************************************************************************************************
190 template< typename T >
191 struct AlignmentOf< const T >
192  : public IntegralConstant<size_t,AlignmentOfHelper<T>::value>
193 {};
195 //*************************************************************************************************
196 
197 
198 //*************************************************************************************************
203 template< typename T >
204 struct AlignmentOf< volatile T >
205  : public IntegralConstant<size_t,AlignmentOfHelper<T>::value>
206 {};
208 //*************************************************************************************************
209 
210 
211 //*************************************************************************************************
216 template< typename T >
217 struct AlignmentOf< const volatile T >
218  : public IntegralConstant<size_t,AlignmentOfHelper<T>::value>
219 {};
221 //*************************************************************************************************
222 
223 
224 //*************************************************************************************************
237 template< typename T >
239 //*************************************************************************************************
240 
241 } // namespace blaze
242 
243 #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:58
Header file for the IsVectorizable type trait.
constexpr size_t AlignmentOf_v
Auxiliary variable template for the AlignmentOf type trait.The AlignmentOf_v variable template provid...
Definition: AlignmentOf.h:238
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:179