Skip to content

docs/design.md: opcode differences between gfx1013 and the gfx1036 oracle - #3517

Open
Vonsek wants to merge 2 commits into
ItsNotRexed:mainfrom
Vonsek:claude/docs-gfx1013-opcodes
Open

Vonsek wants to merge 2 commits into
ItsNotRexed:mainfrom
Vonsek:claude/docs-gfx1013-opcodes

Conversation

@Vonsek

@Vonsek Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Requested by Lucas · project thread

Claimed in the coordination issue as: EGEN-DOCS-GFX1013-OPCODES, #3381 (comment)

What and why

The console is gfx1013 (GFX10.1), but the hardware oracle most rows were measured on is gfx1036 (GFX10.3). I checked where their instruction sets differ. I disassembled every opcode value of every GFX10 encoding with LLVM 21 llvm-mc, once for -mcpu=gfx1013 and once for gfx1030/gfx1036, and compared the mnemonics. The gfx1030 and gfx1036 lists are identical. 119 opcode slots differ, and every other slot decodes to the same mnemonic on both sides. So the gfx1036 measurements describe the same instructions the console runs, though nothing in an opcode table can show microarchitectural differences.

Only on gfx1013:

  • v_mac_f32, v_mad_f32, v_mac_legacy_f32, v_mad_legacy_f32: the translator handles these.
  • v_mul_lo_i32: Unsupported until rdna2spirv: v_mul_lo_i32 (GFX10.1-only VOP3 0x16b) #3504 translates it.
  • s_get_waveid_in_workgroup: the translator handles it.
  • Scalar stores, scalar atomics, scalar scratch, s_dcache_wb and s_dcache_discard: Unsupported.
  • The 31 ds_*_src2_* forms: Unsupported.

Only on gfx103x:

  • The dot products.
  • v_fmac_legacy_f32 and v_fma_legacy_f32, which use the same encodings as v_mac_legacy_f32 and v_mad_legacy_f32.
  • *_dword_addtid and *_atomic_csub.

The translator handles the integer dot products and refuses the rest of the gfx103x-only list. That means a listing disassembled for the wrong target fails loudly instead of being translated as an FMA.

Changes in docs/design.md:

  • A new row records the sweep and the translator's status for each differing opcode.
  • In the v_mad_f32/v_mac_f32/v_mad_legacy_f32 denormal row, the text "needs an RDNA1/RDNA2 part" becomes "an RDNA1 part". No RDNA2 part has these opcodes, and a raw-encoding run on gfx1036 would measure the fused *_legacy forms instead.

Tested

Docs only. pytest tests/test_docs_design_rows.py passes.

For reference, the sweep script (standard library plus llvm-mc, not committed) disassembles each opcode in its own llvm-mc call. It tries a few operand templates per encoding, because the decoder rejects non-zero unused fields. Slots that no template decoded on either target are not compared.

AI-assisted.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

@iurysf

iurysf commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Code read of 190aff6: the opcode split matches what I could check; two small notes.

I assembled 20 instructions with llvm-mc 23.1.6 for gfx1013, gfx1030 and gfx1036 (11 from your "only gfx1013" list, 7 from "only gfx103x", 2 common ones). All 20 matched the PR: v_mac_f32, v_mad_f32, v_mac_legacy_f32, v_mad_legacy_f32, v_mul_lo_i32, s_get_waveid_in_workgroup, s_store_dword, s_atomic_add, s_dcache_wb, s_dcache_discard, ds_add_src2_u32 assemble only on gfx1013; v_dot2_f32_f16, v_dot4_i32_i8, v_fmac_legacy_f32, v_fma_legacy_f32, global_load_dword_addtid, global_atomic_csub, buffer_atomic_csub only on gfx1030/gfx1036 (which agree). Through tests/semantic/support.translate_lines on this commit: the four mac/mad forms and v_dot4_i32_i8 translate; v_mul_lo_i32, s_store_dword, s_atomic_add, s_dcache_wb, v_dot2_f32_f16, v_fmac_legacy_f32, v_fma_legacy_f32 and global_atomic_csub raise Unsupported. There is no _src2_ handler in tools/rdna2spirv.py. I did not re-run the full 119-slot sweep, and I did not re-check s_get_waveid_in_workgroup in a compute shader.

Notes: (1) "translated in compute and mesh shaders" for s_get_waveid_in_workgroup could say it's refused elsewhere (Unsupported: ... outside compute, rdna2spirv.py:7278). (2) The sweep behind "119 slots" isn't in the repo; a short script or the exact command would make the row repeatable.

Ran at this commit (Windows 11): tests/test_docs_design_rows.py, test_docs_links.py, test_docs_list_items.py, test_docs_repo_paths.py, test_i18n_index.py, test_text_write_line_endings.py — all OK.

AI-assisted code read (Claude). No game data used.

@thirteenhustler

Copy link
Copy Markdown

Read 602a404: the translator status in the new row matches the code; the denormal sentence still argues with the measurement above it

