Repository navigation
Description
Found by the 2026-07-29 library audit (GAPS.md §4). #15 closed with lcsf
built, measured and declined, and the scaffold unmodified — which was the right
answer. These are the two things about Job that #15 did not answer, both
named by the kernels themselves.
1. Job cannot express a warp-asynchronous item stream
examples/src/gemm_ws.rs:135-145 states it directly:
The one thing the trait cannot express is a warp-asynchronous item stream.
Job::work(&mut self, item: u32) is entered by every thread of the cluster with
one item, so every warp is always on the same item and an epilogue can lag by
exactly one — which is what Ws's pending/finish machinery does. The
reference warp-specialized kernel publishes (tile_m, tile_n) through a shared
word plus a TILE_READY mbarrier and runs three warp groups at different
items. Under run, the per-item barrier re-arming is a rendezvous of the whole
cluster, so the producer warps cannot run ahead into the next item at all.
This is a real limit and not obviously worth removing — the cost of removing it
is that the item boundary stops being a place the scaffold can re-arm barriers,
which is run's whole reason for existing (src/pipeline.rs:5-8). Worth
recording as a decision rather than an omission, and worth pricing: #90 and #94
measured the item boundary at a fifth to a third of the launch.
2. There is no teardown hook, and nine call sites remember it by hand
A job that defers its epilogue by one item owes one drain after run returns.
src/pipeline.rs:177-178 says so — "a job that defers its last item's store
owes one drain after [run] returns, which is a whole output tile computed by
nobody if it is forgotten" — and then does not provide anywhere to put it.
Both deferred jobs invent the same thing: a pending: u32 field with a
u32::MAX sentinel and a finish() the entry point must call
(gemm.rs:2029-2071 with the call at 2951; gemm_ws.rs:890-974 with the call
at 1191, 1235, 1283, 1331, 1373, 1413, 1448, 1491 and 1535 — nine entry points,
nine chances to forget). StoreRing::drain has the same shape of obligation
(gemm.rs:3171-3173).
A fn finish(&mut self) {} on Job with an empty default, called by run and
run_stealing after the loop, removes all ten call sites and cannot be
forgotten. It costs nothing for a job that does not defer.
Scope
- Add
Job::finish, default empty, called at the end of both loops. ~10 lines.
Note it must run before the caller'sdealloc_*, and both current callers
already sequence it that way. - Write down, in
pipeline.rs, that a warp-asynchronous item stream is out of
scope for this trait and why — or file the design for a second scaffold that
admits one. Do not leave it stated only inexamples/src/gemm_ws.rs, which is
being restructured.
Acceptance
Neither GEMM's entry points call a finish of their own, and the sentence in
pipeline.rs about the drain a job owes points at the hook instead of at the
caller.
Related: #15 (closed; lcsf needed no scaffold change and this is what it
left), #51 (the item-belongs-to-a-cluster fix), #88/#97 (run_stealing, which
has the same missing hook).
Activity
Audit the library whole: three doc claims were wrong, and the surface…
The drain a job owes is the hook's, and docs/library/pipeline.md says…
The drain a deferred job owes is `Job::finish`, and thirteen entry po…