-
Notifications
You must be signed in to change notification settings - Fork 15.4k
clang/AMDGPU: Enable opencl 2.0 features for unknown target #170308
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
clang/AMDGPU: Enable opencl 2.0 features for unknown target #170308
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
🐧 Linux x64 Test Results
✅ The build succeeded and all tests passed. |
This is a partial fix for the rocm device-libs build. This was most likely broken by 423bdb2
|
@llvm/pr-subscribers-backend-amdgpu @llvm/pr-subscribers-clang Author: Matt Arsenault (arsenm) ChangesAssume amdhsa triples support flat addressing, which matches Full diff: https://github.com/llvm/llvm-project/pull/170308.diff 2 Files Affected:
diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h
index 1d8f27ab915e2..8dcf1d1c9561a 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -84,6 +84,18 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
return TT.getArch() == llvm::Triple::r600;
}
+ bool hasFlatSupport() const {
+ if (GPUKind >= llvm::AMDGPU::GK_GFX700)
+ return true;
+
+ // Dummy target is assumed to be gfx700+ for amdhsa.
+ if (GPUKind == llvm::AMDGPU::GK_NONE &&
+ getTriple().getOS() == llvm::Triple::AMDHSA)
+ return true;
+
+ return false;
+ }
+
public:
AMDGPUTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
@@ -325,7 +337,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
Opts["__opencl_c_atomic_order_seq_cst"] = true;
Opts["__opencl_c_atomic_scope_all_devices"] = true;
- if (GPUKind >= llvm::AMDGPU::GK_GFX700) {
+ if (hasFlatSupport()) {
Opts["__opencl_c_generic_address_space"] = true;
Opts["__opencl_c_device_enqueue"] = true;
}
diff --git a/clang/test/Misc/amdgcn.languageOptsOpenCL.cl b/clang/test/Misc/amdgcn.languageOptsOpenCL.cl
index 57ea891b3eb29..08715fc5a1f4a 100644
--- a/clang/test/Misc/amdgcn.languageOptsOpenCL.cl
+++ b/clang/test/Misc/amdgcn.languageOptsOpenCL.cl
@@ -11,6 +11,9 @@
// RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple amdgcn-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
// RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple amdgcn-unknown-unknown -target-cpu gfx700 -Wpedantic-core-features -DTEST_CORE_FEATURES -DFLAT_SUPPORT
+// Test none target with amdhsa triple, which implies >= gfx700
+// RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple amdgcn-unknown-amdhsa -Wpedantic-core-features -DTEST_CORE_FEATURES -DFLAT_SUPPORT
+
// Extensions in all versions
#ifndef cl_clang_storage_class_specifiers
#error "Missing cl_clang_storage_class_specifiers define"
|
Assume amdhsa triples support flat addressing, which matches the backend logic for the default target. This fixes the rocm device-libs build.
4e719a7 to
bab99b5
Compare
a16dd22 to
afb198a
Compare
wenju-he
left a comment
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.
LGTM

Assume amdhsa triples support flat addressing, which matches
the backend logic for the default target. This fixes the
rocm device-libs build.