Repository navigation
Shaders: lower v_mad_i64_i32; test the 64-bit integer vector operations against their definitions - #635
Open
Gruzzberry wants to merge 1 commit into
Open
Shaders: lower v_mad_i64_i32; test the 64-bit integer vector operations against their definitions#635Gruzzberry wants to merge 1 commit into
Gruzzberry wants to merge 1 commit into
Conversation
…ns against their definitions v_mad_i64_i32 (a signed 32 x 32 multiply plus a 64-bit addend into a 64-bit result) had no lowering, so a program using it was refused as "unsupported" and its pipelines were dropped, while its unsigned sibling v_mad_u64_u32 was lowered. It is the same operation on sign-extended factors. The carry out is not modelled: a program that reads it is refused as for any lane mask read as data (the title's shader pack has no program with the instruction, so none changes: a translate run over all 26148 programs refuses none for it). The new test runs v_lshlrev_b64, v_lshrrev_b64, v_ashrrev_i64 (the count is the low six bits of the first operand, including counts of 32 to 63 and above 63) and v_mad_u64_u32 / v_mad_i64_i32 as one-thread compute shaders over the sign and carry edges of the halves, comparing both dwords of the result with the definition in Rust, on the hardware adapter and WARP. The two multiply-adds and the shifts agree; before the lowering the signed multiply-add stops the test at "Unsupported". valu_tests.rs only gains pub(super) on the helpers the new module shares. Assisted-by: Claude Code (Claude Sonnet 5.5)
|
An AMD run of this PR's new tests. The setup, and the same run for eight related shader PRs, are in one table on #637: #637 (comment) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
v_mad_u64_u32is lowered; its signed siblingv_mad_i64_i32(a signed 32 x 32 multiply plus a 64-bit addend, into a 64-bit result) is not, so a program using it is refused asUnsupported { what: "v_mad_i64_i32" }and its pipelines are dropped. This lowers it as the same operation on sign-extended factors, and adds a test of the 64-bit integer vector operations (the three 64-bit shifts and both multiply-adds) against the definitions in the RDNA2 instruction set document.What is in it
crates/victory-shader/src/emit/lower.rs: a"v_mad_i64_i32"arm next to"v_mad_u64_u32": sign-extend both factors to 64 bits, multiply, add the 64-bit addend, write the two result dwords. The carry out is not modelled: the lane-mask value of the instruction's carry destination isVal::Missing("the carry of a signed multiply-add"), so a program that reads it is refused as for any lane mask read as data, and one that ignores it (the usual address computation) translates.crates/victory-shader/src/emit/int64_tests.rs(new, registered inemit/mod.rs): two tests, one-thread compute shaders run twice (low dword of the result, then the high one) on the hardware adapter and WARP:shifts_of_64_bits_use_the_low_six_bits_of_the_count:v_lshlrev_b64,v_lshrrev_b64,v_ashrrev_i64with counts 0, 1, 31, 32, 33, 63, 64, 65 and0xffffffc1over 64 values built from the halves' sign and carry edges.multiply_add_of_32_by_32_plus_64_matches_the_definition:v_mad_u64_u32andv_mad_i64_i32over eight values for each factor and four addends (0, 2^32-1, -1, and 2^63+1).valu_tests.rsonly gainspub(super)on five helpers the new module shares.Before the lowering,
multiply_add_of_32_by_32_plus_64_matches_the_definitionstops atlower: Unsupported { offset: 36, what: "v_mad_i64_i32" }. With it, both operations and the three shifts agree with the definitions on WARP.Does the title use it?
No:
victory translateover the whole shader pack (26,148 programs, base2119b0e) translates all of them and refuses none for this instruction. The change is coverage; the test is the main point. If you would rather have the test alone, drop thelower.rshunk and the signed multiply-add half of the second test.Tested
c96b4f2, one commit.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean. Without--all-featuresit fails onc96b4f2itself (placed_filler_twinsinvictory-gpu/src/resource.rsis never used); this change adds no warning.cargo xtask policy: 170 files ok.cargo test --workspace --lockedon the RTX 4070 (default adapter, run directly):victory-shader214 passed, 2 failed (emit::rect::tests::the_rectangle_stage_is_a_geometry_shaderandrectangles_are_drawn_whole, the PSV0 validator issue of Shaders: write every PSV0 semantic name again, as DXC does (fixes #12) #61); every other crate passes.c96b4f2without this change: 212 passed, the same 2 failed.VICTORY_WARP=1 cargo test --workspace --locked(every GPU test on WARP):victory-shader210 passed, 6 failed. The same 6 fail onc96b4f2(208 passed): the twoemit::rectones, andds_min_max_f32_order_floats_and_return_the_old_value,v_permlane16_and_x16_read_the_lanes_their_selectors_pick,whole_wave_f64_sum_and_cvt_f32_f64anda_lane_mask_joined_with_a_number_is_read_as_the_number_it_is, which need a 32-lane device thatVICTORY_WARP=1takes away. No new failure.Not tested
v_mad_i64_i32(not modelled; the RDNA2 document's wording for the signed form is not what I rely on).v_add_co_u32chains, f64).AI use
Claude Code (Claude Sonnet 5.5) wrote the lowering and the tests and ran the checks above on my machine. The reference functions follow the RDNA2 instruction set document. Nothing is taken from the game.
🤖 Generated with Claude Code
🤖 Generated with Claude Code