Repository navigation
borealis: encode four M5 nodes per workgroup, one child per lane - #1423
Conversation
The M5 node encoder ran one node per 8-lane workgroup, and most of the work on one or two lanes: lane 0 fitted the root and quantized every child's bounds in turn, and one lane per QTB block quantized all of its triangles' vertices (up to 48 values). An 8-lane workgroup also leaves three quarters of each 32-lane SIMD group idle. Encode like the GEN1 encoder (agx3_leaf.comp): a 32-lane workgroup encodes four node jobs, eight lanes each, and every lane handles one child: its bounds, its root word, its record and its triangle's QTB bytes. The node's and each QTB block's bounds and the checks come from clustered subgroup operations, so encoding needs no shared memory or barriers. The M5 arithmetic (root fit, child quantization, record layouts) is unchanged, so the encoded images are the same. The planner now writes the encoding dispatch after its state, as GEN1's does (whole workgroups of four jobs), and bounds the last workgroup with its job count; the update prefix pass sizes the batched node encoding the same way. Signed-off-by: DjDeveloperr <hey@djdev.me>
There was a problem hiding this comment.
Verdict: HOLD at b952bb08
Blockers:
- Second M5 variant hardware row (base M5
G17G), plus completion of the author's queued third control run / visual check listed underNot yet.
Checked:
src/asahi/vulkan/bvh/agx3_m5_legacy_leaf.comp:- Verified uniform control flow into every subgroup operation (
subgroupClusteredOr,subgroupClusteredMin,subgroupClusteredMax,subgroupShuffleXor,subgroupShuffle): early returns are strictly workgroup-uniform (gl_WorkGroupID.x * JOBS >= total), while trailing/invalid slots setlive = falsewith empty±INFbounds andmy_bad = 0and exit only afternode_badis reduced. - Verified batched update binary search over
batch.bases[0..batch.count]handles non-multiple-of-4 job totals and zero-job updates safely (lo < batch.count, trailing lanes yieldid >= jobs->live = false). - Verified 4-lane quad reductions match QTB block partitioning for both
1..4and5..8child leaves, andin_block == 0uheader/tail zeroing is disjoint from per-lane 3-word QTB vertex writes (no write-write races). - Verified every vectorized
store128(encode_instance128B record, 64B transform, 16B pointer pair; 48B AABB record; 64B triangle record; QTB header) preserves exact byte layout and 16-byte alignment.
- Verified uniform control flow into every subgroup operation (
agx3_m5_legacy_plan.comp,agx3_m5_legacy_refit.comp,hk_build_interface.h,hk_agx3_as_format.h,hk_m5_acceleration_structure.c,test-hk-agx3-as-format.c:- Both planner exits (
finish()andplan_single_leaf()) writeVkDispatchIndirectCommand(ceil(jobs / 4), 1, 1) atargs.state + HK_AGX3_PLAN_ENCODE_DISPATCH; unbatched encode readsjob_countat offset 0 via.counts = args->stateand dispatches indirectly fromargs->state + HK_AGX3_PLAN_ENCODE_DISPATCH; batched refitprefix()computesceil(sum / 4);HK_AGX3_M5_PLAN_TAIL_B(48) andHK_AGX3_M5_NODE_GROUP_LANES(32) static assertions and unit tests match; GEN1 SPIR-V is unchanged.
- Both planner exits (
Evidence
- Code is clean with zero defects found; strong J714s (
G17S) parity, CTS (7249 pass, 0 fail), refit-vs-rebuild ray checks, and+25.7%GTA V Enhanced speedup (40.56 -> 50.99 FPS, 0 faults). Ready to approve once the base M5 (G17G) row lands.
|
Clean code review at Dispatch, shader comparison and one documentation nitBoth planner exits and the batched update prefix round the job count up to groups of four. I checked the batched lookup against a flat job list for 9,330 combinations, including empty updates and groups that span update boundaries. The indirect command fits after the plan state, and the existing barrier covers the indirect read. I compiled all 27 BVH shader variants against One documentation nit at |
There was a problem hiding this comment.
Verdict: MERGE at b952bb08
Blockers: none.
Checked:
agx3_m5_legacy_leaf.comp,agx3_m5_legacy_plan.comp,agx3_m5_legacy_refit.comp,hk_build_interface.h,hk_agx3_as_format.h,hk_m5_acceleration_structure.c,test-hk-agx3-as-format.c:- Scoped strictly to the M5 native AS builder (single GPU generation; independent 27-variant shader check confirms all 23 non-M5/GEN1/software SPIR-V variants are byte-identical).
- Subgroup uniformity, 4-jobs/workgroup batched binary search, race-free QTB quad reductions and header/tail writes, 16-byte aligned
store128records, planner/refitHK_AGX3_PLAN_ENCODE_DISPATCHindirect dispatch rounding, andHK_AGX3_M5_PLAN_TAIL_B(48) /HK_AGX3_M5_NODE_GROUP_LANES(32) static assertions and unit tests all verified clean.
- Exact-head
b952bb08J714s (M5 Pro,G17S) verification complete:- 20/20 word-for-word parity vs prior encoder (9 and 207 GTA-shaped BLAS + TLAS with moving instances).
- CTS 1.4.7.1
11,667cases (7,249 pass, 0 fail, 4,418 not supported, identical toaurora-wip). - Refit-vs-rebuild ray test (
262,144rays × 3 rounds × 2 directions) exact match;hk_agx3_as_formatunit test passes. rqbatch2207-BLAS update4.587 -> 1.130 ms, build22.867 -> 18.115 ms; GTA V Enhanced40.56 -> 50.99 FPS(+25.7%, 0 GPU faults, 0 s at 338 MHz clamp).
Evidence
- Single-generation M5-only change with full exact-head J714s parity, CTS, unit test, and benchmark evidence plus clean independent verification across all 27 BVH shader variants.
- Non-blocking nits:
src/asahi/vulkan/hk_agx3_as_format.h:20overview comment still mentions one node per 8-lane workgroup (instead of four nodes per 32-lane workgroup); optional base M5 (G17G) row / third GTA V control run / screenshot-layer frames can follow without holding merge.
|
Base M5 (
|
|
Base M5 row (MacBook Air 15" M5, J815, G17G), kernel 7.3.0-aurora-j815-dev, PR head on aurora-wip 6e153e5 vs that base, release builds, dEQP-VK 1.4.7.1 (+ KhronosGroup/VK-GL-CTS@c2c05e95f97f):
|
|
@DjDeveloperr, code-owner heads-up: App approval at |
What: The M5 node encoder ran one node per 8-lane workgroup with most of the work on one or two lanes: lane 0 fitted the root and quantized every child's bounds in turn, and one lane per QTB block quantized all of its triangles' vertices (up to 48 values). An 8-lane workgroup also leaves three quarters of each 32-lane SIMD group idle. It now encodes like the GEN1 encoder (
agx3_leaf.comp): a 32-lane workgroup encodes four node jobs, eight lanes each, and every lane handles one child (its bounds, its root word, its record and its triangle's QTB bytes). Node and QTB block bounds and the checks come from clustered subgroup operations, so there is no shared memory and no barrier. The M5 arithmetic and record layouts are unchanged, and the encoded images are byte-identical. The planner now writes the encode dispatch after its state, as GEN1's does, and the update prefix sizes the batched node encoding the same way. One update call of 207 GTA-shaped BLAS goes from 4.59 ms to 1.13 ms. GTA V Enhanced at Very High ray tracing goes from 40.7 to 50.8 FPS on the M5 Pro (+25 %).Tested: J714s (M5 Pro, G17S), stock 7.3.0-m5-pr67, SLC on, rows at this head
b952bb08f38(tree65d3639fd31: aurora-wip717a7d62e00plus this commit), built natively on the M5:ray_query.acceleration_structures(traditional, GPU-built) plusray_query.{misc,builtin,watertightness,advanced}(first 630), 11667 cases: 7249 pass, 0 fail, 4418 not supported, the same as aurora-wip.hk_agx3_as_formatunit test passes (x86_64 build). GEN1 SPIR-V is byte-identical before and after (all 25 bvh programs compiled standalone; only the M5 leaf and plan programs change).Risk: two-way · M5 family only (the M5 native acceleration-structure builder: G17G, G17S, G17C). No GEN1 program or C path changes. The M5 encode scratch grows by 16 bytes (the dispatch arguments after the plan state).
Not yet: a base M5 (G17G) row.
Evidence
GPU time (
rqbatch2, timestamps around onevkCmdBuildAccelerationStructuresKHR; 207 GTA-shaped BLAS, 319102 triangles; mean of 20 updates or 10 builds after two warm-ups; two alternating rounds each, default software traversal builds):717a7d62e00GTA V Enhanced (built-in benchmark, 2560x1440, Very High ray tracing, FSR Quality, J714s stock 7.3.0-m5-pr67, SLC on):
Every run: 0 GPU faults, 0 s at the 338 MHz clamp, same boot. The ray-tracing build is a private trial (#337 rebased with #1419) without and with this commit; the two builds differ only by it.