Skip to main content

SimdMask

Trait SimdMask 

Source
pub trait SimdMask<S: Simd>:
    Copy
    + Sync
    + Send
    + 'static
    + Seal
    + Select<Self>
    + BitAnd<Output = Self>
    + BitAndAssign
    + BitOr<Output = Self>
    + BitOrAssign
    + BitXor<Output = Self>
    + BitXorAssign
    + Not<Output = Self> {
    type Element: SimdElement;

    const N: usize;
Show 13 methods // Required methods fn witness(&self) -> S; fn splat(simd: S, val: bool) -> Self; fn from_bitmask(simd: S, bits: u64) -> Self; fn to_bitmask(self) -> u64; fn set(&mut self, index: usize, value: bool); fn from_slice(simd: S, slice: &[Self::Element]) -> Self; fn store_slice(&self, slice: &mut [Self::Element]); fn simd_eq(self, rhs: impl SimdInto<Self, S>) -> Self; fn any_true(self) -> bool; fn all_true(self) -> bool; fn any_false(self) -> bool; fn all_false(self) -> bool; // Provided method fn test(&self, index: usize) -> bool { ... }
}
Expand description

Functionality implemented by SIMD masks.

A mask has one logical boolean lane per SIMD lane. Its storage is intentionally opaque: current backends may use all-zero/all-one integer vectors internally, while future predicate-register backends may use a compact representation.

Required Associated Constants§

Source

const N: usize

This mask type’s lane count.

Required Associated Types§

Source

type Element: SimdElement

The signed integer type used when converting this mask to and from lane values.

False lanes are encoded as all zeroes (integer value 0), and true lanes are encoded as all ones (integer value -1).

Required Methods§

Source

fn witness(&self) -> S

Get the Simd implementation associated with this type.

Source

fn splat(simd: S, val: bool) -> Self

Create a SIMD mask with all lanes set to the given boolean value.

Source

fn from_bitmask(simd: S, bits: u64) -> Self

Create a mask from a compact bitmask.

Bit i maps to lane i, with lane 0 in the least significant bit. Bits above Self::N are ignored.

Source

fn to_bitmask(self) -> u64

Convert this mask to a compact bitmask.

Bit i maps to lane i, with lane 0 in the least significant bit. Bits above Self::N are cleared.

Source

fn set(&mut self, index: usize, value: bool)

Sets the value of one logical lane.

Panics if index is greater than or equal to the number of lanes in the mask.

Source

fn from_slice(simd: S, slice: &[Self::Element]) -> Self

Create a SIMD mask from signed integer mask lanes.

The slice must be exactly the size of the SIMD mask.

Source

fn store_slice(&self, slice: &mut [Self::Element])

Store this SIMD mask as signed integer mask lanes.

The slice must be exactly the size of the SIMD mask.

Source

fn simd_eq(self, rhs: impl SimdInto<Self, S>) -> Self

Compare two vectors element-wise for equality.

Returns a mask where each logical lane is true if the corresponding elements are equal, and false if not.

Source

fn any_true(self) -> bool

Returns true if any logical lanes in this mask are true.

Masks may be converted to and from signed integer lane arrays for compatibility with older APIs. For those conversions, false is encoded as all zeroes (integer value 0) and true is encoded as all ones (integer value -1).

Behavior on masks constructed from any other integer bit pattern is unspecified. It may vary depending on architecture, feature level, the mask elements’ width, the mask vector’s width, or library version.

The behavior is also not guaranteed to be logically consistent for such non-canonical masks. any_true may not return the same result as !all_false, and all_true may not return the same result as !any_false.

The select operation also has unspecified behavior for non-canonical masks. That behavior may not match the behavior of this operation.

Source

fn all_true(self) -> bool

Returns true if all logical lanes in this mask are true.

Masks may be converted to and from signed integer lane arrays for compatibility with older APIs. For those conversions, false is encoded as all zeroes (integer value 0) and true is encoded as all ones (integer value -1).

Behavior on masks constructed from any other integer bit pattern is unspecified. It may vary depending on architecture, feature level, the mask elements’ width, the mask vector’s width, or library version.

The behavior is also not guaranteed to be logically consistent for such non-canonical masks. any_true may not return the same result as !all_false, and all_true may not return the same result as !any_false.

The select operation also has unspecified behavior for non-canonical masks. That behavior may not match the behavior of this operation.

Source

fn any_false(self) -> bool

Returns true if any logical lanes in this mask are false.

This is logically equivalent to !all_true, but may be faster.

Masks may be converted to and from signed integer lane arrays for compatibility with older APIs. For those conversions, false is encoded as all zeroes (integer value 0) and true is encoded as all ones (integer value -1).

Behavior on masks constructed from any other integer bit pattern is unspecified. It may vary depending on architecture, feature level, the mask elements’ width, the mask vector’s width, or library version.

The behavior is also not guaranteed to be logically consistent for such non-canonical masks. any_true may not return the same result as !all_false, and all_true may not return the same result as !any_false.

The select operation also has unspecified behavior for non-canonical masks. That behavior may not match the behavior of this operation.

Source

fn all_false(self) -> bool

Returns true if all logical lanes in this mask are false.

This is logically equivalent to !any_true, but may be faster.

Masks may be converted to and from signed integer lane arrays for compatibility with older APIs. For those conversions, false is encoded as all zeroes (integer value 0) and true is encoded as all ones (integer value -1).

Behavior on masks constructed from any other integer bit pattern is unspecified. It may vary depending on architecture, feature level, the mask elements’ width, the mask vector’s width, or library version.

The behavior is also not guaranteed to be logically consistent for such non-canonical masks. any_true may not return the same result as !all_false, and all_true may not return the same result as !any_false.

The select operation also has unspecified behavior for non-canonical masks. That behavior may not match the behavior of this operation.

Provided Methods§

Source

fn test(&self, index: usize) -> bool

Test whether one logical lane is set.

Panics if index is greater than or equal to the number of lanes in the mask.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<S: Simd> SimdMask<S> for mask8x16<S>

Source§

const N: usize = 16

Source§

type Element = i8

Source§

impl<S: Simd> SimdMask<S> for mask8x32<S>

Source§

const N: usize = 32

Source§

type Element = i8

Source§

impl<S: Simd> SimdMask<S> for mask8x64<S>

Source§

const N: usize = 64

Source§

type Element = i8

Source§

impl<S: Simd> SimdMask<S> for mask16x8<S>

Source§

impl<S: Simd> SimdMask<S> for mask16x16<S>

Source§

impl<S: Simd> SimdMask<S> for mask16x32<S>

Source§

impl<S: Simd> SimdMask<S> for mask32x4<S>

Source§

impl<S: Simd> SimdMask<S> for mask32x8<S>

Source§

impl<S: Simd> SimdMask<S> for mask32x16<S>

Source§

impl<S: Simd> SimdMask<S> for mask64x2<S>

Source§

impl<S: Simd> SimdMask<S> for mask64x4<S>

Source§

impl<S: Simd> SimdMask<S> for mask64x8<S>