-
Notifications
You must be signed in to change notification settings - Fork 358
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
Apply random float error #4156
base: master
Are you sure you want to change the base?
Apply random float error #4156
Conversation
Please also add a test (as a new function in |
src/intrinsics/mod.rs
Outdated
@@ -202,14 +212,33 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | |||
_ => bug!(), | |||
}; | |||
let res = f.round_to_integral(mode).value; | |||
// Apply a relative error with a magnitude on the order of 2^-12 to simulate | |||
// non-deterministic behaviour of floats |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rounding is fully precise, it should not get any error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I caught that and fixed it locally
src/intrinsics/mod.rs
Outdated
"sqrtf32" => { | ||
let [f] = check_arg_count(args)?; | ||
let f = this.read_scalar(f)?.to_f32()?; | ||
// no host floats for sqrt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// no host floats for sqrt | |
// Sqrt is specified to be fully precise. |
(same below for sqrtf64)
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Almost done I think. I have 1 TODO left, inside of the non-determinism test, it is about this:
Should we do an |
…s and apply more correct error
…s in shims/foreign_items
…e ULP approx check in tests
a64db7e
to
b82c735
Compare
@rustbot ready |
I think the easiest way is something like this; you can do that with a closure returning any |
@rustbot ready |
This partially tries to fix #3555 (does not include the
pow
operations)this just does
apply_random_float_error
on the results of the intrinsics.Things changed from original:
sqrtf*
intrinsics to make the implementation cleaner, since applying the error was not requiredulp_err_scale
, which does-(F::PRECISION - 1 - n
for a2^n
ULP error.test_non_determinism
which tests a lot of non-deterministic operations with the same input to check if they are almost but not entirely equal.