What: a candidate's output is judged against Metal's one 32-bit word at a time
(observation_contract::words). An equal word matches. A differing word is excused only by a
recorded note that reaches it: a note with a bound makes a word within it a match, a note with
no bound makes it a noted word, and a word no reaching note excuses is a mismatch.
- Reach is read from the case's AIR (check::output_words): for each output word, the float
lanes it holds and the operation families whose results feed it, followed byte by byte
through bitcasts, lane moves and the zext/shl/or that pack two halves. A store placed at
A * thread_position_in_grid + B bytes gives each thread's words their own facts. A note of the
module that writes the output reaches the words its operations feed; a note of another module
reaches every word, and so does every note of a word the scan cannot follow (a load of memory
the entry writes, a call outside the intrinsic families).
- Bounds a word can carry are checked there, and a word within one matches: DeviceDenormals
only where Metal's and the device's lanes both lie at or below the smallest normal (2^-126,
2^-14 for half), of one sign unless one is a zero; NativeNanEncoding only two NaNs of the
lane's format (it reaches every float lane: a half read from its bits is no operation);
HalfTexelConversion its recorded one half ulp, or +-65504 beside the infinity; the lane
tables and the reassociation bound as before.
- NativeFma, NativeDot, NativeMix and NativeDivision keep no value bound (each states its bound
over the operands, which a word does not carry) and reach only the words their operations
feed. The fixture knows its inputs, so a per-case bound from the operands is a later form.
- SimdgroupAccessOrder reaches only a word another thread of the kernel may write: one a store
the scan cannot place in its own thread's bytes writes.
- Rows record the output's word facts (census output_words). The batch report prints, per case
and in total, the words matched exactly, within each note's bound and only noted, by note,
the unexcused words, and the cases with a word on the fall-back.
- DeviceDenormals's rustdoc states Metal's measured answer per operation: it flushes before
rounding on some (a product, fma, dot and mix just below 2^-126 answer a zero) and keeps a
denormal on others (sin, tan, asin, sinh, asinh, atanh of a denormal), from the public cases
float-products-flushed-before-rounding and nan-model-float-denormals-per-operation. Its
recording rule already covers plain multiplies; no rule changed.
ENGINE_EXECUTOR_ABI is v215: how a match is decided changed and rows record word facts.
Why: a noted difference was excused whole by any recorded note, so a note that could not cause
a word's difference (a division's note beside a product, an access-order note on a kernel whose
threads write disjoint words) hid it, and a bounded note never matched.
Verified on lavapipe (Mesa 26.2.4, the lavapipe image), the 1,168 public cases, job
m3-max-82854 (this tree with the next commit's doc text) against m3-max-82667 at b3d7464945: match 746 -> 773, noted_difference
188 -> 161, mismatch 5 -> 5 (each held open by clipped_primitive_split, as before); words
2,859,015 exact, 30,212 within a bound, 352,820 noted, 0 unexcused. Of the 188 cases noted
before, 34 have an output word on the fall-back (26 every word) and 32 a differing one.
Tests: the validation suite at an earlier tree, m3-max-82839 (1,331 passed, 3 failed; the three
are fixed here), and the touched modules at the same tree as m3-max-82854, m3-max-82855 (136
passed).
86 lines
2.6 KiB
Rust
86 lines
2.6 KiB
Rust
mod comparison;
|
|
pub mod words;
|
|
|
|
pub use comparison::{
|
|
allowance, census_names, lane_within, reduction_table, reorder_ulps, value_difference,
|
|
Allowance, ComparisonClass, FloatLane, LaneTolerance, ObservationLanes, SumFormat, UlpTable,
|
|
ValueDifference, REDUCTIONS,
|
|
};
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub enum ObservationScalar {
|
|
Float,
|
|
Half,
|
|
Int,
|
|
Uint,
|
|
Short,
|
|
Ushort,
|
|
Bool,
|
|
}
|
|
|
|
/// A varying or render-target type name the census classifies as observable
|
|
/// (`executor_contract::unsupported_observation_requirements`): one to four lanes of these
|
|
/// scalars, parsed from the AIR's declared type name. The generated graphics companions
|
|
/// (`crate::companion`) decide from the IR type instead (`companion::VaryingType`), so the two
|
|
/// agree only where the declared name states the IR type.
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub struct ObservationType {
|
|
pub scalar: ObservationScalar,
|
|
pub lanes: usize,
|
|
}
|
|
|
|
impl ObservationType {
|
|
pub fn parse(type_name: &str) -> Option<Self> {
|
|
let split = type_name
|
|
.bytes()
|
|
.position(|byte| byte.is_ascii_digit())
|
|
.unwrap_or(type_name.len());
|
|
let (base, lanes) = type_name.split_at(split);
|
|
let lanes = if lanes.is_empty() {
|
|
1
|
|
} else {
|
|
lanes.parse().ok()?
|
|
};
|
|
if !(1..=4).contains(&lanes) {
|
|
return None;
|
|
}
|
|
let scalar = match base {
|
|
"float" => ObservationScalar::Float,
|
|
"half" => ObservationScalar::Half,
|
|
"int" => ObservationScalar::Int,
|
|
"uint" => ObservationScalar::Uint,
|
|
"short" => ObservationScalar::Short,
|
|
"ushort" => ObservationScalar::Ushort,
|
|
"bool" => ObservationScalar::Bool,
|
|
_ => return None,
|
|
};
|
|
Some(Self { scalar, lanes })
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn observation_types_are_one_to_four_lanes_of_the_observed_scalars() {
|
|
assert_eq!(
|
|
ObservationType::parse("half3"),
|
|
Some(ObservationType {
|
|
scalar: ObservationScalar::Half,
|
|
lanes: 3
|
|
})
|
|
);
|
|
assert_eq!(
|
|
ObservationType::parse("bool"),
|
|
Some(ObservationType {
|
|
scalar: ObservationScalar::Bool,
|
|
lanes: 1
|
|
})
|
|
);
|
|
assert!(ObservationType::parse("double2").is_none());
|
|
assert!(ObservationType::parse("float8").is_none());
|
|
assert!(ObservationType::parse("uchar2").is_none());
|
|
}
|
|
}
|