VecCore 0.8.1
C++ Library for Portable SIMD Vectorization
Loading...
Searching...
No Matches
VcScalar.h
Go to the documentation of this file.
1#ifndef VECCORE_BACKEND_VC_SCALAR_H
2#define VECCORE_BACKEND_VC_SCALAR_H
3
4namespace vecCore {
5
6template <typename T>
7struct TypeTraits<Vc::Scalar::Mask<T>> {
8 using IndexType = size_t;
9 using ScalarType = bool;
10 static constexpr size_t Size = 1;
11};
12
13template <typename T>
14struct TypeTraits<Vc::Scalar::Vector<T>> {
15 using ScalarType = T;
16 using MaskType = typename Vc::Scalar::Vector<T>::MaskType;
17 using IndexType = typename Vc::Scalar::Vector<T>::IndexType;
18 static constexpr size_t Size = 1;
19};
20
21namespace backend {
22
23template <typename T = Real_s>
24class VcScalarT {
25public:
26 using Real_v = Vc::Scalar::Vector<T>;
27 using Float_v = Vc::Scalar::Vector<float>;
28 using Double_v = Vc::Scalar::Vector<double>;
29
30 using Int_v = Vc::Scalar::Vector<int>;
31 using Int16_v = Vc::Scalar::Vector<int16_t>;
32 using Int32_v = Vc::Scalar::Vector<int32_t>;
33 using Int64_v = Vc::Scalar::Vector<int64_t>;
34
35 using UInt_v = Vc::Scalar::Vector<unsigned int>;
36 using UInt16_v = Vc::Scalar::Vector<uint16_t>;
37 using UInt32_v = Vc::Scalar::Vector<uint32_t>;
38 using UInt64_v = Vc::Scalar::Vector<uint64_t>;
39};
40
42
43} // namespace backend
44
45template <typename T>
47bool MaskEmpty(const Vc::Scalar::Mask<T> &mask)
48{
49 return mask.isEmpty();
50}
51
52template <typename T>
54bool MaskFull(const Vc::Scalar::Mask<T> &mask)
55{
56 return mask.isFull();
57}
58
59template <typename T>
60struct IndexingImplementation<Vc::Scalar::Mask<T>> {
61 using M = Vc::Scalar::Mask<T>;
62 static inline bool Get(const M &mask, size_t i) { return mask[i]; }
63
64 static inline void Set(M &mask, size_t i, const bool val) { mask[i] = val; }
65};
66
67template <typename T>
68struct MaskingImplementation<Vc::Scalar::Vector<T>> {
69 using M = Vc::Scalar::Mask<T>;
70 using V = Vc::Scalar::Vector<T>;
71
72 static inline void Assign(V &dst, M const &mask, V const &src) { dst(mask) = src; }
73
74 static inline void Blend(V &dst, M const &mask, V const &src1, V const src2)
75 {
76 dst = src2;
77 dst(mask) = src1;
78 }
79};
80
81inline namespace math {
82
83template <typename T>
85Vc::Scalar::Mask<T> IsInf(const Vc::Scalar::Vector<T> &x)
86{
87 return Vc::isinf(x);
88}
89
90}
91
92} // namespace vecCore
93
94#endif
#define VECCORE_FORCE_INLINE
Definition: Common.h:32
Vc::Scalar::Vector< int > Int_v
Definition: VcScalar.h:30
Vc::Scalar::Vector< T > Real_v
Definition: VcScalar.h:26
Vc::Scalar::Vector< int32_t > Int32_v
Definition: VcScalar.h:32
Vc::Scalar::Vector< uint64_t > UInt64_v
Definition: VcScalar.h:38
Vc::Scalar::Vector< unsigned int > UInt_v
Definition: VcScalar.h:35
Vc::Scalar::Vector< uint16_t > UInt16_v
Definition: VcScalar.h:36
Vc::Scalar::Vector< float > Float_v
Definition: VcScalar.h:27
Vc::Scalar::Vector< int64_t > Int64_v
Definition: VcScalar.h:33
Vc::Scalar::Vector< uint32_t > UInt32_v
Definition: VcScalar.h:37
Vc::Scalar::Vector< int16_t > Int16_v
Definition: VcScalar.h:31
Vc::Scalar::Vector< double > Double_v
Definition: VcScalar.h:28
VECCORE_FORCE_INLINE UME::SIMD::SIMDVecMask< N > IsInf(const UME::SIMD::SIMDVec_f< T, N > &x)
VECCORE_ATT_HOST_DEVICE bool MaskEmpty(const M &mask)
VECCORE_ATT_HOST_DEVICE bool MaskFull(const M &mask)
static bool Get(const M &mask, size_t i)
Definition: VcScalar.h:62
static void Set(M &mask, size_t i, const bool val)
Definition: VcScalar.h:64
static void Blend(V &dst, M const &mask, V const &src1, V const src2)
Definition: VcScalar.h:74
static void Assign(V &dst, M const &mask, V const &src)
Definition: VcScalar.h:72
typename Vc::Scalar::Vector< T >::IndexType IndexType
Definition: VcScalar.h:17
typename Vc::Scalar::Vector< T >::MaskType MaskType
Definition: VcScalar.h:16
static constexpr size_t Size
Definition: Scalar.h:14