mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-23 23:49:02 +00:00
Fp16 math bruteforce staging (#1863)
* Enable fp16 in math bruteforce * Added modernization of remaining half tests for consistency (issue #142, bruteforce) * Added kernel types related corrections * Added more fixes and general cleanup * Corrected ULP values for half tests (issue #142, bruteforce) * Corrected presubmit check for clang format * Added support for ternary, unary_two_result and unary_two_result_i tests for cl_half (issue #142, bruteforce) * Added missing condition due to vendor's review * code format correction * Added check for lack of support for denormals in binary_half scenario * Corrected procedure to compute nextafter cl_half for flush-to-zero mode * Added correction for external check of reference value for nextafter test * Added correction due to code review request * Changed quantity of tests performed for half in unary and macro_unary procedures from basic * Added corrections related to code review: -added binary_operator_half.cpp and binary_two_results_i_half.cpp -address sanitizer errors fixed -extending list of special half values -removed unnecessary relaxed math references in half tests -corrected conditions to verify ulp narrowing of computation results -several refactoring and cosmetics corrections * Print format correction due to failed CI check * Corrected bug found in code review (fp16 bruteforce) * Corrections related to code review (cl_khr_fp16 support according to #142) -gHostFill missing support added -special half values array extended -cosmetics and unifying * clang format applied * consistency correction * more consistency corrections for cl_fp16_khr supported tests * Corrections related to code review (bureforce #142) * Correction for i_unary_half test capacity * Corrections related to capacity of cl_khr_fp16 tests in bruteforce (#142) --------- Co-authored-by: Wawiorko, Grzegorz <grzegorz.wawiorko@intel.com>
This commit is contained in:
@@ -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,20 @@ 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 HTF(num) cl_half_to_float(num)
|
||||
|
||||
#define LOWER_IS_BETTER 0
|
||||
#define HIGHER_IS_BETTER 1
|
||||
@@ -115,6 +126,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 +174,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