 |
Vc
1.4.1
SIMD Vector Classes for C++
|
|
28 #ifndef VC_COMMON_MASK_H_
29 #define VC_COMMON_MASK_H_
33 namespace Vc_VERSIONED_NAMESPACE
41 template <
typename T,
typename Abi = VectorAbi::Best<T>>
class Mask
57 static constexpr
size_t size() {
return VectorTraits<T, Abi>::size(); }
60 static constexpr
size_t Size = VectorTraits<T, Abi>::size();
66 static constexpr
size_t MemoryAlignment = VectorTraits<T, Abi>::maskMemoryAlignment();
93 using VectorType =
typename VectorTraits<T, Abi>::VectorType;
97 using vector_type = VectorType;
139 Vc_INTRINSIC
explicit Mask(VectorSpecialInitializerZero);
143 Vc_INTRINSIC
explicit Mask(VectorSpecialInitializerOne);
155 Vc_INTRINSIC
explicit Mask(
bool b);
163 template <
typename U>
164 Vc_INTRINSIC
Mask(U &&otherMask,
165 Common::enable_if_mask_converts_implicitly<Mask, T, U> = nullarg);
176 template <
typename U>
178 "use simd_cast instead of explicit type casting to convert between mask types")
180 explicit
Mask(U &&otherMask, Common::enable_if_mask_converts_explicitly<T, U> =
181 nullarg) Vc_INTRINSIC_R;
198 Vc_ALWAYS_INLINE
explicit Mask(
const bool *mem);
207 template <
typename Flags> Vc_ALWAYS_INLINE
explicit Mask(
const bool *mem, Flags flags);
215 Vc_ALWAYS_INLINE
void load(
const bool *mem);
224 template <
typename Flags> Vc_ALWAYS_INLINE
void load(
const bool *mem, Flags flags);
232 Vc_ALWAYS_INLINE
void store(
bool *mem)
const;
240 template <
typename Flags> Vc_ALWAYS_INLINE
void store(
bool *mem, Flags flags)
const;
317 Vc_ALWAYS_INLINE
bool isMix()
const;
323 Vc_ALWAYS_INLINE
bool data()
const;
325 Vc_ALWAYS_INLINE
bool dataI()
const;
326 Vc_ALWAYS_INLINE
bool dataD()
const;
382 Vc_FREE_STORE_OPERATORS_ALIGNED(
alignof(
Mask));
397 template<
typename Mask> constexpr
bool all_of(
const Mask &m) {
return m.isFull(); }
401 constexpr
bool all_of(
bool b) {
return b; }
406 template<
typename Mask> constexpr
bool any_of(
const Mask &m) {
return m.isNotEmpty(); }
410 constexpr
bool any_of(
bool b) {
return b; }
415 template<
typename Mask> constexpr
bool none_of(
const Mask &m) {
return m.isEmpty(); }
425 template<
typename Mask> constexpr
bool some_of(
const Mask &m) {
return m.isMix(); }
429 constexpr
bool some_of(
bool) {
return false; }
433 #endif // VC_COMMON_MASK_H_
constexpr bool any_of(bool b)
Mask(const bool *mem)
Load constructor from an array of bool.
EntryType value_type
The EntryType of masks is always bool, independent of T.
bool isEmpty() const
Returns true if components are false, false otherwise.
bool isNotEmpty() const
Returns a logical OR of all components.
constexpr std::size_t MemoryAlignment
bool isFull() const
Returns a logical AND of all components.
Mask & operator^=(const Mask &mask)
Modifies the mask using an XOR operation with mask.
int firstOne() const
Returns the index of the first one in the mask.
constexpr bool none_of(bool b)
Mask()=default
Construct a zero-initialized vector object.
Mask operator|(const Mask &mask) const
Returns the component-wise application of a binary OR to mask.
bool operator==(const Mask &mask) const
Returns whether the two masks are equal in all components.
bool isMix() const
Returns !isFull() && !isEmpty().
Mask(const bool *mem, Flags flags)
Overload of the above with a load/store flag argument.
Mask(bool b)
Broadcast constructor.
Mask(VectorSpecialInitializerOne)
Initialize the new mask object to one (true).
void load(const bool *mem)
Load the components of the mask from an array of bool.
EntryReference operator[](size_t index)
Lvalue-reference-like access to mask entries.
Mask operator||(const Mask &mask) const
Returns the component-wise application of a logical OR to mask.
EntryReference value_reference
The reference wrapper type used for accessing individual mask components.
typename VectorTraits< T, Abi >::VectorEntryType VectorEntryType
The VectorEntryType, in contrast to EntryType, reveals information about the SIMD implementation.
void load(const bool *mem, Flags flags)
Overload of the above with a load/store flag argument.
typename VectorTraits< T, Abi >::EntryReference EntryReference
The reference wrapper type used for accessing individual mask components.
static Mask One()
Creates a mask object initialized to one/true.
Mask operator^(const Mask &mask) const
Returns the component-wise application of a binary XOR to mask.
int count() const
Returns how many components of the mask are true.
int toInt() const
Convert the boolean components of the mask into bits of an integer.
EntryType operator[](size_t index) const
Read-only access to mask entries.
Mask operator&&(const Mask &mask) const
Returns the component-wise application of a logical AND to mask.
Mask operator&(const Mask &mask) const
Returns the component-wise application of a binary AND to mask.
constexpr bool all_of(bool b)
void store(bool *mem, Flags flags) const
Overload of the above with a load/store flag argument.
Mask shifted(int amount) const
Returns a mask with components shifted by amount places.
Mask operator!() const
Returns a mask with inverted components.
static constexpr size_t size()
Returns the number of boolean components ( ) in a mask of this type.
static Mask Zero()
Creates a new mask object initialized to zero/false.
bool EntryType
The EntryType of masks is always bool, independent of T.
constexpr bool some_of(bool)
static Mask generate(G &&gen)
Generate a mask object from booleans returned from the function gen.
Mask & operator&=(const Mask &mask)
Modifies the mask using an AND operation with mask.
Mask(VectorSpecialInitializerZero)
Zero-initialize the new mask object (false).
Abi abi
The ABI tag type of the current template instantiation.
Mask(U &&otherMask, Common::enable_if_mask_converts_implicitly< Mask, T, U >=nullarg)
Implicit conversion from a compatible (equal on every platform) mask object.
bool operator!=(const Mask &mask) const
Returns whether the two masks are different in at least one component.
Mask & operator|=(const Mask &mask)
Modifies the mask using an OR operation with mask.
void store(bool *mem) const
Store the values of the mask to an array of bool.