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

Use hcubature_buffer for decomposed geometries #157

Closed
wants to merge 15 commits into from
Closed

Conversation

mikeingold
Copy link
Collaborator

@mikeingold mikeingold commented Dec 19, 2024

Changes

  • For geometries that must be decomposed into multiple pieces, use HCubature.hcubature_buffer to pre-allocate a buffer that can be re-used.

Conclusion

Performance did not improve when using this for Rope or CylinderSurface.

@mikeingold mikeingold added the enhancement New feature or request label Dec 19, 2024
@mikeingold mikeingold self-assigned this Dec 19, 2024
Copy link
Contributor

github-actions bot commented Dec 19, 2024

Benchmark Results

main 2e1038d... main/2e1038d07fe2fd...
Differentials/Differential 0.203 ± 0.002 μs 0.202 ± 0.002 μs 1
Differentials/Jacobian 0.167 ± 0.001 μs 0.166 ± 0.001 μs 1.01
Integrals/CylinderSurface, Scalar, GaussKronrod 0.468 ± 0.0028 ms 0.465 ± 0.0031 ms 1.01
Integrals/CylinderSurface, Scalar, GaussLegendre 15.7 ± 0.051 ms 15.7 ± 0.049 ms 1
Integrals/CylinderSurface, Scalar, HAdaptiveCubature 0.135 ± 0.0007 ms 0.155 ± 0.00077 ms 0.869
Integrals/CylinderSurface, Vector, GaussKronrod 0.573 ± 0.0071 ms 0.57 ± 0.0074 ms 1.01
Integrals/CylinderSurface, Vector, GaussLegendre 20.8 ± 3.8 ms 20.4 ± 3.8 ms 1.02
Integrals/CylinderSurface, Vector, HAdaptiveCubature 0.181 ± 0.0014 ms 0.206 ± 0.0016 ms 0.88
Integrals/Segment, Scalar, GaussKronrod 0.819 ± 0.0036 μs 0.888 ± 0.0065 μs 0.922
Integrals/Segment, Scalar, GaussLegendre 4.35 ± 0.11 μs 4.32 ± 0.1 μs 1.01
Integrals/Segment, Scalar, HAdaptiveCubature 1.13 ± 0.14 μs 1.04 ± 0.11 μs 1.09
Integrals/Segment, Vector, GaussKronrod 3.08 ± 0.073 μs 3.08 ± 0.056 μs 1
Integrals/Segment, Vector, GaussLegendre 15.8 ± 0.41 μs 15.3 ± 0.37 μs 1.03
Integrals/Segment, Vector, HAdaptiveCubature 3.92 ± 0.085 μs 3.94 ± 0.074 μs 0.995
Integrals/Sphere, Scalar, GaussKronrod 0.0761 ± 0.00083 ms 0.0758 ± 0.00041 ms 1
Integrals/Sphere, Scalar, GaussLegendre 1.83 ± 0.0088 ms 1.83 ± 0.01 ms 0.999
Integrals/Sphere, Scalar, HAdaptiveCubature 0.0474 ± 0.0001 ms 0.0478 ± 0.00011 ms 0.993
Integrals/Sphere, Vector, GaussKronrod 0.112 ± 0.0011 ms 0.112 ± 0.001 ms 0.995
Integrals/Sphere, Vector, GaussLegendre 3.14 ± 0.033 ms 3.15 ± 0.033 ms 0.998
Integrals/Sphere, Vector, HAdaptiveCubature 0.102 ± 0.0012 ms 0.0994 ± 0.0011 ms 1.03
Rules/GaussLegendre 22.1 ± 0.54 μs 21.7 ± 0.49 μs 1.01
Specializations/BezierCurve, Scalar, GaussLegendre 0.25 ± 0.001 ms 0.253 ± 0.00035 ms 0.989
Specializations/BezierCurve, Scalar, HAdaptiveCubature 0.267 ± 0.0014 ms 0.268 ± 0.00046 ms 0.995
Specializations/Line, Scalar, GaussLegendre 7.22 ± 0.055 μs 7.16 ± 0.058 μs 1.01
Specializations/Line, Scalar, HAdaptiveCubature 10.8 ± 0.12 μs 10.7 ± 0.13 μs 1.01
Specializations/Ngon, Scalar, GaussLegendre 0.598 ± 0.0032 ms 0.598 ± 0.004 ms 1
Specializations/Ngon, Scalar, HAdaptiveCubature 0.136 ± 0.0007 ms 0.137 ± 0.0034 ms 0.99
Specializations/Plane, Scalar, GaussLegendre 0.74 ± 0.0024 ms 0.738 ± 0.0023 ms 1
Specializations/Plane, Scalar, HAdaptiveCubature 2.81 ± 0.015 ms 2.85 ± 0.054 ms 0.987
Specializations/Ray, Scalar, GaussLegendre 6.08 ± 0.047 μs 5.98 ± 0.042 μs 1.02
Specializations/Ray, Scalar, HAdaptiveCubature 7.38 ± 0.083 μs 7.32 ± 0.12 μs 1.01
Specializations/Rope, Scalar, GaussLegendre 0.0516 ± 0.0002 ms 0.0515 ± 0.00019 ms 1
Specializations/Rope, Scalar, HAdaptiveCubature 0.0338 ± 0.0028 ms 0.0368 ± 0.0005 ms 0.92
Specializations/Tetrahedron, Scalar, GaussLegendre 0.249 ± 0.00062 s 0.247 ± 0.00074 s 1.01
Specializations/Tetrahedron, Scalar, HAdaptiveCubature 0.0486 ± 0.00018 s 0.051 ± 0.00023 s 0.953
time_to_load 1.51 ± 0.0068 s 1.51 ± 0.015 s 0.994

Benchmark Plots

A plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR.
Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).

Comment on lines +41 to +45
f,
rope::Meshes.Rope,
rule::HAdaptiveCubature;
FP::Type{T} = Float64,
kwargs...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
f,
rope::Meshes.Rope,
rule::HAdaptiveCubature;
FP::Type{T} = Float64,
kwargs...
f,
rope::Meshes.Rope,
rule::HAdaptiveCubature;
FP::Type{T} = Float64,
kwargs...

Copy link

codecov bot commented Dec 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (16835af) to head (2e1038d).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #157   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           18        18           
  Lines          184       206   +22     
=========================================
+ Hits           184       206   +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mikeingold
Copy link
Collaborator Author

Using this technique seems to be marginally slower for a Rope. I'm guessing that the overhead there just isn't worth the savings per-integral.

I'm going to try some other geometries to see if any others get any benefit.

Comment on lines +36 to +41
f,
cyl::Meshes.CylinderSurface,
rule::HAdaptiveCubature;
FP::Type{T} = Float64,
diff_method::DM = _default_diff_method(cyl, FP),
kwargs...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
f,
cyl::Meshes.CylinderSurface,
rule::HAdaptiveCubature;
FP::Type{T} = Float64,
diff_method::DM = _default_diff_method(cyl, FP),
kwargs...
f,
cyl::Meshes.CylinderSurface,
rule::HAdaptiveCubature;
FP::Type{T} = Float64,
diff_method::DM = _default_diff_method(cyl, FP),
kwargs...

@mikeingold mikeingold closed this Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant