Repository navigation
asahi: share negative-zero operands for G16 uniform clamps - #48
IronsideXXVI wants to merge 4 commits into
Conversation
Preserve f32 saturated-add semantics while materializing one negative-zero GPR per block rather than copying every uniform source. Qualified on an M4 with matching finite blend readbacks and 6.126% lower fill submission time. Retain ASAHI_G16_SHARED_NZ=0 opt-out and include the choice in the Vulkan compiler cache key. Assisted-by: LLM
Retain a reliable opt-out for OpenGL as well as Vulkan when process flags change. Assisted-by: LLM
[Medium impact] The latest changes appear safe to merge because they only clarify comments. SummaryThe PR shares one negative-zero register per block for eligible G16G uniform clamps, while keeping the same float32 add and saturation.
Reviews (3) · Last reviewed commit: "asahi: name the sources of the G16 share..." · Reviewed by Greptile |
|
Thanks. The review found nothing to change, so this stays as it is. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Thanks Dylan. Sharing one -0.0 GPR per block for the saturated uniform adds meets the mixed uniform/GPR operand rule without a copy per clamp, and the old/off/on ordering with a byte-for-byte readback makes the 6 % easy to trust.
What blocks a merge:
ASAHI_G16_SHARED_NZ(agx_g16_shared_nz_enabled()insrc/asahi/compiler/agx_compile.c) is a runtime switch. Merged code here can't carry runtime switches or A/B parameters. Please drop it so the shared operand is the only path, along with the Gallium disk-cache change in b0b3902, which exists only to keep the two settings apart.G16SharedNegativeZerocan then assert the shared form unconditionally.- The
value >= 256andvalue & 1checks need a stated source. Name them, or say in the comment which encoding limit each one comes from. - Hardware conformance, which this tree's policy requires before a merge: a G16G vk-default subset run with 0 new Fail/Crash against the
integration/aurorabase, plus a GL smoke run, because the change reaches Gallium as well. The description is clear that the pixel checks so far are differential, not CTS.
A question, not a blocker: every G16 part executes AGX3b (src/asahi/lib/agx_chip.h), but the pass runs on G16G only. If G16S/G16C are left out only because they weren't measured, please say so in the commit message. If something about them rules the pass out, say what.
Mesa CI on b0b3902 is approved and running.
Merged code cannot carry runtime switches. Remove ASAHI_G16_SHARED_NZ and agx_g16_shared_nz_enabled(): on G16G the saturated uniform add now always shares one -0.0 register per block. The Vulkan compiler-flag bit and the Gallium disk-cache bit only kept the two settings apart, so they go too. G16SharedNegativeZero and the capture test assert the shared form unconditionally. The pass stays limited to G16G because that is the only AGX3b part it was measured on. G16S and G16C were not measured; nothing known rules them out. Assisted-by: LLM
|
Thanks. I'll drop On G16S/G16C: they're left out only because I haven't measured them. The only G16 part I have is the G16G in my M4 MacBook Pro. I'll say so in the commit message. |
|
Pushed 3b5308b ("asahi: drop the G16 shared negative-zero switch"):
The repo's CI Still open: naming the encoding limit behind the |
The odd-index check is an encoding limit: an f32 uniform operand starts on an even 16-bit half, as agx_instr_accepts_uniform() and agx3_uniform_float_encode() require. The 256 bound is not one: the encoder takes uniform sources up to half 511, and the pass keeps the low-half bound it was measured with. Comment only, no change in code generation. Assisted-by: LLM
|
Pushed 948be88 for point 2: the sources are named in the comment above the pass.
Comment only, no change in generated code. meson test: 156 ok, 0 fail. |
|
Retargeted to aurora-silicon#604 |
G16 uniform clamps currently copy each uniform into a GPR before a saturated float32 add. Reuse one negative-zero GPR per block instead, retaining the same add, operand order, saturation and precision. This is restricted to eligible G16G operands.
ASAHI_G16_SHARED_NZ=0restores the previous path; the compiler-cache key includes the choice.On an M4 MacBook Pro, a balanced same-boot old/off/on/on/off/old test of 1080p RGBA8 blended fill (depth 64, three samples per window) measured 371.494 → 348.73585 µs per submit, a 6.126% latency reduction. Every enabled sample was below every disabled sample. The selected shader changed from 178 bytes/25 compiler instructions to 170 bytes/22, with GPR/spill counts unchanged. Across all three arms, a finite 64-frame, 16-layer blend readback matched byte-for-byte and each arm had zero GPU faults. Diagnostic timings were excluded.
Validation: the experimental compiler suite passed 977 tests in both modes (one skipped and one disabled). Added tests cover materialization, captured blend expression compilation, signed zero, finite clamp boundaries and host bit-pattern cases. Production Mesa/Vulkan 1.8145 packages have now passed the official 188 Meson tests with zero failures; default and explicit opt-out compiler cases pass 3/3 each. The integration/aurora port also builds and passes those cases in both modes. Gallium and Vulkan cache keys both separate the opt-out. These are finite differential correctness results, not a full graphics conformance or macOS-parity claim; no constant-program protocol is changed.
Hardware testing used the installed 8f013bf-based Mesa plus three distribution patches. This PR ports only the optimization and its tests onto
integration/aurora; it does not import that entire source branch. No Apple binaries or captures are included.