Re: [LLVMdev] [PATCH] OpenCL half support

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [LLVMdev] [PATCH] OpenCL half support

Chris Lattner

On Feb 23, 2011, at 10:01 AM, Anton Lokhmotov wrote:

> Please find attached Clang/LLVM patches for supporting 'half' - the
> half-precision floating-point type, which in particular is used in OpenCL C.
> Please review.
>
> Background and motivation.  Whilst the half type is defined by IEEE 754-2008
> as storage only (i.e. no arithmetic is supposed to be performed on values of
> this type), it's growing in importance in embedded systems.  The cl_khr_fp16
> extension of OpenCL lifts restrictions for declaring half variables and
> arrays, dereferencing half pointers, performing arithmetic and conversions,
> etc.  The latest version of the C++ ABI supports half as well.  Therefore,
> we believe half should become a fundamental type in LLVM. (After all, LLVM
> already supports x86_fp80, fp128 and ppc_fp128.)

Hi Anton,

Does the spec force evaluation to happen in half mode, or does it specify that there is a promotion to float (or some other type) an operation, then truncation back to half?

-Chris
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: [LLVMdev] [PATCH] OpenCL half support

Anton Lokhmotov
Hi Chris,

> Does the spec force evaluation to happen in half mode, or does it
> specify that there is a promotion to float (or some other type), an
> operation, then truncation back to half?

The last paragraph in section 9.6 says: "NOTE: Implementations may perform
floating-point operations on half scalar or vector data types by converting
the half values to single precision floating-point values and performing the
operation in single precision floating-point. In this case, the
implementation will use the half scalar or vector data type as a storage
only format."

That is, an implementation may perform operations on half scalar and vector
values either using half-precision operations (if supported natively) or
using single-precision operations (always supported natively).  In either
case, it's desirable to represent half operations in the IR, and let the
backend make the decision.

Cheers,
Anton.





       




_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] OpenCL half support

Anton Lokhmotov
In reply to this post by Chris Lattner
Chris Lattner wrote:
> I'm sorry I don't have the patch anymore.  Please resend.
Attached.  (Copying to cfe-dev, as the patch is dual Clang/LLVM.)

Anton Korobeynikov wrote:
> PS: my 2 cents: do not forget to handle the existing half fp <-> float
> conversion intrinsics.
We are not quite sure what to do with them.  Can anyone help?

Best wishes,
Anton.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

00004-half-llvm.patch (16K) Download Attachment
00004-half-clang.patch (32K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] OpenCL half support

Anton Lokhmotov
In reply to this post by Chris Lattner
Any comments at all?

Many thanks,
Anton.

> -----Original Message-----
> From: Anton Lokhmotov [mailto:[hidden email]]
> Sent: 22 March 2011 17:40
> To: [hidden email]
> Cc: [hidden email]
> Subject: RE: [PATCH] OpenCL half support
>
> Chris Lattner wrote:
> > I'm sorry I don't have the patch anymore.  Please resend.
> Attached.  (Copying to cfe-dev, as the patch is dual Clang/LLVM.)
>
> Anton Korobeynikov wrote:
> > PS: my 2 cents: do not forget to handle the existing half fp <->
> float
> > conversion intrinsics.
> We are not quite sure what to do with them.  Can anyone help?
>
> Best wishes,
> Anton.




_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev