Adding FP16 math builtins
- Dominant language
- LLVM
- Stars
- 729
- Forks
- 110
- Avg merge
- 17h 51m
- Merged PRs (30d)
- 23
Description
This is a libclc issue but I think the discussion is also worth having here. I've been working on a couple of ways we could add fp16 implementations of the OpenCL math builtins to the tool:
* upcast implementations based on the existing `float` builtin implementations
* ported implementations from AMD's [rocm](https://github.com/RadeonOpenCompute/ROCm-Device-Libs/tree/amd-stg-open/ocml/src) libraries
The upcast implementations can largely be generated with a simple macro, with some additional logic needed for handling edge cases. I've made this work for a bunch of cases but it is a noticeably slow way to do things.
The rocm builtins also need edge case related tweaking to pass the new fp16 tests in the CTS (not merged yet, branch [here](https://github.com/KhronosGroup/OpenCL-CTS/pull/1433)) but they do seem quicker than the upcast approach (more testing to make sure this isn't just confirmation bias is something I'm still working on). The downside of them is that they are someone else's code. To my untrained eye the licensing situation seems fine: rocm is currently licensed under the same university of Illinois license that LLVM used to be licensed under, and libclc already has a bunch of AMD copyright lines in it so including them in the new builtins shouldn't be an issue... but yeah more due diligence and coordination will be needed to make sure a porting effort is 100% fine and legal.
I'm currently leaning towards the rocm approach, trading more work for better performance (that may change if my assumptions about how much faster it is are proven wrong); so I'm soliciting objections to moving forward with that, with the reassurance that there is another way to go about it if there are any major objections. I'd also be interested in any other possible solutions I could look into, like other places permissively licensed implementations might be found.
Contributor guide
Assessment
This issue has not been assessed yet.