pub fn work_of_plan(
p: &SpatialProgram,
plan: &BlockPlan,
fused: bool,
t: &SpatialTarget,
) -> Option<Work>Expand description
★ THE SAME WORK, PRICED FROM A PLAN INSTEAD OF A BUILT PROGRAM.
work_of walks a scheduled choreography, which is exact but needs the whole pipeline to have run.
A plan search has thousands of candidates — 4,209 at 512^3 — and cannot build them all, so it needs
the same quantity as a closed form over the plan.
These are not two models. spatial_work_model_lock::the_closed_form_is_the_built_choreography_on_*
requires this to equal work_of of the program build_candidate
emits, count for count, on every target, and work_of is in turn checked against the machine. The chain
is closed form == choreography == simulator, each link tested, so the planner ranks by a number the
hardware has already agreed to.
Everything it prices with is read off the GEMM template p and its target t — the tile extents, the
widths (GemmWidths), the matrix engine’s fidelity, the sites and the movement engines per site — so no
caller can hand it a width or an engine count the emitter does not use. None when p has no GEMM.
The movement law, read off the choreography and confirmed at every shape in the ledger:
- A blocked plan makes every site fetch its own operands:
nx*mt*kt + ny*nt*kttiles read. - A multicast plan reads each shared operand tile from DRAM ONCE and multicasts it ONCE, so it pays
for that tile TWICE on the NOC and only twice. That is the whole win: a blocked plan pays
nxandnytimes instead of two. - Every plan writes its output once:
mt*nt. - A streaming plan re-reads both operands for every output tile:
2*mt*nt*kt.