Skip to content

Commit

Permalink
make it build in Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
eggrobin committed Mar 29, 2024
1 parent ec462ff commit 00bf44f
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions numerics/fma.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,34 @@ constexpr bool CanEmitFMAInstructions = true;
constexpr bool CanEmitFMAInstructions = false;
#endif

// The functions in this file unconditionally wrap the appropriate intrinsics.
// The caller may only use them if |UseHardwareFMA| is true.
#if PRINCIPIA_USE_FMA_IF_AVAILABLE()
#define PRINCIPIA_USE_HARDWARE_FMA_DEFAULT \
(CanEmitFMAInstructions && HasCPUFeatures(CPUFeatureFlags::FMA));
#else
#define PRINCIPIA_USE_HARDWARE_FMA_DEFAULT false;
#endif

#if PRINCIPIA_CAN_OVERRIDE_FMA_USAGE_AT_RUNTIME
inline bool DefaultUseHardwareFMA =
CanEmitFMAInstructions && HasCPUFeatures(CPUFeatureFlags::FMA);
inline bool InternalUseHardwareFMA = DefaultUseHardwareFMA;
inline bool InternalUseHardwareFMA = PRINCIPIA_USE_HARDWARE_FMA_DEFAULT;
class FMAPreventer {
public:
FMAPreventer() {
InternalUseHardwareFMA = false;
}
~FMAPreventer() {
InternalUseHardwareFMA = DefaultUseHardwareFMA;
InternalUseHardwareFMA = PRINCIPIA_USE_HARDWARE_FMA_DEFAULT;
}
};
inline bool const& UseHardwareFMA = InternalUseHardwareFMA;
#else
inline bool const UseHardwareFMA =
CanEmitFMAInstructions && HasCPUFeatures(CPUFeatureFlags::FMA);
inline bool const UseHardwareFMA = PRINCIPIA_USE_HARDWARE_FMA_DEFAULT;
class FMAPreventer; // Undefined.
#endif
#else
inline bool const UseHardwareFMA = false;
#endif

#undef PRINCIPIA_USE_HARDWARE_FMA_DEFAULT

// The functions in this file unconditionally wrap the appropriate intrinsics.
// The caller may only use them if |UseHardwareFMA| is true.

// ⟦ab + c⟧.
inline double FusedMultiplyAdd(double a, double b, double c);
Expand Down

0 comments on commit 00bf44f

Please sign in to comment.