| 1 |
From 4f3bdfb30cf5a9626500f03d757166d3ef9c1dff Mon Sep 17 00:00:00 2001 |
| 2 |
From: Wenju He <[email protected]> |
| 3 |
Date: Thu, 16 Jul 2026 13:07:02 +0200 |
| 4 |
Subject: [PATCH] [Clang][OpenCL] Promote a few extensions to OpenCL 3.1 core |
| 5 |
(#204330) |
| 6 |
|
| 7 |
Following 6 OpenCL extensions are promoted to core features in 3.1: |
| 8 |
https://github.com/KhronosGroup/OpenCL-Docs/commit/9fff1a87a975 |
| 9 |
- cl_khr_extended_bit_ops |
| 10 |
- cl_khr_integer_dot_product |
| 11 |
- cl_khr_subgroup_extended_types |
| 12 |
- cl_khr_subgroup_rotate |
| 13 |
- cl_khr_subgroup_shuffle |
| 14 |
- cl_khr_subgroup_shuffle_relative |
| 15 |
|
| 16 |
A target claiming OpenCL C 3.1 conformance without supporting one of |
| 17 |
these features is now diagnosed. |
| 18 |
Updated release notes for the change. |
| 19 |
|
| 20 |
Assisted-by: Claude |
| 21 |
--- |
| 22 |
clang/docs/ReleaseNotes.rst | 5 +++++ |
| 23 |
clang/include/clang/Basic/OpenCLExtensions.def | 6 ++++++ |
| 24 |
clang/test/Misc/amdgcn.unsupported_core_3.1.cl | 8 ++++++++ |
| 25 |
clang/test/SemaOpenCL/extension-version.cl | 2 ++ |
| 26 |
4 files changed, 21 insertions(+) |
| 27 |
create mode 100644 clang/test/Misc/amdgcn.unsupported_core_3.1.cl |
| 28 |
|
| 29 |
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst |
| 30 |
index 3d92c4bcdb90..41f3e3b4a8f2 100644 |
| 31 |
--- a/clang/docs/ReleaseNotes.rst |
| 32 |
+++ b/clang/docs/ReleaseNotes.rst |
| 33 |
@@ -960,6 +960,11 @@ Miscellaneous Clang Crashes Fixed |
| 34 |
OpenCL Specific Changes |
| 35 |
----------------------- |
| 36 |
- Added support for OpenCL C 3.1 language version (``-cl-std=CL3.1``). |
| 37 |
+- Extensions ``cl_khr_extended_bit_ops``, ``cl_khr_integer_dot_product``, |
| 38 |
+ ``cl_khr_subgroup_extended_types``, ``cl_khr_subgroup_rotate``, |
| 39 |
+ ``cl_khr_subgroup_shuffle``, and ``cl_khr_subgroup_shuffle_relative`` are |
| 40 |
+ promoted to core features in OpenCL C 3.1. A target claiming OpenCL C 3.1 |
| 41 |
+ conformance without supporting one of these features is now diagnosed. |
| 42 |
|
| 43 |
Target Specific Changes |
| 44 |
----------------------- |
| 45 |
diff --git a/clang/include/clang/Basic/OpenCLExtensions.def b/clang/include/clang/Basic/OpenCLExtensions.def |
| 46 |
index 5d9227504768..9c6f172b94fb 100644 |
| 47 |
--- a/clang/include/clang/Basic/OpenCLExtensions.def |
| 48 |
+++ b/clang/include/clang/Basic/OpenCLExtensions.def |
| 49 |
@@ -78,9 +78,15 @@ OPENCL_EXTENSION(cles_khr_int64, true, 110) |
| 50 |
OPENCL_EXTENSION(cl_khr_depth_images, true, 120) |
| 51 |
|
| 52 |
// OpenCL 2.0. |
| 53 |
+OPENCL_COREFEATURE(cl_khr_extended_bit_ops, false, 200, OCL_C_31) |
| 54 |
+OPENCL_COREFEATURE(cl_khr_integer_dot_product, false, 200, OCL_C_31) |
| 55 |
OPENCL_EXTENSION(cl_khr_mipmap_image, true, 200) |
| 56 |
OPENCL_EXTENSION(cl_khr_mipmap_image_writes, true, 200) |
| 57 |
OPENCL_EXTENSION(cl_khr_srgb_image_writes, true, 200) |
| 58 |
+OPENCL_COREFEATURE(cl_khr_subgroup_extended_types, false, 200, OCL_C_31) |
| 59 |
+OPENCL_COREFEATURE(cl_khr_subgroup_rotate, false, 200, OCL_C_31) |
| 60 |
+OPENCL_COREFEATURE(cl_khr_subgroup_shuffle_relative, false, 200, OCL_C_31) |
| 61 |
+OPENCL_COREFEATURE(cl_khr_subgroup_shuffle, false, 200, OCL_C_31) |
| 62 |
OPENCL_EXTENSION(cl_khr_subgroups, true, 200) |
| 63 |
|
| 64 |
// Clang Extensions. |
| 65 |
diff --git a/clang/test/Misc/amdgcn.unsupported_core_3.1.cl b/clang/test/Misc/amdgcn.unsupported_core_3.1.cl |
| 66 |
new file mode 100644 |
| 67 |
index 000000000000..5a406670777a |
| 68 |
--- /dev/null |
| 69 |
+++ b/clang/test/Misc/amdgcn.unsupported_core_3.1.cl |
| 70 |
@@ -0,0 +1,8 @@ |
| 71 |
+// RUN: %clang_cc1 -cl-std=CL3.1 -triple amdgcn-amd-amdhsa -Wpedantic-core-features %s 2>&1 | FileCheck %s |
| 72 |
+ |
| 73 |
+// CHECK: cl_khr_extended_bit_ops is a core feature in OpenCL C version 3.1 but not supported on this target |
| 74 |
+// CHECK: cl_khr_integer_dot_product is a core feature in OpenCL C version 3.1 but not supported on this target |
| 75 |
+// CHECK: cl_khr_subgroup_extended_types is a core feature in OpenCL C version 3.1 but not supported on this target |
| 76 |
+// CHECK: cl_khr_subgroup_rotate is a core feature in OpenCL C version 3.1 but not supported on this target |
| 77 |
+// CHECK: cl_khr_subgroup_shuffle_relative is a core feature in OpenCL C version 3.1 but not supported on this target |
| 78 |
+// CHECK: cl_khr_subgroup_shuffle is a core feature in OpenCL C version 3.1 but not supported on this target |
| 79 |
diff --git a/clang/test/SemaOpenCL/extension-version.cl b/clang/test/SemaOpenCL/extension-version.cl |
| 80 |
index ffa837684e3c..3af59f06ae58 100644 |
| 81 |
--- a/clang/test/SemaOpenCL/extension-version.cl |
| 82 |
+++ b/clang/test/SemaOpenCL/extension-version.cl |
| 83 |
@@ -4,12 +4,14 @@ |
| 84 |
// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown |
| 85 |
// RUN: %clang_cc1 -x cl -cl-std=clc++ %s -verify -triple spir-unknown-unknown |
| 86 |
// RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple spir-unknown-unknown |
| 87 |
+// RUN: %clang_cc1 -x cl -cl-std=CL3.1 %s -verify -triple spir-unknown-unknown |
| 88 |
// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES |
| 89 |
// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES |
| 90 |
// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES |
| 91 |
// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES |
| 92 |
// RUN: %clang_cc1 -x cl -cl-std=clc++ %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES |
| 93 |
// RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES |
| 94 |
+// RUN: %clang_cc1 -x cl -cl-std=CL3.1 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES |
| 95 |
|
| 96 |
// Extensions in all versions |
| 97 |
#ifndef cl_clang_storage_class_specifiers |
| 98 |
-- |
| 99 |
2.53.0 |
| 100 |
|