mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
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:
35
test_common/harness/mathHelpers.h
Normal file
35
test_common/harness/mathHelpers.h
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2025 The Khronos Group Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
//
|
||||||
|
#ifndef _mathHelpers_h
|
||||||
|
#define _mathHelpers_h
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
#include <OpenCL/cl_platform.h>
|
||||||
|
#else
|
||||||
|
#include <CL/cl_platform.h>
|
||||||
|
#endif
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
template <typename T> inline bool isnan_fp(const T &v) { return std::isnan(v); }
|
||||||
|
|
||||||
|
template <> inline bool isnan_fp<cl_half>(const cl_half &v)
|
||||||
|
{
|
||||||
|
uint16_t h_exp = (((cl_half)v) >> (CL_HALF_MANT_DIG - 1)) & 0x1F;
|
||||||
|
uint16_t h_mant = ((cl_half)v) & 0x3FF;
|
||||||
|
return (h_exp == 0x1F && h_mant != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // _mathHelpers_h
|
||||||
@@ -14,7 +14,6 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
using std::isnan;
|
|
||||||
#include "harness/compat.h"
|
#include "harness/compat.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -26,6 +25,7 @@ using std::isnan;
|
|||||||
|
|
||||||
#include <CL/cl_half.h>
|
#include <CL/cl_half.h>
|
||||||
#include "harness/conversions.h"
|
#include "harness/conversions.h"
|
||||||
|
#include "harness/mathHelpers.h"
|
||||||
#include "harness/typeWrappers.h"
|
#include "harness/typeWrappers.h"
|
||||||
|
|
||||||
extern cl_half_rounding_mode halfRoundingMode;
|
extern cl_half_rounding_mode halfRoundingMode;
|
||||||
@@ -102,16 +102,6 @@ const char * kernel_explicit_s2v_set[NUM_VEC_TYPES][NUM_VEC_TYPES][5] = {
|
|||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
bool IsHalfNaN(cl_half v)
|
|
||||||
{
|
|
||||||
// Extract FP16 exponent and mantissa
|
|
||||||
uint16_t h_exp = (((cl_half)v) >> (CL_HALF_MANT_DIG - 1)) & 0x1F;
|
|
||||||
uint16_t h_mant = ((cl_half)v) & 0x3FF;
|
|
||||||
|
|
||||||
// NaN test
|
|
||||||
return (h_exp == 0x1F && h_mant != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_explicit_s2v_function(cl_context context,
|
static int test_explicit_s2v_function(cl_context context,
|
||||||
cl_command_queue queue, cl_kernel kernel,
|
cl_command_queue queue, cl_kernel kernel,
|
||||||
ExplicitType srcType, unsigned int count,
|
ExplicitType srcType, unsigned int count,
|
||||||
@@ -183,19 +173,20 @@ static int test_explicit_s2v_function(cl_context context,
|
|||||||
{
|
{
|
||||||
bool isSrcNaN =
|
bool isSrcNaN =
|
||||||
(((srcType == kHalf)
|
(((srcType == kHalf)
|
||||||
&& IsHalfNaN(*reinterpret_cast<cl_half *>(inPtr)))
|
&& isnan_fp(*reinterpret_cast<cl_half *>(inPtr)))
|
||||||
|| ((srcType == kFloat)
|
|| ((srcType == kFloat)
|
||||||
&& isnan(*reinterpret_cast<cl_float *>(inPtr)))
|
&& isnan_fp(*reinterpret_cast<cl_float *>(inPtr)))
|
||||||
|| ((srcType == kDouble)
|
|| ((srcType == kDouble)
|
||||||
&& isnan(*reinterpret_cast<cl_double *>(inPtr))));
|
&& isnan_fp(*reinterpret_cast<cl_double *>(inPtr))));
|
||||||
bool isDestNaN = (((destType == kHalf)
|
bool isDestNaN =
|
||||||
&& IsHalfNaN(*reinterpret_cast<cl_half *>(
|
(((destType == kHalf)
|
||||||
|
&& isnan_fp(*reinterpret_cast<cl_half *>(
|
||||||
outPtr + destTypeSize * s)))
|
outPtr + destTypeSize * s)))
|
||||||
|| ((destType == kFloat)
|
|| ((destType == kFloat)
|
||||||
&& isnan(*reinterpret_cast<cl_float *>(
|
&& isnan_fp(*reinterpret_cast<cl_float *>(
|
||||||
outPtr + destTypeSize * s)))
|
outPtr + destTypeSize * s)))
|
||||||
|| ((destType == kDouble)
|
|| ((destType == kDouble)
|
||||||
&& isnan(*reinterpret_cast<cl_double *>(
|
&& isnan_fp(*reinterpret_cast<cl_double *>(
|
||||||
outPtr + destTypeSize * s))));
|
outPtr + destTypeSize * s))));
|
||||||
|
|
||||||
if (isSrcNaN && isDestNaN)
|
if (isSrcNaN && isDestNaN)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
#include "harness/compat.h"
|
#include "harness/compat.h"
|
||||||
|
#include "harness/mathHelpers.h"
|
||||||
#include "harness/rounding_mode.h"
|
#include "harness/rounding_mode.h"
|
||||||
#include "harness/stringHelpers.h"
|
#include "harness/stringHelpers.h"
|
||||||
|
|
||||||
@@ -57,16 +58,6 @@ template <typename T> double toDouble(T val)
|
|||||||
return 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)
|
cl_half half_plus(cl_half a, cl_half b)
|
||||||
{
|
{
|
||||||
return HFF(std::plus<float>()(HTF(a), HTF(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]);
|
T r = test.ref(inA[i], inB[i]);
|
||||||
bool both_nan = false;
|
bool both_nan = false;
|
||||||
|
|
||||||
if (std::is_same<T, cl_half>::value)
|
both_nan = isnan_fp(r) && isnan_fp(output[i]);
|
||||||
{
|
|
||||||
both_nan = isHalfNan(r) && isHalfNan(output[i]);
|
|
||||||
}
|
|
||||||
else if (std::is_floating_point<T>::value)
|
|
||||||
{
|
|
||||||
both_nan = std::isnan(r) && std::isnan(output[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If not both nan, check if the result is the same
|
// If not both nan, check if the result is the same
|
||||||
if (!both_nan && (r != output[i]))
|
if (!both_nan && (r != output[i]))
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
#include "harness/mathHelpers.h"
|
||||||
#include "harness/testHarness.h"
|
#include "harness/testHarness.h"
|
||||||
#include "harness/compat.h"
|
#include "harness/compat.h"
|
||||||
#include "harness/ThreadPool.h"
|
#include "harness/ThreadPool.h"
|
||||||
@@ -955,24 +956,6 @@ void MapResultValuesComplete(const std::unique_ptr<CalcRefValsBase> &info)
|
|||||||
// destroyed automatically soon after we exit.
|
// destroyed automatically soon after we exit.
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> static bool isnan_fp(const T &v)
|
|
||||||
{
|
|
||||||
if (std::is_same<T, cl_half>::value)
|
|
||||||
{
|
|
||||||
uint16_t h_exp = (((cl_half)v) >> (CL_HALF_MANT_DIG - 1)) & 0x1F;
|
|
||||||
uint16_t h_mant = ((cl_half)v) & 0x3FF;
|
|
||||||
return (h_exp == 0x1F && h_mant != 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if !defined(_WIN32)
|
|
||||||
return std::isnan(v);
|
|
||||||
#else
|
|
||||||
return _isnan(v);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename InType>
|
template <typename InType>
|
||||||
void ZeroNanToIntCases(cl_uint count, void *mapped, Type outType, void *input)
|
void ZeroNanToIntCases(cl_uint count, void *mapped, Type outType, void *input)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ int TestFunc_HalfI_Half_Half(const Func *f, MTdata d, bool relaxedMode)
|
|||||||
if (t[j] == q[j] && t2[j] == q2[j]) continue;
|
if (t[j] == q[j] && t2[j] == q2[j]) continue;
|
||||||
|
|
||||||
// Check for paired NaNs
|
// Check for paired NaNs
|
||||||
if (IsHalfNaN(t[j]) && IsHalfNaN(q[j]) && t2[j] == q2[j])
|
if (isnan_fp(t[j]) && isnan_fp(q[j]) && t2[j] == q2[j])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
cl_half test = ((cl_half *)q)[j];
|
cl_half test = ((cl_half *)q)[j];
|
||||||
@@ -282,7 +282,7 @@ int TestFunc_HalfI_Half_Half(const Func *f, MTdata d, bool relaxedMode)
|
|||||||
// then the standard either neglects to say what is returned
|
// then the standard either neglects to say what is returned
|
||||||
// in iptr or leaves it undefined or implementation defined.
|
// in iptr or leaves it undefined or implementation defined.
|
||||||
int iptrUndefined = IsHalfInfinity(p[j]) || (HTF(p2[j]) == 0.0f)
|
int iptrUndefined = IsHalfInfinity(p[j]) || (HTF(p2[j]) == 0.0f)
|
||||||
|| IsHalfNaN(p2[j]) || IsHalfNaN(p[j]);
|
|| isnan_fp(p2[j]) || isnan_fp(p[j]);
|
||||||
if (iptrUndefined) iErr = 0;
|
if (iptrUndefined) iErr = 0;
|
||||||
|
|
||||||
int fail = !(fabsf(err) <= half_ulps && iErr == 0);
|
int fail = !(fabsf(err) <= half_ulps && iErr == 0);
|
||||||
|
|||||||
@@ -274,10 +274,10 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode)
|
|||||||
if (skipNanInf)
|
if (skipNanInf)
|
||||||
{
|
{
|
||||||
if (overflow[j] || IsHalfInfinity(correct)
|
if (overflow[j] || IsHalfInfinity(correct)
|
||||||
|| IsHalfNaN(correct) || IsHalfInfinity(hp0[j])
|
|| isnan_fp(correct) || IsHalfInfinity(hp0[j])
|
||||||
|| IsHalfNaN(hp0[j]) || IsHalfInfinity(hp1[j])
|
|| isnan_fp(hp0[j]) || IsHalfInfinity(hp1[j])
|
||||||
|| IsHalfNaN(hp1[j]) || IsHalfInfinity(hp2[j])
|
|| isnan_fp(hp1[j]) || IsHalfInfinity(hp2[j])
|
||||||
|| IsHalfNaN(hp2[j]))
|
|| isnan_fp(hp2[j]))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,9 +318,9 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode)
|
|||||||
// Note: no double rounding here. Reference
|
// Note: no double rounding here. Reference
|
||||||
// functions calculate in single precision.
|
// functions calculate in single precision.
|
||||||
if (IsHalfInfinity(correct2)
|
if (IsHalfInfinity(correct2)
|
||||||
|| IsHalfNaN(correct2)
|
|| isnan_fp(correct2)
|
||||||
|| IsHalfInfinity(correct3)
|
|| IsHalfInfinity(correct3)
|
||||||
|| IsHalfNaN(correct3))
|
|| isnan_fp(correct3))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,13 +381,13 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode)
|
|||||||
// Note: no double rounding here. Reference
|
// Note: no double rounding here. Reference
|
||||||
// functions calculate in single precision.
|
// functions calculate in single precision.
|
||||||
if (IsHalfInfinity(correct2)
|
if (IsHalfInfinity(correct2)
|
||||||
|| IsHalfNaN(correct2)
|
|| isnan_fp(correct2)
|
||||||
|| IsHalfInfinity(correct3)
|
|| IsHalfInfinity(correct3)
|
||||||
|| IsHalfNaN(correct3)
|
|| isnan_fp(correct3)
|
||||||
|| IsHalfInfinity(correct4)
|
|| IsHalfInfinity(correct4)
|
||||||
|| IsHalfNaN(correct4)
|
|| isnan_fp(correct4)
|
||||||
|| IsHalfInfinity(correct5)
|
|| IsHalfInfinity(correct5)
|
||||||
|| IsHalfNaN(correct5))
|
|| isnan_fp(correct5))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,13 +474,13 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode)
|
|||||||
// Note: no double rounding here. Reference
|
// Note: no double rounding here. Reference
|
||||||
// functions calculate in single precision.
|
// functions calculate in single precision.
|
||||||
if (IsHalfInfinity(correct2)
|
if (IsHalfInfinity(correct2)
|
||||||
|| IsHalfNaN(correct2)
|
|| isnan_fp(correct2)
|
||||||
|| IsHalfInfinity(correct3)
|
|| IsHalfInfinity(correct3)
|
||||||
|| IsHalfNaN(correct3)
|
|| isnan_fp(correct3)
|
||||||
|| IsHalfInfinity(correct4)
|
|| IsHalfInfinity(correct4)
|
||||||
|| IsHalfNaN(correct4)
|
|| isnan_fp(correct4)
|
||||||
|| IsHalfInfinity(correct5)
|
|| IsHalfInfinity(correct5)
|
||||||
|| IsHalfNaN(correct5))
|
|| isnan_fp(correct5))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -551,9 +551,9 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode)
|
|||||||
// Note: no double rounding here. Reference
|
// Note: no double rounding here. Reference
|
||||||
// functions calculate in single precision.
|
// functions calculate in single precision.
|
||||||
if (IsHalfInfinity(correct2)
|
if (IsHalfInfinity(correct2)
|
||||||
|| IsHalfNaN(correct2)
|
|| isnan_fp(correct2)
|
||||||
|| IsHalfInfinity(correct3)
|
|| IsHalfInfinity(correct3)
|
||||||
|| IsHalfNaN(correct3))
|
|| isnan_fp(correct3))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -613,13 +613,13 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode)
|
|||||||
// Note: no double rounding here. Reference
|
// Note: no double rounding here. Reference
|
||||||
// functions calculate in single precision.
|
// functions calculate in single precision.
|
||||||
if (IsHalfInfinity(correct2)
|
if (IsHalfInfinity(correct2)
|
||||||
|| IsHalfNaN(correct2)
|
|| isnan_fp(correct2)
|
||||||
|| IsHalfInfinity(correct3)
|
|| IsHalfInfinity(correct3)
|
||||||
|| IsHalfNaN(correct3)
|
|| isnan_fp(correct3)
|
||||||
|| IsHalfInfinity(correct4)
|
|| IsHalfInfinity(correct4)
|
||||||
|| IsHalfNaN(correct4)
|
|| isnan_fp(correct4)
|
||||||
|| IsHalfInfinity(correct5)
|
|| IsHalfInfinity(correct5)
|
||||||
|| IsHalfNaN(correct5))
|
|| isnan_fp(correct5))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -689,9 +689,9 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode)
|
|||||||
// Note: no double rounding here. Reference
|
// Note: no double rounding here. Reference
|
||||||
// functions calculate in single precision.
|
// functions calculate in single precision.
|
||||||
if (IsHalfInfinity(correct2)
|
if (IsHalfInfinity(correct2)
|
||||||
|| IsHalfNaN(correct2)
|
|| isnan_fp(correct2)
|
||||||
|| IsHalfInfinity(correct3)
|
|| IsHalfInfinity(correct3)
|
||||||
|| IsHalfNaN(correct3))
|
|| isnan_fp(correct3))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -249,9 +249,9 @@ int TestFunc_Half2_Half(const Func *f, MTdata d, bool relaxedMode)
|
|||||||
if (skipNanInf && overflow[j]) continue;
|
if (skipNanInf && overflow[j]) continue;
|
||||||
// Note: no double rounding here. Reference functions
|
// Note: no double rounding here. Reference functions
|
||||||
// calculate in single precision.
|
// calculate in single precision.
|
||||||
if (IsHalfInfinity(correct1) || IsHalfNaN(correct1)
|
if (IsHalfInfinity(correct1) || isnan_fp(correct1)
|
||||||
|| IsHalfInfinity(correct2) || IsHalfNaN(correct2)
|
|| IsHalfInfinity(correct2) || isnan_fp(correct2)
|
||||||
|| IsHalfInfinity(pIn[j]) || IsHalfNaN(pIn[j]))
|
|| IsHalfInfinity(pIn[j]) || isnan_fp(pIn[j]))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,13 +320,13 @@ int TestFunc_Half2_Half(const Func *f, MTdata d, bool relaxedMode)
|
|||||||
// Note: no double rounding here. Reference
|
// Note: no double rounding here. Reference
|
||||||
// functions calculate in single precision.
|
// functions calculate in single precision.
|
||||||
if (IsHalfInfinity(correctp)
|
if (IsHalfInfinity(correctp)
|
||||||
|| IsHalfNaN(correctp)
|
|| isnan_fp(correctp)
|
||||||
|| IsHalfInfinity(correctn)
|
|| IsHalfInfinity(correctn)
|
||||||
|| IsHalfNaN(correctn)
|
|| isnan_fp(correctn)
|
||||||
|| IsHalfInfinity(correct2p)
|
|| IsHalfInfinity(correct2p)
|
||||||
|| IsHalfNaN(correct2p)
|
|| isnan_fp(correct2p)
|
||||||
|| IsHalfInfinity(correct2n)
|
|| IsHalfInfinity(correct2n)
|
||||||
|| IsHalfNaN(correct2n))
|
|| isnan_fp(correct2n))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "harness/compat.h"
|
#include "harness/compat.h"
|
||||||
#include "harness/rounding_mode.h"
|
#include "harness/rounding_mode.h"
|
||||||
#include "harness/fpcontrol.h"
|
#include "harness/fpcontrol.h"
|
||||||
|
#include "harness/mathHelpers.h"
|
||||||
#include "harness/testHarness.h"
|
#include "harness/testHarness.h"
|
||||||
#include "harness/ThreadPool.h"
|
#include "harness/ThreadPool.h"
|
||||||
#include "harness/conversions.h"
|
#include "harness/conversions.h"
|
||||||
@@ -172,16 +173,6 @@ inline int IsFloatNaN(double x)
|
|||||||
return ((u.u & 0x7fffffffU) > 0x7F800000U);
|
return ((u.u & 0x7fffffffU) > 0x7F800000U);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool IsHalfNaN(const cl_half v)
|
|
||||||
{
|
|
||||||
// Extract FP16 exponent and mantissa
|
|
||||||
uint16_t h_exp = (((cl_half)v) >> (CL_HALF_MANT_DIG - 1)) & 0x1F;
|
|
||||||
uint16_t h_mant = ((cl_half)v) & 0x3FF;
|
|
||||||
|
|
||||||
// NaN test
|
|
||||||
return (h_exp == 0x1F && h_mant != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool IsHalfInfinity(const cl_half v)
|
inline bool IsHalfInfinity(const cl_half v)
|
||||||
{
|
{
|
||||||
// Extract FP16 exponent and mantissa
|
// Extract FP16 exponent and mantissa
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "harness/mathHelpers.h"
|
||||||
#include "harness/stringHelpers.h"
|
#include "harness/stringHelpers.h"
|
||||||
|
|
||||||
#include <CL/cl_half.h>
|
#include <CL/cl_half.h>
|
||||||
@@ -368,9 +369,8 @@ int RelationalsFPTest::test_equiv_kernel(unsigned int vecSize,
|
|||||||
{
|
{
|
||||||
if (gInfNanSupport == 0)
|
if (gInfNanSupport == 0)
|
||||||
{
|
{
|
||||||
float a = inDataA[i * vecSize + j];
|
if (isnan_fp(inDataA[i * vecSize + j])
|
||||||
float b = inDataB[i * vecSize + j];
|
|| isnan_fp(inDataB[i * vecSize + j]))
|
||||||
if (isnan(a) || isnan(b))
|
|
||||||
fail = 0;
|
fail = 0;
|
||||||
else
|
else
|
||||||
fail = 1;
|
fail = 1;
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
#include "harness/errorHelpers.h"
|
#include "harness/errorHelpers.h"
|
||||||
|
#include "harness/mathHelpers.h"
|
||||||
|
#include "harness/testHarness.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
@@ -834,9 +836,9 @@ size_t check_half(const void *const test, const void *const correct,
|
|||||||
// Allow nans to be binary different
|
// Allow nans to be binary different
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
float fcorrect = cl_half_to_float(c[i]);
|
if ((t[i] != c[i])
|
||||||
float ftest = cl_half_to_float(t[i]);
|
&& !(isnan_fp(cl_half_to_float(c[i]))
|
||||||
if ((t[i] != c[i]) && !(isnan(fcorrect) && isnan(ftest)))
|
&& isnan_fp(cl_half_to_float(t[i]))))
|
||||||
{
|
{
|
||||||
log_error("\n(check_half) Error for vector size %zu found at "
|
log_error("\n(check_half) Error for vector size %zu found at "
|
||||||
"0x%8.8zx (of 0x%8.8zx): "
|
"0x%8.8zx (of 0x%8.8zx): "
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#define _testBase_h
|
#define _testBase_h
|
||||||
|
|
||||||
#include "harness/compat.h"
|
#include "harness/compat.h"
|
||||||
|
#include "harness/mathHelpers.h"
|
||||||
#include "harness/rounding_mode.h"
|
#include "harness/rounding_mode.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ static inline
|
|||||||
f = cl_half_to_float(cl_half_from_float(f, half_rounding));
|
f = cl_half_to_float(cl_half_from_float(f, half_rounding));
|
||||||
|
|
||||||
To val = static_cast<To>(std::min<float>(std::max<float>(f, loVal), hiVal));
|
To val = static_cast<To>(std::min<float>(std::max<float>(f, loVal), hiVal));
|
||||||
if (isnan(cl_half_to_float(rhs)))
|
if (isnan_fp(rhs))
|
||||||
{
|
{
|
||||||
val = 0;
|
val = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user