28 #ifndef VC_COMMON_TYPES_H_
29 #define VC_COMMON_TYPES_H_
31 #ifdef Vc_CHECK_ALIGNMENT
36 #include <Vc/global.h>
37 #include "../traits/type_traits.h"
38 #include "permutation.h"
39 #include "vectorabi.h"
41 namespace Vc_VERSIONED_NAMESPACE
43 template<
typename T,
typename Abi>
class Mask;
44 template<
typename T,
typename Abi>
class Vector;
70 struct VectorSpecialInitializerZero {};
74 struct VectorSpecialInitializerOne {};
78 struct VectorSpecialInitializerIndexesFromZero {};
84 constexpr VectorSpecialInitializerZero
Zero = {};
89 constexpr VectorSpecialInitializerOne
One = {};
99 template<
typename T>
struct MayAliasImpl {
101 #pragma GCC diagnostic push
102 #pragma GCC diagnostic ignored "-Wattributes"
104 typedef T type Vc_MAY_ALIAS;
106 #pragma GCC diagnostic pop
118 template <
typename T>
using MayAlias [[gnu::may_alias]] = T;
120 template <
typename T>
using MayAlias =
typename Detail::MayAliasImpl<T>::type;
129 enum class Operator : char {
171 template <
typename T, std::
size_t N>
struct array;
208 #ifndef Vc_CHECK_ALIGNMENT
209 template<
typename _T>
static Vc_ALWAYS_INLINE
void assertCorrectAlignment(
const _T *){}
211 template<
typename _T>
static Vc_ALWAYS_INLINE
void assertCorrectAlignment(
const _T *ptr)
213 const size_t s =
alignof(_T);
214 if((reinterpret_cast<size_t>(ptr) & ((s ^ (s & (s - 1))) - 1)) != 0) {
215 fprintf(stderr,
"A vector with incorrect alignment has just been created. Look at the stacktrace to find the guilty object.\n");
229 template<
size_t StructSize>
class SuccessiveEntries
234 using size_type = unsigned;
236 using size_type = size_t;
238 const size_type m_first;
241 typedef SuccessiveEntries AsArg;
242 Vc_INTRINSIC SuccessiveEntries(size_type first) : m_first(first) {}
243 Vc_INTRINSIC Vc_PURE size_type operator[](size_type offset)
const
245 return m_first + offset * StructSize;
247 Vc_INTRINSIC Vc_PURE size_type data()
const {
return m_first; }
248 Vc_INTRINSIC Vc_PURE SuccessiveEntries
operator+(
const SuccessiveEntries &rhs)
const
250 return SuccessiveEntries(m_first + rhs.m_first);
252 Vc_INTRINSIC Vc_PURE SuccessiveEntries
operator*(
const SuccessiveEntries &rhs)
const
254 return SuccessiveEntries(m_first * rhs.m_first);
256 Vc_INTRINSIC Vc_PURE SuccessiveEntries
operator<<(size_type x)
const
258 return {m_first << x};
261 friend Vc_INTRINSIC SuccessiveEntries &internal_data(SuccessiveEntries &x)
265 friend Vc_INTRINSIC
const SuccessiveEntries &internal_data(
const SuccessiveEntries &x)
272 template <std::
size_t alignment>
273 Vc_INTRINSIC_L
void *aligned_malloc(std::size_t n) Vc_INTRINSIC_R;
274 Vc_ALWAYS_INLINE_L
void free(
void *p) Vc_ALWAYS_INLINE_R;
279 template <
typename T,
typename U>
280 using enable_if_mask_converts_implicitly =
281 enable_if<(Traits::is_simd_mask<U>::value && !Traits::isSimdMaskArray<U>::value &&
282 Traits::is_implicit_cast_allowed_mask<
283 Traits::entry_type_of<typename Traits::decay<U>::Vector>, T>::value)>;
287 template <
typename T,
typename U>
288 using enable_if_mask_converts_explicitly = enable_if<(
289 Traits::isSimdMaskArray<U>::value ||
290 (Traits::is_simd_mask<U>::value &&
291 !Traits::is_implicit_cast_allowed_mask<
292 Traits::entry_type_of<typename Traits::decay<U>::Vector>, T>::value))>;
297 template <
typename T>
using WidthT = std::integral_constant<std::size_t, sizeof(T)>;
300 template <std::
size_t Bytes>
class MaskBool;
303 template <
typename T,
typename IndexVector,
typename Scale,
bool>
304 class SubscriptOperation;
313 template <
typename T,
typename IndexVector>
struct GatherArguments
315 const IndexVector indexes;
316 const T *
const address;
326 template <
typename T,
typename IndexVector>
struct ScatterArguments
328 const IndexVector indexes;
335 template <
typename I, I Begin, I End,
typename F>
336 Vc_INTRINSIC enable_if<(Begin >= End),
void> unrolled_loop(F &&)
345 template <
typename I, I Begin, I End,
typename F>
346 Vc_INTRINSIC Vc_FLATTEN enable_if<(Begin < End), void> unrolled_loop(F &&f)
349 unrolled_loop<I, Begin + 1, End>(f);
356 template <std::
size_t Size,
typename F> Vc_INTRINSIC
void for_all_vector_entries(F &&f)
358 unrolled_loop<std::size_t, 0u, Size>(std::forward<F>(f));
365 template <
class T, std::
size_t Size = sizeof(T), std::
size_t Alignment = alignof(T)>
366 struct ensure_alignment_equals_sizeof {
367 Vc_ALIGNED_TYPEDEF(Size, T, type);
369 template <
class T, std::
size_t Size>
370 struct ensure_alignment_equals_sizeof<T, Size, Size> {
379 #include "memoryfwd.h"
381 #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
The main vector class for expressing data parallelism.
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.
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...