#[non_exhaustive]#[repr(u8)]pub enum InstructionSet {
Scalar = 0,
Unknown = 1,
X86V1 = 2,
X86V2 = 3,
X86V3 = 4,
X86V4 = 5,
}Expand description
Enum of supported instruction sets
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Scalar = 0
Scalar (no SIMD)
Unknown = 1
Unknown ISA, usually the result of register emulation, such as with Glam vectors as registers.
X86V1 = 2
x86/x86_64 SIMD instruction set level 1 (SSE2)
X86V2 = 3
x86/x86_64 SIMD instruction set level 2 (SSE4.2 + POPCNT)
X86V3 = 4
x86/x86_64 SIMD instruction set level 3 (AVX2 + FMA)
X86V4 = 5
x86/x86_64 SIMD instruction set level 4 (AVX-512F)
Implementations§
Source§impl InstructionSet
impl InstructionSet
Sourcepub fn get() -> InstructionSet
Available on x86 or x86-64 only.
pub fn get() -> InstructionSet
Detect the current instruction set at runtime. This result is cached for future calls.
Sourcepub const fn min(a: InstructionSet, b: InstructionSet) -> InstructionSet
pub const fn min(a: InstructionSet, b: InstructionSet) -> InstructionSet
Order two sets by capability, returning the weaker.
Ordering is the enum’s declaration order, which ascends by capability
within an architecture (Scalar < X86V1 < .. < X86V4). Across
architectures it is meaningless, but two architectures’ variants never
coexist, since each is cfg-gated to its own target.
Sourcepub const fn max(a: InstructionSet, b: InstructionSet) -> InstructionSet
pub const fn max(a: InstructionSet, b: InstructionSet) -> InstructionSet
Order two sets by capability, returning the stronger. See min.
Sourcepub const fn assert_eq(a: InstructionSet, b: InstructionSet) -> InstructionSet
pub const fn assert_eq(a: InstructionSet, b: InstructionSet) -> InstructionSet
Assert two sets are the same, returning it. Compares discriminants
because PartialEq is not callable in a const fn.
Sourcepub const fn has_instruction_level_parallelism(self) -> bool
pub const fn has_instruction_level_parallelism(self) -> bool
Whether the target executes independent instructions in parallel, so that breaking a dependency chain into several accumulators pays off.
A property of the hardware, not of the instruction set: a superscalar CPU reorders scalar code just as happily as SIMD code, so this does not vary by variant. SIMT targets (SPIR-V) hide latency with occupancy instead and gain nothing from extra accumulators.
Source§impl InstructionSet
impl InstructionSet
Sourcepub const fn num_registers(self) -> usize
pub const fn num_registers(self) -> usize
Estimate of how many SIMD registers the ISA exposes. Used by
inlining/unrolling heuristics. See also NativeIsa::Registers,
the type-level equivalent.
Sourcepub const fn has_fma(self) -> bool
pub const fn has_fma(self) -> bool
Whether the ISA has a true fused multiply-add (one rounding).
Sourcepub const fn is_simd(self) -> bool
pub const fn is_simd(self) -> bool
Whether the ISA is actually SIMD. False for Scalar, Unknown,
and SPIR-V (which is SIMT: one lane per invocation).
Sourcepub const fn unaligned_is_cheap(self) -> bool
pub const fn unaligned_is_cheap(self) -> bool
Whether unaligned loads/stores cost about the same as aligned ones, so an unaligned iterator need not be avoided.
Sourcepub const fn unroll_factor(self) -> usize
pub const fn unroll_factor(self) -> usize
Suggested unroll factor for bulk loops, scaled to the register file: more registers allow more accumulators in flight.
Sourcepub const fn has_masked_operations(self) -> bool
pub const fn has_masked_operations(self) -> bool
Whether the ISA has first-class masked operations (AVX-512
opmask registers), letting the _c/_m/_z variants lower to a
single instruction instead of a blend.
Trait Implementations§
Source§impl Clone for InstructionSet
impl Clone for InstructionSet
Source§fn clone(&self) -> InstructionSet
fn clone(&self) -> InstructionSet
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for InstructionSet
Source§impl Debug for InstructionSet
impl Debug for InstructionSet
impl Eq for InstructionSet
Source§impl Hash for InstructionSet
impl Hash for InstructionSet
Source§impl Ord for InstructionSet
impl Ord for InstructionSet
Source§fn cmp(&self, other: &InstructionSet) -> Ordering
fn cmp(&self, other: &InstructionSet) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for InstructionSet
impl PartialEq for InstructionSet
Source§impl PartialOrd for InstructionSet
impl PartialOrd for InstructionSet
impl StructuralPartialEq for InstructionSet
Auto Trait Implementations§
impl Freeze for InstructionSet
impl RefUnwindSafe for InstructionSet
impl Send for InstructionSet
impl Sync for InstructionSet
impl Unpin for InstructionSet
impl UnsafeUnpin for InstructionSet
impl UnwindSafe for InstructionSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.