Blaze 3.9
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>
46#include <blaze/util/Types.h>
48
49
50namespace blaze {
51
52//=================================================================================================
53//
54// CLASS DEFINITION
55//
56//=================================================================================================
57
58//*************************************************************************************************
63template< typename T >
64struct AlignmentOfHelper
65{
66 private:
67 //**********************************************************************************************
68 static constexpr size_t defaultAlignment = std::alignment_of<T>::value;
69 //**********************************************************************************************
70
71 public:
72 //**********************************************************************************************
73 static constexpr size_t value =
74#if BLAZE_AVX512BW_MODE
75 ( IsVectorizable_v<T> )?( 64UL ):( defaultAlignment );
76#elif BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
77 ( IsVectorizable_v<T> )?( sizeof(T) >= 4UL ? 64UL : 32UL ):( defaultAlignment );
78#elif BLAZE_AVX2_MODE
79 ( IsVectorizable_v<T> )?( 32UL ):( defaultAlignment );
80#elif BLAZE_SSE2_MODE
81 ( IsVectorizable_v<T> )?( 16UL ):( defaultAlignment );
82#else
83 defaultAlignment;
84#endif
85 //**********************************************************************************************
86};
88//*************************************************************************************************
89
90
91//*************************************************************************************************
96template<>
97struct AlignmentOfHelper<float>
98{
99 public:
100 //**********************************************************************************************
101 static constexpr size_t value =
102#if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
103 64UL;
104#elif BLAZE_AVX_MODE
105 32UL;
106#elif BLAZE_SSE_MODE
107 16UL;
108#else
109 std::alignment_of<float>::value;
110#endif
111 //**********************************************************************************************
112};
114//*************************************************************************************************
115
116
117//*************************************************************************************************
122template<>
123struct AlignmentOfHelper<double>
124{
125 public:
126 //**********************************************************************************************
127 static constexpr size_t value =
128#if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
129 64UL;
130#elif BLAZE_AVX_MODE
131 32UL;
132#elif BLAZE_SSE2_MODE
133 16UL;
134#else
135 std::alignment_of<double>::value;
136#endif
137 //**********************************************************************************************
138};
140//*************************************************************************************************
141
142
143//*************************************************************************************************
148template< typename T >
149struct AlignmentOfHelper< complex<T> >
150{
151 public:
152 //**********************************************************************************************
153 static constexpr size_t value = AlignmentOfHelper<T>::value;
154 //**********************************************************************************************
155};
157//*************************************************************************************************
158
159
160//*************************************************************************************************
179template< typename T >
181 : public IntegralConstant<size_t,AlignmentOfHelper<T>::value>
182{};
183//*************************************************************************************************
184
185
186//*************************************************************************************************
191template< typename T >
192struct AlignmentOf< const T >
193 : public IntegralConstant<size_t,AlignmentOfHelper<T>::value>
194{};
196//*************************************************************************************************
197
198
199//*************************************************************************************************
204template< typename T >
205struct AlignmentOf< volatile T >
206 : public IntegralConstant<size_t,AlignmentOfHelper<T>::value>
207{};
209//*************************************************************************************************
210
211
212//*************************************************************************************************
217template< typename T >
218struct AlignmentOf< const volatile T >
219 : public IntegralConstant<size_t,AlignmentOfHelper<T>::value>
220{};
222//*************************************************************************************************
223
224
225//*************************************************************************************************
238template< typename T >
240//*************************************************************************************************
241
242} // namespace blaze
243
244#endif
Header file for the complex data type.
Header file for the IsVectorizable type trait.
Complex data type of the Blaze library.
constexpr size_t AlignmentOf_v
Auxiliary variable template for the AlignmentOf type trait.
Definition: AlignmentOf.h:239
Evaluation of the required alignment of the given data type.
Definition: AlignmentOf.h:182
Generic wrapper for a compile time constant integral value.
Definition: IntegralConstant.h:74
System settings for the SSE mode.
Header file for basic type definitions.