simdpp::mask_int32<N,void>

From libsimdpp-docs
template< unsigned N >
class mask_int32<N,void> : public any_int32<N, mask_int32<N,void> >;

Defines a integer mask type with N elements. Each element defines a boolean value - either 0 or 1. The mask can be used to select elements within uint32, int32 or float32 vectors.

The physical representation of the mask vector depends on the selected instruction set. Some instruction sets have efficient mask representation where each element only takes 1 bit of space. On other platforms the mask is a uint32 with elements whose bits are either all zeroes or all ones depending on the value of the mask.

This is a template specialization for the parameter Expr being void. It corresponds to a physical vector data as opposed to a vector expression. See this page for documentation of operations available on vector expressions.

If N corresponds to a register size supported on current instruction set then the type wraps a native register and provides APIs to access underlying type provided by compiler SIMD intrinsics.

Template parameters[edit]

N - the number of elements in the vector

Member types[edit]

Member type Definition
expr_type void
native_type Instruction-set and compiler specific type corresponding to a single register.
(Provided only if the vector type wraps native register)

Member functions[edit]

(constructor)
constructor
(public member function)
operator=
assigns data to vector
(public member function)
vec
returns a base vector corresponding to native register
(public member function)
eval
evaluates vector expression. Simply returns *this
(public member function)
native
returns wrapped SIMD type
(Provided only if the vector type wraps native register)
(public member function)
operator native_type
returns wrapped SIMD type
(deprecated since v2.1)
(public member function)

simdpp::mask_int32::mask_int32

mask_int32<N>( ) = default;
(1)
mask_int32<N>( const mask_int32<N>& other ) = default;
(2)
template< class E >
mask_int32<N>( const mask_int32<N,E>& other );
(3)
template< class V >
explicit mask_int32<N>( const uint32<N>& other );
(4) (provided only if uint32 is used as physical storage)
(deprecated since v2.1)
mask_int32<N>( const native_type& n );
(5) (Provided only if the vector type wraps native register)

Constructs the mask vector object.

(1) Default constructor is default.
(2) Copy constructor is default.
(3) The vector can be constructed from a vector expression evaluating it.
(4) The vector can be constructed from uint32 if it is used as physical storage (i.e. the instruction set does not provide efficient mask type). This function is deprecated, use to_mask()} as a replacement.
(5) The vector can be constructed from a native SIMD type if it corresponds to one.

Parameters

other - another vector to construct from
e - a value returned by either of splat, make_int, make_uint, make_float functions
n - native SIMD type to construct from

simdpp::mask_int32::operator=

mask_int32<N>& operator=( const mask_int32<N>& other ) = default;

Assigns data to vector object. Copy assignment operator is default.

Parameters

other - another vector to assign data from

Return value

*this

simdpp::mask_int32::vec

const mask_int32<W>& vec( unsigned index ) const;
mask_int32<W>& vec( unsigned index );

Returns a base vector corresponding to a native register of width W. W might be less than N or equal to it. For example, on AVX mask_int32<8> corresponds to two native __m128i values; vec(0) will return the lower half, whereas vec(1) will return the higher.

If mask_int32<N> itself corresponds to native register, returns *this regardless of index.

Parameters

index - the index of the subvector to return

Return value

A base vector corresponding to a native register.

simdpp::mask_int32::eval

mask_int32<N> eval() const;

Evaluates vector expression. Types with Expr parameter being void corresponds to physical data already, thus evaluation is a nop and returns *this.

Parameters

(none)

Return value

*this

simdpp::mask_int32::native

native_type native() const;
(Provided only if the vector type wraps native register)

Returns the wrapped native SIMD type.

Parameters

(none)

Return value

Wrapped SIMD type.

simdpp::mask_int32::operator native_type(deprecated since v2.1)

native_type operator native_type() const;
(Provided only if the vector type wraps native register)

Returns the wrapped native SIMD type.

This API has been deprecated because Clang supports native vector extension which interferes with simdpp types and allows wrong code being allowed to be compiled.

The native vector extension defines operators between vector types. SSE types such as __m128 and __m128i are implemented on top of this extension, which causes code like this being possible:

__m128i a, b; a = a + b;

Having an implicit conversion operator to vector types allows types such as uint8<16> and uint16<8> to be implicitly converted to __m128i. This leads to code like this being accepted on clang.

uint8<16> a;
uint16<8> b;
a = a + b;

Here, both a and b are implicitly converted to __m128i values and they are added using an operator provided by the clang vector extension. Unexpectedly, the result is paddq instruction (64-bit integer addition).

Because of this, the implicit native vector type conversion operators are deprecated and a native() method is provided as a replacement. This change only affects code that interacts with native intrinsics. Altivec/VSX and MSA are affected only slightly, because intrinsics of those instruction sets never accepted implicit conversions from libsimdpp types.

Parameters

(none)

Return value

Wrapped SIMD type.

Inherited from simdpp::any_int32<N,V>

Member types

Member type Definition
uint_element_type uint32_t
int_vector_type int32<N>
uint_vector_type uint32<N>
mask_vector_type mask_int32<N>

Member constants

Member constant Value
length N
base_length SIMDPP_FAST_INT32_SIZE
vec_length The number of base vectors of SIMDPP_FAST_INT32_SIZE size in this vector
num_bits 32
all_bits 0xffffffff

Inherited from simdpp::any_vec32<N,V>

Member constants

Member constant Value
size_tag SIMDPP_TAG_SIZE32

Inherited from simdpp::any_vec<B,V>

Member types

Member type Definition
type V

Member constants

Member constant Value
length_bytes B

Member functions

wrapped
returns the wrapped type
(public member function)

simdpp::any_vec::wrapped

V& wrapped();
const V& wrapped() const;

Returns the wrapped type. Effectively the same as static_cast<V&>(*this) or static_cast<const V&>(*this) respectively.