Fix 'fpclassify: ambiguous call' compile fail in MSVC 2022 (#2426)

Similar to #2219, we see "'fpclassify': ambiguous call" error in
test_conformance\basic\test_fpmath.cpp
due to missing constexpr at
https://github.com/KhronosGroup/OpenCL-CTS/blob/9265cbb2c274/test_conformance/basic/test_fpmath.cpp#L104
This PR fixes the issue by moving utility function isnan_fp in
testHarness.h and use it.
Note this PR doesn't modify use of isnan in many tests where only
float/double values are checked.
This commit is contained in:
Wenju He
2025-08-06 00:08:04 +08:00
committed by GitHub
parent 9ca0126c54
commit e15c6eb760
12 changed files with 94 additions and 107 deletions

View File

@@ -14,6 +14,7 @@
// limitations under the License.
//
#include "harness/compat.h"
#include "harness/mathHelpers.h"
#include "harness/rounding_mode.h"
#include "harness/stringHelpers.h"
@@ -57,16 +58,6 @@ template <typename T> double toDouble(T val)
return val;
}
bool isHalfNan(cl_half v)
{
// Extract FP16 exponent and mantissa
uint16_t h_exp = (v >> (CL_HALF_MANT_DIG - 1)) & 0x1F;
uint16_t h_mant = v & 0x3FF;
// NaN test
return (h_exp == 0x1F && h_mant != 0);
}
cl_half half_plus(cl_half a, cl_half b)
{
return HFF(std::plus<float>()(HTF(a), HTF(b)));
@@ -101,14 +92,7 @@ int verify_fp(std::vector<T> (&input)[2], std::vector<T> &output,
T r = test.ref(inA[i], inB[i]);
bool both_nan = false;
if (std::is_same<T, cl_half>::value)
{
both_nan = isHalfNan(r) && isHalfNan(output[i]);
}
else if (std::is_floating_point<T>::value)
{
both_nan = std::isnan(r) && std::isnan(output[i]);
}
both_nan = isnan_fp(r) && isnan_fp(output[i]);
// If not both nan, check if the result is the same
if (!both_nan && (r != output[i]))