-
Notifications
You must be signed in to change notification settings - Fork 356
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
Use non-deterministic precision for float operations that do not have guaranteed precision #3555
Comments
This should also be used for fast-math and "algebraic" float operations. |
Hi, i would like to try this. I have 2 questions though. Do you mean that we should add the float_error to this part of the code? And should we use the same magnitude as the x86 instrinics? Line 413 in 95558ba
|
Yes, all of those there except for sqrt should apply a float error. There's no fixed value for the magnitude of the error so we might as well pick the same as the x86 intrinsic. |
@rustbot claim |
Hi, I think I successfully implemented it for all but 2 match arms because I don't know how to do it nicely. It is about the | "fadd_algebraic"
| "fsub_algebraic"
| "fmul_algebraic"
| "fdiv_algebraic"
| "frem_algebraic"
=> {
let [a, b] = check_arg_count(args)?;
let a = this.read_immediate(a)?;
let b = this.read_immediate(b)?;
let op = match intrinsic_name {
"fadd_algebraic" => mir::BinOp::Add,
"fsub_algebraic" => mir::BinOp::Sub,
"fmul_algebraic" => mir::BinOp::Mul,
"fdiv_algebraic" => mir::BinOp::Div,
"frem_algebraic" => mir::BinOp::Rem,
_ => bug!(),
};
let res = this.binary_op(op, &a, &b)?;
// `binary_op` already called `generate_nan` if necessary.
this.write_immediate(*res, dest)?;
} I don't know how I can nicely implement this. And the Should I follow the second comment from RalfJung or this comment in the code? Also, is this the conventional way of asking for help? Or is Zullip used more? Or another way? Thanks for the help! |
I don't think I quite understand what the problem is. I would propose you open a PR that implements this for one or two (blocks of) shims, so that we can give feedback on a concrete implementation, and hopefully that will help clarify these things as well. Regarding asking for help, Zulip is a good place for that. :)
Note that this refers to different non-determinism than what the issue is about. That comment is about making the NaN payload bits and sign non-deterministic. |
As per rust-lang/rust#124609, these operations behave non-deterministically, so we should implement that in Miri. The
apply_random_float_error
function (currently only used for x86 intrinsics) could be used to do that.The text was updated successfully, but these errors were encountered: