-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setrounding regression for 0.5.0-rc1 #17926
Comments
Looks to be that the example function is being optimized: julia> x = 0.1
0.1
julia> setrounding(Float64,RoundDown) do
1.1 + x
end
1.2 |
I suspect this is LLVM inlining and constant folding. LLVM doesn't model rounding modes, so there is very little we can do. |
Makes sense. I guess the best course of action would be to update the manual to have a more complicated but working example. |
That's not good: previously we relied on the fact that anonymous functions weren't really optimised. Now that they are, I'm not sure what we can do until LLVM get around to allowing rounding mode changes (I wouldn't hold your breath...). We should probably stick some warnings in there, and mark it as an experimental feature. |
IIUC constant folding are usually done at default rounding mode. I don't think it's possible to know the right rounding mode anyway unless we disable all constant folding for floating point numbers since the rounding mode is a runtime setting. |
Could we have a meta tag that would disable constant folding in a particular region? |
|
Doesn't that just disable constant folding at definition time? How could I use it in the above example? |
|
I just mean that |
So one option is that we could change it to a macro which pulls out all the literals into a @setrounding Float64 RoundDown 1.1 + 0.1 transforms to @noinline literals() = (1.1,0.1)
old = rounding(Float64)
setrounding(Float64, RoundDown)
a,b = literals()
a+b
setrounding(Float64, old) |
Although that won't work with |
Ouch. This sounds like it will seriously break ValidatedNumerics.jl. |
How did it not get picked up by your test suite? :P |
Apparently because we never have literals; everything that gets rounded comes out of an |
I guess our rounding-mode tests aren't as comprehensive as they could be? That doc example was also not a doctest, but if it had been we likely would have noticed sooner. |
Fixes the doc problem mentioned in #17926, but not the underlying problem.
Fixes the doc problem mentioned in #17926, but not the underlying problem.
Fixes the doc problem mentioned in JuliaLang#17926, but not the underlying problem.
|
Taken from a rounding mode example in the manual:
Julia 0.4.6
Julia 0.5.0-rc1
The text was updated successfully, but these errors were encountered: