[LLVMdev] [PATCH] OpenCL half support

Chris Lattner clattner at apple.com
Fri Mar 18 22:59:24 PDT 2011


On Mar 18, 2011, at 1:47 PM, Dan Bailey wrote:

>> [Villmow, Micah] Chris, In OpenCL, the user has to explicitly state that they want to use fp16 and it is illegal to use the half data type for computation if it isn't natively supported. I think it would be useful to have fp16 in the IR for the reason that we support load/stores of the data type, but not operations on the data type. Right now we handle that by treating them like 16bit ints, but it would be nice to be able to represent them correctly.

My understanding is that OpenCL allows promoting to float (32-bit) types.   OpenCL doesn't (afaik) require support for fp16.

>>  
> Maybe worth pointing out that there are architectures that natively support 16bit floating point in llvm. PTX, the new backend of which has just been added to 2.9 can handle fp16 -> fp32 conversion in hardware. I agree we should have support for fp16 in the IR, it's fiddly trying to make do without this and gets used frequently in simulations and graphics in particular.

LLVM already fully supports fp16 <-> fp32 conversions.  If you want to add saturation support for these conversions, that is completely orthogonal to adding fp16 as a "native" llvm type:  Adding fp16 as a "native" LLVM IR type doesn't give you saturating conversions.

-Chris



More information about the llvm-dev mailing list