pub struct Constraint { /* private fields */ }Expand description
One [constraints] expression, parsed once and evaluated per candidate.
A constraint prunes the cartesian product before anything is compiled or
measured: tile % block_x == 0 removes the combinations a kernel cannot
use. It is the author’s statement about their own kernel, not an
analysis — launchbound evaluates it and attaches no meaning to the
dimension names.
Implementations§
Source§impl Constraint
impl Constraint
Sourcepub fn parse(expr: &str, dims: &[&str]) -> Result<Self, SpaceError>
pub fn parse(expr: &str, dims: &[&str]) -> Result<Self, SpaceError>
Parse one expression, checking every identifier against dims.
Unknown identifiers are refused here rather than at evaluation, so a
typo in kernel.toml is reported once at load instead of once per
candidate.
Sourcepub fn eval(&self, config: &Config) -> Result<bool, SpaceError>
pub fn eval(&self, config: &Config) -> Result<bool, SpaceError>
Does this configuration satisfy the constraint?
Arithmetic that would overflow or divide by zero is an
SpaceError::Constraint, never a silent false: a candidate
dropped because the constraint could not be computed is
indistinguishable from one the author meant to exclude, and the two
need different fixes.
Trait Implementations§
Source§impl Clone for Constraint
impl Clone for Constraint
Source§fn clone(&self) -> Constraint
fn clone(&self) -> Constraint
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more