[cfe-dev] [OpenCL] Representing OpenCL half type by _Float16 type
Bader, Alexey via cfe-dev
cfe-dev at lists.llvm.org
Fri Oct 19 06:15:46 PDT 2018
I assume OpenCL half type mapped to __fp16 as OpenCL specification defines it as "A 16-bit floating-point conforming to the IEEE 754-2008 half precision storage format". This aligned with __fp16 description from clang documentation.
OpenCL cl_khr_fp16 extension enables arithmetic operations on 'half' data types and I think it's reasonable to map 'half' data type to _Float16 if cl_khr_fp16 is enabled.
Is it possible to map 'half' data type to _Float16 and keep the restrictions of OpenCL core specification?
From: Liu, Yaxun (Sam) [mailto:Yaxun.Liu at amd.com]
Sent: Wednesday, October 17, 2018 7:31 PM
To: 'anastasia.stulova at arm.com' <anastasia.stulova at arm.com>; Bader, Alexey <alexey.bader at intel.com>; Sumner, Brian <Brian.Sumner at amd.com>; cfe-dev (cfe-dev at lists.llvm.org) <cfe-dev at lists.llvm.org>
Subject: [OpenCL] Representing OpenCL half type by _Float16 type
Clang supports two 16 bit floating point builtin types: __fp16 and _Float16. Their differences are here
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 18.104.22.168 (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.
Yaxun (Sam) Liu
Joint Stock Company Intel A/O
Registered legal address: Krylatsky Hills Business Park,
17 Krylatskaya Str., Bldg 4, Moscow 121614,
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev