Skip to main content

finishes_in_place

Function finishes_in_place 

Source
pub fn finishes_in_place(
    p: &SpatialProgram,
    plan: &BlockPlan,
    target: &SpatialTarget,
) -> bool
Expand description

★ WHERE THE PARTIAL ALREADY IS THE RESULT, THE REDUCTION FINISHES IN THE OUTPUT’S PAGE. Exact numerics hold the partial sums at the accumulator’s own width; where the output is stored at that width and nothing computes after the matmul, the last K block’s sum is the result itself. A target whose packer adds into the output’s page (PackerAccumulate::IntoTheOutput) then accumulates every block there — the intermediate shares the output’s memory (Buffer::alias_of) — and never reloads the partial into the register file, which Wormhole and Blackhole cannot do at that width.

★ ONLY WHERE THE SUM IS THE SAME IN EVERY ORDER. The packer adds a block’s sum, formed from zero in the register file, to the partial: it re-associates the reduction at every block boundary, where exact numerics promise a straight K-ascending accumulation. The two agree bit for bit exactly when every partial sum is an integer the accumulator holds exactly, which the program’s claim states (NumericsClaim::Exact: integer operands whose bound times K stays inside fp32’s mantissa). On data whose range is unknown the reduction keeps its order.