Repository navigation
agx: skip coherent loads in agx3_merge_m5_word_loads - #1609
DjDeveloperr merged 1 commit into
Conversation
DjDeveloperr
left a comment
There was a problem hiding this comment.
Checked at fa6a810 merged on aurora-wip 80c8e76 (merges clean).
What I ran:
agx_tests:AGX3VisionOpts.MergeWordLoadsAGX3Bpasses. The whole binary is 2,010 pass / 1 skip, andmeson test --suite asahiis 410 OK / 0 fail / 1 skip (x86, debugoptimized, assertions on).- A wide drm-shim compile slice, base vs this PR: 15,641 Vulkan CTS cases (compute, ssbo, robustness, glsl), each run with the real kernel feature word of our G15S, G16G and G17P Macs. No refused shaders in either arm on any of the three, and no case changed status. Code changed in 3 cases on G15S and G16G and in none on G17P. All three are robustness2
volatilestorage-buffer fragment tests (132 B and 256 B smaller in total). No compute shader in the slice changed.
Before this can merge:
-
Volatile loads. In this backend
coherentis also set for volatile accesses (nir_is_coherent()), and SPIR-V says a volatile access can't be combined with another. On AGX3B the pass now merges them in fragment shaders. Those three robustness2volatilefragment tests are the only changes the slice shows. Please skipI->coherentloads in every stage, not just compute. That also stops it on AGX3C fragment, which has the same problem today. -
A measured gain. The −0.47 % median on one shader is inside the run-to-run noise you measured yourself, so it doesn't show a gain yet. For a perf change we need a gain above noise on a real workload; we aim for ≥5 %, or first a throwaway hack that shows the ceiling is worth chasing.
This change also turns the pass on for AGX3B compute. The pass kept compute out on purpose: a vector load needs an aligned register range, which can push a shader past an occupancy step. The CTS slice has no compute shader that this pass changes, so it can't show that risk either way. In the three fragment changes, register counts moved both ways (on G16G one shader went from 40 to 56 halves, another from 30 to 26). Next to the gain, please post the thread counts (base vs head) for a big compute set, such as the ggml-vulkan or GB6 compute pipelines. -
The 8 in
span_scale. It's a tuning number with no stated reason. Please say which merges need more than the current2 * (count + 1)span (for example, how many of the four inmg_restrict). If they don't need it, keep the current span and drop the parameter.
Small: the PR title says fragment, but the commit also enables compute.
Once it's updated, we'll run the wide CTS slice on an AGX3B Mac at the new head before merging.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
In this backend, I->coherent also covers SPIR-V volatile accesses (via nir_is_coherent()), and SPIR-V forbids combining volatile loads with another load. Skip I->coherent in agx3_m5_word_load() so coherent/volatile scalar word loads are never merged on AGX3C fragment shaders (or any future stage using the helper), matching agx3_ordered_load_candidate(). Expose agx3_merge_m5_word_loads() for unit testing and add AGX3VisionOpts.MergeWordLoadsSkipsCoherent. Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
fa6a810 to
ed35ca8
Compare
|
Thanks for the thorough review and CTS slice. Agree on all three points: across your 15,641 CTS cases, 0 non-volatile shaders changed, 0/84 RW compute shaders changed on G16G, and our single-shader G17P I've narrowed this PR at
Note: since this now targets AGX3C (M5) only, I don't have an M5 here to run the hardware CTS row. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Checked again at ed35ca8, merged onto aurora-wip 23f7c86 (clean merge).
This is now only the volatile fix. agx3_m5_word_load() skips coherent loads, which in this backend also means SPIR-V volatile, so the pass never merges them. The rest of the diff is the export for the unit test and the test itself. The pass still runs only on AGX3C fragment shaders, so M3, M4 and Neo code doesn't change. The title and body match the commit.
What I ran (x86 debugoptimized build, assertions on):
- The new test
MergeWordLoadsSkipsCoherentfails if I take the!I->coherentcheck back out (the two coherent loads become one load with mask 0x3), and passes at this head.agx_tests: 2,013 pass, 1 skip.meson test --suite asahi: 410 OK, 0 fail, 1 skip. - drm-shim compile slice, aurora-wip vs this PR, each Mac's own feature word:
- The 15,641-case wide list on G15S, G16G, G17P and G17S: no refused shaders on either side and no case changed result. Code changes only on G17S, in 3 cases, all robustness2
volatilefragment tests. - A quarter of the robustness2 fragment storage-buffer cases (576 volatile, 576 nonvolatile): 158 cases change code on G17S, every one of them volatile; none of the nonvolatile ones change. In each, the merged load is split back into two, so those shaders are about 1.6 % larger with no change in thread count.
- ggml-vulkan (1,099 compute shaders) and GTA V (685 compute, 5,885 graphics pipelines) on G17S: no change at all.
- The 15,641-case wide list on G15S, G16G, G17P and G17S: no refused shaders on either side and no case changed result. Code changes only on G17S, in 3 cases, all robustness2
- I ran this first on cea627b and again after aurora-wip moved to 23f7c86. The result is the same: the merge is clean, the tests pass, and the changed cases give the same picture (154 changed, all volatile, 0 refused).
Approving. Before merge it still needs the J714s (M5 Pro) CTS row at this head. The kit is sealed. It runs the volatile fragment storage-buffer cases first, then their nonvolatile counterparts and the wide list.
J714s Exact-Head Hardware Receipt (
|
| Suite | Base (23f7c8697dbc) |
Head (ed35ca8519f8 merge) |
Diffs | Refused |
|---|---|---|---|---|
Focus (rt list, 2,305 cases) |
1,857 Pass / 448 NS / 0 Fail |
1,857 Pass / 448 NS / 0 Fail |
0 |
0 |
Extra (2,304 cases) |
1,856 Pass / 448 NS / 0 Fail |
1,856 Pass / 448 NS / 0 Fail |
0 |
0 |
Wide (15,641 cases) |
8,351 Pass / 7,278 NS / 12 Fail |
8,351 Pass / 7,278 NS / 12 Fail |
0 |
0 |
Total (20,239 cases/arm, 111/111 chunks, 270s wall) |
12,056 Pass / 8,171 NS / 12 Fail / 0 Warn / 0 Crash |
12,056 Pass / 8,171 NS / 12 Fail / 0 Warn / 0 Crash |
0 |
0 |
- New fails / refusals on head:
0(12cooperative_matrix.khr_rfloate4m3cases fail identically on both base and head). - GPU fault / reset / timeout lines in kernel log:
0
J714s ed35ca8519f8 VERDICT PASS (20,239 cases/arm, 0 differ, 0 new fails, 0 refused, 0 GPU fault lines).
What: Skip
I->coherent(which also carries SPIR-Vvolatilevianir_is_coherent()) inagx3_m5_word_load(), soagx3_merge_m5_word_loads()never combines volatile/coherent scalar 32-bit device loads on AGX3C fragment shaders (or any future stage using the helper).Tested: Host assertions-enabled build (
-Db_ndebug=false) ated35ca8519f:agx_tests2010 pass / 1 skip (including newAGX3VisionOpts.MergeWordLoadsSkipsCoherent).Risk: two-way door · M5 (AGX3C fragment shaders).
Not yet: M5 (AGX3C) hardware CTS row at
ed35ca8519f(we only have an M4 Max / AGX3B here).Details
agx3_ordered_load_candidate()already rejectsI->coherent, whileagx3_m5_word_load()did not.nir_is_coherent()setscoherentfor SPIR-Vvolatileaccesses,agx3_merge_m5_word_loads()could combine adjacent volatile 32-bit fragment loads on AGX3C, violating SPIR-V volatile semantics.span_scaleparameter after review showed 0 non-volatile CTS changes across 15,641 cases, 0/84 RW compute hits on G16G, and only noise-level (−0.47 %) delta on G17Pmg_restrict.agx3_merge_m5_word_loads()inagx_compiler.hfor unit testing and addsAGX3VisionOpts.MergeWordLoadsSkipsCoherent.Evidence
ninja -C build src/asahi/compiler/agx_tests && ./build/src/asahi/compiler/agx_tests: 2010 pass, 1 skip, 0 fail ated35ca8519f.AGX3VisionOpts.MergeWordLoadsSkipsCoherent: verifies coherent consecutive loads stay separate while non-coherent consecutive loads on AGX3C fragment still merge.