docs/design.md:409. On this head:

  • v_mac_f32 / v_mad_f32 are handled at tools/rdna2spirv.py:8096, and v_mac_legacy_f32 / v_mad_legacy_f32 at :7586.
  • v_mul_lo_i32 has no handler. rdna2spirv: v_mul_lo_i32 (GFX10.1-only VOP3 0x16b) #3504 is still open, and its title names VOP3 0x16b, which is the encoding in the row.
  • s_get_waveid_in_workgroup is emitted for compute and mesh (stage not in ("cs", "ms") at :7909). The error string still says "outside compute".
  • The integer dots are handled: v_dot2_i32_i16, v_dot2_u32_u16, v_dot4_u32_u8, v_dot8_i32_i4, v_dot8_u32_u4 at :5718, and v_dot4_i32_i8 / v_dot4c_i32_i8 at :9432. v_dot2_f32_f16, v_dot2c_f32_f16, v_fmac_legacy_f32, v_fma_legacy_f32, the *_dword_addtid forms, global_atomic_csub, buffer_atomic_csub, s_dcache_wb and the ds_*_src2_* names do not appear in the translator, so they come out Unsupported.

docs/design.md:406 already reports a native RDNA1 run (RX 5600 XT, gfx1010, 48 of 48, both waves). The clause this commit rewrites still says "not GPU-verified — a native measurement still needs an RDNA1 part". That measurement is the sentence above it. The encoding warning (gfx103x 0x06 / 0x140 are the fused legacy ops) can stay; the "still needs an RDNA1 part" tail should go.

I did not re-run the LLVM 21 llvm-mc sweep, so the encoding numbers and "every other slot matches" stay a stated measurement. test_docs_design_rows.py, test_docs_links.py, test_docs_list_items.py, test_docs_repo_paths.py: OK. git diff --check clean. This head is current main plus the two row edits. No game data.

@sds-228 sds-228 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review of 602a404: one issue. The edited row now records a native RDNA1 measurement but still says the behaviour is not GPU-verified and needs an RDNA1 part; please remove or reword the stale claim.

AI-assisted (OpenCode).

@memorypressure

Copy link
Copy Markdown

Verified merged with current main: the new GFX10.1-vs-GFX10.3 contract-table row sits correctly in docs/design.md and matches the adjacent mad/legacy rows' encodings (VOP2 0x06, VOP3 0x106/0x140 as the fused forms on gfx103x). test_docs_design_rows, test_docs_links, test_docs_repo_paths, test_docs_table_rows and compileall all pass. The full gfx1013-vs-gfx1030/1036 llvm-mc decode sweep was not re-run in this CPU-only check; the toolchain (LLVM 21) is stated explicitly, which is the right way to record it. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@KkelebekK

Copy link
Copy Markdown

Reviewed c541801, checked with llvm-mc 23.1.4 (-triple=amdgcn--amdpal, -mcpu=gfx1013 vs gfx1030/gfx1036, -show-encoding and --disassemble).

The opcode claims hold:

  • gfx1013 accepts, gfx1030/gfx1036 reject: v_mac_f32 (VOP2 0x1f), v_mad_f32 (VOP3 0x141), v_mac_legacy_f32 (VOP2 0x06 / VOP3 0x106), v_mad_legacy_f32 (VOP3 0x140), v_mul_lo_i32 (VOP3 0x16b), s_get_waveid_in_workgroup (SMEM 0x2a), the scalar store/atomic/scratch/s_dcache_wb/discard forms I tried, and ds_*_src2_*. A sweep of the DS opcode field gives exactly 31 slots that decode on gfx1013 and not on gfx1036, all ds_*_src2_*, and none the other way round.
  • gfx1030/gfx1036 accept, gfx1013 rejects: the dot products, v_fmac_legacy_f32/v_fma_legacy_f32 (the same bytes disassemble as v_mac_legacy_f32/v_mad_legacy_f32 on gfx1013), global_load/store_dword_addtid and buffer_atomic_csub. I did not reproduce the 119-slot total, only the DS count.

Two things:

  1. 190aff6 is already on main (merge 9bf2613), so this PR is now only the edit to the denormal-flush row. That row ends with two "not GPU-verified" sentences, and the edit rewrites the stale one ("still needs an RDNA1/RDNA2 part that has these opcodes") into a second verbatim copy of the new one: at c541801 the "still needs an RDNA1 part (gfx1010-gfx1013): no RDNA2 part has these opcodes, ..." sentence appears twice. Deleting the stale sentence instead would fix it.
  2. The description says the translator handles the integer dot products and refuses the rest of the gfx103x-only list, but tools/rdna2spirv.py also translates v_dot2_f32_f16 and v_dot2c_f32_f16 (around L6108). Minor, description only.

Merges cleanly into main. I did not run tests/test_docs_design_rows.py.

@kapitche

Copy link
Copy Markdown
Contributor

Tested c541801 merged with main 98fa503 on Linux (Python 3.12.16): pass. the four tests/test_docs_*.py 4/4 ok. Docs-only change, no negative control.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants