diff options
| author | hugo <63666848+hugo0024@users.noreply.github.com> | 2026-11-25 17:38:41 +0800 |
|---|---|---|
| committer | hugo <63666848+hugo0024@users.noreply.github.com> | 2026-11-28 12:44:48 +0800 |
| commit | 420116dbbcf78d75d8f0893c8cd8bcfbfb0bcdab (patch) | |
| tree | 4c6eca585f1983014b197fe8508f8bfefcf315c9 /runtime | |
| parent | ef8fbf09f3ba00460e1c08102b096b76702a70b6 (diff) | |
tests: cs_fma_fused takes its f16 operands at run time, like its f32 ones (TEST-FMA-FUSED-F16-RUNTIME)
The fixture reads the operands of its f32 multiply-adds from s4..s7 so that a driver has to
compute them at run time. The three operands of its v_fma_f16 were literals, which made the
whole f16 multiply-add a compile-time constant. MoltenVK 1.4.2 gives the wrong constant: word
7 read 0x0000 on an Apple M5 (0x3c00 in the docs' row) where 0x7351 is expected, the
cs_fma_fused failure listed in docs/testing.md and in the macOS job's EXPECTED_FAILURES. The
same translation with any one of the three operands taken at run time gives 0x7351.
The triple is now the s4 word XOR a literal each, so the test checks the translator's
round-to-odd sequence as the GPU runs it. The translator is not changed.
tests/semantic/test_fma_fused_fixture.py runs the fixture in the interpreter against the eight
words of its header and checks that no multiply-add in it reads a register only literals fed.
The Known problems row says what is left: an f16 multiply-add with only constant operands.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/test/shaders/cs_fma_fused.asm | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/runtime/test/shaders/cs_fma_fused.asm b/runtime/test/shaders/cs_fma_fused.asm index 31282c47a..198ca6137 100644 --- a/runtime/test/shaders/cs_fma_fused.asm +++ b/runtime/test/shaders/cs_fma_fused.asm | |||
| @@ -21,6 +21,10 @@ | |||
| 21 | ; --fma glsl and --fma khr. | 21 | ; --fma glsl and --fma khr. |
| 22 | ; The operands come in through s4..s7 (VKC_SGPRS=0x3f800800,0x3f800001,0x3f7ffffe,0xbf800002: a, 1+2^-23, 1-2^-23, | 22 | ; The operands come in through s4..s7 (VKC_SGPRS=0x3f800800,0x3f800001,0x3f7ffffe,0xbf800002: a, 1+2^-23, 1-2^-23, |
| 23 | ; -(1+2^-22)), so a driver cannot fold the multiply-adds at compile time; only the fmaak/fmamk constants are literals. | 23 | ; -(1+2^-22)), so a driver cannot fold the multiply-adds at compile time; only the fmaak/fmamk constants are literals. |
| 24 | ; The f16 triple is a XOR a literal each (0x3f800800 ^ 0x3f8064e1 = 0x6ce1, ^ 0x3f804a00 = 0x4200, ^ 0x3f808804 = | ||
| 25 | ; 0x8004) for the same reason (TEST-FMA-FUSED-F16-RUNTIME). As three literals the whole f16 multiply-add was a | ||
| 26 | ; compile-time constant, and MoltenVK 1.4.2 gave the wrong one: word 7 read 0x0000 on an Apple M5 (0x3c00 in an | ||
| 27 | ; earlier report), while the same translation with any one of the three taken at run time gave 0x7351. | ||
| 24 | ; Run: VKC_SGPRS=0x3f800800,0x3f800001,0x3f7ffffe,0xbf800002 vk_compute_test cs_fma_fused.spv 1 dump | 28 | ; Run: VKC_SGPRS=0x3f800800,0x3f800001,0x3f7ffffe,0xbf800002 vk_compute_test cs_fma_fused.spv 1 dump |
| 25 | ; out[0..7] = 33800000 a8800000 3a000400 33800000 33800000 33800000 28800000 00007351 (hex) | 29 | ; out[0..7] = 33800000 a8800000 3a000400 33800000 33800000 33800000 28800000 00007351 (hex) |
| 26 | ; group: 1,1,1 | 30 | ; group: 1,1,1 |
| @@ -47,9 +51,9 @@ buffer_store_dword v12, v20, s[0:3], 0 offen offset:20 | |||
| 47 | v_mov_b32_e32 v13, s7 | 51 | v_mov_b32_e32 v13, s7 |
| 48 | v_fma_f32 v14, v5, v5, v13 | 52 | v_fma_f32 v14, v5, v5, v13 |
| 49 | buffer_store_dword v14, v20, s[0:3], 0 offen offset:24 | 53 | buffer_store_dword v14, v20, s[0:3], 0 offen offset:24 |
| 50 | v_mov_b32_e32 v15, 0x6ce1 | 54 | v_xor_b32_e32 v15, 0x3f8064e1, v0 |
| 51 | v_mov_b32_e32 v16, 0x4200 | 55 | v_xor_b32_e32 v16, 0x3f804a00, v0 |
| 52 | v_mov_b32_e32 v17, 0x8004 | 56 | v_xor_b32_e32 v17, 0x3f808804, v0 |
| 53 | v_fma_f16 v18, v15, v16, v17 | 57 | v_fma_f16 v18, v15, v16, v17 |
| 54 | v_and_b32_e32 v18, 0xffff, v18 | 58 | v_and_b32_e32 v18, 0xffff, v18 |
| 55 | buffer_store_dword v18, v20, s[0:3], 0 offen offset:28 | 59 | buffer_store_dword v18, v20, s[0:3], 0 offen offset:28 |