-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[OpenCL] Add cl_khr_subgroup_named_barrier and cl_intel_required_subgroup_size to OpenCLExtensions.def #171433
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
[OpenCL] Add cl_khr_subgroup_named_barrier and cl_intel_required_subgroup_size to OpenCLExtensions.def #171433
Conversation
…roup_size to OpenCLExtensions.def Fix typo cl_intel_bfloat16_conversion. Add test for checking intel extension functions.
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.
Pull request overview
This PR fixes a typo in an Intel OpenCL extension name and adds support for two missing OpenCL extensions. The typo correction changes cl_intel_bfloat16_conversion to cl_intel_bfloat16_conversions (adding the missing 's'), and the PR adds cl_khr_subgroup_named_barrier and cl_intel_required_subgroup_size to the extension definitions.
Key changes:
- Corrected the extension name from
cl_intel_bfloat16_conversiontocl_intel_bfloat16_conversionsin OpenCLExtensions.def - Added
cl_khr_subgroup_named_barrierandcl_intel_required_subgroup_sizeextensions to OpenCLExtensions.def - Added comprehensive test coverage for Intel extension functions in a new test file
- Updated existing extension version tests to include the new extensions and the corrected extension name
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| clang/include/clang/Basic/OpenCLExtensions.def | Fixes typo in cl_intel_bfloat16_conversions and adds two new extension definitions |
| clang/test/SemaOpenCL/extension-version.cl | Updates tests to verify the corrected extension name and adds test blocks for the two new extensions |
| clang/test/SemaOpenCL/intel-unsupported-extensions.cl | New test file that verifies Intel extension functions are correctly gated by their corresponding extension macros |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@llvm/pr-subscribers-clang Author: Wenju He (wenju-he) ChangesFix typo cl_intel_bfloat16_conversion. Full diff: https://github.com/llvm/llvm-project/pull/171433.diff 3 Files Affected:
diff --git a/clang/include/clang/Basic/OpenCLExtensions.def b/clang/include/clang/Basic/OpenCLExtensions.def
index b0c08b7f320c4..55122987d2d75 100644
--- a/clang/include/clang/Basic/OpenCLExtensions.def
+++ b/clang/include/clang/Basic/OpenCLExtensions.def
@@ -88,6 +88,7 @@ OPENCL_EXTENSION(cl_khr_srgb_image_writes, true, 200)
OPENCL_EXTENSION(cl_khr_subgroup_ballot, false, 200)
OPENCL_EXTENSION(cl_khr_subgroup_clustered_reduce, false, 200)
OPENCL_EXTENSION(cl_khr_subgroup_extended_types, false, 200)
+OPENCL_EXTENSION(cl_khr_subgroup_named_barrier, false, 200)
OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_arithmetic, false, 200)
OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_vote, false, 200)
OPENCL_EXTENSION(cl_khr_subgroup_rotate, false, 200)
@@ -140,7 +141,8 @@ OPENCL_EXTENSION(cl_amd_media_ops, true, 100)
OPENCL_EXTENSION(cl_amd_media_ops2, true, 100)
// Intel OpenCL extensions
-OPENCL_EXTENSION(cl_intel_bfloat16_conversion, false, 100)
+OPENCL_EXTENSION(cl_intel_bfloat16_conversions, false, 100)
+OPENCL_EXTENSION(cl_intel_required_subgroup_size, false, 200)
OPENCL_EXTENSION(cl_intel_subgroups, true, 120)
OPENCL_EXTENSION(cl_intel_subgroups_char, true, 120)
OPENCL_EXTENSION(cl_intel_subgroups_long, true, 120)
diff --git a/clang/test/SemaOpenCL/extension-version.cl b/clang/test/SemaOpenCL/extension-version.cl
index f736e5f5ff9fe..77531479d3a0f 100644
--- a/clang/test/SemaOpenCL/extension-version.cl
+++ b/clang/test/SemaOpenCL/extension-version.cl
@@ -249,6 +249,18 @@
// expected-warning@+1{{OpenCL extension 'cl_khr_subgroup_extended_types' unknown or does not require pragma - ignoring}}
#pragma OPENCL EXTENSION cl_khr_subgroup_extended_types : enable
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_subgroup_named_barrier
+#error "Missing cl_khr_subgroup_named_barrier define"
+#endif
+#else
+#ifdef cl_khr_subgroup_named_barrier
+#error "Incorrect cl_khr_subgroup_named_barrier define"
+#endif
+#endif
+// expected-warning@+1{{OpenCL extension 'cl_khr_subgroup_named_barrier' unknown or does not require pragma - ignoring}}
+#pragma OPENCL EXTENSION cl_khr_subgroup_named_barrier : enable
+
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
#ifndef cl_khr_subgroup_non_uniform_arithmetic
#error "Missing cl_khr_subgroup_non_uniform_arithmetic define"
@@ -332,16 +344,37 @@
#pragma OPENCL EXTENSION cl_khr_depth_images : enable
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 100)
-#ifndef cl_intel_bfloat16_conversion
-#error "Missing cl_intel_bfloat16_conversion define"
+#ifndef cl_intel_bfloat16_conversions
+#error "Missing cl_intel_bfloat16_conversions define"
+#endif
+#else
+#ifdef cl_intel_bfloat16_conversions
+#error "Incorrect cl_intel_bfloat16_conversions define"
+#endif
+#endif
+// expected-warning@+1{{OpenCL extension 'cl_intel_bfloat16_conversions' unknown or does not require pragma - ignoring}}
+#pragma OPENCL EXTENSION cl_intel_bfloat16_conversions : enable
+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#ifndef cl_intel_required_subgroup_size
+#error "Missing cl_intel_required_subgroup_size define"
+#endif
+#else
+#ifdef cl_intel_required_subgroup_size
+#error "Incorrect cl_intel_required_subgroup_size define"
#endif
#endif
+// expected-warning@+1{{OpenCL extension 'cl_intel_required_subgroup_size' unknown or does not require pragma - ignoring}}
+#pragma OPENCL EXTENSION cl_intel_required_subgroup_size : enable
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
#ifndef cl_intel_subgroups
#error "Missing cl_intel_subgroups define"
#endif
#else
+#ifdef cl_intel_subgroups
+#error "Incorrect cl_intel_subgroups define"
+#endif
// expected-warning@+2{{unsupported OpenCL extension 'cl_intel_subgroups' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_intel_subgroups : enable
@@ -351,6 +384,9 @@
#error "Missing cl_intel_subgroups_char define"
#endif
#else
+#ifdef cl_intel_subgroups_char
+#error "Incorrect cl_intel_subgroups_char define"
+#endif
// expected-warning@+2{{unsupported OpenCL extension 'cl_intel_subgroups_char' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_intel_subgroups_char : enable
@@ -360,6 +396,9 @@
#error "Missing cl_intel_subgroups_long define"
#endif
#else
+#ifdef cl_intel_subgroups_long
+#error "Incorrect cl_intel_subgroups_long define"
+#endif
// expected-warning@+2{{unsupported OpenCL extension 'cl_intel_subgroups_long' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_intel_subgroups_long : enable
@@ -369,6 +408,9 @@
#error "Missing cl_intel_subgroups_short define"
#endif
#else
+#ifdef cl_intel_subgroups_short
+#error "Incorrect cl_intel_subgroups_short define"
+#endif
// expected-warning@+2{{unsupported OpenCL extension 'cl_intel_subgroups_short' - ignoring}}
#endif
#pragma OPENCL EXTENSION cl_intel_subgroups_short : enable
@@ -377,13 +419,25 @@
#ifndef cl_intel_subgroup_buffer_prefetch
#error "Missing cl_intel_subgroup_buffer_prefetch define"
#endif
+#else
+#ifdef cl_intel_subgroup_buffer_prefetch
+#error "Incorrect cl_intel_subgroup_buffer_prefetch define"
+#endif
#endif
+// expected-warning@+1{{OpenCL extension 'cl_intel_subgroup_buffer_prefetch' unknown or does not require pragma - ignoring}}
+#pragma OPENCL EXTENSION cl_intel_subgroup_buffer_prefetch : enable
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
#ifndef cl_intel_subgroup_local_block_io
#error "Missing cl_intel_subgroup_local_block_io define"
#endif
+#else
+#ifdef cl_intel_subgroup_local_block_io
+#error "Incorrect cl_intel_subgroup_local_block_io define"
+#endif
#endif
+// expected-warning@+1{{OpenCL extension 'cl_intel_subgroup_local_block_io' unknown or does not require pragma - ignoring}}
+#pragma OPENCL EXTENSION cl_intel_subgroup_local_block_io : enable
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
#ifndef cl_intel_device_side_avc_motion_estimation
diff --git a/clang/test/SemaOpenCL/intel-unsupported-extensions.cl b/clang/test/SemaOpenCL/intel-unsupported-extensions.cl
new file mode 100644
index 0000000000000..72172ce6b3dd0
--- /dev/null
+++ b/clang/test/SemaOpenCL/intel-unsupported-extensions.cl
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -finclude-default-header -cl-std=CL3.0 -cl-ext=-cl_intel_subgroups,-cl_intel_subgroup_buffer_prefetch,-cl_intel_subgroups_char,-cl_intel_subgroups_short,-cl_intel_subgroups_long,-cl_intel_bfloat16_conversions,-cl_intel_subgroup_local_block_io,-cl_intel_device_side_avc_motion_estimation %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -finclude-default-header -cl-std=CL3.0 %s
+
+#if defined(cl_intel_subgroups) && defined(cl_intel_subgroup_buffer_prefetch) && defined(cl_intel_subgroups_char) && defined(cl_intel_subgroups_short) && defined(cl_intel_subgroups_long) && defined(cl_intel_bfloat16_conversions) && defined(cl_intel_subgroup_local_block_io) && defined(cl_intel_device_side_avc_motion_estimation)
+// expected-no-diagnostics
+#endif
+
+uint test1(read_only image2d_t im, int2 i) {
+ return intel_sub_group_block_read(im, i);
+}
+#if !defined(cl_intel_subgroups)
+// expected-error@-3{{use of undeclared identifier 'intel_sub_group_block_read'}}
+#endif
+
+void test2(const __global uint *p) {
+ return intel_sub_group_block_prefetch_ui(p);
+}
+#if !defined(cl_intel_subgroup_buffer_prefetch)
+// expected-error@-3{{use of undeclared identifier 'intel_sub_group_block_prefetch_ui'}}
+#endif
+
+uchar test4(read_only image2d_t im, int2 i) {
+ return intel_sub_group_block_read_uc(im, i);
+}
+#if !defined(cl_intel_subgroups_char)
+// expected-error@-3{{use of undeclared identifier 'intel_sub_group_block_read_uc'}}
+#endif
+
+ushort test5(const __local ushort* p) {
+ return intel_sub_group_block_read_us(p);
+}
+#if !defined(cl_intel_subgroups_short)
+// expected-error@-3{{use of undeclared identifier 'intel_sub_group_block_read_us'}}
+#endif
+
+ulong test6(const __global ulong* p) {
+ return intel_sub_group_block_read_ul(p);
+}
+#if !defined(cl_intel_subgroups_long)
+// expected-error@-3{{use of undeclared identifier 'intel_sub_group_block_read_ul'}}
+#endif
+
+ushort test7(float f) {
+ return intel_convert_bfloat16_as_ushort(f);
+}
+#if !defined(cl_intel_bfloat16_conversions)
+// expected-error@-3{{use of undeclared identifier 'intel_convert_bfloat16_as_ushort'}}
+#endif
+
+uint test8(const __local uint* p) {
+ return intel_sub_group_block_read(p);
+}
+#if !defined(cl_intel_subgroup_local_block_io)
+// expected-error@-3{{use of undeclared identifier 'intel_sub_group_block_read'}}
+#endif
+
+uchar test9(uchar slice_type, uchar qp) {
+ return intel_sub_group_avc_mce_get_default_inter_base_multi_reference_penalty(slice_type, qp);
+}
+#if !defined(cl_intel_device_side_avc_motion_estimation)
+// expected-error@-3{{use of undeclared identifier 'intel_sub_group_avc_mce_get_default_inter_base_multi_reference_penalty'}}
+#endif
|
svenvh
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.
khr parts LGTM.
thanks @svenvh |
|
kindly ping @michalpaszkowski for review |
Fix typo cl_intel_bfloat16_conversion.
Add test for checking intel extension functions.