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:
@@ -14,7 +14,6 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
#include <cmath>
|
||||
using std::isnan;
|
||||
#include "harness/compat.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -26,6 +25,7 @@ using std::isnan;
|
||||
|
||||
#include <CL/cl_half.h>
|
||||
#include "harness/conversions.h"
|
||||
#include "harness/mathHelpers.h"
|
||||
#include "harness/typeWrappers.h"
|
||||
|
||||
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
|
||||
|
||||
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,
|
||||
cl_command_queue queue, cl_kernel kernel,
|
||||
ExplicitType srcType, unsigned int count,
|
||||
@@ -183,20 +173,21 @@ static int test_explicit_s2v_function(cl_context context,
|
||||
{
|
||||
bool isSrcNaN =
|
||||
(((srcType == kHalf)
|
||||
&& IsHalfNaN(*reinterpret_cast<cl_half *>(inPtr)))
|
||||
&& isnan_fp(*reinterpret_cast<cl_half *>(inPtr)))
|
||||
|| ((srcType == kFloat)
|
||||
&& isnan(*reinterpret_cast<cl_float *>(inPtr)))
|
||||
&& isnan_fp(*reinterpret_cast<cl_float *>(inPtr)))
|
||||
|| ((srcType == kDouble)
|
||||
&& isnan(*reinterpret_cast<cl_double *>(inPtr))));
|
||||
bool isDestNaN = (((destType == kHalf)
|
||||
&& IsHalfNaN(*reinterpret_cast<cl_half *>(
|
||||
outPtr + destTypeSize * s)))
|
||||
|| ((destType == kFloat)
|
||||
&& isnan(*reinterpret_cast<cl_float *>(
|
||||
outPtr + destTypeSize * s)))
|
||||
|| ((destType == kDouble)
|
||||
&& isnan(*reinterpret_cast<cl_double *>(
|
||||
outPtr + destTypeSize * s))));
|
||||
&& isnan_fp(*reinterpret_cast<cl_double *>(inPtr))));
|
||||
bool isDestNaN =
|
||||
(((destType == kHalf)
|
||||
&& isnan_fp(*reinterpret_cast<cl_half *>(
|
||||
outPtr + destTypeSize * s)))
|
||||
|| ((destType == kFloat)
|
||||
&& isnan_fp(*reinterpret_cast<cl_float *>(
|
||||
outPtr + destTypeSize * s)))
|
||||
|| ((destType == kDouble)
|
||||
&& isnan_fp(*reinterpret_cast<cl_double *>(
|
||||
outPtr + destTypeSize * s))));
|
||||
|
||||
if (isSrcNaN && isDestNaN)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user