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
FEPointEvaluation: Remove signal to keep track of reinit() state #16925
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.
This looks much cleaner than before (including the variable names).👍
It is good to remove the signal from a performance perspective 👍🏽 @kronbichler I still think it would be the cleanest option to shift this responsibility to call Making the "automatic" reinitalization more efficient (what this PR does) is a step in the right direction. One question: We can also set the new bool dealii/include/deal.II/matrix_free/fe_point_evaluation.h Lines 2299 to 2310 in e9eb5ab
reinit function and evaluate/integrate afterwards.
I would like to have @gassmoeller s opinion on this one more time since he is the one with the use case. |
I did think about it, but the question is when we would turn the value, once it is |
You are right, this exactly what the bool can't do but the signal can. I am in favour of the current PR. But it will probably slow down @gassmoeller s use case because there |
@gassmoeller any comments or should we merge? |
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.
Very good catch @kronbichler . I do not foresee any issue with this.
Sorry for the slow response, I am in the middle of a move right now. Do I understand correctly that the only negative consequence of this PR could be that the performance degrades somewhat for expensive mappings if the MappingInfo object is shared between multiple FEPointEvaluation objects? I would want to do some benchmarks to evaluate that impact once I have some time, but as long as this change doesnt break existing user code we can merge this for now. As background: ASPECT has the use case where 3 or 4 FEPointEvaluation objects (one each for the different variables of a FESystem) share the MappingInfo object, with a MappingQ(4) mapping including derivatives. |
Yes, the only negative consequence will be a minor performance degradation for your use case. It comes from multiple |
Let me add a little on the comment by @bergbauer: There is some integer work that gets done more often. We could work around this (and I would be willing to create a follow-up patch or addition to this patch) by letting the dealii/tests/matrix_free/point_evaluation_19.cc Lines 110 to 113 in 36dc1a7
I guess this could be clearer from a use perspective, in that reinit() always makes sure information is not called again.
|
If we are only talking about setting some pointers I do not think this is a problem. I was concerned the mapping information may have to be computed several times, but as long as that is not the case feel free to merge this PR. |
In the analysis for the particle benchmark done for #16854, I observed a high cost for the
boost::signals2::connection
(for my analysis around 10% of the cost inFEPointEvaluation::reinit()
. We introduced this in #14982 in order to support the case where severalFEPointEvaluation
objects share the sameMappingInfo
object (typically because we want to query the expensive mapping only once). I now implement a simpler strategy that only keeps track of whether the object itself calledreinit()
or whether the data comes from anotherMappingInfo
object, which then decides whether we must call the respective call inFEPointEvaluation::evaluate()
orFEPointEvaluation::integrate()
. There are some cases where my simple setup fails, e.g. when we callreinit()
on the derived object on some cells only, but I don't think they are relevant to how we typically use them. We might want to add some basic assertions regarding the sizes (I would have to check how to do it). Furthermore, we evaluate the polynomials twice if we callevaluate()
andintegrate()
on such a derived object; this could be avoided by calling a suitablereinit(numbers::invalid_unsigned_int)
function I believe (again not checked). @bergbauer opinions?Related to #15650.