29 #ifndef VC_COMMON_TYPES_H_
30 #define VC_COMMON_TYPES_H_
32 #ifdef Vc_CHECK_ALIGNMENT
37 #include <Vc/global.h>
38 #include "../traits/type_traits.h"
39 #include "permutation.h"
40 #include "vectorabi.h"
42 namespace Vc_VERSIONED_NAMESPACE
44 template<
typename T,
typename Abi>
class Mask;
45 template<
typename T,
typename Abi>
class Vector;
71 struct VectorSpecialInitializerZero {};
75 struct VectorSpecialInitializerOne {};
79 struct VectorSpecialInitializerIndexesFromZero {};
85 constexpr VectorSpecialInitializerZero
Zero = {};
90 constexpr VectorSpecialInitializerOne
One = {};
100 template<
typename T>
struct MayAliasImpl {
typedef T type Vc_MAY_ALIAS; };
110 template <
typename T>
using MayAlias [[gnu::may_alias]] = T;
112 template <
typename T>
using MayAlias =
typename Detail::MayAliasImpl<T>::type;
121 enum class Operator : char {
163 template <
typename T, std::
size_t N>
struct array;
200 #ifndef Vc_CHECK_ALIGNMENT
201 template<
typename _T>
static Vc_ALWAYS_INLINE
void assertCorrectAlignment(
const _T *){}
203 template<
typename _T>
static Vc_ALWAYS_INLINE
void assertCorrectAlignment(
const _T *ptr)
205 const size_t s =
alignof(_T);
206 if((reinterpret_cast<size_t>(ptr) & ((s ^ (s & (s - 1))) - 1)) != 0) {
207 fprintf(stderr,
"A vector with incorrect alignment has just been created. Look at the stacktrace to find the guilty object.\n");
221 template<
size_t StructSize>
class SuccessiveEntries
225 typedef SuccessiveEntries AsArg;
226 constexpr SuccessiveEntries(
size_t first) : m_first(first) {}
227 constexpr Vc_PURE
size_t operator[](
size_t offset)
const {
return m_first + offset * StructSize; }
228 constexpr Vc_PURE
size_t data()
const {
return m_first; }
229 constexpr Vc_PURE SuccessiveEntries operator+(
const SuccessiveEntries &rhs)
const {
return SuccessiveEntries(m_first + rhs.m_first); }
230 constexpr Vc_PURE SuccessiveEntries operator*(
const SuccessiveEntries &rhs)
const {
return SuccessiveEntries(m_first * rhs.m_first); }
231 constexpr Vc_PURE SuccessiveEntries
operator<<(std::size_t x)
const {
return {m_first << x}; }
233 friend SuccessiveEntries &internal_data(SuccessiveEntries &x) {
return x; }
234 friend const SuccessiveEntries &internal_data(
const SuccessiveEntries &x)
241 template <std::
size_t alignment>
242 Vc_INTRINSIC_L
void *aligned_malloc(std::size_t n) Vc_INTRINSIC_R;
243 Vc_ALWAYS_INLINE_L
void free(
void *p) Vc_ALWAYS_INLINE_R;
248 template <
typename T,
typename U>
249 using enable_if_mask_converts_implicitly =
250 enable_if<(Traits::is_simd_mask<U>::value && !Traits::isSimdMaskArray<U>::value &&
251 Traits::is_implicit_cast_allowed_mask<
252 Traits::entry_type_of<typename Traits::decay<U>::Vector>, T>::value)>;
256 template <
typename T,
typename U>
257 using enable_if_mask_converts_explicitly = enable_if<(
258 Traits::isSimdMaskArray<U>::value ||
259 (Traits::is_simd_mask<U>::value &&
260 !Traits::is_implicit_cast_allowed_mask<
261 Traits::entry_type_of<typename Traits::decay<U>::Vector>, T>::value))>;
266 template <
typename T>
using WidthT = std::integral_constant<std::size_t, sizeof(T)>;
269 template <std::
size_t Bytes>
class MaskBool;
272 template <
typename T,
typename IndexVector,
typename Scale,
bool>
273 class SubscriptOperation;
282 template <
typename T,
typename IndexVector>
struct GatherArguments
284 const IndexVector indexes;
285 const T *
const address;
295 template <
typename T,
typename IndexVector>
struct ScatterArguments
297 const IndexVector indexes;
304 template <
typename I, I Begin, I End,
typename F>
305 Vc_INTRINSIC enable_if<(Begin >= End),
void> unrolled_loop(F &&)
314 template <
typename I, I Begin, I End,
typename F>
315 Vc_INTRINSIC Vc_FLATTEN enable_if<(Begin < End), void> unrolled_loop(F &&f)
318 unrolled_loop<I, Begin + 1, End>(f);
325 template <std::
size_t Size,
typename F> Vc_INTRINSIC
void for_all_vector_entries(F &&f)
327 unrolled_loop<std::size_t, 0u, Size>(std::forward<F>(f));
335 #include "memoryfwd.h"
337 #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.
long long llong
long long shorthand
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...