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

§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.

source

pub fn new() -> Self

Create an empty bitmap

See Bitmap::new.

source

pub fn full() -> Self

Create a full bitmap

See Bitmap::full.

source

pub fn from_range<Idx>(range: impl RangeBounds<Idx>) -> Self
where Idx: Copy + TryInto<BitmapIndex>, <Idx as TryInto<BitmapIndex>>::Error: Debug,

Creates a new bitmap with the given range of indices set

See Bitmap::from_range.

source

pub fn copy_from(&mut self, other: impl Deref<Target = Self>)

Turn this bitmap into a copy of another bitmap

See Bitmap::copy_from.

source

pub fn clear(&mut self)

Clear all indices

See Bitmap::clear.

source

pub fn fill(&mut self)

Set all indices

See Bitmap::fill.

source

pub fn set_only<Idx>(&mut self, idx: Idx)
where Idx: TryInto<BitmapIndex>, <Idx as TryInto<BitmapIndex>>::Error: Debug,

Clear all indices except for idx, which is set

See Bitmap::set_only.

source

pub fn set_all_but<Idx>(&mut self, idx: Idx)
where Idx: TryInto<BitmapIndex>, <Idx as TryInto<BitmapIndex>>::Error: Debug,

Set all indices except for idx, which is cleared

See Bitmap::set_all_but.

source

pub fn set<Idx>(&mut self, idx: Idx)
where Idx: TryInto<BitmapIndex>, <Idx as TryInto<BitmapIndex>>::Error: Debug,

Set index idx

See Bitmap::set.

source

pub fn set_range<Idx>(&mut self, range: impl RangeBounds<Idx>)
where Idx: Copy + TryInto<BitmapIndex>, <Idx as TryInto<BitmapIndex>>::Error: Debug,

Set indices covered by range

See Bitmap::set_range.

source

pub fn unset<Idx>(&mut self, idx: Idx)
where Idx: TryInto<BitmapIndex>, <Idx as TryInto<BitmapIndex>>::Error: Debug,

Clear index idx

See Bitmap::unset.

source

pub fn unset_range<Idx>(&mut self, range: impl RangeBounds<Idx>)
where Idx: Copy + TryInto<BitmapIndex>, <Idx as TryInto<BitmapIndex>>::Error: Debug,

Clear indices covered by range

See Bitmap::unset_range.

source

pub fn singlify(&mut self)

Keep a single index among those set in the bitmap

See Bitmap::singlify.

source

pub fn is_set<Idx>(&self, idx: Idx) -> bool
where Idx: TryInto<BitmapIndex>, <Idx as TryInto<BitmapIndex>>::Error: Debug,

Check if index idx is set

See Bitmap::is_set.

source

pub fn is_empty(&self) -> bool

Check if all indices are unset

See Bitmap::is_empty.

source

pub fn is_full(&self) -> bool

Check if all indices are set

See Bitmap::is_full.

source

pub fn first_set(&self) -> Option<BitmapIndex>

Check the first set index, if any

See Bitmap::first_set.

source

pub fn iter_set(&self) -> Iter<&Bitmap>

Iterate over set indices

See Bitmap::iter_set.

source

pub fn last_set(&self) -> Option<BitmapIndex>

Check the last set index, if any

See Bitmap::last_set.

source

pub fn weight(&self) -> Option<usize>

The number of indices that are set in the bitmap

See Bitmap::weight.

source

pub fn first_unset(&self) -> Option<BitmapIndex>

Check the first unset index, if any

See Bitmap::first_unset.

source

pub fn iter_unset(&self) -> Iter<&Bitmap>

Iterate over unset indices

See Bitmap::iter_unset.

source

pub fn last_unset(&self) -> Option<BitmapIndex>

Check the last unset index, if any

See Bitmap::last_unset.

source

pub fn invert(&mut self)

Optimized version of *self = !self

See Bitmap::invert.

source

pub fn intersects(&self, rhs: impl Deref<Target = Self>) -> bool

Truth that self and rhs have some set indices in common

See Bitmap::intersects.

source

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

§CpuSet-specific API

source

pub fn singlify_per_core(&mut self, topology: &Topology, which: usize)

Available on crate feature 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.

source

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.
§

type Parameters = <Bitmap as Arbitrary>::Parameters

The type of parameters that arbitrary_with accepts for configuration of the generated Strategy. Parameters must implement Default.
§

type Strategy = Map<<Bitmap as Arbitrary>::Strategy, fn(_: Bitmap) -> CpuSet>

The type of Strategy used to generate values of type Self.
source§

fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). The strategy is passed the arguments given in args. Read more
source§

fn arbitrary() -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). Read more
source§

impl AsMut<Bitmap> for CpuSet

source§

fn as_mut(&mut self) -> &mut Bitmap

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsRef<Bitmap> for CpuSet

source§

fn as_ref(&self) -> &Bitmap

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<B: Borrow<CpuSet>> BitAnd<B> for &CpuSet

§

type Output = CpuSet

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: B) -> CpuSet

Performs the & operation. Read more
source§

impl<B: Borrow<Self>> BitAnd<B> for CpuSet

§

type Output = CpuSet

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: B) -> Self

Performs the & operation. Read more
source§

impl<B: Borrow<Self>> BitAndAssign<B> for CpuSet

source§

