Struct hwlocality::cpu::binding::CpuBindingFlags
source · pub struct CpuBindingFlags(/* private fields */);
Expand description
Process/Thread binding flags
These bit flags can be used to refine the binding policy. All flags can
be OR’ed together with the exception of the binding targets flags
ASSUME_SINGLE_THREAD
, THREAD
and PROCESS
, which are mutually
exclusive.
When using one of the methods that target the active process, you must
use exactly one of these flags. The most portable binding targets are
ASSUME_SINGLE_THREAD
, THREAD
and PROCESS
, in this order. These
flags must generally not be used with any other method, except on
Linux where flag THREAD
can also be used to turn process-binding
methods into thread-binding methods.
Individual CPU binding methods may not support all of these flags. Please check the documentation of the cpu binding method that you are calling for more information.
Implementations§
source§impl CpuBindingFlags
impl CpuBindingFlags
sourcepub const ASSUME_SINGLE_THREAD: Self = _
pub const ASSUME_SINGLE_THREAD: Self = _
Assume that the current process is single threaded
This lets hwloc pick between thread and process binding for increased portability.
This is mutually exclusive with PROCESS
and THREAD
.
sourcepub const THREAD: Self = _
pub const THREAD: Self = _
Bind the current thread of the current process
This is the second most portable option where ASSUME_SINGLE_THREAD
is inapplicable.
On Linux, this flag can also be used to turn process-binding methods into thread-binding methods.
This is mutually exclusive with ASSUME_SINGLE_THREAD
and PROCESS
.
sourcepub const PROCESS: Self = _
pub const PROCESS: Self = _
Bind all threads of the current process
This is mutually exclusive with ASSUME_SINGLE_THREAD
and THREAD
.
sourcepub const STRICT: Self = _
pub const STRICT: Self = _
Request for strict binding from the OS
By default, when the designated CPUs are all busy while other CPUs are idle, operating systems may execute the thread/process on those other CPUs instead of the designated CPUs, to let them progress anyway. Strict binding means that the thread/process will never execute on other CPUs than the designated CPUs, even when those are busy with other tasks and other CPUs are idle.
Depending on the operating system, strict binding may not be possible (e.g. the OS does not implement it) or not allowed (e.g. for an administrative reasons), and the binding method will fail in that case.
When retrieving the binding of a process, this flag checks whether all its threads actually have the same binding. If the flag is not given, the binding of each thread will be accumulated.
This flag should not be used when retrieving the binding of a thread or the CPU location of a process.
sourcepub const NO_MEMORY_BINDING: Self = _
pub const NO_MEMORY_BINDING: Self = _
Avoid any effect on memory binding
On some operating systems, some CPU binding method would also bind
the memory on the corresponding NUMA node. It is often not a
problem for the application, but if it is, setting this flag will
make hwloc avoid using OS functions that would also bind memory.
This will however reduce the support of CPU bindings, i.e.
potentially result in the binding method erroring out with a
CpuBindingError
.
This flag should only be used with methods that set the CPU binding.
source§impl CpuBindingFlags
impl CpuBindingFlags
sourcepub const fn bits(&self) -> hwloc_cpubind_flags_t
pub const fn bits(&self) -> hwloc_cpubind_flags_t
Get the underlying bits value.
The returned value is exactly the bits set in this flags value.
sourcepub const fn from_bits(bits: hwloc_cpubind_flags_t) -> Option<Self>
pub const fn from_bits(bits: hwloc_cpubind_flags_t) -> Option<Self>
Convert from a bits value.
This method will return None
if any unknown bits are set.
sourcepub const fn from_bits_truncate(bits: hwloc_cpubind_flags_t) -> Self
pub const fn from_bits_truncate(bits: hwloc_cpubind_flags_t) -> Self
Convert from a bits value, unsetting any unknown bits.
sourcepub const fn from_bits_retain(bits: hwloc_cpubind_flags_t) -> Self
pub const fn from_bits_retain(bits: hwloc_cpubind_flags_t) -> Self
Convert from a bits value exactly.
sourcepub fn from_name(name: &str) -> Option<Self>
pub fn from_name(name: &str) -> Option<Self>
Get a flags value with the bits of a flag with the given name set.
This method will return None
if name
is empty or doesn’t
correspond to any named flag.
sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Whether any set bits in a source flags value are also set in a target flags value.
sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Whether all set bits in a source flags value are also set in a target flags value.
sourcepub fn remove(&mut self, other: Self)
pub fn remove(&mut self, other: Self)
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
remove
won’t truncate other
, but the !
operator will.
sourcepub fn toggle(&mut self, other: Self)
pub fn toggle(&mut self, other: Self)
The bitwise exclusive-or (^
) of the bits in two flags values.
sourcepub fn set(&mut self, other: Self, value: bool)
pub fn set(&mut self, other: Self, value: bool)
Call insert
when value
is true
or remove
when value
is false
.
sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
The bitwise and (&
) of the bits in two flags values.
sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
The bitwise or (|
) of the bits in two flags values.
sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
difference
won’t truncate other
, but the !
operator will.
sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
The bitwise exclusive-or (^
) of the bits in two flags values.
sourcepub const fn complement(self) -> Self
pub const fn complement(self) -> Self
The bitwise negation (!
) of the bits in a flags value, truncating the result.
source§impl CpuBindingFlags
impl CpuBindingFlags
sourcepub const fn iter(&self) -> Iter<CpuBindingFlags>
pub const fn iter(&self) -> Iter<CpuBindingFlags>
Yield a set of contained flags values.
Each yielded flags value will correspond to a defined named flag. Any unknown bits will be yielded together as a final flags value.
sourcepub const fn iter_names(&self) -> IterNames<CpuBindingFlags>
pub const fn iter_names(&self) -> IterNames<CpuBindingFlags>
Yield a set of contained named flags values.
This method is like iter
, except only yields bits in contained named flags.
Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
Trait Implementations§
source§impl Arbitrary for CpuBindingFlags
Available on crate feature proptest
only.
impl Arbitrary for CpuBindingFlags
proptest
only.§type Parameters = ()
type Parameters = ()
arbitrary_with
accepts for configuration
of the generated Strategy
. Parameters must implement Default
.§type Strategy = Map<Subsequence<CpuBindingFlags>, fn(_: Vec<CpuBindingFlags>) -> CpuBindingFlags>
type Strategy = Map<Subsequence<CpuBindingFlags>, fn(_: Vec<CpuBindingFlags>) -> CpuBindingFlags>
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 Binary for CpuBindingFlags
impl Binary for CpuBindingFlags
source§impl BitAnd for CpuBindingFlags
impl BitAnd for CpuBindingFlags
source§impl BitAndAssign for CpuBindingFlags
impl BitAndAssign for CpuBindingFlags
source§fn bitand_assign(&mut self, other: Self)
fn bitand_assign(&mut self, other: Self)
The bitwise and (&
) of the bits in two flags values.
source§impl BitOr for CpuBindingFlags
impl BitOr for CpuBindingFlags
source§fn bitor(self, other: CpuBindingFlags) -> Self
fn bitor(self, other: CpuBindingFlags) -> Self
The bitwise or (|
) of the bits in two flags values.
§type Output = CpuBindingFlags
type Output = CpuBindingFlags
|
operator.source§impl BitOrAssign for CpuBindingFlags
impl BitOrAssign for CpuBindingFlags
source§fn bitor_assign(&mut self, other: Self)
fn bitor_assign(&mut self, other: Self)
The bitwise or (|
) of the bits in two flags values.
source§impl BitXor for CpuBindingFlags
impl BitXor for CpuBindingFlags
source§impl BitXorAssign for CpuBindingFlags
impl BitXorAssign for CpuBindingFlags
source§fn bitxor_assign(&mut self, other: Self)
fn bitxor_assign(&mut self, other: Self)
The bitwise exclusive-or (^
) of the bits in two flags values.
source§impl Clone for CpuBindingFlags
impl Clone for CpuBindingFlags
source§fn clone(&self) -> CpuBindingFlags
fn clone(&self) -> CpuBindingFlags
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for CpuBindingFlags
impl Debug for CpuBindingFlags
source§impl Extend<CpuBindingFlags> for CpuBindingFlags
impl Extend<CpuBindingFlags> for CpuBindingFlags
source§fn extend<T: IntoIterator<Item = Self>>(&mut self, iterator: T)
fn extend<T: IntoIterator<Item = Self>>(&mut self, iterator: T)
The bitwise or (|
) of the bits in each flags value.
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 Flags for CpuBindingFlags
impl Flags for CpuBindingFlags
source§const FLAGS: &'static [Flag<CpuBindingFlags>] = _
const FLAGS: &'static [Flag<CpuBindingFlags>] = _
source§fn bits(&self) -> hwloc_cpubind_flags_t
fn bits(&self) -> hwloc_cpubind_flags_t
source§fn from_bits_retain(bits: hwloc_cpubind_flags_t) -> CpuBindingFlags
fn from_bits_retain(bits: hwloc_cpubind_flags_t) -> CpuBindingFlags
source§fn from_bits_truncate(bits: Self::Bits) -> Self
fn from_bits_truncate(bits: Self::Bits) -> Self
source§fn from_name(name: &str) -> Option<Self>
fn from_name(name: &str) -> Option<Self>
source§fn iter_names(&self) -> IterNames<Self>
fn iter_names(&self) -> IterNames<Self>
source§fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
source§fn contains(&self, other: Self) -> boolwhere
Self: Sized,
fn contains(&self, other: Self) -> boolwhere
Self: Sized,
source§fn insert(&mut self, other: Self)where
Self: Sized,
fn insert(&mut self, other: Self)where
Self: Sized,
|
) of the bits in two flags values.source§fn remove(&mut self, other: Self)where
Self: Sized,
fn remove(&mut self, other: Self)where
Self: Sized,
&!
). Read moresource§fn toggle(&mut self, other: Self)where
Self: Sized,
fn toggle(&mut self, other: Self)where
Self: Sized,
^
) of the bits in two flags values.source§fn intersection(self, other: Self) -> Self
fn intersection(self, other: Self) -> Self
&
) of the bits in two flags values.source§fn difference(self, other: Self) -> Self
fn difference(self, other: Self) -> Self
&!
). Read moresource§fn symmetric_difference(self, other: Self) -> Self
fn symmetric_difference(self, other: Self) -> Self
^
) of the bits in two flags values.source§fn complement(self) -> Self
fn complement(self) -> Self
!
) of the bits in a flags value, truncating the result.source§impl From<CpuBindingFlags> for CpuBindingError
impl From<CpuBindingFlags> for CpuBindingError
source§fn from(value: CpuBindingFlags) -> Self
fn from(value: CpuBindingFlags) -> Self
source§impl FromIterator<CpuBindingFlags> for CpuBindingFlags
impl FromIterator<CpuBindingFlags> for CpuBindingFlags
source§fn from_iter<T: IntoIterator<Item = Self>>(iterator: T) -> Self
fn from_iter<T: IntoIterator<Item = Self>>(iterator: T) -> Self
The bitwise or (|
) of the bits in each flags value.
source§impl Hash for CpuBindingFlags
impl Hash for CpuBindingFlags
source§impl IntoIterator for CpuBindingFlags
impl IntoIterator for CpuBindingFlags
source§impl LowerHex for CpuBindingFlags
impl LowerHex for CpuBindingFlags
source§impl Not for CpuBindingFlags
impl Not for CpuBindingFlags
source§impl Octal for CpuBindingFlags
impl Octal for CpuBindingFlags
source§impl PartialEq for CpuBindingFlags
impl PartialEq for CpuBindingFlags
source§fn eq(&self, other: &CpuBindingFlags) -> bool
fn eq(&self, other: &CpuBindingFlags) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PublicFlags for CpuBindingFlags
impl PublicFlags for CpuBindingFlags
source§impl Sub for CpuBindingFlags
impl Sub for CpuBindingFlags
source§fn sub(self, other: Self) -> Self
fn sub(self, other: Self) -> Self
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
difference
won’t truncate other
, but the !
operator will.
§type Output = CpuBindingFlags
type Output = CpuBindingFlags
-
operator.source§impl SubAssign for CpuBindingFlags
impl SubAssign for CpuBindingFlags
source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
difference
won’t truncate other
, but the !
operator will.