pub struct KernelSelector { /* private fields */ }Expand description
Picks a kernel implementation from measured execution times.
Calibration runs blocks of consecutive calls of one implementation so that worker wake-up and cache warm-up are charged the way steady execution would see them. The first calls of every block, which pay for moving the state between cores, are discarded. After the configured number of rounds, the implementation with the lower median call time is kept; the partitioned kernel must win by a margin, since the sequential kernel needs no worker threads.
A measured decision is checked again after a number of calls that doubles with every check, so a choice made while the host was busy, or before the simulation reached its steady state, does not stay wrong for the whole run. Checks become rare quickly and cost a few dozen calls each.
Implementations§
Source§impl KernelSelector
impl KernelSelector
pub fn new(selection: KernelSelection) -> Self
Sourcepub fn diagnostic_id(&self) -> &str
pub fn diagnostic_id(&self) -> &str
Process-local identity preserved across moves, but not across clones.
Sourcepub fn next(&self) -> (KernelChoice, bool)
pub fn next(&self) -> (KernelChoice, bool)
The implementation to run next, and whether its duration should be
reported with Self::record.
Sourcepub fn decided(&self) -> Option<KernelChoice>
pub fn decided(&self) -> Option<KernelChoice>
The current decision, or None while measuring.
Sourcepub fn advance(&mut self, calls: u64)
pub fn advance(&mut self, calls: u64)
Account for calls executions of the decided implementation; a
measured decision is checked again when its interval has elapsed.
Sourcepub fn record(&mut self, choice: KernelChoice, nanos: u64)
pub fn record(&mut self, choice: KernelChoice, nanos: u64)
Report the duration of a call started after Self::next asked for
timing.