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

Fix FPEs in tests #6265

Merged
merged 9 commits into from
Sep 4, 2024
Merged

Conversation

nilsdeppe
Copy link
Member

Proposed changes

There are a couple MC neutrino tests I commented out because they're too hard for me to fix. That code isn't currently being used in simulations and will need a lot more debugging and testing in general. I'll talk with Francois Foucart about getting that fixed separately. My main goal is to just get FPEs on again in tests.

Upgrade instructions

Code review checklist

  • The code is documented and the documentation renders correctly. Run
    make doc to generate the documentation locally into BUILD_DIR/docs/html.
    Then open index.html.
  • The code follows the stylistic and code quality guidelines listed in the
    code review guide.
  • The PR lists upgrade instructions and is labeled bugfix or
    new feature if appropriate.

Further comments

Copy link
Member

@wthrowe wthrowe left a comment

Choose a reason for hiding this comment

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

Thanks for going through all these. I agree we can deal with the MC problems later.

T c(std::numeric_limits<T>::signaling_NaN());
T d(std::numeric_limits<T>::signaling_NaN());
// T c(std::numeric_limits<T>::quiet_NaN());
// T d(std::numeric_limits<T>::quiet_NaN());
Copy link
Member

Choose a reason for hiding this comment

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

Remove.

@@ -350,13 +351,21 @@ bool FixConservatives::operator()(
: static_cast<SimdType>(0);

// Equation B.27 of Foucart
//
// We avoid division by zero in the SIMD case using a mask and effectively
// set the result to zero by dividing by the max double.
Copy link
Member

Choose a reason for hiding this comment

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

It looks like you decided on a different implementation than this, without the max double part.

@@ -22,7 +22,10 @@ TimeDelta choose_lts_step_size(const Time& time, const double desired_step) {
// n because of floating-point truncation. The inner ceil call
// avoids this problem.
const auto desired_step_power =
static_cast<size_t>(std::ceil(std::log2(std::ceil(desired_step_count))));
desired_step == std::numeric_limits<double>::infinity()
Copy link
Member

Choose a reason for hiding this comment

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

This needs an abs(), since the step can be negative, or check for desired_step_count == 0.0 instead.

We should check for negative numbers before trying a c2p. This is also more
efficient.
We need to get FPEs in tests enabled again so we can actually resolve these
things before they get merged. I think getting these FPEs fixed will actually
take some effort and the code isn't used right now anyway.
I don't know if this is the intended test, but it at least resolves the FPE. I
also don't know why the quiet NaN causes an FPE on comparison or if the quiet
NaN somehow gets changed to a signaling one in the middle.
@nilsdeppe
Copy link
Member Author

I made the changes. Since they are pretty small I just went ahead and squashed it. Partly to get this in before more FPEs appear 🙃

Copy link
Member

@wthrowe wthrowe left a comment

Choose a reason for hiding this comment

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

Looks good. I would have requested a direct squash if I'd thought of it.

@wthrowe wthrowe merged commit 154d47c into sxs-collaboration:develop Sep 4, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants