aql: no packet-header acquire on chained launches whose kernels acquire for themselves

A chained kernel that has lost its barrier bit is launched ahead of the kernels
it depends on and reads nothing until its prologue wait has passed, where it
acquires itself (and, since the previous change, empties the scalar cache). The
acquire in its packet header runs when the packet processor launches the kernel,
before the launches in front have written, so it guards nothing the kernel
reads and only holds the packet processor: on an R9700, 2.1 us per launch with
the agent-scope acquire against 1.2 us without.

rad_kernel_chain may now answer 2 (libr4d's rows do): the chained forms' acquire
covers everything they read. The loader records it (KernelRow::chain_fenced);
the engine asks rad_dev_chain_infer(2) when chaining pays and every row that can
chain, from every loaded library, says 2 (one row answering 1 keeps the acquire
on all chained packets). The backend then issues a chained dispatch without its
barrier bit with no header acquire, live and in played passes, unless the ring,
the host epoch or a copy asks for one; releases, barrier packets, plain kernels
and the prefetch stream are untouched, and a card with its arguments in VRAM
and no HDP flush register keeps the acquire. RADIANCE_AQL_CHAIN_FENCE=1 puts it
back on every chained launch.

Qwen3.8-Flash-Next IQR-V4, TP2, MTP chain 3 with coupling, ABBA over 2 pairs:
+0.75% tok/s [0.73, 0.78], all 156 texts identical. The three device tests
added before now also run with the packets unacquired, and a shipped-plugins
test requires libr4d's chained rows to answer 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Code000andClaude Opus 5.5 committed 2026-11-17 19:21:59 +01:00
1 parent 304597970f
commit 01f08152dc
11 files changed
+214 -50

No files matched your search

+11 -1
View File
@@ -544,7 +544,17 @@ typedef int (*RadKernelConcurrentFn)(int i);
* do, adds exactly once. The record is RAD_CHAIN_REC_BYTES at byte RAD_CHAIN_KARG_OFF of the
* kernel's argument segment: { magic, target, ctr, check }, with check = magic ^ target ^ ctr ^
* RAD_CHAIN_CHECK. A record whose magic or check does not match means: run without waiting and do
* not add. Without the symbol, or with 0, the engine never asks. Symbol name: `rad_kernel_chain`. */
* not add. Without the symbol, or with 0, the engine never asks.
*
* 2 instead of 1 adds a second promise: the chained form's own acquire covers everything it reads
* behind the wait, scalar loads included. A compiler's agent-scope fence invalidates the vector
* caches only; a load every lane shares may be a scalar one, served from the scalar data cache,
* which still holds what was there before the launch in front wrote. A form that invalidates that
* cache behind its acquire (`s_dcache_inv`), or reads no operand through it, may say 2. Where
* every chainable row an engine loads says 2, the engine issues a chained launch that has lost
* its barrier bit without the packet processor's acquire as well: on an R9700 that acquire holds
* the processor ~0.9 us a launch, and it comes too early to serve a kernel that then waits for
* the launch in front. With 1 the packets keep it. Symbol name: `rad_kernel_chain`. */
typedef int (*RadKernelChainFn)(int i);
#define RAD_CHAIN_KARG_OFF 992
#define RAD_CHAIN_REC_BYTES 32