-
Notifications
You must be signed in to change notification settings - Fork 202
Clang UB sanitizer CI test: increase coverage #5597
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
base: development
Are you sure you want to change the base?
Clang UB sanitizer CI test: increase coverage #5597
Conversation
@@ -298,7 +298,7 @@ void ParticleHistogram2D::WriteToFile (int step) const | |||
data.setPosition<amrex::Real>({0.5, 0.5}); | |||
|
|||
auto dataset = io::Dataset( | |||
io::determineDatatype<double>(), | |||
io::determineDatatype<amrex::Real>(), |
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.
Wouldn't the properties be in ParticleReal
?
io::determineDatatype<amrex::Real>(), | |
io::determineDatatype<amrex::ParticleReal>(), |
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.
Yes, you are right!
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.
However, we also have to modify the datatype of m_h_data_2D
to be coherent (I've done that in my latest commit): amrex::TableData<amrex::Real,2> m_h_data_2D
-> amrex::TableData<amrex::ParticleReal,2> m_h_data_2D
Co-authored-by: Axel Huebl <[email protected]>
ping, @EZoni ! |
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 good, thanks!
I will comment that NaNs always make me nervous that there is something bad lurking in the code. Do you know why they appear in that case with single precision?
Thanks, @dpgrote . The NaN comes from this line in
|
Actually, in this case, we have a 250 GeV electron beam. So we can't represent beta reliably in single precision for such high energies. I think that the best we can do is to add an assert to ensure that beta < 1 . |
@dpgrote , I've added this check inside
so that at least the user has a more readable error message. |
…erage_clang_ub_sanitizer
…erage_clang_ub_sanitizer
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 kind of wondering, instead of running specific input files manually, couldn't we simply run specific tests with ctest
?
I would expect this to be equivalent and it is part of what the CTest migration was meant for (I mean, run tests through ctest
rather than manually).
For example, replacing the mpirun
commands with
ctest --test-dir build --output-on-failure -R "laser_acceleration"
ctest --test-dir build --output-on-failure -R "laser_ion"
...
We could also make the -R
filter more complex to filter specific tests and/or only execute the .run
tests, if we want to skip analysis, checksums, etc.
What do you think? Would you be okay with trying this?
In CI test based on clang UB sanitizers, most of the time (~ 1h30) is spent in compiling the code, while just a few minutes are spent actually running some simulations. This means that we can increase the coverage of the test by adding some more simulations to the tests with a negligible increase of the total runtime.
This PR does just that: now most of the cases in
Examples/Physics_applications
are tested with the UB sanitizer.Note that some cases cannot run in double precision (see below). For this reason, the PR also splits the UB sanitizer test into single precision and double precision (in double precision only the cases that cannot run in single precision are tested).
Updates:
Issue found while running inputs_test_3d_beam_beam_collision --> We need to run this case in double precision
The tool has found an issue while running
mpirun -n 2 ./build/bin/warpx.3d Examples/Physics_applications/beam_beam_collision/inputs_test_3d_beam_beam_collision
:I've temporarily commented out this case while I investigate the cause.
For the moment, I am not able to reproduce the issue on my local machine. The issue is using single precision for this specific test case! Specifically, momenta end up beingNaN
and the sanitizer detects the attempt to convert a floating point NaN into an integer.I have added an
ABLASTR_ALWAYS_ASSERT_WITH_MESSAGE
inPoissonSolver.H
so that a more readable error message is provided to the user.Issue found while running inputs_test_2d_background_mcc --> We need to run this case in double precision
MLMG
does not converge in single precision for this simulation case. We need to run it in double precision.Issue found while running free_electron_laser --> We need to run this case in double precision
I have observed this issue:
which seems to be related to using single precision instead of double precision. Therefore, we need to run this case in double precision.
Issue found while running inputs_test_2d_laser_ion_acc --> bugfix in WarpX
inputs_test_2d_laser_ion_acc
case has the following issue in single precision:This comes from the fact that the datatype of this dataset in
ParticleHistogram2D.cpp
is hard-coded as double:this PR modifies these lines as follows: