[PATCH] D90409: [HIP] Math Headers to use type promotion

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 3 12:33:52 PST 2020


yaxunl added a comment.

In D90409#2371987 <https://reviews.llvm.org/D90409#2371987>, @tra wrote:

> In D90409#2371969 <https://reviews.llvm.org/D90409#2371969>, @yaxunl wrote:
>
>> nvcc does not support fma(float,float,char)
>
> It does, it just needs an explicit flag to match clang's treatment of `constexpr` functions as HD.



In D90409#2371972 <https://reviews.llvm.org/D90409#2371972>, @tra wrote:

> In D90409#2371679 <https://reviews.llvm.org/D90409#2371679>, @jlebar wrote:
>
>>> LGTM. I think the change would make sense for CUDA, too. @jlebar - WDYT?
>>
>> I agree that the C and C++ standard libraries should behave the same in CUDA mode and host mode!
>>
>> But if doing so would make our behavior different than nvcc's, maybe we could emit a warning or something?  Like, "this code you wrote maybe for nvcc is going to do something different with clang."
>
> Interestingly enough CUDA 10.1+ already promotes integer `fma()` arguments to double:
> https://godbolt.org/z/crbqTe
>
> I wonder what makes HIP different to require this change.

Practically the behavior is the same since they all promote integer types to double. This matches the C++ behavior. However the HIP change will make it conform to C++ for a target supporting long double whereas the previous header did not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90409



More information about the cfe-commits mailing list