KhronosGroup / KhronosGroup/OpenCL-Docs
Incorrect image conversion rules in OpenCL 1.2 and C language specs
- Dominant language
- Python
- Stars
- 420
- Forks
- 131
- Avg merge
- 5d 13h
- Merged PRs (30d)
- 11
Description
Section 8.3 of the OpenCL Specification (1.2) and OpenCL C 2.0 Specification incorrectly specifies some of the conversion rules. Most of the issues are corrected in the OpenCL™ SPIR-V Environment Specification and The OpenCL™ C++ 1.0 Specification.
1. Conversion algorithms are overly prescriptive, e.g. (in 8.3.1.1 of OCL 1.2 ) _normalized float value = (float)c / 255.0f_ dictates the division be done in float math, while not specifying the rounding mode. Section 9.4 of the SPIR-V spec relaxes this to _normalized_float_value(x)=round_to_float(x/255)_
2. Rounding rules for conversions from float to normalized integers are wrong, e.g. (in 8.3.1.2 of OCL 1.2) in the rule _fabs(fpreferred – fapprox) must be <= 0.6_, _fpreferred_ and _fapprox_ are defined as integer values, so the 0.6 limit makes no sense. The SPIR-V spec corrects this to compare with the exact value rather than the rounded one.
Minor issues remaining in the SPIR-V and OpenCL++ specs:
1. In SPIR-V 9.4.1, Converting Floating-point Values to Normalized Integer Channel Data Types, the sentence beginning _The conversions from half precision floating-point values to normalized integer values_ should not refer to half precision.
2. In SPIR-V 9.4.1, the sentence _The precision of the above conversions is <= 1.5 ulp except for the following cases._ should use the word accuracy, not precision.
Contributor guide
Assessment
This issue has not been assessed yet.