28 #ifndef VC_COMMON_TYPES_H_ 29 #define VC_COMMON_TYPES_H_ 31 #ifdef Vc_CHECK_ALIGNMENT 37 #include "../global.h" 38 #include "../traits/type_traits.h" 39 #include "permutation.h" 41 namespace Vc_VERSIONED_NAMESPACE
67 struct VectorSpecialInitializerZero {};
71 struct VectorSpecialInitializerOne {};
75 struct VectorSpecialInitializerIndexesFromZero {};
81 constexpr VectorSpecialInitializerZero
Zero = {};
86 constexpr VectorSpecialInitializerOne
One = {};
96 template<
typename T>
struct MayAliasImpl {
98 #pragma GCC diagnostic push 99 #pragma GCC diagnostic ignored "-Wattributes" 101 typedef T type Vc_MAY_ALIAS;
103 #pragma GCC diagnostic pop 115 template <
typename T>
using MayAlias [[gnu::may_alias]] = T;
117 template <
typename T>
using MayAlias =
typename Detail::MayAliasImpl<T>::type;
120 template <
class To,
class From> MayAlias<To> &aliasing_cast(From &x)
122 return *
reinterpret_cast<MayAlias<To> *
>(&x);
124 template <
class To,
class From>
const MayAlias<To> &aliasing_cast(
const From &x)
126 return *
reinterpret_cast<const MayAlias<To> *
>(&x);
129 template <
class To,
class From> MayAlias<To> *aliasing_cast(From *x)
131 return reinterpret_cast<MayAlias<To> *
>(x);
133 template <
class To,
class From>
const MayAlias<To> *aliasing_cast(
const From *x)
135 return reinterpret_cast<const MayAlias<To> *
>(x);
144 enum class Operator : char {
186 template <
typename T, std::
size_t N>
struct array;
189 template <
typename T, std::ptrdiff_t N>
class span;
227 #ifndef Vc_CHECK_ALIGNMENT 228 template<
typename _T>
static Vc_ALWAYS_INLINE
void assertCorrectAlignment(
const _T *){}
230 template<
typename _T>
static Vc_ALWAYS_INLINE
void assertCorrectAlignment(
const _T *ptr)
232 const size_t s =
alignof(_T);
233 if((reinterpret_cast<size_t>(ptr) & ((s ^ (s & (s - 1))) - 1)) != 0) {
234 fprintf(stderr,
"A vector with incorrect alignment has just been created. Look at the stacktrace to find the guilty object.\n");
243 template <
typename T, std::
size_t Pieces, std::
size_t Index>
struct Segment;
251 template<
size_t StructSize>
class SuccessiveEntries
256 using size_type = unsigned;
258 using size_type = size_t;
260 const size_type m_first;
263 typedef SuccessiveEntries AsArg;
264 Vc_INTRINSIC SuccessiveEntries(size_type first) : m_first(first) {}
265 Vc_INTRINSIC Vc_PURE size_type operator[](size_type offset)
const 267 return m_first + offset * StructSize;
269 Vc_INTRINSIC Vc_PURE size_type data()
const {
return m_first; }
270 Vc_INTRINSIC Vc_PURE SuccessiveEntries
operator+(
const SuccessiveEntries &rhs)
const 272 return SuccessiveEntries(m_first + rhs.m_first);
274 Vc_INTRINSIC Vc_PURE SuccessiveEntries
operator*(
const SuccessiveEntries &rhs)
const 276 return SuccessiveEntries(m_first * rhs.m_first);
278 Vc_INTRINSIC Vc_PURE SuccessiveEntries
operator<<(size_type x)
const 280 return {m_first << x};
283 friend Vc_INTRINSIC SuccessiveEntries &internal_data(SuccessiveEntries &x)
287 friend Vc_INTRINSIC
const SuccessiveEntries &internal_data(
const SuccessiveEntries &x)
294 template <std::
size_t alignment>
295 Vc_INTRINSIC_L
void *aligned_malloc(std::size_t n) Vc_INTRINSIC_R;
296 Vc_ALWAYS_INLINE_L
void free(
void *p) Vc_ALWAYS_INLINE_R;
301 template <
typename Mask,
typename T,
typename U>
302 using enable_if_mask_converts_implicitly =
303 enable_if<(!std::is_same<Mask, Traits::decay<U>>::value &&
305 Traits::is_implicit_cast_allowed_mask<
306 Traits::entry_type_of<typename Traits::decay<U>::Vector>, T>::value)>;
310 template <
typename T,
typename U>
311 using enable_if_mask_converts_explicitly = enable_if<(
314 !Traits::is_implicit_cast_allowed_mask<
315 Traits::entry_type_of<typename Traits::decay<U>::Vector>, T>::value))>;
320 template <
typename T>
using WidthT = std::integral_constant<std::size_t, sizeof(T)>;
323 template <std::
size_t Bytes>
class MaskBool;
326 template <
typename T,
typename IndexVector,
typename Scale,
bool>
327 class SubscriptOperation;
336 template <
class T,
class IndexVector,
int Scale = 1>
337 struct GatherArguments {
338 static_assert(std::is_same<T, remove_cvref_t<T>>::value && !std::is_pointer<T>::value,
339 "GatherArguments expects an cv unqualified non-ref/ptr type");
340 const IndexVector indexes;
341 const T *
const address;
343 template <
int Scale,
class T,
class I>
344 GatherArguments<T, I, Scale> make_gather(
const T *m,
const I &i)
356 template <
typename T,
typename IndexVector>
struct ScatterArguments
358 const IndexVector indexes;
365 template <
typename I, I Begin, I End,
typename F>
366 Vc_INTRINSIC enable_if<(Begin >= End),
void> unrolled_loop(F &&)
375 template <
typename I, I Begin, I End,
typename F>
376 Vc_INTRINSIC Vc_FLATTEN enable_if<(Begin < End), void> unrolled_loop(F &&f)
379 unrolled_loop<I, Begin + 1, End>(f);
386 template <std::
size_t Size,
typename F> Vc_INTRINSIC
void for_all_vector_entries(F &&f)
388 unrolled_loop<std::size_t, 0u, Size>(std::forward<F>(f));
396 #include "memoryfwd.h" 398 #endif // VC_COMMON_TYPES_H_ signed char schar
signed char shorthand
void free(T *p)
Frees memory that was allocated with Vc::malloc.
unsigned char uchar
unsigned char shorthand
unsigned int uint
unsigned int shorthand
unsigned long long ullong
unsigned long long shorthand
constexpr VectorSpecialInitializerIndexesFromZero IndexesFromZero
The special object Vc::IndexesFromZero can be used to construct Vector objects initialized to values ...
std::ostream & operator<<(std::ostream &out, const Vc::Vector< T, Abi > &v)
Prints the contents of a vector into a stream object.
result_vector_type< L, R > operator*(L &&lhs, R &&rhs)
Applies * component-wise and concurrently.
Identifies any possible SimdMaskArray<T, N> type (independent of const/volatile or reference) ...
long long llong
long long shorthand
result_vector_type< L, R > operator+(L &&lhs, R &&rhs)
Applies + component-wise and concurrently.
unsigned long ulong
unsigned long shorthand
unsigned short ushort
unsigned short shorthand
constexpr VectorSpecialInitializerZero Zero
The special object Vc::Zero can be used to construct Vector and Mask objects initialized to zero/fals...
constexpr VectorSpecialInitializerOne One
The special object Vc::One can be used to construct Vector and Mask objects initialized to one/true...
Identifies any SIMD mask type (independent of implementation or whether it's SimdMaskArray<T, N>).
Common::AdaptSubscriptOperator< Common::span< T, Extent > > span
An adapted std::span with additional subscript operators supporting gather and scatter operations...
This is std::array with additional subscript operators supporting gather and scatter operations...