-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #10656 - Rewrite the CLIPLINE algorithm
Use the Liang-Barsky algorithm * Loosely adapted from https://en.wikipedia.org/wiki/Liang%E2%80%93Barsky_algorithm * Rewrote it until performance is optimal I used microbenchmarking: https://github.com/jmarrec/CppBenchmarks/blob/94f0e1594ff17f9833a0547f0725d68c561311a1/bench_clipline.cpp BM_CLIPLINE is the current E+ algorithm. BM_liang_barsky_clipper3 is my final version that I used here, and which is 15% faster than the original while being actually correct. in the edge cases ``` ------------------------------------------------------------------- Benchmark Time CPU Iterations ------------------------------------------------------------------- BM_CLIPLINE 567 ns 566 ns 1231826 BM_Clip2 703 ns 703 ns 991672 BM_liang_barsky_clipper 588 ns 588 ns 1199750 BM_liang_barsky_clipper2 490 ns 490 ns 1430600 BM_liang_barsky_clipper3 482 ns 482 ns 145236 ```
- Loading branch information
Showing
3 changed files
with
84 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
251ea56
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.
10656_CLIPLINE (jmarrec) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (3696 of 3697 tests passed, 0 test warnings)
Failures:\n
EnergyPlusFixture Test Summary
251ea56
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.
10656_CLIPLINE (jmarrec) - x86_64-MacOS-10.18-clang-15.0.0: OK (3655 of 3656 tests passed, 0 test warnings)
Failures:\n
EnergyPlusFixture Test Summary
251ea56
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.
10656_CLIPLINE (jmarrec) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (2071 of 2072 tests passed, 0 test warnings)
Failures:\n
EnergyPlusFixture Test Summary
251ea56
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.
10656_CLIPLINE (jmarrec) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: OK (795 of 795 tests passed, 0 test warnings)