Printf fixes for reference results #673 #675 (#680)

* Moved float tests that expect limits into their own sub-test.

These are harder to test generically on the CPU so have them be their own test which will retain hard-coded reference results.

* Remove unused variable.

* Switched reference result type from (char**) to (vector::const char*)

* printf: generate reference results where possible #673 #675

The reference results had two issues:
- They did not take into account the rounding mode of the device.
- Scientific notation results did not have trailing zero's, meaning that the exponent could be a single digit, despite the requirement being at least two digits.

This change introduces runtime generated reference results for types with numerical representations (float, int, hex, etc) where a direct mapping to standard C99 (sn)printf is possible to execute on the CPU.

* Trim leading zeroes from the exponent when verifying result #675.

There is no limit on how many leading zeros may be in the exponent, so strip them all.

* Switched to using get_default_rounding_mode.
This commit is contained in:
Jeremy Kemp
2020-04-15 14:30:29 +01:00
committed by GitHub
parent 349da6e6fb
commit ce39ffdda7
3 changed files with 247 additions and 200 deletions

View File

@@ -677,17 +677,19 @@ int test_float_17(cl_device_id deviceID, cl_context context, cl_command_queue qu
{
return doTest(gQueue, gContext, TYPE_FLOAT, 17, deviceID);
}
int test_float_18(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
int test_float_limits_0(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
{
return doTest(gQueue, gContext, TYPE_FLOAT, 18, deviceID);
return doTest(gQueue, gContext, TYPE_FLOAT_LIMITS, 0, deviceID);
}
int test_float_19(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
int test_float_limits_1(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
{
return doTest(gQueue, gContext, TYPE_FLOAT, 19, deviceID);
return doTest(gQueue, gContext, TYPE_FLOAT_LIMITS, 1, deviceID);
}
int test_float_20(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
int test_float_limits_2(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
{
return doTest(gQueue, gContext, TYPE_FLOAT, 20, deviceID);
return doTest(gQueue, gContext, TYPE_FLOAT_LIMITS, 2, deviceID);
}
@@ -841,9 +843,10 @@ test_definition test_list[] = {
ADD_TEST( float_15 ),
ADD_TEST( float_16 ),
ADD_TEST( float_17 ),
ADD_TEST( float_18 ),
ADD_TEST( float_19 ),
ADD_TEST( float_20 ),
ADD_TEST( float_limits_0 ),
ADD_TEST( float_limits_1 ),
ADD_TEST( float_limits_2 ),
ADD_TEST( octal_0 ),
ADD_TEST( octal_1 ),
@@ -1035,5 +1038,8 @@ test_status InitCL( cl_device_id device )
releaseOutputStream(gFd);
// Generate reference results
generateRef(device);
return TEST_PASS;
}