redbluegreen wiki

The bisect

Ten one-question kernels that turned a vadd hang into a rule about VGPR blocks.

vadd hangs: rptr 0, signal 1, no store asks next store42 wg 256 8 waves of known-good code? pass vadd wg 1 vadd code as one wave? hang vadd fine data coarse or fine data? hang vload one vector load, then store? pass sload 3 scalar loads, one 128-bit? pass sdump all registers correct? pass vbranch exec mask and branch, no loads? pass vadd2 vadd using v0 to v3 only? pass two dwords differ v4probe the value through v4 alone? pass vadd16 same bytes, 16 VGPRs? pass Rule 3: ask for 8 spare VGPRs bisect kernel the packet retired the queue hung, one reset
Ten kernels, one question each, narrowed a vadd hang down to the VGPR count in the kernel descriptor.

vadd hung on its first run.

The harness printed rptr 0, signal 1 and c[0] 0. The packet never retired, and the kernel never reached its store. The log showed no fault.

Every experiment costs one GPU reset. So each kernel answers one question, and the order gets the most information per reset.

Every kernel runs with one wave, one element, and the harness unchanged.

The kernels and what each one shows:

  1. store42 at workgroup 256 runs eight waves of known-good code. Eight waves are safe.
  2. vadd as one wave hangs on coarse data and on fine-grained data. The data type is not the cause.
  3. vload does one vector load, then a store. It passes.
  4. sload does vadd's three scalar loads, including the 128-bit one. It passes.
  5. sdump writes s4..s7, s10, s2 and v0 to memory. It cannot hang, so it runs first.
  6. vbranch runs vadd's exec-mask sequence and branch with no loads. It passes.

sdump shows that every register vadd depends on is correct: a, b, n, the workgroup id and the lane id.

kernelwhat it isolatesresult
store42 (wg 256)8 waves of a known-good kernel pass
vadd (wg 1)vadd code as one wave hang
vadd (wg 1, fine data)coarse vs fine data hang
vloadone vector load, then store pass
sloadvadd's 3 scalar loads incl. 128-bit pass
sdumpdump s4..s7, s10, s2, v0 to memory all correct
vbranchvadd's exec-mask and branch, no loads pass
vadd2vadd using v0..v3 only pass
v4probevload with the value through v4 pass
vadd16vadd bytes, descriptor asks 16 VGPRs pass

Two dwords make the difference.

vadd2 is vadd with the second load in v0 instead of v4. Nothing else changes, and vadd2 passes.

Their descriptors are identical. The assembler counts VGPRs in blocks of 8 for wave32, so 4 and 5 registers encode to the same block.

vadd16 is vadd's exact bytes with the register field one block higher. It runs.

Rule 3: ask the assembler for 8 more VGPRs than the code uses.

Block 0 does not give a wave five usable registers, whatever the encoding says.

v4probe passes alone, so one load into v4 does not hang a wave. The failure needs a second load in flight. The mechanism is not known. The rule is.

On timeout the harness prints rptr, signal and c[0]. So a hang still reports whether the packet retired and whether the kernel stored.

The bisect kernels are in src/kernels/.

Sources