Use sin()/cos() for the right type without need for widening.#8317
Use sin()/cos() for the right type without need for widening.#8317hzeller wants to merge 1 commit intoThe-OpenROAD-Project:masterfrom
sin()/cos() for the right type without need for widening.#8317Conversation
|
clang-tidy review says "All clean, LGTM! 👍" |
|
Looks like the relevant-looking test @oharboe you have done this a bunch before, is that simple to do ? |
c7a2721 to
e9d4d58
Compare
|
ran it manually and yes looks like there are some values with bits at the end a bit differently as expected. |
|
@hzeller Looks like the test is executed in bazel. Output: |
|
(I don't know how to update the golden files, is there a process ? I just copied the result to the |
|
clang-tidy review says "All clean, LGTM! 👍" |
Don't know... |
|
Marking this as draft right now as there are various questions
In the incremental02 test I saw with a handful of measurements I saw about 3% improvement, but that might be just noise. Need to implement a real unit test with a benchmark suite.. |
Eventually, I'd like to see a |
|
I expect you are seeing #8314 There are save_ok/save_def_ok/etc script to update the golden files thought they consist mostly of copying the result to the corresponding ok file. Low bit noise is probably ok but we will need to test that it doesn't happen to affect some design. Sometimes you can get the butterfly effect. Once the unit tests are sorted I'll run a suite. |
|
incremental02 does seem to return a different DEF file as compared to the cmake build. It's likely it just comes down to a different compiler or compiler options |
I think it should be: |
e9d4d58 to
a47e91e
Compare
|
Rebased, and the manual test run with bazel seems to run (I don't have the Leaving as draft until all questions resolved. |
|
clang-tidy review says "All clean, LGTM! 👍" |
|
Is the 'check that ok files are up to date' failure just expected because I changed the *.ok file ? |
| No differences found. | ||
| Differences found at line 4533. | ||
| - _22166_ INV_X2 + PLACED ( 1266309 950840 ) N ; | ||
| - _22166_ INV_X2 + PLACED ( 1269602 942674 ) N ; |
There was a problem hiding this comment.
This is the cause of the ok file failure. You need to update the file being diff'ed (.defok) so that this shows "No differences found."
There was a problem hiding this comment.
Note that this means you are getting a different result than previously so this PR will need a full testing cycle.
The `sin()` and `cos()` calls are used on float arguments, but these functions are double by default (the corresponding float functions would be `sinf()` and `cosf()`), forcing the argument to be upcast to double and then the result back downcast to float. Instead, use `std::sin()` and `std::cos()` that have overrides for each floating-point type. (Note, there are also a few atan() calls but didn't modify them as the result is divided by some other value, so there might be accuracy losses that need to be assessed first). Found by `performance-type-promotion-in-math-fn` clang-tidy check. Tested: bazel test -c opt src/gpl/test:incremental02-tcl_test Signed-off-by: Henner Zeller <h.zeller@acm.org>
a47e91e to
01181c9
Compare
|
clang-tidy review says "All clean, LGTM! 👍" |
The
sin()andcos()calls are used on float arguments, but these functions are double by default (the corresponding float functions would besinf()andcosf()), forcing the argument to be upcast to double and then the result back downcast to float.Instead, use
std::sin()andstd::cos()that have overrides for each floating-point type.(Note, there are also a few atan() calls but didn't modify them as the result is divided by some other value, so there might be accuracy losses that need to be assessed first).
Found by
performance-type-promotion-in-math-fnclang-tidy check.