Repository navigation
Conversation
…rojectLeonida#509) spirv_mini_interp kept float values as Python floats, and the <f <-> double conversion quiets signalling NaNs (it sets bit 22), so OpBitcast and float outputs changed sNaN words like 0xffa3a095 into 0xffe3a095. Any semantic test that exports a random integer through a float hits this about 0.4% of the time. Represent float values as an _F32 wrapper holding the 32-bit pattern, and widen to a Python float only inside arithmetic ops (where sNaN is undefined anyway). OpBitcast, loads/stores and outputs read the bits directly. Caller-supplied inputs and the float zero value are coerced through the same wrapper. test_float_bits.py round-trips sNaN words through bits_f32/f32_bits and through a uint->float->uint OpBitcast shader, bit-exactly. AI-assisted (Cline).
Collaborator
|
Heads-up: #533 (also TEST-67, fixing #509 with the same |
Contributor
Author
|
Closing as redundant: #533 (the same _F32 wrapper fix for #509) was already merged and covers the same sNaN round-trip tests. Thanks @IAmNotSiob. |
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.
Item: TEST-67 (claimed in #374). Fixes #509.
What
tests/semantic/spirv_mini_interp.pykept float values as Python floats, and the<f<-> double conversion quiets signalling NaNs (it sets bit 22). SoOpBitcastint->float->int and any float output changed an sNaN word like
0xffa3a095into0xffe3a095. Any semantic test that exports a random integer through a floathits this about 0.4% of the time, and the fuzzers report false mismatches.
Float values are now an
_F32wrapper holding the 32-bit pattern, widened to aPython float only inside arithmetic ops (where sNaN is undefined anyway).
OpBitcast, loads/stores and outputs read.bitsdirectly, so they arebit-exact. Caller-supplied inputs and the float zero value are coerced through
the same wrapper.
Tested
tests/semantic/test_float_bits.py: round-trips sNaN words throughbits_f32/f32_bitsand through auint -> float -> uintOpBitcastshader.python -m unittest discover -s tests/semantic(subset):test_float_bits,test_float_compares,test_float_to_int,test_value_semantics,test_ps_semantics,test_interp*,test_alu_subrev_f16,test_salu_pack,test_int*,test_scalar*,test_alu_*-> all pass.Notes