-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[OpenMP] Silently accept neon_vector_type for the offloading device
#127439
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
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
|
@llvm/pr-subscribers-clang Author: None (pradt2) ChangesThis addresses issue #113094 Full diff: https://github.com/llvm/llvm-project/pull/127439.diff 2 Files Affected:
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 1fa5239a597c8..0c5cfdbba8d3d 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8336,12 +8336,11 @@ static bool verifyValidIntegerConstantExpr(Sema &S, const ParsedAttr &Attr,
/// match one of the standard Neon vector types.
static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
Sema &S, VectorKind VecKind) {
- bool IsTargetCUDAAndHostARM = false;
- if (S.getLangOpts().CUDAIsDevice) {
- const TargetInfo *AuxTI = S.getASTContext().getAuxTargetInfo();
- IsTargetCUDAAndHostARM =
- AuxTI && (AuxTI->getTriple().isAArch64() || AuxTI->getTriple().isARM());
- }
+ const TargetInfo *AuxTI = S.getASTContext().getAuxTargetInfo();
+ bool IsArm = AuxTI && (AuxTI->getTriple().isAArch64() || AuxTI->getTriple().isARM());
+
+ bool IsTargetCUDAAndHostARM = IsArm && S.getLangOpts().CUDAIsDevice;
+ bool IsTargetOpenMPDeviceAndHostARM = IsArm && S.getLangOpts().OpenMPIsTargetDevice;
// Target must have NEON (or MVE, whose vectors are similar enough
// not to need a separate attribute)
@@ -8376,7 +8375,7 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
// Only certain element types are supported for Neon vectors.
if (!isPermittedNeonBaseType(CurType, VecKind, S) &&
- !IsTargetCUDAAndHostARM) {
+ !IsTargetCUDAAndHostARM && !IsTargetOpenMPDeviceAndHostARM) {
S.Diag(Attr.getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
Attr.setInvalid();
return;
diff --git a/clang/test/Sema/bug113094.cpp b/clang/test/Sema/bug113094.cpp
new file mode 100644
index 0000000000000..0900db9efb041
--- /dev/null
+++ b/clang/test/Sema/bug113094.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang -fopenmp --offload-arch=sm_90 -nocudalib -target aarch64-unknown-linux-gnu -c -Xclang -verify %s
+// REQUIRES: aarch64-registered-target
+
+// expected-no-diagnostics
+
+typedef __attribute__ ((__neon_vector_type__ (4))) float __f32x4_t;
|
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 the fix! I added more reviewers with offloading/OpenMP background. Could you please also modify the title and the description of the PR so it says what was the problem and how it was fixed instead of simply saying it fixed this bug?
| @@ -0,0 +1,6 @@ | |||
| // RUN: %clang -fopenmp --offload-arch=sm_90 -nocudalib -target aarch64-unknown-linux-gnu -c -Xclang -verify %s | |||
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.
We don't usually use clang driver in front-end tests. Could you please create a run line using pure front-end, i.e. via %clang_cc1 ?
Also, since this is OpenMP related, could you please put the test to OpenMP/ directory?
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.
Seems CUDA used to have a test for this but it was removed for some reason? I would just stash it in SemaOpenMP or OpenMP and copy one of the existing -verify tests.
| const TargetInfo *AuxTI = S.getASTContext().getAuxTargetInfo(); | ||
| bool IsArm = AuxTI && (AuxTI->getTriple().isAArch64() || AuxTI->getTriple().isARM()); | ||
|
|
||
| bool IsTargetCUDAAndHostARM = IsArm && S.getLangOpts().CUDAIsDevice; |
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.
This is more of a question to offloading experts of the community. I think all single-source offloading models eventually run into similar problems. It doesn't depend on the language being used (CUDA/OpenMP/SYCL) and what are the architectures. So I wonder if it makes sense to do a more generalized check, something like "if device doesn't support but the host does, dont error out".
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 agree, unfortunately a lot of this handling is spread out all over the place. There's #126956 up which also tries to clean some of this up. However, right now I'd say that would be a larger cleanup out of scope for this bug fix.
neon_vector_type for the offloading device
|
The test you added doesn't seem to pass. You can run it locally with |
|
|
You can test this locally with the following command:git-clang-format --diff d841c8842e17b7e74c3ee98c13a8a2505566deed 55e4d444572da286fdd4218178c6bc03c3e56b5b --extensions cpp -- clang/test/Sema/bug113094.cpp clang/lib/Sema/SemaType.cppView the diff from clang-format here.diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 0c5cfdbba8..9aeab7595d 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8337,10 +8337,12 @@ static bool verifyValidIntegerConstantExpr(Sema &S, const ParsedAttr &Attr,
static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
Sema &S, VectorKind VecKind) {
const TargetInfo *AuxTI = S.getASTContext().getAuxTargetInfo();
- bool IsArm = AuxTI && (AuxTI->getTriple().isAArch64() || AuxTI->getTriple().isARM());
+ bool IsArm =
+ AuxTI && (AuxTI->getTriple().isAArch64() || AuxTI->getTriple().isARM());
bool IsTargetCUDAAndHostARM = IsArm && S.getLangOpts().CUDAIsDevice;
- bool IsTargetOpenMPDeviceAndHostARM = IsArm && S.getLangOpts().OpenMPIsTargetDevice;
+ bool IsTargetOpenMPDeviceAndHostARM =
+ IsArm && S.getLangOpts().OpenMPIsTargetDevice;
// Target must have NEON (or MVE, whose vectors are similar enough
// not to need a separate attribute)
|
neon_vector_type for the offloading deviceneon_vector_type for the offloading device
| @@ -0,0 +1,6 @@ | |||
| // RUN: %clang -fopenmp --offload-arch=sm_90 -nocudalib -target aarch64-unknown-linux-gnu -c -Xclang -verify %s | |||
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.
Use %clang_cc1 here instead of the driver.
|
While I was working on the tests, I realised I can no longer replicate this issue in main. I guess it got fixed by someone, somewhere. I'm gonna close this now. |
I'm not aware of any changes in this area, but if it doesn't fail anymore I guess that's fine. |
This addresses issue #113094