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
matrix-free FEEvaluation: initialize with nan #14152
Conversation
This is for trying to fix a bug I am seeing in ASPECT and @bangerth gave me the idea to initialize the internal data structures with NaNs to be able to more reliably see when things go wrong. FYI @kronbichler |
And the following tests fail with a FPE:
😃 |
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.
I'm glad this was useful. Let's hope that someone can see what the problem is -- that's exactly why we invented the signaling_nan()
infrastructure.
# ifdef DEBUG | ||
scratch_data_array->clear(); | ||
scratch_data_array->resize(allocated_size, | ||
Number(numbers::signaling_nan<double>())); |
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.
Should this be the following instead?
Number(numbers::signaling_nan<double>())); | |
numbers::signaling_nan<Number>()); |
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.
Won't work because this will be instantiated for Number=VectorizedArray and .
I was too lazy to extend signaling_nan.
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.
Ah, but then what are the semantics of casting a signaling nan double
to a VectorizedArray
?
Leave it as is for the moment -- the patch isn't going to get merged for now while there are failures, but if you don't mind, add the specializations of signaling_nan
for VectorizedArray
objects.
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.
It is calling the constructor that puts this value into all values:
dealii/include/deal.II/base/vectorization.h
Line 440 in cb83302
VectorizedArray(const Number scalar) |
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.
But you should be able to use
Number(numbers::signaling_nan<double>())); | |
Number(numbers::signaling_nan<ScalarNumber>())); |
which is defined here:
dealii/include/deal.II/matrix_free/fe_evaluation_data.h
Lines 125 to 126 in b8f23f1
using ScalarNumber = | |
typename internal::VectorizedArrayTrait<Number>::value_type; |
This approach currently breaks the use case in dealii/include/deal.II/matrix_free/mapping_info.templates.h Lines 2106 to 2108 in b8f23f1
|
Is that the reason for the test failures? |
Indeed, with this fixed I see the tests passing on my local machine. Let me push this fix, it is better coding style to attach separate arrays anyway, irrespective of this PR. |
adjusted and rebased. |
Let's hope this works now! |
The Windows compiler has some trouble:
|
I am not sure how to make MSVC happy, so I am disabling the NaNs there. 🤷 |
Initialize the internal scratch_data of FEEvaluation with signaling_nans in debug mode.
otherwise MSVC tries to use numbers::internal from signaling_nan.h
@@ -892,7 +892,7 @@ namespace numbers | |||
{ | |||
// Use the specialized definition for two ADOL-C taped types | |||
return value_is_less_than(value_1, | |||
internal::NumberType<adouble>::value(value_2)); | |||
::internal::NumberType<adouble>::value(value_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.
(oops My bad - the regression tester had been out of commission for a week. I missed a reboot.)
The global namespace qualifier ::internal
is a typo. Fixed in #14162
Initialize the internal scratch_data of FEEvaluation with signaling_nans
in debug mode.