Allow CL_HALF_FLOAT denorm flushing for write tests (#452) (#453)

* Allow CL_HALF_FLOAT denorm flushing for write tests (#452)

* On mismatch, add relaxation when denormal half result is expected
* Refactor to use common validation function
* Clean up some diagnostics

* Fix review comments

- use cl_half
- remove extraneous casts
- replace literals with sizeof()

* Document rollover trick for IsHalfSubnormal
This commit is contained in:
Jim Lewis
2020-04-16 02:23:44 -07:00
committed by GitHub
parent 2fa8611862
commit f3a3ec2b47
9 changed files with 95 additions and 134 deletions

View File

@@ -114,7 +114,8 @@ static inline cl_ulong DoubleFromUInt( cl_uint bits )
static inline int IsHalfSubnormal( uint16_t x )
{
return ((x&0x7fffU)-1U) < 0x03ffU;
// this relies on interger overflow to exclude 0 as a subnormal
return ( ( x & 0x7fffU ) - 1U ) < 0x03ffU;
}
// prevent silent failures due to missing FLT_RADIX