Repository navigation
spirv: make image texels available after the write and visible before the read - #1155
Conversation
… the read
OpImageWrite with MakeTexelAvailable and OpImageRead with MakeTexelVisible
describe the texel of that very access. vtn_handle_image split their
semantics with vtn_split_barrier_semantics, which places MakeAvailable
before the operation and MakeVisible after it. That is right for a release
or acquire atomic, but it put a texel write outside its own availability
operation. nir_lower_memory_model marks only the writes that precede a
MakeAvailable barrier as coherent, so the store stayed non-coherent.
On G13C (M1 Max) a devicecoherent image payload published across
workgroups then failed: dEQP-VK.memory_model.message_passing.ext
u32.coherent.*.{device,queuefamily}.payload_local.image.guard_local.*.comp
(30 cases, deterministic, 30 of 30 in 6 of 6 runs, with and without the
dependency-tracked CDM barrier). The failing and passing shader pairs had
identical barrier and cache-flush sequences; the only difference in the
disassembly was the coherent flag on the image write. Four cache flush
variants did not change the result.
Swap the two sides for ImageRead, ImageSparseRead and ImageWrite. These
carry no Acquire or Release bits, so only the MakeTexel semantics move.
Atomics keep the old placement.
Add opimageread_vis and opimagewrite_avail to the availability and
visibility unit tests. They assert the order, which the existing tests
do not: the available barrier follows the image store and the visible
barrier precedes the image load. Both fail on the parent commit
(barrier position 10 vs load 9, and barrier 14 vs store 15) and pass with
this change; the 27 spirv_tests pass.
Results on G13C (aurora 12.6 prerelease kernel), same driver with and
without the change:
- the 30 cases: Pass in 3 of 3 runs
- memory_model.* and subgroups.basic.* (18,600 cases): 2,283 Pass,
16,317 NotSupported, 0 Fail; 30 Fail -> Pass, 0 Pass -> other
- the 20,683-case bf16, precision, cooperative_matrix and
compute.pipeline list: 0 status changes
Same lists on G13G (M1) and G14C (M2 Max) with and without the change:
the 30 cases pass in 3 of 3 runs, the memory model and subgroup list has
0 status changes (these chips already passed the 30 cases without the
change), and the 20,683-case list has 0 status changes.
Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins. |
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: MERGE at 09d42db9a90c
Blockers: none
Checked: Read the diff against the SPIR-V spec wording: MakeTexelAvailable is an availability operation after the write, MakeTexelVisible a visibility operation before the read, so swapping the split for OpImageRead/OpImageSparseRead/OpImageWrite is right; these ops cannot carry Acquire/Release bits, so nothing else moves, and image atomics keep the release/acquire placement. Shared Mesa code with no driver or chip condition. Tests fail without the fix: I disabled the swap in the batch tree and rebuilt spirv_tests: opimageread_vis and opimagewrite_avail both FAIL, the other 7 pass; with the fix all 9 pass. Since this is core spirv_to_nir code, it is also worth sending upstream.
Evidence
Local Mesa gate (stands in for CI; buildbox x86 docker aurora/hk6356-mesa-x86-tests:local, clang release with asserts, -Dbuild-tests=true -Dtools=asahi,drm-shim, meson test --suite asahi --suite poly):
- base
aurora-wip90211df6816: 335/335 OK. - batch build:
90211df6816with 22 open PR heads merged on top (#1133 #1137 #1155 #1136 #1140 #1157 #1158 #1160 #1164 #1165 #1167 #1168 #1170 #1171 #1172 #1175 #1182 #1183 #1185 #1187 #1190 #1191; each also merges cleanly alone, and into currentaurora-wipd2e883ab2e3): 335/336 OK. The one failure,agx3_cmat_mixed_mma8, reproduces with #1187 alone on the base (329/330) and is caused by that PR's new test; nothing else in the batch fails. spirv_testsin the batch build: OK;AvailabilityVisibility.*9/9. Negative control (swap disabled): 2 FAILED (opimageread_vis,opimagewrite_avail), 7 passed.
|
09d42db J473 M2 mini (G14G B0, 7.3.0-aurora-fleet89) PASS: memory_model.* 2,976 pass / 15,554 not supported / 0 fail (18,530 cases, every listed case ran), 0 GPU faults, Enforcing, 0 failed, 0 AVC; system Mesa untouched Details
|
|
|
What
Fix
MakeTexelAvailableandMakeTexelVisiblebarrier placement insrc/compiler/spirv/spirv_to_nir.c:vtn_handle_image()forSpvOpImageRead,SpvOpImageSparseRead, andSpvOpImageWrite.OpImageWritewithMakeTexelAvailableandOpImageReadwithMakeTexelVisibledescribe the texel of that very access.vtn_handle_image()split their memory semantics withvtn_split_barrier_semantics(), which putsMakeAvailablebefore the operation andMakeVisibleafter it. That placement is right for release/acquire atomics, but for plain image reads and writes it placed the texel write outside its own availability barrier and the texel read before its own visibility barrier. Becausenir_lower_memory_modelmarks only writes that precede aMakeAvailablebarrier as coherent, the image store stayed non-coherent.Plain image reads and writes carry no Acquire or Release bits, so swapping
before_semanticsandafter_semanticsforSpvOpImageRead,SpvOpImageSparseRead, andSpvOpImageWriteplacesMakeTexelAvailableafter the write andMakeTexelVisiblebefore the read. Image atomics keep the existing placement.Adds
opimageread_visandopimagewrite_availinsrc/compiler/spirv/tests/avail_vis.cppasserting the exact intrinsic order (visible barrier beforeimage_deref_load, available barrier afterimage_deref_store). Both fail onaurora-wip(90b5a80e55c) and pass with this change.No runtime switches, no environment variables, and no chip gates.
Verification
Unit tests (exact head
09d42db9a90onaurora-wip90b5a80e55c, native aarch64 clang release build)spirv_tests: 32/32 passed (includingAvailabilityVisibility9/9:opimageread_vis,opimagewrite_avail,opimageread_vis_opimagewrite_avail_coherent).mesa:asahi): 212/212 passed (0 fail, 0 skip, 0 timeout).Hardware CTS results (same driver with and without this change)
G13C):dEQP-VK.memory_model.message_passing.ext.u32.coherent.*.{device,queuefamily}.payload_local.image.guard_local.*.comp(30 cases): 30/30 deterministic Fail (6/6 runs) -> 30/30 Pass (3/3 runs).dEQP-VK.memory_model.*anddEQP-VK.subgroups.basic.*(18,600 cases): 2,283 Pass, 16,317 NotSupported, 0 Fail (30 Fail -> Pass, 0 Pass -> other).bf16,precision,cooperative_matrix, andcompute.pipelinesuite: 0 status changes.G13G) and M2 Max (G14C):Risk
Very low. Six-line swap in
vtn_handle_image()scoped strictly toSpvOpImageRead,SpvOpImageSparseRead, andSpvOpImageWrite(none of which can carry Acquire/Release semantics). Image atomics are unchanged. No performance impact (zero extra instructions outside the affectedMakeTexelAvailable/MakeTexelVisiblememory-model path).