Repository navigation
drm/asahi: g17: scale base compute pool with active cores - #3833
Conversation
G17P compute pools reserve per-core shader-context scratch (SCS) pages on top of a base free-list block count. Leaving the base at the 5-core A18 Pro floor (21 blocks = 1.05 blocks/core on 20-core T6040) starves concurrent USC private-memory and SCS allocations once more than one wave is active, throttling 20-core ray-tracing traversal and ray-query compute by 5x-10x. Scale the base compute pool linearly with active cores at three 1 MiB blocks per core (matching MULTI_CLUSTER_RENDER_BLOCKS_PER_CORE and 32-core T6041's 96-block pool), floored at COMPUTE_BLOCKS (21) and preserving any larger static floor (such as 40-core T6041's 160 blocks). Add KUnit coverage for base_blocks() and required_blocks(). Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
Hardware qualification row — J616s (20-core M4 Pro, T6040) at exact head
|
| Benchmark | Saved Edge (base=21) |
PR #3833 (852ce265059e1) |
Speedup | macOS Metal (J616s) | Linux / Metal |
|---|---|---|---|---|---|
rt.scene raster d2 |
— | 745.00 fps | — | 723.80 fps | 1.03x |
rt.scene light d2 |
— | 3,228.03 fps | — | 2,849.53 fps | 1.13x |
rt.scene medium d2 |
74.74 fps | 246.00 fps | 3.29x | 268.70 fps | 0.92x |
rt.scene solarbay d2 |
69.77 fps | 171.60 fps | 2.46x | 187.00 fps | 0.92x |
rt.scene heavy d2 |
— | 70.36 fps | — | 72.44 fps | 0.97x |
rt.scene extreme d2 |
— | 14.11 fps | — | 13.20 fps | 1.07x |
rt.rays coherent d16 |
355.7 Mray/s | 2,210.31 Mray/s | 6.21x | 1,939.0 Mray/s | 1.14x |
rt.rays incoherent d16 |
336.1 Mray/s | 1,290.54 Mray/s | 3.84x | — | — |
rt.trav miss d16 |
4,907.5 Mray/s | 5,007.68 Mray/s | 1.02x | 1,035.5 Mray/s | 4.84x |
rt.trav single d16 |
568.1 Mray/s | 2,811.12 Mray/s | 4.95x | 1,320.7 Mray/s | 2.13x |
rt.trav comb 16 d16 |
1,499.4 Mray/s | 2,808.76 Mray/s | 1.87x | 1,650.7 Mray/s | 1.70x |
rt.trav grid 128 d16 |
444.1 Mray/s | 2,161.34 Mray/s | 4.87x | 1,311.6 Mray/s | 1.65x |
rt.trav grid 2048 d16 |
371.4 Mray/s | 1,950.63 Mray/s | 5.25x | 1,912.6 Mray/s | 1.02x |
rt.trav gap 64 eps=0.01 d16 |
43.63 Mray/s | 409.40 Mray/s | 9.38x | 215.7 Mray/s | 1.90x |
rt.trav gap 64 eps=0.0001 d16 |
16.03 Mray/s | 163.00 Mray/s | 10.17x | 216.1 Mray/s | 0.75x |
rt.trav gap 64 eps=0.125 d16 |
1,449.9 Mray/s | 2,472.05 Mray/s | 1.71x | 2,969.2 Mray/s | 0.83x |
rt.asbuild blas/refit/tlas d1 |
— | 70.76 / 365.10 Mtri/s, 1.71 Minst/s |
— | — | — |
- Restore: plain reboot returned to saved
7.3.0-aurora-edge(aurora-edge-933f8226,boot_success=1,next_entryempty, saved BLS/GRUB/Stage 2/cmdline byte-identical, all trial files removed,Enforcing,failed=0,speakerguardd-v2active).
There was a problem hiding this comment.
Verdict: MERGE at 852ce26
Checked: base_blocks = max(base, 21, 3cores) with a checked multiply. For every non-M5 part the scaled floor is at or above the old 21 blocks, so no pool gets smaller. Larger static floors (160 on 40-core) are kept. required_blocks now converts the scaled base to bytes with checked_mul and adds the SCS extra afterwards, so the extra is not scaled. The E2BIG ceiling is PAGE_LIST_SIZE / (0x1008) = 1024 blocks, and 32 cores plus 791-page scratch stays far below it. The only caller is compute_capacity (runtime.rs:3150): M5 returns early, and other parts grow the pool on demand through ensure_compute, so the larger floor only costs memory on owners that submit compute. KUnit cases match the hand arithmetic (20 cores 791 pages: 60 + ceil(20*803/256)=63). CI green; exact-head J616s row PASS.
Follow-ups (not blocking): each compute owner on a 16/20-core T6040 now reserves 48/60 MiB of compute blocks, up from 21. Record the per-owner footprint with many compute clients (for example a browser plus a game) in a later perf note.
Problem
On 20-core M4 Pro (T6040 / J616s), Vulkan ray-tracing workloads (
rt.trav,rt.rays,rt.scene) ran 5x-10x slower than macOS Metal and slower in absolute throughput than 5-core A18 Pro (Neo) on identical Mesa Borealis binaries, while non-hit BVH traversal (rt.trav miss,comb) and ordinary ALU/render scaled normally with core count.Ray-count scaling showed
rt.trav singleran at full Metal speed (~1,437 Mray/s) up to 16,384 rays (~1 wave across 20 cores) and dropped 3x-5x once multiple waves ran concurrently.A live sweep on J616s (T6040, 20 active cores) isolated the cause to
compute_blocks: T6040 inherited A18 Pro'sCOMPUTE_BLOCKS = 21floor (1.05blocks/core), whereas 5-core A18 Pro has4.20blocks/core and 32-core T6041 has96(3.00blocks/core). Sweeping21..80blocks saturates cleanly at56..60blocks (2.8..3.0blocks/core):d4ad4a4dce)base=21(stock)base=60(3/core)rt.trav singled16549 us)92.6 us)rt.trav grid 2048d16805 us)132 us)rt.trav gap 64 eps=0.0001d1619.1 ms)1.60 ms)rt.rays coherentd16843 us)117 us)rt.rays incoherentd16866 us)200 us)rt.scene mediumd213.7 ms)4.07 ms)rt.scene solarbayd214.5 ms)5.87 ms)Fix
COMPUTE_BLOCKS_PER_CORE = 3indrivers/gpu/drm/asahi/g17/fw/freelist.rs(matchingMULTI_CLUSTER_RENDER_BLOCKS_PER_CORE = 3and 32-core T6041's 96-block compute pool).base_blocks(base, active_cores)indrivers/gpu/drm/asahi/g17/fw/compute_pool.rsand use it inrequired_blocks(), scaling linearly with active cores while keepingCOMPUTE_BLOCKS(21) as the floor and preserving any larger static floor (such as 40-core T6041's 160 blocks).21blocks)48blocks (3/core)60blocks (3/core)96blocks)160blocks)ComputeCapacity::M5)asahi_g17_compute_poolcovering floor preservation, core-count scaling, SCS scratch additions, invalid shapes, and overflow/bounds checks.Tested: KUnit suite
asahi_g17_compute_pool(apple-build-kunit) + live J616scompute_blockssweep (21..80, 0 GPU faults); exact-SHA J616s hardware qualification row (gate + s2idle + Vulkan RT CTS + fullgpubench-rt-vk+gpubench-vkcompute/render control) running now and will be posted below.Risk: two-way · M4 Pro (T6040) — increases base compute free-list pool from 21 to 48/60 MiB on 16/20-core T6040 only (
service_compute_poolsandplace_lowerhandle reclamation/pressure cleanly); 5/6-core A18 Pro, 32/40-core T6041, and M5 keep identical pool sizes.