Repository navigation
agx/optimizer: keep out-of-range ASR shift counts in a register on AGX3 - #1279
Conversation
AGX3B/AGX3C immediate ASR only encodes shift counts in [1, width - 1] (1..15 for 16-bit values, 1..31 for 32-bit values). Folding a MOV_IMM of 0 or >= width into src[1] of AGX_OPCODE_ASR caused agx3_pack_program() to refuse the shader (hitting VK_ERROR_UNKNOWN on cooperative-matrix matrixmuladd_dequant.*.decode tests). Keep out-of-range ASR shift counts in their register so AGX3 uses the register-count ASR encoding, and add Optimizer.Agx3AsrImmediateRange. Signed-off-by: Satya Benson <satya@benson.earth>
|
Verified combined with
|
There was a problem hiding this comment.
Verdict: MERGE at 5071e934
Blockers: none.
Checked: no Apple material, no AI attribution, no board/firmware gates (ISA encoding check AGX_ISA_ENCODING_AGX3B || AGX_ISA_ENCODING_AGX3C matching AGX3 binary packer constraints), human Signed-off-by, 16-bit (max_shift = 15) and 32-bit (max_shift = 31) immediate bounds and 0 exclusion, AGX2 unchanged, Optimizer.Agx3AsrImmediateRange unit tests, 337/337 asahi suite, J775c Vulkan CTS subgroupscope.matrixmuladd_dequant.* 0/6 -> 6/6 PASS.
Evidence
- Inspected
src/asahi/compiler/agx_optimizer.c:676-690andtest-optimizer.cpp: prevents immediate inlining intoAGX_OPCODE_ASRsrc[1]on AGX3B/AGX3C whendef->imm == 0 || def->imm > max_shift(15forAGX_SIZE_16,31forAGX_SIZE_32), keeping valid[1, width - 1]immediates and AGX2 unchanged. - Verified on J775c M5 Max (
G17C B1) at exact head5071e934: 337/337 asahi unit tests, CTSdEQP-VK.compute.pipeline.cooperative_matrix.khr_r.subgroupscope.matrixmuladd_dequant.*improved from0/6to6/6 PASS, 0 GPU faults.
|
@DjDeveloperr, code-owner heads-up: this PR has an aurora-silicon-review App approval at |
|
Merge-train landing at
Revert: |
What
Stops
agx_optimizerfrom folding out-of-rangeMOV_IMMshift counts (0or>= width) intosrc[1]ofAGX_OPCODE_ASRon AGX3 (AGX3B/AGX3C).agx3_pack_program()only has immediateASRencodings for shift counts in[1, 15](16-bit value) and[1, 31](32-bit value). Foldingimm#0(or>= width) intosrc[1]caused the binary packer to refuse the shader (VK_ERROR_UNKNOWN), failing all runnableVK_NV_cooperative_matrix2matrixmuladd_dequant.*.decodetests on M5. Keeping out-of-range counts in a register routes them to the register-countASRencoding cleanly.Also adds
Optimizer.Agx3AsrImmediateRangeinsrc/asahi/compiler/test/test-optimizer.cpp.Tested
Tested at exact HEAD
5071e934c45on Apple M5 Max (J775c, 40-coreG17C B1, Borealis):meson test -C build --suite asahi— 337/337 OK, 0 FAIL (including newOptimizer.Agx3AsrImmediateRange).dEQP-VK.compute.pipeline.cooperative_matrix.khr_r.subgroupscope.matrixmuladd_dequant.*):aurora-wipdd57f9350c2):0/6 PASS, 6/6 FAIL(AGX3 binary packer refused asr [d32 s0=32 s1=16:imm#0]).5071e934c45): 6/6 PASS, 0 FAIL, 14 NotSupported, 0 GPU faults.workgroupscope.matrixmuladd_dequant.*.decodetests from agx,borealis: implement VK_NV_cooperative_matrix2 cooperativeMatrixWorkgroupScope #1278.)Risk
AGX_OPCODE_ASRsrc[1]on AGX3B/AGX3C when the immediate is0or> width - 1(cases that the AGX3 binary packer unconditionally refuses). Valid shifts1..15/1..31and AGX2 are unchanged.Not yet
G17C B1);G17P(AGX3B) hardware row not yet run (covered by unit testagx3b-32-zero/agx3b-32-one).