From 3c3d939e8fc73e049de12b682319545935bc8def Mon Sep 17 00:00:00 2001 From: David Rohr Date: Wed, 18 Jun 2025 22:35:59 +0200 Subject: [PATCH] Hide NaN code with -ffast-math --- Common/ML/include/ML/3rdparty/GPUORTFloat16.h | 2 ++ GPU/Common/GPUCommonMath.h | 7 ++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Common/ML/include/ML/3rdparty/GPUORTFloat16.h b/Common/ML/include/ML/3rdparty/GPUORTFloat16.h index 3bf2f465b2a35..75e146d872cd1 100644 --- a/Common/ML/include/ML/3rdparty/GPUORTFloat16.h +++ b/Common/ML/include/ML/3rdparty/GPUORTFloat16.h @@ -568,9 +568,11 @@ GPUdi() uint16_t BFloat16Impl::ToUint16Impl(float v) noexcept template GPUdi() float BFloat16Impl::ToFloatImpl() const noexcept { +#ifndef __FAST_MATH__ if (IsNaN()) { return o2::gpu::CAMath::QuietNaN(); } +#endif float result; char* const first = reinterpret_cast(&result); char* const second = first + sizeof(uint16_t); diff --git a/GPU/Common/GPUCommonMath.h b/GPU/Common/GPUCommonMath.h index b448a30107dad..372e067b14aff 100644 --- a/GPU/Common/GPUCommonMath.h +++ b/GPU/Common/GPUCommonMath.h @@ -99,12 +99,9 @@ class GPUCommonMath GPUhdi() static float Remainderf(float x, float y); GPUd() constexpr static bool Finite(float x); GPUd() constexpr static bool IsNaN(float x); -#pragma GCC diagnostic push -#if defined(__FAST_MATH__) && defined(__clang__) -#pragma GCC diagnostic ignored "-Wnan-infinity-disabled" -#endif +#ifndef __FAST_MATH__ GPUd() constexpr static float QuietNaN() { return GPUCA_CHOICE(std::numeric_limits::quiet_NaN(), __builtin_nanf(""), nan(0u)); } -#pragma GCC diagnostic pop +#endif GPUd() constexpr static uint32_t Clz(uint32_t val); GPUd() constexpr static uint32_t Popcount(uint32_t val);