Replace incorrect, UB-prone fptoui_sat with a corret implementation.#287
Merged
FractalFir merged 1 commit intoRust-GPU:mainfrom Oct 5, 2025
Merged
Replace incorrect, UB-prone fptoui_sat with a corret implementation.#287FractalFir merged 1 commit intoRust-GPU:mainfrom
FractalFir merged 1 commit intoRust-GPU:mainfrom
Conversation
081bcd3 to
5857477
Compare
LegNeato
requested changes
Oct 5, 2025
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.
Currently, we replace unsupported
fptoui_satwithfptoui. This is incorrect(fptouiis wrapping, not saturating in CUDA) and UB-prone(casting values out of range is UB).fptoui_satcan be correctly emulated at the cost of 2 additional PTX instructions(max & min).This PR implements such emulation, removing another source of UB in Rust-CUDA.
(Equivalent, but slightly more complex approach can be applied to
fptosi_sat. I will implement that in a separate PR. After we fix that too, we can disable-Z saturating_float_casts=false, and remove that kind of UB fully.)