[LLVMdev] [PATCH] OpenCL half support

Chris Lattner clattner at apple.com
Mon Mar 21 11:26:14 PDT 2011


On Mar 21, 2011, at 3:44 AM, Anton Lokhmotov wrote:

>> Adding half float to LLVM IR is *only* reasonable if you have hardware
>> that supports half float, or if you want to add softfloat operations
>> for these.
> Yes, our graphics hardware natively supports some fp16 arithmetic
> operations.

Ok.

>> Just like C compilers need to know sizeof(long), sizeof(void*) and 
>> many many other target specific details, an OpenCL compiler would need 
>> to know whether to generate fp16 or not.
> Yes, it's just another example of LLVM-IR non-portability.  Basically, any
> fp16 arithmetic code can be generated only if the cl_khr_fp16 extension is
> supported (otherwise, the frontend would reject even declaring fp16
> variables, leave alone performing arithmetic on them).

If the backend generates softfloat (or some other expansion) for fp16, then a native fp16 type would be perfectly portable.  This is just not the "portability" that you're looking for (which is not behavior preserving, so it isn't portability by its standard definition).

-Chris



More information about the llvm-dev mailing list