KhronosGroup / KhronosGroup/OpenCL-Docs
cl_khr_fp16 extension consistency issues with core C spec
@bashbaug is already working on this.
Since Jan 15, 2024.
- Dominant language
- Python
- Stars
- 421
- Forks
- 132
- Avg merge
- 5d 13h
- Merged PRs (30d)
- 11
Description
Some issues that have come up while integrating language from the extension to the core C spec for #950. These mostly arise from the situation that there is a considerable amount of cl_khr_fp16-related functionality in the C spec already, and many footnotes saying "only if cl_khr_fp16 is supported", but by no means all of the extension language. In particular, the functions operating on 'half' data types are not included, nor are compile-time constants. So it is unclear if the extension was already considered to be included in the C spec or not, but fully including it as I've been doing with the other C language extensions raises a bunch of questions:
-
The extension spec says "The OpenCL compiler accepts an h and H suffix on floating-point literals, indicating the literal is typed as a half" while the C spec says "The
halfdata type can only be used to declare a pointer to a buffer that contains half values", which seems like a major functionality difference. -
The "Explicit Conversions" section excludes the 'half' data type while the extension says the conversion functions are extended to take 'half' and 'halfn'. Note this is unlike the implicit conversions / explicit casts sections, which exclude 'half' unless cl_khr_fp16 is supported, and I assume should be treated similarly.
-
The Math Functions table for fract() refers to fmin(x - floor(x), 0x1.fffffep-1f), while the table in the extension refers to fmin(x - floor(x), 0x1.ffcp-1f). Why are the constants different? If the extension constant is intended to be a half-precision version of the fract() in the C spec, (a) shouldn't it have a 'h' suffix and (b) why isn't there also a double-precision constant version for the versions of fract() taking doubles?
-
The nextafter() function in the C spec is defined to "Compute the next representable floating-point value following x in the direction of y" but accepts gentype arguments - should it not be "next representable FP value of the precision of its arguments" or similar?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.