The scan kernel, in two shapes a guest builds from the maxThreadgroupMemoryLength it is told:
scan_static (a declared array of the bytes) and scan_length (a [[threadgroup(0)]] region the
encoder sets at the bytes, none declared). Each runs at 1,024 threads, its ragged grid [25, 1, 1]
and its whole grid [1024, 1, 1], at Metal's 32 KiB (the device's limit where smaller) and at the
device's maxComputeSharedMemorySize less the 4-byte vote word, rounded down to 16 and at most
32 KiB. Where 32 KiB and the word pass the limit the ragged grids are refused, scan_static's as
Gap::PartialThreadgroups and scan_length's as Limit::ThreadgroupMemory; every other run answers
the program's sums. Replaces the previous scan test at the limit and 4 bytes less.
Not yet run: the legs (lavapipe, a 780M under RADV and AMDVLK) follow.