An encoder call's success path executes no locked instruction, since one between two recorded
commands flushes a write-combining command stream (about 490 ns on the RX 7900 XTX). Three GPU
device tests now hold the encoders to that, each as a difference: a recording of 4,000 commands
less one of 2,000, over the 2,000 added, so what a command buffer costs once (its begin, commit,
submission and retirement) drops out:
- draws: 2,000 draws more in one pass;
- binds: 2,000 draws more, each with a vertex buffer and a fragment texture set before it, both
alternating between two objects, so every set changes its slot;
- dispatches: 2,000 dispatches more, each reading the one before's writes.
The count is the whole test process's in user space, with inherited counters opened before the
instance: the encoding thread's, the runtime's threads' and the driver's. Each length is
recorded twice at the longer length to warm the rings, lists and pools, then 7 times each,
alternating; the least count of each length is compared, and every round's difference is
printed (`LOCKS <device>: ...`) with the bound, 0.02 locked instructions per added command.
The CPU's event is the node's: `M2V_LOCK_EVENT` names it as perf names a raw event
(`cpu_core/r21d0`, an Intel performance core's MEM_INST_RETIRED.LOCK_LOADS; `r1e25`, Zen 4's
locked instructions). A node that names none prints LOCKS-UNMEASURED and passes. The test pins
itself to the CPUs of the event's unit (a hybrid CPU's performance cores) before it starts the
device's threads.
devtools gains the counter it reads with: instructions::ProcessEvent (a raw event of the whole
process in user space on one unit, named `<unit>/r<hex>` or `r<hex>`) and pin_this_thread, with
tests of the name and CPU-list parsing and of rc0 (retired instructions on Intel and AMD alike)
counting the fixed loop on its unit's CPUs.