KhronosGroup / KhronosGroup/OpenCL-Docs
Clarify precision dot/cross absolute error expression is calculated with
- Dominant language
- Python
- Stars
- 420
- Forks
- 131
- Avg merge
- 5d 13h
- Merged PRs (30d)
- 11
Description
The precision of the `cross` & `dot` math builtins has an absolute error tolerance that is defined by an expression. For example:
Single precision `cross`
```quote
absolute error tolerance of 'max * max * (3 * FLT_EPSILON)' per vector component, where max is the maximum input operand magnitude
```
Single precision `dot`
```
absolute error tolerance of 'max * max * (2n - 1) * FLT_EPSILON', for vector width n and maximum input operand magnitude max across all vector components
```
However, the precision to which the expressions are calculated with is not specified. This has come up in the cl_khr_fp16 tests for these builtins - https://github.com/KhronosGroup/OpenCL-CTS/pull/1633#discussion_r1132244096 - where the two interpretations are:
1. The expression is calculated in the same precision as is being used by the builtin, more likely to overflow/underflow.
2. The expression is calculated to infinite precision (how ULP is specified), which in practice would just be double as per the other builtin verifications. This approach makes the builtins more challenging to implement, but arguably makes them more useful to users.
Based on how the CTS currently tests 32-bit float, it looks like approach 1 is what is currently assumed for conformance as a float is the type used to calculate the error expression.
* cross - https://github.com/KhronosGroup/OpenCL-CTS/blob/main/test_conformance/geometrics/test_geometrics.cpp#L141-L148
* dot - https://github.com/KhronosGroup/OpenCL-CTS/blob/main/test_conformance/geometrics/test_geometrics.cpp#L442-L443
Contributor guide
Research direction
Start with the linked discussion and the cross and dot checks in test_conformance/geometrics/test_geometrics.cpp, especially the cited lines. Determine which precision the conformance tests assume, then update the relevant OpenCL documentation so the expression’s evaluation precision and expected behavior are unambiguous.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100