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§
Required Associated Types§
Sourcetype Element: SimdElement
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§
Sourcefn splat(simd: S, val: bool) -> Self
fn splat(simd: S, val: bool) -> Self
Create a SIMD mask with all lanes set to the given boolean value.
Sourcefn from_bitmask(simd: S, bits: u64) -> Self
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.
Sourcefn to_bitmask(self) -> u64
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.
Sourcefn set(&mut self, index: usize, value: bool)
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.
Sourcefn from_slice(simd: S, slice: &[Self::Element]) -> Self
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.
Sourcefn store_slice(&self, slice: &mut [Self::Element])
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.
Sourcefn simd_eq(self, rhs: impl SimdInto<Self, S>) -> Self
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.
Sourcefn any_true(self) -> bool
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.
Sourcefn all_true(self) -> bool
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.
Sourcefn any_false(self) -> bool
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.
Sourcefn all_false(self) -> bool
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§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".