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

Remove the FMA preventer and avoid FMA for Clang in core-math #3993

Merged
merged 4 commits into from
Apr 25, 2024

Conversation

pleroy
Copy link
Member

@pleroy pleroy commented Apr 24, 2024

functions/cos.cc Outdated
Comment on lines 50 to 53
#define __builtin_fma(x, y, z) \
(principia::numerics::_fma::UseHardwareFMA \
? principia::numerics::_fma::FusedMultiplyAdd(x, y, z) \
: x * y + z)
Copy link
Member

Choose a reason for hiding this comment

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

  1. I think this makes the functions incorrect in MSVC debug and on clang; we should call std::fma if we really cannot use FMA;
  2. Clang has a __builtin_fma, which calls std::fma if there is no FMA available: https://godbolt.org/z/814Ebdanr.
Suggested change
#define __builtin_fma(x, y, z) \
(principia::numerics::_fma::UseHardwareFMA \
? principia::numerics::_fma::FusedMultiplyAdd(x, y, z) \
: x * y + z)
#if PRINCIPIA_COMPILER_MSVC
#define __builtin_fma(x, y, z) principia::numerics::_fma::FusedMultiplyAdd(x, y, z)
#endif

@eggrobin eggrobin added the LGTM label Apr 25, 2024
@pleroy pleroy merged commit de651a2 into mockingbirdnest:master Apr 25, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants