Skip to content
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

ENH: SampleSurfaceMesh and GeometryMath Speed Optimizations #1020

Merged

Conversation

nyoungbq
Copy link
Contributor

@nyoungbq nyoungbq commented Jul 16, 2024

Fixes #962
Fixes #961
Updated Documentation

Version Time CPU Iterations
Baseline 7232 ns 7231 ns 75982
Post-Cache 6249 ns 6249 ns 107611
branch-reduction 6234 ns 6234 ns 104425

Todo:

  • add caching routing
  • strip extraneous copies
  • extract all major tight loop constructions
  • extract extraneous if statements
  • consolidate calculations for coditionals in tight loops
  • Strip if from DoesRayIntersectBox
  • Strip if from IsPointInTriangle
  • Strip if from RayCrossesTriangle
  • Ray.hpp now uses a cached variant in the algorithm to avoid inserting Eigen (after discussion) while preserving API

@nyoungbq nyoungbq force-pushed the enh/geometry_math_optimizations branch from 8a44899 to a70e938 Compare July 19, 2024 11:05
@nyoungbq nyoungbq marked this pull request as ready for review July 19, 2024 20:37
@nyoungbq nyoungbq requested a review from JDuffeyBQ July 19, 2024 20:37
@JDuffeyBQ
Copy link
Collaborator

Do you have the code that you used for the timings?

@nyoungbq
Copy link
Contributor Author

Do you have the code that you used for the timings?

I slacked it to you because it uses hardcoding to get around additional library linkage

@nyoungbq nyoungbq force-pushed the enh/geometry_math_optimizations branch from e0af8f7 to e4f09c9 Compare July 30, 2024 16:04
@imikejackson imikejackson force-pushed the enh/geometry_math_optimizations branch from e4f09c9 to fd0d738 Compare August 1, 2024 00:54
@nyoungbq nyoungbq force-pushed the enh/geometry_math_optimizations branch from fd0d738 to befb4da Compare August 1, 2024 19:55
@imikejackson imikejackson force-pushed the enh/geometry_math_optimizations branch 2 times, most recently from 8030e48 to 0dd51be Compare August 2, 2024 18:44
@nyoungbq nyoungbq force-pushed the enh/geometry_math_optimizations branch from 0dd51be to 52586d0 Compare August 2, 2024 19:35
src/simplnx/Utilities/Math/GeometryMath.cpp Outdated Show resolved Hide resolved
src/simplnx/Common/Ray.hpp Outdated Show resolved Hide resolved
src/simplnx/Utilities/Math/GeometryMath.hpp Outdated Show resolved Hide resolved
src/simplnx/Common/Ray.hpp Outdated Show resolved Hide resolved
src/simplnx/Utilities/Math/GeometryMath.hpp Show resolved Hide resolved
src/simplnx/Utilities/Math/GeometryMath.hpp Outdated Show resolved Hide resolved
@imikejackson imikejackson force-pushed the enh/geometry_math_optimizations branch from 52586d0 to 6773be1 Compare August 3, 2024 16:43
@nyoungbq nyoungbq force-pushed the enh/geometry_math_optimizations branch from 6773be1 to 511ea86 Compare August 6, 2024 16:48
@imikejackson imikejackson force-pushed the enh/geometry_math_optimizations branch from 511ea86 to a503f66 Compare August 8, 2024 14:20
@imikejackson imikejackson requested a review from JDuffeyBQ August 8, 2024 14:20
@imikejackson imikejackson enabled auto-merge (squash) August 8, 2024 14:21
@imikejackson imikejackson disabled auto-merge August 8, 2024 14:23
@nyoungbq nyoungbq force-pushed the enh/geometry_math_optimizations branch from a503f66 to 5873abc Compare August 8, 2024 20:46
@nyoungbq nyoungbq force-pushed the enh/geometry_math_optimizations branch from 1bef4a7 to 07e0742 Compare August 8, 2024 21:17
@nyoungbq nyoungbq merged commit e1f4593 into BlueQuartzSoftware:develop Aug 9, 2024
7 checks passed
imikejackson pushed a commit to imikejackson/simplnx that referenced this pull request Oct 20, 2024
…tzSoftware#1020)

* Add caching routine - approx 15% speedup

* Clear excessive branching and excess copying

* extract costly construction in tight loop

* Consolidate if statement calculations, strip expensive modulo with bitwise calculation, reenable randomness

* strip extraneous coping, further if cleanup

* Initial Ray changes to attempt to preserve pure c++, converted 'DoesRayIntersectBox` if statements

* Add a caching version of Ray to prevent repeated calculations for the same result in loops. Selected to preserve existing API

* extract if statements in favor of integer math for CPU pipeline speed, parameter reordering for clearer distinction in overloads

* clean up remaining ifs and reduce ray misses by appropriately sizing ray

* patch bounding box bug in branchless calculations

* repair overlooked functionality in Ray (cached version)

* Default seed cleans up output and speeds up process

* Modified Ray class

* walk back branchless changes -- processing time is roughly equivalent between branched and branchless, and branched is more readable

* Add type declarations for Clang Compiler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants