-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang][SYCL] Disable float128 device mode diagnostic #128513
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
This diagnostic is disabled for device compilation as float128 is not supported on the device side. Other diagnostics are already covering the cases where float128 is actually used in the kernel code, and it's already tested for in the existing test. This is expanding on the patch 318bff6 that handled this for cuda compilation.
@llvm/pr-subscribers-clang Author: Nicolas Miller (npmiller) ChangesThis diagnostic is disabled for device compilation as float128 is not supported on the device side. Other diagnostics are already covering the cases where float128 is actually used in the kernel code, and it's already tested for in the existing test. This is expanding on the patch 318bff6 that handled this for cuda compilation. Full diff: https://github.com/llvm/llvm-project/pull/128513.diff 2 Files Affected:
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 620290af9509f..a13c04d69c4ba 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -4700,7 +4700,8 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo &CI,
if (NewElemTy.isNull()) {
// Only emit diagnostic on host for 128-bit mode attribute
- if (!(DestWidth == 128 && getLangOpts().CUDAIsDevice))
+ if (!(DestWidth == 128 &&
+ (getLangOpts().CUDAIsDevice || getLangOpts().SYCLIsDevice)))
Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
return;
}
diff --git a/clang/test/SemaSYCL/float128.cpp b/clang/test/SemaSYCL/float128.cpp
index b1a022216aaff..e41dea38dbe75 100644
--- a/clang/test/SemaSYCL/float128.cpp
+++ b/clang/test/SemaSYCL/float128.cpp
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -verify -fsyntax-only %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsycl-is-device -fsyntax-only %s
+typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
typedef __float128 BIGTY;
template <class T>
|
@@ -4700,7 +4700,8 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo &CI, | |||
|
|||
if (NewElemTy.isNull()) { | |||
// Only emit diagnostic on host for 128-bit mode attribute | |||
if (!(DestWidth == 128 && getLangOpts().CUDAIsDevice)) | |||
if (!(DestWidth == 128 && | |||
(getLangOpts().CUDAIsDevice || getLangOpts().SYCLIsDevice))) |
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.
Side-note CUDAIsDevice || SYCLIsDevice
seems like a pretty common pattern and I believe HIP also uses CUDAIsDevice
, it could be good to refactor in the future this to have a common "device compilation" option if possible.
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.
On that note: I think the same problem can be reproduced by OpenMP offload as well, so we might need to extend the condition with || (getLangOpts().OpenMP && getLangOpts().OpenMPIsTargetDevice)
.
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.
I'll try to reproduce this with OpenMP and open a follow up PR if it has the same issue
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.
Not sure exactly how it works for OpenMP, but it doesn't seem to be affected, with a float128.cpp
file just containing:
typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
And testing without this patch:
With SYCL:
$ ./bin/clang++ float128.cpp -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xclang -fsycl-is-device -fsyntax-only -o o
float128.cpp:1:52: error: unsupported machine mode '__TC__'
1 | typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
| ^
1 error generated.
$
With OpenMP:
$ ./bin/clang++ ../build/float128.cpp -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -Xclang -fopenmp-is-target-device -fsyntax-only -o o
$
And same thing without specifying an OpenMP target.
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.
Now, I'd like to understand how OpenMP compiler solves that problem and why OpenMP solution seems to be different from CUDA. @npmiller, do you know any reason why they should be different?
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.
No I'm not very familiar with this part of the compiler, and even less with OpenMP.
I'm a bit confused about this.
building intel/llvm@sycl
At first I assumed that something had changed in libstdc++, but it turns out this line is actually in glibc and has been this way since 2017. Since this is happening in dpc++ and has been in glibc for a long time, I'm wondering what has changed. The present patch might be the right fix, but I'm not sure. Perhaps @AaronBallman could suggest a reviewer (or review this himself) to decide whether this belongs here or has a better root-cause fix? |
I'm not certain if the fix is correct or not, so adding a few other reviewers who may have more confidence. |
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.
The fix looks right to me.
@@ -4700,7 +4700,8 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo &CI, | |||
|
|||
if (NewElemTy.isNull()) { | |||
// Only emit diagnostic on host for 128-bit mode attribute | |||
if (!(DestWidth == 128 && getLangOpts().CUDAIsDevice)) | |||
if (!(DestWidth == 128 && | |||
(getLangOpts().CUDAIsDevice || getLangOpts().SYCLIsDevice))) |
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.
On that note: I think the same problem can be reproduced by OpenMP offload as well, so we might need to extend the condition with || (getLangOpts().OpenMP && getLangOpts().OpenMPIsTargetDevice)
.
Cherry-pick of: llvm/llvm-project#128513 Fixes: #16903 ------ This diagnostic is disabled for device compilation as float128 is not supported on the device side. Other diagnostics are already covering the cases where float128 is actually used in the kernel code, and it's already tested for in the existing test. This is expanding on the patch 318bff6 that handled this for cuda compilation.
This diagnostic is disabled for device compilation as float128 is not supported on the device side. Other diagnostics are already covering the cases where float128 is actually used in the kernel code, and it's already tested for in the existing test. This is expanding on the patch 318bff6 that handled this for cuda compilation.
This diagnostic is disabled for device compilation as float128 is not supported on the device side.
Other diagnostics are already covering the cases where float128 is actually used in the kernel code, and it's already tested for in the existing test.
This is expanding on the patch 318bff6 that handled this for cuda compilation.