pub struct TargetFeatures { /* private fields */ }Expand description
A set of target features.
Implementations§
Source§impl TargetFeatures
impl TargetFeatures
Sourcepub const fn suggested_simd_width<T: SimdElement>(&self) -> Option<usize>
pub const fn suggested_simd_width<T: SimdElement>(&self) -> Option<usize>
Returns a suggested number of elements for a SIMD vector of type T.
The returned value is an approximation and not necessarily indicative of the optimal vector width. A few caveats:
- Every instruction set is different, and this function doesn’t take into account any particular operations–it’s just a guess, and should be accurate at least for basic arithmetic.
- Variable-length vector instruction sets (ARM SVE and RISC-V V) only return the minimum vector length.
Source§impl TargetFeatures
impl TargetFeatures
Sourcepub const fn enabled_for_target() -> Self
pub const fn enabled_for_target() -> Self
Returns the target features enabled at compile time.
This includes features enabled by the target specification, target CPU,
and -C target-feature compiler options.
Sourcepub const fn contains(self, required: Self) -> bool
pub const fn contains(self, required: Self) -> bool
Returns whether self contains every target feature in required.
Examples found in repository?
examples/proof-token.rs (line 76)
67fn safe_avx_fn<P: Proof>(_: P) {
68 #[target_feature(enable = "avx")]
69 unsafe fn unsafe_avx_fn() {
70 println!("called an avx function")
71 }
72
73 // Future improvements to const generics might make it possible to assert this at compile time.
74 // Since P::TARGET is const, this assert disappears if the required features are present.
75 assert!(
76 P::TARGET.contains(target_features::x86_64::AVX),
77 "avx feature not supported"
78 );
79 unsafe { unsafe_avx_fn() }
80}Trait Implementations§
Source§impl Clone for TargetFeatures
impl Clone for TargetFeatures
Source§fn clone(&self) -> TargetFeatures
fn clone(&self) -> TargetFeatures
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for TargetFeatures
Source§impl Debug for TargetFeatures
impl Debug for TargetFeatures
impl Eq for TargetFeatures
Source§impl Hash for TargetFeatures
impl Hash for TargetFeatures
Source§impl PartialEq for TargetFeatures
impl PartialEq for TargetFeatures
impl StructuralPartialEq for TargetFeatures
Auto Trait Implementations§
impl Freeze for TargetFeatures
impl RefUnwindSafe for TargetFeatures
impl Send for TargetFeatures
impl Sync for TargetFeatures
impl Unpin for TargetFeatures
impl UnsafeUnpin for TargetFeatures
impl UnwindSafe for TargetFeatures
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
Mutably borrows from an owned value. Read more