Repository navigation
fix(cutile): use unordered compare for float != - #1546
Open
Rachit2323 wants to merge 1 commit into
Open
Rachit2323 wants to merge 1 commit into
Rachit2323 wants to merge 1 commit into
Conversation
Signed-off-by: Rachit2323 <atreyrachit23@gmail.com>
This branch has not been deployed
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
Float
!=is using an ordered compare, but it should be unordered.Rust says
a != bhas to be the opposite ofa == b. With floats, NaN is not equal to anything, not even itself. SoNaN == NaNis false, which meansNaN != NaNhas to be true. Only the unordered compare gives that. With the ordered one,x != xalways comes out false, so the normal way of checking for NaN stops working. Nothing warns you, you just get a wrong answer.The SIMT side already handles this, see #123. cuTile never got the same fix.
Changes
compile_binary_op.rswas passing "ordered" for all six float comparisons. Now the ordering comes from the operator instead. Only!=changes, the other five stay ordered.Here is the IR for
if a != bwith two f32 values, before and after:I compiled
==,<and>=in the same kernel to check they did not move.They are unchanged.
The two other
cmp_ordering_attrcalls incompile_cuda_tile_op.rstake the ordering from the user's owncmpfargument, so I left those alone.Testing
Added two unit tests:
!=must be unordered, and the other five must stay ordered.The same 7 tests fail on main too. They need the
tileirasbinary and I do not have it installed, so they are not related to this change.cargo fmt --checkandcargo clippyare both clean.The before and after IR above came from
KernelCompiler, which compiles to Tile IR text on the host. No GPU was needed.Checklist