-
Notifications
You must be signed in to change notification settings - Fork 798
[SYCL][NVPTX][AMDGCN] Fix compilation for cmath long double #19558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Make sure to not define `long double` wrappers in the cmath wrapper. We unintentionally defined these for two or three argument functions with mixed types. These definitions fail to compile if we try to use them, because there are no SPIR-V builtins for long double. By not defining them, overload resolution will pick the "host" versions. We can't make overload resolution fail, because function bodies that are not called on the device still need to be semantically valid for the device. This was discovered by the SYCL CTS, in its reference implementation for the builtins. That code is never called on the device, but it needs to compile without errors.
The mentioned code from the SYCL-CTS is here: https://github.com/KhronosGroup/SYCL-CTS/blob/main/util/math_reference.h#L433 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the SYCL-CTS test the std
math function on device? How do we know that long double
is even supported on a given device?
Co-authored-by: Steffen Larsen <[email protected]>
Co-authored-by: Steffen Larsen <[email protected]>
@Maetveis - Please see my previous comment. I don't necessarily think this is wrong, but I am concerned about the need for the use of |
Yes, it runs on the device and is compared to reference values on the host. long double is not used on the device, only for the host reference implementations. However that "host" code still has to make it through semantic analysis during device compilation, we will just not codegen it.
I don't think long double is ever supported by any device actually. The comment about the SYCL-CTS is mostly for reference. The reduced testcase added in the PR can be reasonably expected to compile in SYCL language mode, and without the rest of the changes it does not. |
I checked more deeply and I think I was wrong on this in the previous comment, the test only calls the math functions from the (Called functions are defined here: https://github.com/KhronosGroup/SYCL-CTS/blob/main/tests/math_builtin_api/modules/sycl_functions.py#L44, the first namespace field is never |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for clarifying! I think the change is fine, though I feel like the long double
specialization is a little redundant. The note is nice though.
@intel/llvm-gatekeepers I believe this should be ready to merge, thanks :) |
Make sure to not define
long double
wrappers in the cmath wrapper. We unintentionally defined these for two or three argument functions with mixed types. These definitions fail to compile if we try to use them, because there are no SPIR-V builtins for long double. By not defining them, overload resolution will pick the "host" versions. We can't make overload resolution fail, because function bodies that are not called on the device still need to be semantically valid for the device.This was discovered by the SYCL CTS, in its reference implementation for the builtins. That code is never called on the device, but it needs to compile without errors.