KhronosGroup / KhronosGroup/OpenCL-Docs
Unified OpenCL C: Unsafe Math ULP
- Dominant language
- Python
- Stars
- 420
- Forks
- 131
- Avg merge
- 5d 13h
- Merged PRs (30d)
- 11
Description
When unifying the OpenCL C spec "Table 44. ULP values for single precision built-in math functions with unsafe math optimizations in the full and embedded profiles" will need to be marked as only applying to OpenCL C 2.0+.
However, does that mean that a device has the option to ignore this table when a program is compiled with `-cl-std=CL1.2` or indeed without a version and thus using the highest supported 1.x? Arguably that was already the case in OpenCL 2.0-2.2 based on the specifications, though I doubt that any implementation was implemented that way because the CTS does not seem to set `-cl-std=CL2.0` when checking the ULP of builtin functions under `-cl-unsafe-math-optimizations`.
Related, but with a different outcome the unified SPIR-V environment specification's "Table 7. ULP Values for Single Precision Math Instructions with -cl-unsafe-math-optimizations" applies to all OpenCL versions. E.g. an OpenCL 1.2 implementation that implements the `cl_khr_il_progam` extension would need to match the specified ULP under `-cl-unsafe-math-optimizations`. This makes sense if the ULPs are a property of the source language.
In practice I think that implementers will use the 2.0+/SPIR-V unsafe math ULPs for OpenCL C 1.x whether required to or not, because they'll be required to support it for OpenCL C 3.0 and maintaining more versions of the builtin functions doesn't provide much value as being arbitrarily inaccurate is not helpful to users.
Tasks:
1. When unifying OpenCL C note that the unsafe math builtin function ULP tables only apply to OpenCL C 2.0+.
2. Determine whether compiling a program with `-cl-std=CL1.2 -cl-unsafe-math-optimizations` on an OpenCL 2.0+ device is expected to meet the 2.0+ specified ULPs.
Contributor guide
Assessment
This issue has not been assessed yet.