[PATCH] D100980: [OpenCL] Allow use of double type without extension pragma

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 26 03:02:28 PDT 2021


Anastasia added a comment.

In D100980#2712534 <https://reviews.llvm.org/D100980#2712534>, @azabaznov wrote:

>> We could of course keep it just for this particular case of doubles, but even half is allowed in certain circumstances without the pragma and it is still an extension. https://godbolt.org/z/K34sP81nx
>
> I am confused again... after looking into //OpenCL C 1.0, 9.10 Half Floating-Point//: it says that pragma is required too. So is it a bug in clang implementation are do you prefer keep existing functionality for double?

I am not sure, to be honest I personally think the extension pragma is a spec failure as it is not specified properly or to allow reasonable implementation. And since nobody really understands the original intent it was not possible to provide any reasonable implementation either.

For example, in case of half the extension spec said this:

> An application that wants to use half and halfn types will need to include the #pragma OPENCL EXTENSION cl_khr_fp16 : enabledirective.

While main spec has:

> The half data type can only be used to declare a pointer to a buffer that contains half values.



> half is not supported as half can be used as a storage format only and is not a data type on which floating-point arithmetic can be performed

It has no pragma in any examples.

I can't really tell what the pragma was intended for. We have this separate spec bug for it btw: https://github.com/KhronosGroup/OpenCL-Docs/issues/21

I didn't look at fp16 in my cleanup yet as it doesn't have a similar pattern with any other extension and it is more complicated in my opinion.

Anyway since there is not clear benefit that can be found now for the pragma I think we should minimize its use as much as possible.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100980/new/

https://reviews.llvm.org/D100980



More information about the cfe-commits mailing list