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

@@ -1155,7 +1155,7 @@ bool validate_float_write_results( float *expected, float *actual, image_descrip
{
bool pass = true;
// Compare floats
if( memcmp( expected, actual, 4 * get_format_channel_count( imageInfo->format ) ) != 0 )
if( memcmp( expected, actual, sizeof( cl_float ) * get_format_channel_count( imageInfo->format ) ) != 0 )
{
// 8.3.3 Fix up cases where we have NaNs or flushed denorms; "all other values must be preserved"
for ( size_t j = 0; j < get_format_channel_count( imageInfo->format ); j++ )
@@ -1171,6 +1171,25 @@ bool validate_float_write_results( float *expected, float *actual, image_descrip
return pass;
}
bool validate_half_write_results( cl_half *expected, cl_half *actual, image_descriptor *imageInfo )
{
bool pass = true;
// Compare half floats
if (memcmp(expected, actual, sizeof( cl_half ) * get_format_channel_count(imageInfo->format)) != 0) {
// 8.3.2 Fix up cases where we have NaNs or generated half denormals
for ( size_t j = 0; j < get_format_channel_count( imageInfo->format ); j++ ) {
if ( is_half_nan( expected[j] ) && is_half_nan( actual[j] ) )
continue;
if ( is_half_denorm( expected[j] ) && is_half_zero( actual[j] ) )
continue;
pass = false;
break;
}
}
return pass;
}
int test_read_image_2D( cl_context context, cl_command_queue queue, cl_kernel kernel,
image_descriptor *imageInfo, image_sampler_data *imageSampler,
bool useFloatCoords, ExplicitType outputType, MTdata d )