mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-25 00:09:02 +00:00
Add fp16 testing to conversions and bruteforce (#1975)
Merge the `fp16-staging` branch into `main`, adding fp16 (`half`) testing to the conversions and math bruteforce tests. --------- Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com> Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com> Signed-off-by: Guo, Yilong <yilong.guo@intel.com> Signed-off-by: John Kesapides <john.kesapides@arm.com> Co-authored-by: Marcin Hajder <marcin.hajder@gmail.com> Co-authored-by: Ewan Crawford <ewan@codeplay.com> Co-authored-by: Wawiorko, Grzegorz <grzegorz.wawiorko@intel.com> Co-authored-by: Sreelakshmi Haridas Maruthur <sharidas@quicinc.com> Co-authored-by: Harald van Dijk <harald@gigawatt.nl> Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com> Co-authored-by: Haonan Yang <haonan.yang@intel.com> Co-authored-by: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Co-authored-by: niranjanjoshi121 <43807392+niranjanjoshi121@users.noreply.github.com> Co-authored-by: Wenwan Xing <wenwan.xing@intel.com> Co-authored-by: Yilong Guo <yilong.guo@intel.com> Co-authored-by: Romaric Jodin <89833130+rjodinchr@users.noreply.github.com> Co-authored-by: joshqti <127994991+joshqti@users.noreply.github.com> Co-authored-by: Pekka Jääskeläinen <pekka.jaaskelainen@tuni.fi> Co-authored-by: imilenkovic00 <155085410+imilenkovic00@users.noreply.github.com> Co-authored-by: John Kesapides <46718829+JohnKesapidesARM@users.noreply.github.com> Co-authored-by: Aharon Abramson <aharon.abramson@mobileye.com>
This commit is contained in:
committed by
GitHub
parent
b3c89ebde0
commit
b6941b6c61
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
// Copyright (c) 2017-2024 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.
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "harness/testHarness.h"
|
||||
#include "harness/ThreadPool.h"
|
||||
#include "harness/conversions.h"
|
||||
#include "CL/cl_half.h"
|
||||
|
||||
#define BUFFER_SIZE (1024 * 1024 * 2)
|
||||
#define EMBEDDED_REDUCTION_FACTOR (64)
|
||||
@@ -61,10 +62,21 @@ extern int gFastRelaxedDerived;
|
||||
extern int gWimpyMode;
|
||||
extern int gHostFill;
|
||||
extern int gIsInRTZMode;
|
||||
extern int gHasHalf;
|
||||
extern int gInfNanSupport;
|
||||
extern int gIsEmbedded;
|
||||
extern int gVerboseBruteForce;
|
||||
extern uint32_t gMaxVectorSizeIndex;
|
||||
extern uint32_t gMinVectorSizeIndex;
|
||||
extern cl_device_fp_config gFloatCapabilities;
|
||||
extern cl_device_fp_config gHalfCapabilities;
|
||||
extern RoundingMode gFloatToHalfRoundingMode;
|
||||
|
||||
extern cl_half_rounding_mode gHalfRoundingMode;
|
||||
|
||||
#define HFF(num) cl_half_from_float(num, gHalfRoundingMode)
|
||||
#define HFD(num) cl_half_from_double(num, gHalfRoundingMode)
|
||||
#define HTF(num) cl_half_to_float(num)
|
||||
|
||||
#define LOWER_IS_BETTER 0
|
||||
#define HIGHER_IS_BETTER 1
|
||||
@@ -115,6 +127,12 @@ inline int IsFloatResultSubnormal(double x, float ulps)
|
||||
return x < MAKE_HEX_DOUBLE(0x1.0p-126, 0x1, -126);
|
||||
}
|
||||
|
||||
inline int IsHalfResultSubnormal(float x, float ulps)
|
||||
{
|
||||
x = fabs(x) - MAKE_HEX_FLOAT(0x1.0p-24, 0x1, -24) * ulps;
|
||||
return x < MAKE_HEX_FLOAT(0x1.0p-14, 0x1, -14);
|
||||
}
|
||||
|
||||
inline int IsFloatResultSubnormalAbsError(double x, float abs_err)
|
||||
{
|
||||
x = x - abs_err;
|
||||
@@ -157,6 +175,26 @@ inline int IsFloatNaN(double x)
|
||||
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)
|
||||
{
|
||||
// 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;
|
||||
|
||||
// Inf test
|
||||
return (h_exp == 0x1F && h_mant == 0);
|
||||
}
|
||||
|
||||
cl_uint RoundUpToNextPowerOfTwo(cl_uint x);
|
||||
|
||||
// Windows (since long double got deprecated) sets the x87 to 53-bit precision
|
||||
|
||||
Reference in New Issue
Block a user