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

@@ -117,6 +117,11 @@ static inline int IsDoubleSubnormal( double x )
#endif
}
static inline int IsHalfSubnormal( cl_half x )
{
return ( ( x & 0x7fffU ) - 1U ) < 0x03ffU;
}
#if defined(__cplusplus)
}
#endif

View File

@@ -640,7 +640,14 @@ protected:
extern int DetectFloatToHalfRoundingMode( cl_command_queue ); // Returns CL_SUCCESS on success
int inline is_half_nan( cl_ushort half ){ return (half & 0x7fff) > 0x7c00; }
// sign bit: don't care, exponent: maximum value, significand: non-zero
static int inline is_half_nan( cl_ushort half ){ return ( half & 0x7fff ) > 0x7c00; }
// sign bit: don't care, exponent: zero, significand: non-zero
static int inline is_half_denorm( cl_ushort half ){ return IsHalfSubnormal( half ); }
// sign bit: don't care, exponent: zero, significand: zero
static int inline is_half_zero( cl_ushort half ){ return ( half & 0x7fff ) == 0; }
cl_ushort convert_float_to_half( cl_float f );
cl_float convert_half_to_float( cl_ushort h );