pub enum CpuWaitPolicy {
Active,
Passive,
SpinPolls(u32),
}Expand description
How the idle workers of a CPU pool wait for the next parallel section.
A worker that has nothing to do polls for a while before it sleeps. With the
default budget it keeps polling through a serial phase of the caller that is
shorter than that budget, so a pool of N workers can use N times the wall
time in CPU time. A smaller budget trades that CPU time for a longer wake-up
of the next parallel section. The names follow OpenMP’s OMP_WAIT_POLICY.
The budget is threadteam’s PoolBuilder::spin_polls, a count of polls and
not a duration, so how long it lasts depends on the CPU.
§Examples
use tensor4all_tensorbackend::CpuWaitPolicy;
assert_eq!(CpuWaitPolicy::default(), CpuWaitPolicy::Active);
assert_eq!(CpuWaitPolicy::Passive.spin_polls(), Some(0));
assert_eq!(CpuWaitPolicy::SpinPolls(4096).spin_polls(), Some(4096));Variants§
Active
Keep the pool’s default spin budget (the behaviour before this type existed).
Passive
Do not spin: a waiting worker yields a few times and then sleeps, for a shared machine or parallel test processes.
SpinPolls(u32)
Spin for this many polls before the yields and the sleep.
Implementations§
Source§impl CpuWaitPolicy
impl CpuWaitPolicy
Sourcepub fn spin_polls(self) -> Option<u32>
pub fn spin_polls(self) -> Option<u32>
The spin budget this policy sets on the pool, or None for the pool’s
default.
§Examples
use tensor4all_tensorbackend::CpuWaitPolicy;
assert_eq!(CpuWaitPolicy::Active.spin_polls(), None);
assert_eq!(CpuWaitPolicy::SpinPolls(7).spin_polls(), Some(7));Trait Implementations§
Source§impl Clone for CpuWaitPolicy
impl Clone for CpuWaitPolicy
impl Copy for CpuWaitPolicy
Source§impl Debug for CpuWaitPolicy
impl Debug for CpuWaitPolicy
Source§impl Default for CpuWaitPolicy
impl Default for CpuWaitPolicy
impl Eq for CpuWaitPolicy
Source§impl PartialEq for CpuWaitPolicy
impl PartialEq for CpuWaitPolicy
impl StructuralPartialEq for CpuWaitPolicy
Auto Trait Implementations§
impl Freeze for CpuWaitPolicy
impl RefUnwindSafe for CpuWaitPolicy
impl Send for CpuWaitPolicy
impl Sync for CpuWaitPolicy
impl Unpin for CpuWaitPolicy
impl UnsafeUnpin for CpuWaitPolicy
impl UnwindSafe for CpuWaitPolicy
Blanket Implementations§
impl<T> Boilerplate for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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
§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
key and return true if they are equal.impl<T, U> Imply<T> for U
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> ⓘ
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> ⓘ
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