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

Inline most point functions. #301

Merged

Conversation

MFraters
Copy link
Member

@MFraters MFraters commented Jul 3, 2021

I am still testing to see if this make any (positive) difference at all this. So this pull request is currently mostly to see how the difference benchmarks do.

@codecov
Copy link

codecov bot commented Jul 3, 2021

Codecov Report

Merging #301 (8100c33) into master (0f2c4cd) will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #301      +/-   ##
==========================================
- Coverage   99.00%   98.98%   -0.02%     
==========================================
  Files          74       74              
  Lines        4227     4155      -72     
==========================================
- Hits         4185     4113      -72     
  Misses         42       42              
Impacted Files Coverage Δ
source/point.cc 100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f2c4cd...8100c33. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Jul 3, 2021

Benchmark Master Feature Difference (99.9% CI)
Slab interpolation simple none 1.406 ± 0.009 (s=346) 1.178 ± 0.008 (s=353) -16.4% .. -16.1%
Slab interpolation curved simple none 1.352 ± 0.048 (s=368) 1.136 ± 0.053 (s=357) -16.9% .. -15.0%
Spherical slab interpolation simple none 1.937 ± 0.035 (s=264) 1.514 ± 0.025 (s=260) -22.3% .. -21.4%
Slab interpolation simple curved CMS 1.968 ± 0.509 (s=214) 1.861 ± 0.481 (s=260) -13.2% .. +2.3%
Spherical slab interpolation simple CMS 4.708 ± 0.009 (s=103) 4.281 ± 0.011 (s=100) -9.2% .. -9.0%
Spherical fault interpolation simple none 2.790 ± 0.047 (s=191) 1.985 ± 0.038 (s=188) -29.4% .. -28.4%

@MFraters MFraters force-pushed the inline_point_functions branch from a33f5fc to 296ff04 Compare July 3, 2021 18:10
@MFraters MFraters changed the title [WIP] inline some point functions. Inline most point functions. Jul 3, 2021
@MFraters MFraters added the performance Requests or proposes performance improvements label Jul 3, 2021
@MFraters
Copy link
Member Author

MFraters commented Jul 3, 2021

It turns out that in inlineing most of (but not all) of the point function has a significant (positive) influence on the performance. I have approached this incrementally both locally and here in this pull request to get a sence of the influence of each set of inlining. The incremental changes can still be seen in the github-actions bot comment by looking at the previous edits and it should match one-to-one with the commits.

This is related to/relevant for #300, #264 #219

@MFraters MFraters merged commit 578f0eb into GeodynamicWorldBuilder:master Jul 3, 2021
@bangerth
Copy link
Contributor

bangerth commented Jul 4, 2021

Impressive!

{
WBAssert(coordinate_system == point_right.get_coordinate_system(),
"Cannot substract two points which represent different coordinate systems. Internal has type " << static_cast<int>(coordinate_system)
<< ", other point has type " << static_cast<int>(point_right.get_coordinate_system()));
Copy link
Contributor

Choose a reason for hiding this comment

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

This is true for the dot product operator as well, by the way, even though it doesn't have this assertion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Moreover, the formula for the dot product is only correct for Cartesian coordinate systems :-)

inline
Point<dim> &operator+=(const Point<dim> &point_right)
{
for (unsigned int i = 0; i < dim; ++i)
Copy link
Contributor

Choose a reason for hiding this comment

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

and here

inline
Point<dim> &operator-=(const Point<dim> &point_left)
{
for (unsigned int i = 0; i < dim; ++i)
Copy link
Contributor

Choose a reason for hiding this comment

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

and here and probably some others as well

@MFraters
Copy link
Member Author

MFraters commented Jul 4, 2021

Thanks! I agree with that there should be assert there to prevent mixing of coordinates. Would you be willing to make a quick pull request for this? :P

For the dot product in spherical coordinates, I agree that it is not the correct equation, but it is something I am actually using. I am using it in 2d to get an approximation of where along the line between two points you are and I found that it seems accurate enough. I am not sure how much I sinned against mathematics by doing this, but I haven't really though about the correct way of doing this yet. I will make an issue for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Requests or proposes performance improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants