Vc
1.3.2-dev
SIMD Vector Classes for C++
|
|
The main SIMD mask class.
#include <Vc/vector.h>
Public Types | |
using | abi = Abi |
The ABI tag type of the current template instantiation. | |
using | EntryType = bool |
The EntryType of masks is always bool , independent of T . | |
using | value_type = EntryType |
The EntryType of masks is always bool , independent of T . More... | |
using | EntryReference = typename VectorTraits< T, Abi >::EntryReference |
The reference wrapper type used for accessing individual mask components. | |
using | value_reference = EntryReference |
The reference wrapper type used for accessing individual mask components. More... | |
using | VectorEntryType = typename VectorTraits< T, Abi >::VectorEntryType |
The VectorEntryType , in contrast to EntryType , reveals information about the SIMD implementation. More... | |
Public Member Functions | |
int | count () const |
Returns how many components of the mask are true . | |
int | firstOne () const |
Returns the index of the first one in the mask. More... | |
int | toInt () const |
Convert the boolean components of the mask into bits of an integer. More... | |
Mask | shifted (int amount) const |
Returns a mask with components shifted by amount places. | |
Compile-Time Constant Initialization | |
Mask ()=default | |
Construct a zero-initialized vector object. More... | |
Mask (VectorSpecialInitializerZero) | |
Zero-initialize the new mask object (false ). More... | |
Mask (VectorSpecialInitializerOne) | |
Initialize the new mask object to one (true ). More... | |
Conversion/Broadcast Constructors | |
Mask (bool b) | |
Broadcast constructor. More... | |
template<typename U > | |
Mask (U &&otherMask, Common::enable_if_mask_converts_implicitly< T, U >=nullarg) | |
Implicit conversion from a compatible (equal \(\mathcal{W}_\mathtt{T}\) on every platform) mask object. More... | |
Loads & Stores | |
Mask (const bool *mem) | |
Load constructor from an array of bool . More... | |
template<typename Flags > | |
Mask (const bool *mem, Flags flags) | |
Overload of the above with a load/store flag argument. More... | |
void | load (const bool *mem) |
Load the components of the mask from an array of bool . More... | |
template<typename Flags > | |
void | load (const bool *mem, Flags flags) |
Overload of the above with a load/store flag argument. More... | |
void | store (bool *mem) const |
Store the values of the mask to an array of bool . More... | |
template<typename Flags > | |
void | store (bool *mem, Flags flags) const |
Overload of the above with a load/store flag argument. More... | |
Comparison Operators | |
bool | operator== (const Mask &mask) const |
Returns whether the two masks are equal in all components. More... | |
bool | operator!= (const Mask &mask) const |
Returns whether the two masks are different in at least one component. More... | |
Logical and Binary Operators | |
Component-wise logical/binary operations on mask objects. The effect of logical and binary | |
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 . | |
Mask | operator|| (const Mask &mask) const |
Returns the component-wise application of a logical OR to mask . | |
Mask | operator| (const Mask &mask) const |
Returns the component-wise application of a binary OR to mask . | |
Mask | operator^ (const Mask &mask) const |
Returns the component-wise application of a binary XOR to mask . | |
Mask | operator! () const |
Returns a mask with inverted components. | |
Mask & | operator&= (const Mask &mask) |
Modifies the mask using an AND operation with mask . | |
Mask & | operator|= (const Mask &mask) |
Modifies the mask using an OR operation with mask . | |
Mask & | operator^= (const Mask &mask) |
Modifies the mask using an XOR operation with mask . | |
Reductions | |
bool | isFull () const |
Returns a logical AND of all components. | |
bool | isNotEmpty () const |
Returns a logical OR of all components. | |
bool | isEmpty () const |
Returns true if components are false , false otherwise. | |
bool | isMix () const |
Returns !isFull() && !isEmpty() . | |
Scalar Subscript Operators | |
EntryReference | operator[] (size_t index) |
Lvalue-reference-like access to mask entries. More... | |
EntryType | operator[] (size_t index) const |
Read-only access to mask entries. More... | |
new/delete overloads for correct alignment | |
void * | operator new (size_t size) |
Allocates correctly aligned memory. | |
void * | operator new (size_t, void *p) |
Returns p . | |
void * | operator new[] (size_t size) |
Allocates correctly aligned memory. | |
void * | operator new[] (size_t, void *p) |
Returns p . | |
void | operator delete (void *ptr, size_t) |
Frees aligned memory. | |
void | operator delete (void *, void *) |
Does nothing. | |
void | operator delete[] (void *ptr, size_t) |
Frees aligned memory. | |
void | operator delete[] (void *, void *) |
Does nothing. | |
Static Public Member Functions | |
static constexpr size_t | size () |
Returns the number of boolean components ( \(\mathcal{W}_\mathtt{T}\)) in a mask of this type. More... | |
Generators | |
static Mask | Zero () |
Creates a new mask object initialized to zero/false . More... | |
static Mask | One () |
Creates a mask object initialized to one/true . More... | |
template<typename G > | |
static Mask | generate (G &&gen) |
Generate a mask object from booleans returned from the function gen . | |
Static Public Attributes | |
static constexpr size_t | Size = VectorTraits<T, Abi>::size() |
Returns the number of boolean components ( \(\mathcal{W}_\mathtt{T}\)) in a mask of this type. More... | |
static constexpr size_t | MemoryAlignment = VectorTraits<T, Abi>::maskMemoryAlignment() |
Specifies the alignment requirement for aligned load and store calls for objects of this mask type. | |
using value_type = EntryType |
using value_reference = EntryReference |
using VectorEntryType = typename VectorTraits<T, Abi>::VectorEntryType |
|
inlinedefault |
Construct a zero-initialized vector object.
This constructor follows the behavior of the underlying bool
type in that the expression bool()
zero-initializes the object (to false
). On the other hand the variable x
in bool x;
is uninitialized. Since, for class types, both expressions call the default constructor Mask<T> x
must zero-initialize x
as well.
|
inlineexplicit |
|
inlineexplicit |
|
inlineexplicit |
Broadcast constructor.
Set all components of the new mask object to b
.
b | Determines the initial state of the mask. |
|
inline |
Implicit conversion from a compatible (equal \(\mathcal{W}_\mathtt{T}\) on every platform) mask object.
otherMask | The mask to be converted. |
|
inlineexplicit |
Load constructor from an array of bool
.
This constructor implements an explicit conversion from an array of booleans to a mask object. It corresponds to a Vector load constructor.
mem | A pointer to the start of the array of booleans. |
|
inlineexplicit |
Overload of the above with a load/store flag argument.
mem | A pointer to the start of the array of booleans. |
flags | Choose a combination of flags such as Vc::Aligned, Vc::Streaming, Vc::Unaligned, Vc::PrefetchDefault, ... |
|
inlinestatic |
Returns the number of boolean components ( \(\mathcal{W}_\mathtt{T}\)) in a mask of this type.
The size of the mask. I.e. the number of boolean entries in the mask. Do not make any assumptions about the size of masks.
In addition, you can easily use if clauses that compare sizes. The compiler can statically evaluate and fully optimize dead code away (very much like #ifdef, but with syntax checking).
|
inlinestatic |
Creates a new mask object initialized to zero/false
.
|
inlinestatic |
Creates a mask object initialized to one/true
.
true
.
|
inline |
Load the components of the mask from an array of bool
.
mem | A pointer to the start of the array of booleans. |
|
inline |
Overload of the above with a load/store flag argument.
mem | A pointer to the start of the array of booleans. |
flags | Choose a combination of flags such as Vc::Aligned, Vc::Streaming, Vc::Unaligned, Vc::PrefetchDefault, ... |
|
inline |
Store the values of the mask to an array of bool
.
mem | A pointer to the start of the array of booleans. |
|
inline |
Overload of the above with a load/store flag argument.
mem | A pointer to the start of the array of booleans. |
flags | Choose a combination of flags such as Vc::Aligned, Vc::Streaming, Vc::Unaligned, Vc::PrefetchDefault, ... |
|
inline |
Returns whether the two masks are equal in all components.
mask | The other mask to compare against. |
a == b
return the same as a ^ b
. In general, it is more useful to query all_of(a ^ b)
which is the same as this equality operator. Returns whether the two masks are different in at least one component.
mask | The other mask to compare against. |
(a == b) == !(a != b)
holds
|
inline |
Lvalue-reference-like access to mask entries.
index | Determines the boolean to be accessed. |
index
th entry of the mask.bool
), but rather a temporary (rvalue) object that mimics an lvalue reference (as much as is possible with C++11/14).
|
inline |
Read-only access to mask entries.
index | Determines the boolean to be accessed. |
index
th entry of the mask as a bool
(rvalue).const bool
), but rather a temporary (rvalue) bool
.
|
inline |
Returns the index of the first one in the mask.
true
.Thus, unless none_of(mask)
, mask[mask.firstOne()] == true
holds and mask[i] == false
for all i < mask.firstOne()
.
|
inline |
Convert the boolean components of the mask into bits of an integer.
int
where each bit corresponds to the boolean value in the mask.For example, the mask [true, false, false, true]
results in a 9
(in binary: 1001
).
|
static |
Returns the number of boolean components ( \(\mathcal{W}_\mathtt{T}\)) in a mask of this type.
The size of the mask. I.e. the number of boolean entries in the mask. Do not make any assumptions about the size of masks.
In addition, you can easily use if clauses that compare sizes. The compiler can statically evaluate and fully optimize dead code away (very much like #ifdef, but with syntax checking).