Allow CL_FLOAT denorm flushing for write tests (#28) (#456)

* Require exact for match normals, instead of arbitrary .005 relative error
* Add relaxation to allow 0 when float denormal is expected
* Refactor to use common validation function
This commit is contained in:
Jim Lewis
2019-11-15 07:38:15 -06:00
committed by Kévin Petit
parent 88004077e3
commit 040321d8b9
7 changed files with 50 additions and 69 deletions

View File

@@ -1151,6 +1151,26 @@ int validate_image_2D_sRGB_results(void *imageValues, void *resultValues, double
return 0;
}
bool validate_float_write_results( float *expected, float *actual, image_descriptor *imageInfo )
{
bool pass = true;
// Compare floats
if( memcmp( expected, actual, 4 * 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++ )
{
if ( isnan( expected[j] ) && isnan( actual[j] ) )
continue;
if ( IsFloatSubnormal( expected[j] ) && actual[j] == 0.0f )
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 )