-
Notifications
You must be signed in to change notification settings - Fork 97
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
Support for fast math intrinsics #804
Conversation
@@ -129,6 +129,13 @@ impl Stmt { | |||
_ => None, | |||
} | |||
} | |||
|
|||
pub fn get_stmts(&self) -> Option<&Vec<Stmt>> { |
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.
This is part of an earlier version where the intrinsics where encoded in a block statement, so I needed to retrieve statements within in order to prepend the finite checks. This version does not use it, but I figured it could be useful for something else. We can remove it otherwise.
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.
If you do keep it, can you please add a comment?
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.
Added a comment.
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.
Nice test coverage! Just minor comments.
(false, false) => kani::assume(x > f64::MIN - y), | ||
_ => (), | ||
} | ||
let _z = unsafe { std::intrinsics::fadd_fast(x, y) }; |
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.
Can you please assert that the result is equal to regular add? The same for the other tests.
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.
Changed it so we assert it in the case of addition and substraction, as other operations show serious performance issues. Created #809 to revisit this.
@@ -129,6 +129,13 @@ impl Stmt { | |||
_ => None, | |||
} | |||
} | |||
|
|||
pub fn get_stmts(&self) -> Option<&Vec<Stmt>> { |
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.
If you do keep it, can you please add a comment?
Some changes I made:
|
* Support for fast math intrinsics * Add (failing) positive test for `fadd_fast` * Undo change in `typecheck_binop_args` * Encode fast math intrinsics as regular binops * Add all tests for fast math intrinsics * Add tests for 32-bit values and compare results * Drop support for `frem_fast` * Add comment to `get_stmts`
* Support for fast math intrinsics * Add (failing) positive test for `fadd_fast` * Undo change in `typecheck_binop_args` * Encode fast math intrinsics as regular binops * Add all tests for fast math intrinsics * Add tests for 32-bit values and compare results * Drop support for `frem_fast` * Add comment to `get_stmts`
* Support for fast math intrinsics * Add (failing) positive test for `fadd_fast` * Undo change in `typecheck_binop_args` * Encode fast math intrinsics as regular binops * Add all tests for fast math intrinsics * Add tests for 32-bit values and compare results * Drop support for `frem_fast` * Add comment to `get_stmts`
* Support for fast math intrinsics * Add (failing) positive test for `fadd_fast` * Undo change in `typecheck_binop_args` * Encode fast math intrinsics as regular binops * Add all tests for fast math intrinsics * Add tests for 32-bit values and compare results * Drop support for `frem_fast` * Add comment to `get_stmts`
Description of changes:
Models fast math intrinsics as regular floating point operations. Includes function to check inputs are finite arguments. Adds 16 new test cases (8 positive, 8 negative) for testing fast math intrinsics.
Resolved issues:
Resolves #788
Call-outs:
Testing:
How is this change tested? Existing regression + 16 new tests.
Is this a refactor change? No.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.