Struct hwlocality::cpu::cpuset::CpuSet
source · pub struct CpuSet(/* private fields */);
Expand description
Bitmap
whose bits are set according to CPU physical OS indexes
A CpuSet
represents a set of logical CPU cores, as exposed by the
underlying operating system. These logical cores may map into either
complete hardware CPU cores or SMT threads thereof
(aka “hyper-threads”) depending on the underlying hardware and OS
configuration.
Each bit may be converted into a PU object using
Topology::pu_with_os_index()
.
Implementations§
source§impl CpuSet
impl CpuSet
§Re-export of the Bitmap API
Only documentation headers are repeated here, you will find most of
the documentation attached to identically named Bitmap
methods.
sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty bitmap
See Bitmap::new
.
sourcepub fn full() -> Self
pub fn full() -> Self
Create a full bitmap
See Bitmap::full
.
sourcepub fn from_range<Idx>(range: impl RangeBounds<Idx>) -> Self
pub fn from_range<Idx>(range: impl RangeBounds<Idx>) -> Self
Creates a new bitmap with the given range of indices set
See Bitmap::from_range
.
sourcepub fn copy_from(&mut self, other: impl Deref<Target = Self>)
pub fn copy_from(&mut self, other: impl Deref<Target = Self>)
Turn this bitmap into a copy of another bitmap
See Bitmap::copy_from
.
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clear all indices
See Bitmap::clear
.
sourcepub fn fill(&mut self)
pub fn fill(&mut self)
Set all indices
See Bitmap::fill
.
sourcepub fn set_only<Idx>(&mut self, idx: Idx)
pub fn set_only<Idx>(&mut self, idx: Idx)
Clear all indices except for idx
, which is set
See Bitmap::set_only
.
sourcepub fn set_all_but<Idx>(&mut self, idx: Idx)
pub fn set_all_but<Idx>(&mut self, idx: Idx)
Set all indices except for idx
, which is cleared
See Bitmap::set_all_but
.
sourcepub fn set<Idx>(&mut self, idx: Idx)
pub fn set<Idx>(&mut self, idx: Idx)
Set index idx
See Bitmap::set
.
sourcepub fn set_range<Idx>(&mut self, range: impl RangeBounds<Idx>)
pub fn set_range<Idx>(&mut self, range: impl RangeBounds<Idx>)
Set indices covered by range
See Bitmap::set_range
.
sourcepub fn unset<Idx>(&mut self, idx: Idx)
pub fn unset<Idx>(&mut self, idx: Idx)
Clear index idx
See Bitmap::unset
.
sourcepub fn unset_range<Idx>(&mut self, range: impl RangeBounds<Idx>)
pub fn unset_range<Idx>(&mut self, range: impl RangeBounds<Idx>)
Clear indices covered by range
See Bitmap::unset_range
.
sourcepub fn singlify(&mut self)
pub fn singlify(&mut self)
Keep a single index among those set in the bitmap
See Bitmap::singlify
.
sourcepub fn is_set<Idx>(&self, idx: Idx) -> bool
pub fn is_set<Idx>(&self, idx: Idx) -> bool
Check if index idx
is set
See Bitmap::is_set
.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Check if all indices are unset
See Bitmap::is_empty
.
sourcepub fn is_full(&self) -> bool
pub fn is_full(&self) -> bool
Check if all indices are set
See Bitmap::is_full
.
sourcepub fn first_set(&self) -> Option<BitmapIndex>
pub fn first_set(&self) -> Option<BitmapIndex>
Check the first set index, if any
See Bitmap::first_set
.
sourcepub fn last_set(&self) -> Option<BitmapIndex>
pub fn last_set(&self) -> Option<BitmapIndex>
Check the last set index, if any
See Bitmap::last_set
.
sourcepub fn weight(&self) -> Option<usize>
pub fn weight(&self) -> Option<usize>
The number of indices that are set in the bitmap
See Bitmap::weight
.
sourcepub fn first_unset(&self) -> Option<BitmapIndex>
pub fn first_unset(&self) -> Option<BitmapIndex>
Check the first unset index, if any
See Bitmap::first_unset
.
sourcepub fn iter_unset(&self) -> Iter<&Bitmap> ⓘ
pub fn iter_unset(&self) -> Iter<&Bitmap> ⓘ
Iterate over unset indices
See Bitmap::iter_unset
.
sourcepub fn last_unset(&self) -> Option<BitmapIndex>
pub fn last_unset(&self) -> Option<BitmapIndex>
Check the last unset index, if any
See Bitmap::last_unset
.
sourcepub fn invert(&mut self)
pub fn invert(&mut self)
Optimized version of *self = !self
See Bitmap::invert
.
sourcepub fn intersects(&self, rhs: impl Deref<Target = Self>) -> bool
pub fn intersects(&self, rhs: impl Deref<Target = Self>) -> bool
Truth that self
and rhs
have some set indices in common
See Bitmap::intersects
.
sourcepub fn includes(&self, inner: impl Deref<Target = Self>) -> bool
pub fn includes(&self, inner: impl Deref<Target = Self>) -> bool
Truth that the indices set in inner
are a subset of those set
in self
See Bitmap::includes
.
source§impl CpuSet
impl CpuSet
§CpuSet-specific API
sourcepub fn singlify_per_core(&mut self, topology: &Topology, which: usize)
Available on crate feature hwloc-2_2_0
only.
pub fn singlify_per_core(&mut self, topology: &Topology, which: usize)
hwloc-2_2_0
only.Remove simultaneous multithreading PUs from a CPU set
For each Core
in topology
, if this cpuset contains several PUs of
that core, modify it to only keep a single PU for that core.
which
specifies which PU will be kept, in physical index order. If it
is set to 0, for each core, the function keeps the first PU that was
originally set in cpuset
. If it is larger than the number of PUs in a
core that were originally set in cpuset
, no PU is kept for that core.
PUs that are not below a Core
object (for instance if the topology
does not contain any Core
object) are kept in the cpuset.
sourcepub fn from_nodeset(
topology: &Topology,
nodeset: impl Deref<Target = NodeSet>,
) -> Self
pub fn from_nodeset( topology: &Topology, nodeset: impl Deref<Target = NodeSet>, ) -> Self
Convert a NUMA node set into a CPU set
nodeset
can be a &'_ NodeSet
or a BitmapRef<'_, NodeSet>
.
For each NUMA node included in the input nodeset
, set the
corresponding local PUs in the output cpuset.
If some CPUs have no local NUMA nodes, this function never sets their indexes in the output CPU set, even if a full node set is given in input.
Hence the entire topology node set, that one can query via
Topology::nodeset()
, would be converted by this function into the
set of all CPUs that have some local NUMA nodes.
Trait Implementations§
source§impl Arbitrary for CpuSet
Available on crate feature proptest
only.
impl Arbitrary for CpuSet
proptest
only.§type Parameters = <Bitmap as Arbitrary>::Parameters
type Parameters = <Bitmap as Arbitrary>::Parameters
arbitrary_with
accepts for configuration
of the generated Strategy
. Parameters must implement Default
.§type Strategy = Map<<Bitmap as Arbitrary>::Strategy, fn(_: Bitmap) -> CpuSet>
type Strategy = Map<<Bitmap as Arbitrary>::Strategy, fn(_: Bitmap) -> CpuSet>
Strategy
used to generate values of type Self
.source§fn arbitrary_with(args: Self::Parameters) -> Self::Strategy
fn arbitrary_with(args: Self::Parameters) -> Self::Strategy
source§impl<B: Borrow<Self>> BitAndAssign<B> for CpuSet
impl<B: Borrow<Self>> BitAndAssign<B> for CpuSet
source§fn bitand_assign(&mut self, rhs: B)
fn bitand_assign(&mut self, rhs: B)
&=
operation. Read moresource§impl<B: Borrow<Self>> BitOrAssign<B> for CpuSet
impl<B: Borrow<Self>> BitOrAssign<B> for CpuSet
source§fn bitor_assign(&mut self, rhs: B)
fn bitor_assign(&mut self, rhs: B)
|=
operation. Read moresource§impl<B: Borrow<Self>> BitXorAssign<B> for CpuSet
impl<B: Borrow<Self>> BitXorAssign<B> for CpuSet
source§fn bitxor_assign(&mut self, rhs: B)
fn bitxor_assign(&mut self, rhs: B)
^=
operation. Read moresource§impl<'target> BorrowMut<Bitmap> for CpuSet
impl<'target> BorrowMut<Bitmap> for CpuSet
source§fn borrow_mut(&mut self) -> &mut Bitmap
fn borrow_mut(&mut self) -> &mut Bitmap
source§impl<BI: Borrow<BitmapIndex>> Extend<BI> for CpuSet
impl<BI: Borrow<BitmapIndex>> Extend<BI> for CpuSet
source§fn extend<T: IntoIterator<Item = BI>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = BI>>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl<'target> From<&'target CpuSet> for MemoryAttributeLocation<'target>
Available on crate feature hwloc-2_3_0
only.
impl<'target> From<&'target CpuSet> for MemoryAttributeLocation<'target>
hwloc-2_3_0
only.source§impl<BI: Borrow<BitmapIndex>> FromIterator<BI> for CpuSet
impl<BI: Borrow<BitmapIndex>> FromIterator<BI> for CpuSet
source§fn from_iter<I: IntoIterator<Item = BI>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = BI>>(iter: I) -> Self
source§impl<'newtype> IntoIterator for &'newtype CpuSet
impl<'newtype> IntoIterator for &'newtype CpuSet
source§impl IntoIterator for CpuSetwhere
Bitmap: IntoIterator,
impl IntoIterator for CpuSetwhere
Bitmap: IntoIterator,
source§impl Ord for CpuSet
impl Ord for CpuSet
source§impl<B: Borrow<Self>> PartialOrd<B> for CpuSet
impl<B: Borrow<Self>> PartialOrd<B> for CpuSet
source§impl SpecializedBitmap for CpuSet
impl SpecializedBitmap for CpuSet
source§impl<B: Borrow<Self>> SubAssign<B> for CpuSet
impl<B: Borrow<Self>> SubAssign<B> for CpuSet
source§fn sub_assign(&mut self, rhs: B)
fn sub_assign(&mut self, rhs: B)
-=
operation. Read moreimpl Eq for CpuSet
impl OwnedBitmap for CpuSet
Auto Trait Implementations§
impl Freeze for CpuSet
impl RefUnwindSafe for CpuSet
impl Send for CpuSet
impl Sync for CpuSet
impl Unpin for CpuSet
impl UnwindSafe for CpuSet
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,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)