[PATCH] D77910: AMDGPU: Define cl_khr_gl_sharing as a supported extension

Matt Arsenault via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 14 13:31:11 PDT 2020


arsenm updated this revision to Diff 257470.
arsenm added a comment.

Check triple OS


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77910/new/

https://reviews.llvm.org/D77910

Files:
  clang/lib/Basic/Targets/AMDGPU.h
  clang/test/Misc/amdgcn.languageOptsOpenCL.cl


Index: clang/test/Misc/amdgcn.languageOptsOpenCL.cl
===================================================================
--- clang/test/Misc/amdgcn.languageOptsOpenCL.cl
+++ clang/test/Misc/amdgcn.languageOptsOpenCL.cl
@@ -8,6 +8,20 @@
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple amdgcn-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple amdgcn-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 
+// Test extensions supported by amdhsa and amdpal
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple amdgcn-unknown-amdhsa -Wpedantic-core-features -DTEST_CORE_FEATURES -DHSAPAL
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple amdgcn-unknown-amdhsa -Wpedantic-core-features -DTEST_CORE_FEATURES -DHSAPAL
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple amdgcn-unknown-amdhsa -Wpedantic-core-features -DTEST_CORE_FEATURES -DHSAPAL
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple amdgcn-unknown-amdpal -Wpedantic-core-features -DTEST_CORE_FEATURES -DHSAPAL
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple amdgcn-unknown-amdpal -Wpedantic-core-features -DTEST_CORE_FEATURES -DHSAPAL
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple amdgcn-unknown-amdpal -Wpedantic-core-features -DTEST_CORE_FEATURES -DHSAPAL
+
+// Test extensions supported by mesa3d/clover
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple amdgcn-unknown-mesa3d -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple amdgcn-unknown-mesa3d -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple amdgcn-unknown-mesa3d -Wpedantic-core-features -DTEST_CORE_FEATURES
+
+
 // Extensions in all versions
 #ifndef cl_clang_storage_class_specifiers
 #error "Missing cl_clang_storage_class_specifiers define"
@@ -29,11 +43,20 @@
 #endif
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics: enable
 
+#ifdef HSAPAL
+#ifndef cl_khr_gl_sharing
+#error "Incorrect cl_khr_gl_sharing define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_gl_sharing: enable
+
+#else
+
 #ifdef cl_khr_gl_sharing
 #error "Incorrect cl_khr_gl_sharing define"
 #endif
 #pragma OPENCL EXTENSION cl_khr_gl_sharing: enable
 // expected-warning at -1{{unsupported OpenCL extension 'cl_khr_gl_sharing' - ignoring}}
+#endif
 
 #ifndef cl_khr_icd
 #error "Missing cl_khr_icd define"
Index: clang/lib/Basic/Targets/AMDGPU.h
===================================================================
--- clang/lib/Basic/Targets/AMDGPU.h
+++ clang/lib/Basic/Targets/AMDGPU.h
@@ -267,6 +267,11 @@
       Opts.support("cl_khr_mipmap_image_writes");
       Opts.support("cl_khr_subgroups");
       Opts.support("cl_khr_3d_image_writes");
+
+      if (getTriple().getOS() == llvm::Triple::AMDHSA ||
+          getTriple().getOS() == llvm::Triple::AMDPAL)
+        Opts.support("cl_khr_gl_sharing");
+
       Opts.support("cl_amd_media_ops");
       Opts.support("cl_amd_media_ops2");
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77910.257470.patch
Type: text/x-patch
Size: 3057 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200414/3b17492b/attachment-0001.bin>


More information about the cfe-commits mailing list