Skip to content

[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

Merged
merged 1 commit into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Copy link
Contributor Author

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.

Copy link
Contributor

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).

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
return;
}
Expand Down
1 change: 1 addition & 0 deletions clang/test/SemaSYCL/float128.cpp
Original file line number Diff line number Diff line change
@@ -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>
Expand Down