Repository navigation
fix(shader): emit ordered not-equal through an integer NaN check - #1473
Conversation
|
Tested on Windows 11, MinGW-w64 GCC 16.2.0 (not the CI 15.2.0), Release,
On the 780M, AI-assisted: yes (Claude Code). |
|
Follow-up after updating the AMD driver to 32.0.31041.1004 (2026-08-17), same setup: on main, |
|
Linux results on both vendors. Nobara 44 (Linux 7.2), GCC 16.2.1, Release, this PR cherry-picked onto
Both devices pass with and without the PR, so it causes no regressions here. RADV on RDNA2 doesn't miscompile the float form either, which is consistent with a bug in AMD's Windows compiler. |
4c0b476 to
3dc4a41
Compare
|
Rebased onto |
3dc4a41 to
ca7313a
Compare
|
RDNA 4 result: the same rows fail on Windows 11 Pro 10.0.26300, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release,
The AI-assisted: yes |
|
Tested this PR on an RX 7900 XT (RDNA 3), extending the reported RDNA 3.5 coverage. Environment: Windows 11 Pro 10.0.26200, Ryzen 7 7700X, 32 GB RAM, AMD driver 32.0.31041.1004; Vulkan 1.4.349, device 0x744c. WinLibs MinGW-w64 GCC 15.2.0 UCRT/POSIX/SEH r7, Release, BUILD_TESTING=ON, SPIRV-Tools validation OFF. ANYPS5_GPU=7900 XT and ANYPS5_REQUIRE_VULKAN=1. Main Applied PR head Full CTest with this PR, four workers outside the sandbox: 505 passed, 1 failed, 1 skipped (507 total). The failure was No title testing. No changes to the PR implementation were made. |
|
Thanks @tezzgod74 and @joelfernandes23, added both runs (RDNA 4 and RDNA 3) to the description. |
|
Reviewed the complete implementation and the cross-device test reports. The integer NaN check is equivalent to ordered not-equal for all f32 values, and the reports cover RDNA 3.5, RDNA 4, RDNA 3 and an RDNA 2 control. One contribution-rule follow-up: this PR currently targets base f145139, while upstream main is d70b899. Please rebase onto current main so the exact current-head checks run before merge; your reported d70b899 hardware runs provide useful additional evidence. |
ca7313a to
1edba8b
Compare
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed the complete diff on rebased head 1edba8b. The bitwise NaN classification implements ordered-not-equal for all binary32 inputs, while avoiding the measured AMD driver miscompile when the result feeds a ballot. The report now covers RDNA 3.5, RDNA 4, RDNA 3 and an RDNA 2 control; the author also reports 212 AGC tests passing and five repeats of the affected test on the Radeon 860M. Conventions and the official Linux, Windows, and macOS relinker jobs pass. No blocking issue found.
The AMD Windows driver returns 1 for a NaN operand when any float form of ordered not-equal feeds a ballot on a 32-wide subgroup, which is how e32 compares are read in wave32. FPOrdNotEqual32 is now emitted as an unordered not-equal with both operands checked for NaN on their bits, which gives the same result for every input. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…2 denormal entries Co-Authored-By: Claude <noreply@anthropic.com>
|
Checked on the HW oracle (gfx1035, IEEE=0, f32 denormals flushed): Added one commit: the TechnicalDebt line sat right after the f32 denormals entries and conflicted with #2045 and #2046; moved it to a spot that merges cleanly with both (checked with |
1edba8b to
8404c49
Compare
…pare-amd-wave32 fix(shader): emit ordered not-equal through an integer NaN check
Closes #825.
What
FPOrdNotEqual32, whichv_cmp_lg_f32/v_cmpx_lg_f32and the f16 LG compares lower to, is now emitted asOpFUnordNotEqual(a, b) && (bits(a) & 0x7fffffff) <= 0x7f800000 && (bits(b) & 0x7fffffff) <= 0x7f800000instead ofOpFOrdNotEqual. The two agree for every input.The AMD Windows driver returns 1 for a NaN operand when an ordered not-equal feeds a ballot on a 32-wide subgroup, which is how VCC is read for e32 compares in wave32.
OpFOrdNotEqual,FOrdLessThan || FOrdGreaterThan,FUnordNotEqual && !IsNan && !IsNanand an integer OR of the two compares all fail the same way, so the driver appears to fold any float form; checking NaN on the bits avoids it (analysis in #825). The image compare emulation's not-equal (SpirvImageEmitter.cpp) feeds a select, not a ballot, and is unchanged. Recorded in TechnicalDebt.Failing rows on
mainAMD Radeon 860M (RDNA 3.5, device 0x1114), Windows driver 32.0.13058.8001, Vulkan 1.3.302,
agc_driver_vopc_compare_table, wave32 run only; e64, wave64 and wave64 split pass:Tested
Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release with
BUILD_TESTING=ON,main8388121.ctestagc_driver_vopc_compare_tablemain, passesVK_DRIVER_FILES)mainOther AMD GPUs on Windows (
maind70b899 and fullctestunless the row says otherwise), with and without this PR:mainvopc_compare_tablefails (same lane 29 row)vopc_compare*5/5 repeatsvopc_compare_tablepassesvopc_compare_tablefails (same lane 29 row)ctest505/507, the failure isagc_driver_shader_clock(#1615, also onmain)vopc_compare_tablefails (lane 29cmp_lg_f32_e32/cmp_lg_f16_e32, lane 31cmp_lg_f16_e32) onmainf8c2f071edba8b1, withvopc_compareandvopc_compare_f64; fullctestat this head not reportedNot tested on NVIDIA or Intel.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code