fn bitand_assign(&mut self, rhs: B)

Performs the &= operation. Read more
source§

impl<B: Borrow<CpuSet>> BitOr<B> for &CpuSet

§

type Output = CpuSet

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: B) -> CpuSet

Performs the | operation. Read more
source§

impl<B: Borrow<Self>> BitOr<B> for CpuSet

§

type Output = CpuSet

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: B) -> Self

Performs the | operation. Read more
source§

impl<B: Borrow<Self>> BitOrAssign<B> for CpuSet

source§

fn bitor_assign(&mut self, rhs: B)

Performs the |= operation. Read more
source§

impl<B: Borrow<CpuSet>> BitXor<B> for &CpuSet

§

type Output = CpuSet

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: B) -> CpuSet

Performs the ^ operation. Read more
source§

impl<B: Borrow<Self>> BitXor<B> for CpuSet

§

type Output = CpuSet

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: B) -> Self

Performs the ^ operation. Read more
source§

impl<B: Borrow<Self>> BitXorAssign<B> for CpuSet

source§

fn bitxor_assign(&mut self, rhs: B)

Performs the ^= operation. Read more
source§

impl<'target> Borrow<Bitmap> for CpuSet

source§

fn borrow(&self) -> &Bitmap

Immutably borrows from an owned value. Read more
source§

impl<'target> BorrowMut<Bitmap> for CpuSet

source§

fn borrow_mut(&mut self) -> &mut Bitmap

Mutably borrows from an owned value. Read more
source§

impl Clone for CpuSet

source§

fn clone(&self) -> CpuSet

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CpuSet

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for CpuSet

source§

fn default() -> CpuSet

Returns the “default value” for a type. Read more
source§

impl Display for CpuSet

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<BI: Borrow<BitmapIndex>> Extend<BI> for CpuSet

source§

fn extend<T: IntoIterator<Item = BI>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<'set> From<&'set CpuSet> for AllowSet<'set>

Available on crate feature hwloc-2_3_0 only.
source§

fn from(set: &'set CpuSet) -> Self

Converts to this type from the input type.
source§

impl<'target> From<&'target CpuSet> for MemoryAttributeLocation<'target>

Available on crate feature hwloc-2_3_0 only.
source§

fn from(cpuset: &'target CpuSet) -> Self

Converts to this type from the input type.
source§

impl<BI: Borrow<BitmapIndex>> From<BI> for CpuSet

source§

fn from(value: BI) -> Self

Converts to this type from the input type.
source§

impl From<Bitmap> for CpuSet

source§

fn from(original: Bitmap) -> CpuSet

Converts to this type from the input type.
source§

impl From<CpuSet> for Bitmap

source§

fn from(original: CpuSet) -> Self

Converts to this type from the input type.
source§

impl<BI: Borrow<BitmapIndex>> FromIterator<BI> for CpuSet

source§

fn from_iter<I: IntoIterator<Item = BI>>(iter: I) -> Self

Creates a value from an iterator. Read more
source§

impl Hash for CpuSet

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'newtype> IntoIterator for &'newtype CpuSet

§

type Item = PositiveInt

The type of the elements being iterated over.
§

type IntoIter = Iter<&'newtype Bitmap>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl IntoIterator for CpuSet

§

type Item = <Bitmap as IntoIterator>::Item

The type of the elements being iterated over.
§

type IntoIter = <Bitmap as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl Not for &CpuSet

§

type Output = CpuSet

The resulting type after applying the ! operator.
source§

fn not(self) -> CpuSet

Performs the unary ! operation. Read more
source§

impl Not for CpuSet

§

type Output = CpuSet

The resulting type after applying the ! operator.
source§

fn not(self) -> CpuSet

Performs the unary ! operation. Read more
source§

impl Ord for CpuSet

source§

fn cmp(&self, other: &CpuSet) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<B: Borrow<Self>> PartialEq<B> for CpuSet

source§

fn eq(&self, other: &B) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<B: Borrow<Self>> PartialOrd<B> for CpuSet

source§

fn partial_cmp(&self, other: &B) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Pointer for CpuSet

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter.
source§

impl SpecializedBitmap for CpuSet

source§

const BITMAP_KIND: BitmapKind = BitmapKind::CpuSet

Tag used to discriminate between specialized bitmaps in code
§

type Owned = CpuSet

Owned form of this specialized bitmap
source§

fn to_owned(&self) -> Self

Construct an owned specialized bitmap from a borrowed one Read more
source§

impl<B: Borrow<CpuSet>> Sub<B> for &CpuSet

§

type Output = CpuSet

The resulting type after applying the - operator.
source§

fn sub(self, rhs: B) -> CpuSet

Performs the - operation. Read more
source§

impl<B: Borrow<Self>> Sub<B> for CpuSet

§

type Output = CpuSet

The resulting type after applying the - operator.
source§

fn sub(self, rhs: B) -> Self

Performs the - operation. Read more
source§

impl<B: Borrow<Self>> SubAssign<B> for CpuSet

source§

fn sub_assign(&mut self, rhs: B)

Performs the -= operation. Read more
source§

impl Eq for CpuSet

source§

impl OwnedBitmap for CpuSet

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<B> OwnedSpecializedBitmap for B
where B: OwnedBitmap + SpecializedBitmap<Owned = B>,