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

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 23 06:20:37 PDT 2021


Anastasia added a comment.

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

>> For cl_khr_fp64 I still want to keep the pragma for the other use case - to convert double literal into single-precision (https://github.com/KhronosGroup/OpenCL-Docs/issues/578). The reason why I think it could be useful is that the precision change might lead to a different result depending on the precision of the calculation. So I think pragmas could be useful to control whether double literal is single-precision or not to avoid this problem occur when code is compiled for different targets?
>
> Yeah, then we should  use `S.getOpenCLOptions().isAvailableOption("cl_khr_fp64", S.getLangOpts())` to check for enabled pragma.

Just to be clear, we already use `isAvailableOption` in other cases, for example this:
https://clang.llvm.org/doxygen/SemaExpr_8cpp_source.html#l00816

My idea was to simplify only one particular case when the data types are being used because I don't find the pragma useful for it and it is also inconsistent.

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

So I personally don't see a big value to keep it just for the particular case of doubles.

> And do I understand correctly that the pragma is not needed in OpenCL C 1.2+ since extension became core?

To be honest I don't really know. In the unified spec there is nothing about the pragmas. For now I just want to address the use cases that don't cause backward compatibility issues.


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

https://reviews.llvm.org/D100980



More information about the cfe-commits mailing list