llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Wenju He (wenju-he)

<details>
<summary>Changes</summary>

Fix typo cl_intel_bfloat16_conversion.
Add test for checking intel extension functions.

---
Full diff: https://github.com/llvm/llvm-project/pull/171433.diff


3 Files Affected:

- (modified) clang/include/clang/Basic/OpenCLExtensions.def (+3-1) 
- (modified) clang/test/SemaOpenCL/extension-version.cl (+56-2) 
- (added) clang/test/SemaOpenCL/intel-unsupported-extensions.cl (+62) 


``````````diff
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

``````````

</details>


https://github.com/llvm/llvm-project/pull/171433
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to