Repository navigation
Recompiler: translate v_mullit_f32 and v_cvt_off_f32_i4 as RDNA2 runs them - #2241
Draft
NWProgramming00 wants to merge 1 commit into
Draft
NWProgramming00 wants to merge 1 commit into
NWProgramming00 wants to merge 1 commit into
Conversation
… them Both instructions were refused by both backends. Their behaviour was measured on an RDNA2 gfx1036 (2,656 rows): - v_cvt_off_f32_i4: bits 3:0 as a signed 4-bit number in sixteenths (-0.5 .. 0.4375); bits 31:4 are ignored. - v_mullit_f32: -MAX_FLOAT when S2 is not above +0 (-0, negative or NaN) or S1 is -MAX_FLOAT, -inf or NaN; otherwise S0 * S1 with 0 * anything = +0 (as v_mul_legacy_f32). The HLSL path gets a `mullit` prelude helper, the direct DXIL path the same rule on the operand bits. gpu_mullit_and_cvt_off_match_rdna2 checks both backends against hardware values (rows with a NaN S0 or a denormal left out). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Both backends refused
v_mullit_f32(VOP3) andv_cvt_off_f32_i4(VOP1). This translates both as RDNA2 hardware runs them. I measured the hardware first, because the ISA text forv_mullit_f32does not spell out its special cases.Measured on an RDNA2 gfx1036 (2,656 input rows: 18 special S0 / S1 values × 8 S2 values, plus 64
cvt_offinputs with high bits set):v_cvt_off_f32_i4: bits 3:0 are a signed 4-bit number in sixteenths (1→ 0.0625,8→ -0.5,15→ -0.0625). Bits 31:4 are ignored.v_mullit_f32:0xff7fffff) when S2 is not above +0 (that is, +0, -0, negative or NaN), or when S1 is -MAX_FLOAT, -inf or NaN.v_mul_legacy_f32. For example, 0 × +inf = +0 and 0 × -1 = +0.What is in it
crates/xcl/src/gpu/recomp/emit.rs: both instructions, plus amullit()helper in the HLSL prelude. It decides on the operand bits, so no float compare can be folded away.crates/xcl/src/gpu/dxil/lower_valu.rs: the same rule in the direct DXIL translator.crates/xcl/src/gpu/recomp/tests.rs:gpu_mullit_and_cvt_off_match_rdna2runs both backends (HLSL + DXC, and direct DXIL) and checks them against hardware values:v_mullit_f32rows: every special S1 with a positive S2, every S2, every non-NaN S0, and the zero products;v_cvt_off_f32_i4inputs.Tested
XCL_ADAPTER=radeon). Rust 1.100 MSVC, release.v_cvt_off_f32_i4: 2656/2656 equal everywhere.v_mullit_f32: 2458 equal on the RTX 5070 Ti and 2488 on the Radeon, in each backend. Every other row is either a NaN result that differs only in payload bits (60 / 30) or a row with a denormal (138). No other difference.S2 < 0only (HLSL);cvt_offscale changed (direct DXIL).cargo build --release --workspace, thencargo test --release --workspace --no-fail-fast -- --test-threads=4, with and withoutXCL_DIRECT_DXIL=all, against base568e7dbon the same machine:568e7dbd7df3f9)XCL_DIRECT_DXIL=allXCL_DIRECT_DXIL=allThe +1 is the new test. The failing tests are the same on base and PR, and all are tracked:
fuzz_validate_and_gpu_0..3on NVIDIA (#1905),fuzz_validate_and_gpu_1seed 540 on RDNA2 (#2115, #2170),gpu_image_get_resinfo_1d_arraywith direct DXIL (#2046) andoffline_compute_pipeline_is_reused_by_a_second_processwith direct DXIL (#1674).Regression run
No usable pair yet, for the reason given on #2222. On this machine the title currently exits at the same point on
main(rechecked on568e7dbjust before opening this) as on the PR heads. That holds with fresh data and shader caches and on both adapters. This PR stays a draft until I can add amain/ head pair whose runs reach their end.Not tested
v_mullit_f32in a program that sets a non-default f32 rounding mode. The rounding-mode path (valu_f32_rm) does not cover it, so it rounds to nearest.AI use
🤖 Generated with Claude Code