compute icon indicating copy to clipboard operation
compute copied to clipboard

Too much precision expected of OpenCL `length()` function

Open etomzak opened this issue 6 years ago • 0 comments

The test_closure::triangle_area and test_extrema::max_vector_length (and possibly others) expect too much precision of the OpenCL built-in length() function when calculating the lengths of vectors.

The precision of length() is defined in ULP as <= 3 + 0.5 * ((0.5 * n) + 0.5 * (n - 1)) where n is the number of vector elements. [source] For the float4s used in triangle_area, this works out to 4.75 ULP. Given the expected result is 1.0f, the actual answer should be approximately 1.0 +/- 5.7e-07 [1]. The precision expected by the test is 1.0e-6 percent, or 1.0e-8.

That is, the triangle_area test can fail even on a conformant OpenCL implementation. The max_vector_length test has a similar problem.

[1] This doesn't take into account the division by 2 in the test, which introduces further error.

etomzak avatar Oct 15 '19 14:10 etomzak