Vc
1.3.2-dev
SIMD Vector Classes for C++
|
|
Data-parallel mask type with user-defined number of boolean elements.
T | The value type of the corresponding SimdArray. Depending on the target platform this type determines a different bit representation to work most efficient with SimdArray types instantiated for T . |
N | The number of boolean elements to store and process concurrently. You can choose an arbitrary number, though not every number is a good idea. Generally, a power of two value or the sum of two power of two values might work efficiently, though this depends a lot on the target system. |
V | Don't change the default value unless you really know what you are doing. This type is set to the underlying native Vc::Vector type used in the implementation of the type. Having it as part of the type name guards against some cases of ODR violations (i.e. linking incompatible translation units / libraries). |
Wt | Don't ever change the default value. This parameter is an unfortunate implementation detail shining through. |
Definition at line 121 of file simdarrayfwd.h.
#include <Vc/SimdArray>
Public Types | |
using | value_type = typename storage_type0::EntryType |
The EntryType of masks is always bool , independent of T . More... | |
using | MaskType = mask_type |
Construct a zero-initialized vector object. More... | |
using | VectorEntryType = vectorentry_type |
The VectorEntryType , in contrast to EntryType , reveals information about the SIMD implementation. More... | |
using | EntryType = value_type |
The EntryType of masks is always bool , independent of T . More... | |
using | EntryReference = Vc::Detail::ElementReference< SimdMaskArray > |
The reference wrapper type used for accessing individual mask components. More... | |
using | Vector = SimdArray< T, N, V, V::Size > |
An alias for the corresponding SimdArray type. | |
Public Member Functions | |
SimdMaskArray ()=default | |
Construct a zero-initialized vector object. More... | |
SimdMaskArray (VectorSpecialInitializerOne one) | |
Initialize the new mask object to one (true ). | |
SimdMaskArray (VectorSpecialInitializerZero zero) | |
Zero-initialize the new mask object (false ). | |
SimdMaskArray (bool b) | |
Broadcast constructor. More... | |
bool | operator== (const SimdMaskArray &mask) const |
Returns whether the two masks are equal in all components. More... | |
bool | operator!= (const SimdMaskArray &mask) const |
Returns whether the two masks are different in at least one component. More... | |
SimdMaskArray | operator! () const |
Returns a mask with inverted components. | |
SimdMaskArray & | operator&= (const SimdMaskArray &rhs) |
Modifies the mask using an AND operation with mask . | |
SimdMaskArray & | operator|= (const SimdMaskArray &rhs) |
Modifies the mask using an OR operation with mask . | |
SimdMaskArray & | operator^= (const SimdMaskArray &rhs) |
Modifies the mask using an XOR operation with mask . | |
SimdMaskArray | operator& (const SimdMaskArray &rhs) const |
Returns the component-wise application of a binary AND to mask . | |
SimdMaskArray | operator| (const SimdMaskArray &rhs) const |
Returns the component-wise application of a binary OR to mask . | |
SimdMaskArray | operator^ (const SimdMaskArray &rhs) const |
Returns the component-wise application of a binary XOR to mask . | |
SimdMaskArray | operator&& (const SimdMaskArray &rhs) const |
Returns the component-wise application of a logical AND to mask . | |
SimdMaskArray | operator|| (const SimdMaskArray &rhs) const |
Returns the component-wise application of a logical OR to mask . | |
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() . | |
int | toInt () const |
Convert the boolean components of the mask into bits of an integer. More... | |
reference | operator[] (size_t index) noexcept |
Return a smart reference to the boolean element at index index . More... | |
value_type | operator[] (size_t index) const noexcept |
Return a copy of the boolean element at index index . More... | |
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... | |
SimdMaskArray | shifted (int amount) const |
Returns a mask with components shifted by amount places. | |
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. | |
Loads & Stores | |
template<typename Flags = DefaultLoadTag> | |
SimdMaskArray (const bool *mem, Flags f=Flags()) | |
Load N boolean values from the consecutive addresses starting at mem . More... | |
void | load (const bool *mem) |
Load N boolean values from the consecutive addresses starting at mem . More... | |
template<typename Flags > | |
void | load (const bool *mem, Flags f) |
Load N boolean values from the consecutive addresses starting at mem . More... | |
void | store (bool *mem) const |
Store N boolean values to the consecutive addresses starting at mem . More... | |
template<typename Flags > | |
void | store (bool *mem, Flags f) const |
Store N boolean values to the consecutive addresses starting at mem . More... | |
Static Public Member Functions | |
static constexpr std::size_t | size () |
Returns the number of boolean components ( \(\mathcal{W}_\mathtt{T}\)) in a mask of this type. More... | |
static SimdMaskArray | Zero () |
Creates a new mask object initialized to zero/false . More... | |
static SimdMaskArray | One () |
Creates a mask object initialized to one/true . More... | |
template<typename G > | |
static SimdMaskArray | generate (const G &gen) |
Generate a mask object from booleans returned from the function gen . | |
Static Public Attributes | |
static constexpr std::size_t | Size = size() |
Returns the number of boolean components ( \(\mathcal{W}_\mathtt{T}\)) in a mask of this type. More... | |
static constexpr std::size_t | MemoryAlignment |
Specifies the alignment requirement for aligned load and store calls for objects of this mask type. More... | |
using value_type = typename storage_type0::EntryType |
The EntryType
of masks is always bool
, independent of T
.
Definition at line 340 of file simdmaskarray.h.
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.
Definition at line 342 of file simdmaskarray.h.
using VectorEntryType = vectorentry_type |
The VectorEntryType
, in contrast to EntryType
, reveals information about the SIMD implementation.
This type is useful for the sizeof
operator in generic functions.
Definition at line 344 of file simdmaskarray.h.
using EntryType = value_type |
The EntryType
of masks is always bool
, independent of T
.
Definition at line 346 of file simdmaskarray.h.
using EntryReference = Vc::Detail::ElementReference<SimdMaskArray> |
The reference wrapper type used for accessing individual mask components.
Definition at line 348 of file simdmaskarray.h.
|
default |
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 |
Broadcast constructor.
Set all components of the new mask object to b
.
b | Determines the initial state of the mask. |
Definition at line 409 of file simdmaskarray.h.
|
inlineexplicit |
Load N boolean values from the consecutive addresses starting at mem
.
mem | A pointer to an array of booleans. |
f | A combination of flags to modify specific behavior of the load. |
Definition at line 426 of file simdmaskarray.h.
|
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).
Definition at line 326 of file simdmaskarray.h.
|
inlinestatic |
Creates a new mask object initialized to zero/false
.
Definition at line 412 of file simdmaskarray.h.
|
inlinestatic |
Creates a mask object initialized to one/true
.
true
. Definition at line 414 of file simdmaskarray.h.
|
inline |
Load N boolean values from the consecutive addresses starting at mem
.
mem | A pointer to an array of booleans. |
Definition at line 436 of file simdmaskarray.h.
|
inline |
Load N boolean values from the consecutive addresses starting at mem
.
mem | A pointer to an array of booleans. |
f | A combination of flags to modify specific behavior of the load. |
Definition at line 448 of file simdmaskarray.h.
|
inline |
Store N boolean values to the consecutive addresses starting at mem
.
mem | A pointer to an array of booleans. |
Definition at line 459 of file simdmaskarray.h.
|
inline |
Store N boolean values to the consecutive addresses starting at mem
.
mem | A pointer to an array of booleans. |
f | A combination of flags to modify specific behavior of the load. |
Definition at line 471 of file simdmaskarray.h.
|
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. Definition at line 479 of file simdmaskarray.h.
|
inline |
Returns whether the two masks are different in at least one component.
mask | The other mask to compare against. |
(a == b) == !(a != b)
holds Definition at line 484 of file simdmaskarray.h.
|
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
).
Definition at line 554 of file simdmaskarray.h.
|
inlinenoexcept |
Return a smart reference to the boolean element at index index
.
index | The element index to be accessed. |
Definition at line 590 of file simdmaskarray.h.
|
inlinenoexcept |
Return a copy of the boolean element at index index
.
index | The element index to be accessed. |
index
. Definition at line 602 of file simdmaskarray.h.
|
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()
.
Definition at line 611 of file simdmaskarray.h.