pub struct CpuTopology { /* private fields */ }Expand description
Process-visible CPU topology used for execution placement.
Each usable NUMA node contains only CPUs also present in the process affinity mask. Empty nodes are omitted and OS node IDs are not renumbered.
§Examples
use tenferro_cpu::{CpuId, CpuSet, CpuTopology};
let topology = CpuTopology::all_allowed(CpuSet::new([CpuId::new(0)])?);
assert_eq!(topology.allowed_cpus().len(), 1);
assert!(!topology.has_numa_nodes());Implementations§
Source§impl CpuTopology
impl CpuTopology
Sourcepub fn all_allowed(allowed_cpus: CpuSet) -> Self
pub fn all_allowed(allowed_cpus: CpuSet) -> Self
Construct a topology with only the all-allowed execution domain.
This is the portable fallback when NUMA discovery is unavailable.
§Examples
use tenferro_cpu::{CpuId, CpuSet, CpuTopology};
let topology = CpuTopology::all_allowed(CpuSet::new([CpuId::new(2)])?);
assert!(topology.nodes().is_empty());Sourcepub fn allowed_cpus(&self) -> &CpuSet
pub fn allowed_cpus(&self) -> &CpuSet
Return the complete process affinity CPU set.
§Examples
use tenferro_cpu::{CpuId, CpuSet, CpuTopology};
let topology = CpuTopology::all_allowed(CpuSet::new([CpuId::new(1)])?);
assert!(topology.allowed_cpus().contains(CpuId::new(1)));Sourcepub fn nodes(&self) -> &[CpuNode]
pub fn nodes(&self) -> &[CpuNode]
Return usable NUMA nodes ordered by their sparse OS node IDs.
§Examples
use tenferro_cpu::{CpuId, CpuSet, CpuTopology};
let topology = CpuTopology::all_allowed(CpuSet::new([CpuId::new(0)])?);
assert!(topology.nodes().is_empty());Sourcepub fn node_ids(&self) -> Vec<NumaNodeId>
pub fn node_ids(&self) -> Vec<NumaNodeId>
Copy the usable sparse operating-system NUMA node IDs.
§Examples
use tenferro_cpu::{CpuId, CpuSet, CpuTopology};
let topology = CpuTopology::all_allowed(CpuSet::new([CpuId::new(0)])?);
assert!(topology.node_ids().is_empty());Sourcepub fn node(&self, id: NumaNodeId) -> Option<&CpuNode>
pub fn node(&self, id: NumaNodeId) -> Option<&CpuNode>
Look up a usable node by its original OS node ID.
§Examples
use tenferro_cpu::{CpuId, CpuSet, CpuTopology, NumaNodeId};
let topology = CpuTopology::all_allowed(CpuSet::new([CpuId::new(0)])?);
assert!(topology.node(NumaNodeId::new(0)).is_none());Sourcepub fn has_numa_nodes(&self) -> bool
pub fn has_numa_nodes(&self) -> bool
Report whether NUMA discovery produced any usable node domains.
§Examples
use tenferro_cpu::{CpuId, CpuSet, CpuTopology};
let topology = CpuTopology::all_allowed(CpuSet::new([CpuId::new(0)])?);
assert!(!topology.has_numa_nodes());Trait Implementations§
Source§impl Clone for CpuTopology
impl Clone for CpuTopology
Source§fn clone(&self) -> CpuTopology
fn clone(&self) -> CpuTopology
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 moreSource§impl Debug for CpuTopology
impl Debug for CpuTopology
Source§impl PartialEq for CpuTopology
impl PartialEq for CpuTopology
Source§fn eq(&self, other: &CpuTopology) -> bool
fn eq(&self, other: &CpuTopology) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for CpuTopology
impl StructuralPartialEq for CpuTopology
Auto Trait Implementations§
impl Freeze for CpuTopology
impl RefUnwindSafe for CpuTopology
impl Send for CpuTopology
impl Sync for CpuTopology
impl Unpin for CpuTopology
impl UnsafeUnpin for CpuTopology
impl UnwindSafe for CpuTopology
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more