Repository navigation
compute: lower the d16 descriptor-format buffer loads - #2165
Conversation
buffer_load_format_d16_{x,xy,xyz,xyzw} now use the descriptor-format
decoder, with the same validity rule and refusal. Two 16-bit channels
pack per word, x low. The format's type decides the value. FLOAT16
formats give their stored halves. UNORM and SNORM16 give binary16, rounded
to nearest even by long division with denormals kept. 16-bit UINT and
SINT give the 16-bit integer, not a float. 32-bit formats have no d16
rule here and are invalid. An odd count leaves the last word low-16 only:
it reaches a store or an ALU operand through v_and_b32 0xffff, as for
the caller-format D16 reads.
A second fixture makes ten d16 loads over the same t0 words. It compares
all 320 words for one and two groups on WARP and hardware. Three
invalid-format runs must leave u0 unwritten. Seven wrong references and
nine mutated sources must fail, among them integer-as-float, truncated
or flushed binary16, and swapped packing. LLVM 15 assembles both
fixtures and the round trip matches.
Refs R0Y00#2022 (item A, d16 follow-up to the format decoder)
AI-assisted (Claude Code); reviewed and run locally.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tedin7
left a comment
There was a problem hiding this comment.
Review of head 340c608.
P1: 0. P2: 0.
Logic: the binary16 long division in descriptor_ratio16 is correct. Normal results keep 11 bits, and denormals count units of 2^-24. Rounding is nearest-even with a sticky bit, and a carry into the exponent is fine. SNORM16 clamps -32767 and below to -1.0. 16-bit UINT and SINT stay integer, and 32-bit formats have no d16 arm. The odd last half is tracked as alu_low16, so it must be masked before a whole-word store.
Linux, run locally:
python3 tests/compute_load_format_check.pypassed.python3 tests/docs_links_check.pypassed.python3 tests/bidi_controls_check.pypassed.git diff --check origin/main...HEADwas clean.
Mutations in tools/compute_store_aot.py:
- Dropping the odd-half low16 condition made the test fail (rc=1).
- Passing
0uinstead of the packed flag made the test fail (rc=1). - Changing the SNORM clamp constant from 0xbc00 to 0xbc01 is not caught by the Linux controls, which only check strings. The Win2025 WARP readback test covers the real values.
Win2025 (x2w_pipe.py win2025 2165 --wait 3600): Debug 60/60 passed and Release /O2 60/60 passed. This includes compute_store_aot_descriptor_load_format_d16_warp, a GPU readback test against a CPU reference. GitHub CI Build and test on Windows = SUCCESS.
Competing PRs: no other open PR covers d16 descriptor-format buffer loads. #2139 is D16 image_load, a different opcode.
AI-assisted; commands listed were executed locally.
stan495
left a comment
There was a problem hiding this comment.
Verified head 340c6085 on Windows x64 (dev preset, MSVC 19.44.35228.0, SDK/DXC 10.0.26100.0):
python -B tests/compute_load_format_check.py-> passedctest --preset dev --no-tests=error -R '^compute_store_aot_descriptor_load_format_' -V-> 4/4 passed (compute_store_aot_descriptor_load_format_{hardware,warp}andcompute_store_aot_descriptor_load_format_d16_{hardware,warp})descriptor_load_format: 6 dispatches, 13 wrong references, 11 mutated sources checked;descriptor_load_format_d16: 5 dispatches, 10 wrong references, 9 mutated sources checked (debug_errors=0 debug_warnings=0).- Hardware:
AMD Radeon RX 7900 XTX(vendor=1002 device=744c, driver32.0.32029.2010) - WARP:
Microsoft Basic Render Driver(vendor=1414 device=008c, driver10.0.26100.9818)
Verdict: Approved at 340c6085.
|
Ran head
AI-assisted. |
|
@archielcqp-a11y could you rebase this branch onto current GitHub reports head Files that conflict with current
Commands run locally: Once it is rebased and CI is green it will be re-checked right away. AI-assisted; commands listed were executed locally. |
Keeps main's batched references, heap-view loads and 2_10_10_10 format (code 50, 10_10_10_2 invalid) together with the d16 opcodes. A d16 load through a heap view is refused: the heap-view helper has no d16 rule. The d16 fixture's 10-bit row now uses 2_10_10_10_UNORM (50).
|
Pushed 6ceb259: a merge of main into this branch (no force, no rebase) so the PR is mergeable again. The d16 lowering itself is unchanged. Main had changed the same areas, so the merge needed a few decisions. Both sides are kept where they do not clash:
Two behaviours to review:
Commands executed locally:
AI-assisted; commands listed were executed locally. |
|
Pushed 3d84b65: a second merge of main into this branch (no force, no rebase) so the PR is mergeable again. The d16 lowering is unchanged. One real conflict, in Commands executed locally:
The Windows WARP pass on the d16 content was recorded earlier in this thread; it was not re-run because the conflict was a keep-both merge of two independent rules. AI-assisted; commands listed were executed locally. |
Refs #2022 (item A). This follows #2150 (merged), which added the descriptor-format decoder.
Summary
R0Y00 asked on #2022 for d16 to follow the first slice, with integer versus float handling and a format-specific rounding or conversion control. This PR adds that.
buffer_load_format_d16_{x,xy,xyz,xyzw}now use the descriptor-format decoder from #2150. The format word, the exact-width validity rule and the refusal (no store when any load is invalid) are unchanged. Two 16-bit channels pack per result word, x in the low half.The format's type decides the 16-bit value:
x / (2^n - 1)ormax(x / 32767, -1), rounded to nearest even by integer long division (descriptor_ratio16). Binary16 denormals are kept, so1/65535is0x0100.32_FLOATto binary16). So32_UINTand32_FLOAT, in one to four channels, are invalid under d16 and publish nothing.Whether the RDNA format unit rounds the same way, or keeps binary16 denormals, is not verified.
Odd channel counts:
d16_xandd16_xyzleave the high half of the last word undefined. That word is now analu_low16value. It reaches a whole-word store or an ALU operand only throughv_and_b32 0xffff, the same rule the existing caller-format D16 reads (source_low16) follow.Fixture
compute_store_aot_descriptor_load_format_d16_{warp,hardware}(tests/compute_load_format_check.py draw-d16).The fixture makes ten d16 loads over the same t0 words as the binary32 fixture, one per format with a d16 rule, into a 64-byte u0 record. The edge values exercise round-up, binary16 denormals, -32768 and -32767, and the sign of 16-bit SINT.
32_32_FLOATunderd16_xy,16_16_UNORMunderd16_x, and8_SNORM). Each must leave u0 unwritten, and a zero-filled reference must fail.draw-mubuf-load-format-d16), which shares the mask rule, still passes on WARP.Results
Run at
340c608(on #2150's headf3a6819), Windows 10 build 19045, debug layer enabled, 0 debug errors and 0 debug warnings on every dispatch. The pull-request CI runs theprsmoke preset, which does not include these tests, so here is the local CTest output:The hardware adapter is an NVIDIA GeForce RTX 3080 (driver 32.0.15.9174), and WARP is 1.0.22 (app-local).
Other checks:
tests/compute_load_format_check.py binarywith LLVM 15: pass, both fixtures.tests/compute_store_check.py binarywith LLVM 15: pass.tests/compute_store_check.py draw-mubuf-load-format-d16on WARP: pass.form_coverage_check,docs_links_check,bidi_controls_checkandshader_census_check: pass.No capability skips.
🤖 Generated with Claude Code