mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 22:19: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:
@@ -4699,6 +4699,49 @@ double reference_nextafter(double xx, double yy)
|
||||
return a.f;
|
||||
}
|
||||
|
||||
cl_half reference_nanh(cl_ushort x)
|
||||
{
|
||||
cl_ushort u;
|
||||
cl_half h;
|
||||
u = x | 0x7e00U;
|
||||
memcpy(&h, &u, sizeof(cl_half));
|
||||
return h;
|
||||
}
|
||||
|
||||
float reference_nextafterh(float xx, float yy, bool allow_denorms)
|
||||
{
|
||||
cl_half tmp_a = cl_half_from_float(xx, CL_HALF_RTE);
|
||||
cl_half tmp_b = cl_half_from_float(yy, CL_HALF_RTE);
|
||||
float x = cl_half_to_float(tmp_a);
|
||||
float y = cl_half_to_float(tmp_b);
|
||||
|
||||
// take care of nans
|
||||
if (x != x) return x;
|
||||
|
||||
if (y != y) return y;
|
||||
|
||||
if (x == y) return y;
|
||||
|
||||
short a_h = cl_half_from_float(x, CL_HALF_RTE);
|
||||
short b_h = cl_half_from_float(y, CL_HALF_RTE);
|
||||
short oa_h = a_h;
|
||||
|
||||
if (a_h & 0x8000) a_h = 0x8000 - a_h;
|
||||
if (b_h & 0x8000) b_h = 0x8000 - b_h;
|
||||
|
||||
a_h += (a_h < b_h) ? 1 : -1;
|
||||
a_h = (a_h < 0) ? (cl_short)0x8000 - a_h : a_h;
|
||||
|
||||
if (!allow_denorms && IsHalfSubnormal(a_h))
|
||||
{
|
||||
if (cl_half_to_float(0x7fff & oa_h) < cl_half_to_float(0x7fff & a_h))
|
||||
a_h = (a_h & 0x8000) ? 0x8400 : 0x0400;
|
||||
else
|
||||
a_h = 0;
|
||||
}
|
||||
|
||||
return cl_half_to_float(a_h);
|
||||
}
|
||||
|
||||
long double reference_nextafterl(long double xx, long double yy)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user