-
Notifications
You must be signed in to change notification settings - Fork 192
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
Combine Shape map calls #6227
Combine Shape map calls #6227
Conversation
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.
Thank you for investigating this!
static constexpr bool use_combined_shape_call = | ||
std::is_same_v<CoordinateMaps::TimeDependent::Shape, Map> and | ||
std::is_same_v<T, DataVector>; |
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.
Instead of checking if this is a shape map explicitly (and thus adding an strange dependency for the general coord map on the time dependent maps), add a meta function that checks if the Map
object has a function named coords_frame_velocity_jacobian
that can be called with the given arguments.
Then this easily allows us to edit the other time dependent maps if we want to to add this feature to those as well
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.
Note: I think we could get away with a forward declaration of the map to avoid the coupling. Just providing another option.
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.
LGTM, no need for my approval to merge.
@@ -258,6 +258,7 @@ class Shape { | |||
size_t l_max_ = 2; | |||
size_t m_max_ = 2; | |||
ylm::Spherepack ylm_{2, 2}; | |||
ylm::Spherepack extended_ylm_{2, 2}; |
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.
3, 3
?
static constexpr bool use_combined_shape_call = | ||
std::is_same_v<CoordinateMaps::TimeDependent::Shape, Map> and | ||
std::is_same_v<T, DataVector>; |
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.
Note: I think we could get away with a forward declaration of the map to avoid the coupling. Just providing another option.
@knelli2 I have factored out large chunks of the jacobian, I do not think this is worth doing for the operator() or frame velocity as it is just two statements. I also avoid duplicate calls to the transition_function in the combined call which I had overlooked before. |
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.
Looks good! You can squash this last change in with everything else
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.
Also fix the compilation errors from gcc-9 and the clang-tidy issues. The one about using l
as a variable you can ignore or add it to our .clang-tidy
file because it's pretty silly
d7a701e
to
bf2cf78
Compare
Thanks for your reviews. I changed everything but the long link |
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.
You can squash directly. As for the long link, our commit hooks check for linked that contain either \link
or \endlink
and ignore those, so just make sure one of those is on the same line as the link.
bf2cf78
to
69a5ac0
Compare
all done and squashed in, thank you for the review! |
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.
Thanks for optimizing this!
This test failure is concerning me since I (and @nilsvu) have never seen it before and I want to make sure it's not related to the shape map changes. The test failure happened twice in a row with the same error |
oh, that is weird. So it only fails with clang-13 in Release mode. I don't know the executable at all. Would this executable call the |
Looks like reducing the |
@knelli2 @nilsvu @nilsdeppe I looked into the test failure a bit more. It seems that the test failure is unrelated to combining the shape map calls. I can "fix" the failure by simply adding or removing some temporaries in the shape map that change the evaluation order of operations (all additions and multiplications). One change that causes the test to fail is e.g. here, where I just introduce a temporary that should definitely be safe: nikwit@6ecb730 Also, simply inlining the I am therefore convinced that this PR simply changes some floating point precision that propagates through the elliptic solver and changes the residuals that are computed (which are still convergent). IMO, we should simply raise the tolerance of that test. |
I ran this branch on my machine and the test passes. It looks like specifically clang-13 Release fails, and specifically the first GMRES iteration after AMR iteration is different. The shape map gets evaluated on the new refined grid points, so at least it's plausible that an issue in the shape map can cause this failure. I worries me enough that I wouldn't just reduce the Lmax to "fix" it without checking that BBH evolutions aren't affected. Suggestions:
It's a very mysterious issue, and I just want to ensure that it doesn't affect our BBH simulations in mysterious ways 😅 |
@nilsvu I think my analysis above shows that the issue is related simply to the order in which expressions are evaluated in the shape map (nikwit@6ecb730 fixes it!). The test appears to blow up a floating point difference to a difference of 1e-9 somehow. I do not see how this can be related to My suspicion is that the test is not a fair test. Can you describe where the residuals that are compared in the test come from? It looks like the test uses 4 grid points per element and no h-refinement. How can this lead to a residual of 1e-11? |
The refinement of the domain and the DG scheme defines a discretized problem Now I don't see how the numerical algorithm that solves the discretized problem should blow up roundoff error in the shape map to truncation error level differences, though I might be missing something of course. |
alright, I see. At this point I would argue that since changing the order in which |
I have now seen two other cases of this test failing on CI, so I agree that it is not directly related to the changes in this PR and I'm happy with this PR getting merged. I still have no idea what causes the issue though :( |
eef6f45
to
dc14ca4
Compare
rebased. Thank you all for your due diligence! |
Currently, the shape map computes the coordinates, frame velocity and jacobians separately which duplicates a lot of work such as computing the spherical harmonic expansion.
This PR adds a combined call to these three quantities. I found that this speeds up simulations between 16 % and 27% (when combined with #6223)
depends on #6223