[cfe-dev] [OpenCL] Representing OpenCL half type by _Float16 type

Liu, Yaxun (Sam) via cfe-dev cfe-dev at lists.llvm.org
Wed Oct 17 09:31:28 PDT 2018


Hi,

Clang supports two 16 bit floating point builtin types: __fp16 and _Float16. Their differences are here

https://clang.llvm.org/docs/LanguageExtensions.html#half-precision-floating-point

Currently clang supports OpenCL half type as __fp16, one significant disadvantage of which is that arithmetic operations are emitted as fp32 instead of fp16 instructions in LLVM IR. Another disadvantage is interoperability with C++ programs, which uses _Float16 mostly since it is an ISO standard whereas __fp16 is not.

OpenCL spec v 2.0 s 6.1.1.1 (https://www.khronos.org/registry/OpenCL/specs/opencl-2.0-openclc.pdf ) defines half type. There is no requirement that it has to be __fp16 or _Float16 type in clang. Actually, it seems both __fp16 and _Float16 can be used to represent OpenCL half type.

Considering the advantages of _Float16 type, I am wondering whether we should consider using _Float16 to represent OpenCL half type.

Any comments are welcome.

Thanks.

Yaxun (Sam) Liu
AMD


-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 15552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181017/58ec5f62/attachment-0001.bin>


More information about the cfe-dev mailing list