25template <
size_t value>
26requires (is::powerOfTwoInt<value>)
27constexpr size_t previousMultipleOf (
size_t numElements)
29 constexpr auto numMaskBits = std::bit_width (value) - 1;
30 constexpr auto allBitsOne = size_t (-1);
31 constexpr auto mask = allBitsOne << numMaskBits;
33 return numElements & mask;
36template <
size_t value>
37requires (is::powerOfTwoInt<value>)
38constexpr size_t nextMultipleOf (
size_t numElements)
40 return size_t ((int64_t (numElements) + int64_t (value) - 1) & -int64_t (value));
52constexpr auto _CMP_LT_OQ = 0;
53constexpr auto _CMP_LE_OQ = 1;
54constexpr auto _CMP_GT_OQ = 2;
55constexpr auto _CMP_GE_OQ = 3;
56constexpr auto _CMP_EQ_OQ = 4;
57constexpr auto _CMP_NEQ_OQ = 5;
65 lessOrEqual = _CMP_LE_OQ,
67 greaterOrEqual = _CMP_GE_OQ,
69 notEqual = _CMP_NEQ_OQ
80template <u
intptr_t requiredAlignment = Config::maxSIMDRegisterSize>
84 if (std::is_constant_evaluated())
87 return reinterpret_cast<std::uintptr_t
> (ptr) % requiredAlignment == 0;
105template <
class StorageType>
111template <has::sizeAndData StorageType>
115 : dataIsSIMDAligned (
false),
116 hasSIMDExtendedStorage (
false)
119 template <is::storageInfo OtherStorageInfoType>
120 constexpr StorageInfo (
const OtherStorageInfoType& other)
121 : dataIsSIMDAligned (other.dataIsSIMDAligned),
122 hasSIMDExtendedStorage (other.hasSIMDExtendedStorage)
126 constexpr StorageInfo init (
const T* ptr,
size_t s)
129 hasSIMDExtendedStorage = (s *
sizeof (T)) % Config::maxSIMDRegisterSize == 0;
133 static constexpr size_t memberAlignment =
alignof (StorageType);
135 bool dataIsSIMDAligned;
137 bool hasSIMDExtendedStorage;
140template <
class ElementType,
size_t alignmentInBytes>
141struct StorageInfo<std::vector<ElementType, AlignedAllocator<ElementType, alignmentInBytes>>>
143 constexpr StorageInfo init (
const void*,
size_t) {
return *
this; }
145 static constexpr size_t memberAlignment =
alignof (std::vector<ElementType, AlignedAllocator<ElementType, alignmentInBytes>>);
147 static constexpr bool dataIsSIMDAligned = alignmentInBytes == Config::maxSIMDRegisterSize;
150 static constexpr bool hasSIMDExtendedStorage =
true;
153template <
class ElementType,
size_t size>
156 constexpr StorageInfo init (
const void*,
size_t) {
return *
this; }
158 static constexpr size_t memberAlignment = Config::alignedArray ? Config::maxSIMDRegisterSize :
alignof (std::array<ElementType, size>);
161 static constexpr bool dataIsSIMDAligned = Config::alignedArray;
163 static constexpr bool hasSIMDExtendedStorage = (size *
sizeof (ElementType)) % Config::maxSIMDRegisterSize == 0;
166template <
class Allocator>
167struct StorageInfo<detail::VectorBoolWorkaround<Allocator>>
169 constexpr StorageInfo init (
const void*,
size_t) {
return *
this; }
171 static constexpr size_t memberAlignment =
alignof (detail::VectorBoolWorkaround<Allocator>);
173 static constexpr bool dataIsSIMDAligned =
false;
175 static constexpr bool hasSIMDExtendedStorage =
false;
181template <
bool isDataSIMDAligned,
bool isStorageSIMDExtended,
size_t customMemberAlignment>
184 static constexpr bool dataIsSIMDAligned = isDataSIMDAligned;
185 static constexpr bool hasSIMDExtendedStorage = isStorageSIMDExtended;
186 static constexpr size_t memberAlignment = customMemberAlignment;
195template <
size_t alignment,
class WrappedInfo>
202 static constexpr size_t memberAlignment = alignment;
209struct ConstexprStorageInfoChecker
217concept constexprStorageInfo =
requires (
const T&) { detail::ConstexprStorageInfoChecker<T::dataIsSIMDAligned, T::hasSIMDExtendedStorage>(); };
220template <
class First,
class... Others>
224 : dataIsSIMDAligned (first.dataIsSIMDAligned && (others.dataIsSIMDAligned && ...)),
225 hasSIMDExtendedStorage (first.hasSIMDExtendedStorage && (others.hasSIMDExtendedStorage && ...))
228 bool dataIsSIMDAligned;
230 bool hasSIMDExtendedStorage;
238 static constexpr bool dataIsSIMDAligned = First::dataIsSIMDAligned && (Others::dataIsSIMDAligned && ...);
240 static constexpr bool hasSIMDExtendedStorage = First::hasSIMDExtendedStorage && (Others::hasSIMDExtendedStorage && ...);
Definition: SIMDHelpers.h:217
The main namespace of the VCTR project.
Definition: Array.h:24
constexpr bool isPtrAligned(const void *ptr)
Helper function to check if a pointer is aligned to the required alignment value.
Definition: SIMDHelpers.h:81
CompareOp
Possible types of (SIMD) compare operations.
Definition: SIMDHelpers.h:63
Definition: SIMDHelpers.h:222
A storage info type especially used to pass compile time constant traits when viewing externally owne...
Definition: SIMDHelpers.h:183
A storage info type especially used for vctr::Span.
Definition: SIMDHelpers.h:197
A helper class to describe some properties regarding the storage class wrapped in a VctrBase instance...
Definition: SIMDHelpers.h:107