Skip to content

Commit 5874ddf

Browse files
authored
[OpenCL] Add cl_khr_subgroup_named_barrier and cl_intel_required_subgroup_size to OpenCLExtensions.def (#171433)
Fix typo cl_intel_bfloat16_conversion. Add test for checking intel extension functions.
1 parent 0c179aa commit 5874ddf

File tree

3 files changed

+121
-3
lines changed

3 files changed

+121
-3
lines changed

clang/include/clang/Basic/OpenCLExtensions.def

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ OPENCL_EXTENSION(cl_khr_srgb_image_writes, true, 200)
8888
OPENCL_EXTENSION(cl_khr_subgroup_ballot, false, 200)
8989
OPENCL_EXTENSION(cl_khr_subgroup_clustered_reduce, false, 200)
9090
OPENCL_EXTENSION(cl_khr_subgroup_extended_types, false, 200)
91+
OPENCL_EXTENSION(cl_khr_subgroup_named_barrier, false, 200)
9192
OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_arithmetic, false, 200)
9293
OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_vote, false, 200)
9394
OPENCL_EXTENSION(cl_khr_subgroup_rotate, false, 200)
@@ -140,7 +141,8 @@ OPENCL_EXTENSION(cl_amd_media_ops, true, 100)
140141
OPENCL_EXTENSION(cl_amd_media_ops2, true, 100)
141142

142143
// Intel OpenCL extensions
143-
OPENCL_EXTENSION(cl_intel_bfloat16_conversion, false, 100)
144+
OPENCL_EXTENSION(cl_intel_bfloat16_conversions, false, 100)
145+
OPENCL_EXTENSION(cl_intel_required_subgroup_size, false, 200)
144146
OPENCL_EXTENSION(cl_intel_subgroups, true, 120)
145147
OPENCL_EXTENSION(cl_intel_subgroups_char, true, 120)
146148
OPENCL_EXTENSION(cl_intel_subgroups_long, true, 120)

clang/test/SemaOpenCL/extension-version.cl

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,18 @@
249249
// expected-warning@+1{{OpenCL extension 'cl_khr_subgroup_extended_types' unknown or does not require pragma - ignoring}}
250250
#pragma OPENCL EXTENSION cl_khr_subgroup_extended_types : enable
251251

252+
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
253+
#ifndef cl_khr_subgroup_named_barrier
254+
#error "Missing cl_khr_subgroup_named_barrier define"
255+
#endif
256+
#else
257+
#ifdef cl_khr_subgroup_named_barrier
258+
#error "Incorrect cl_khr_subgroup_named_barrier define"
259+
#endif
260+
#endif
261+
// expected-warning@+1{{OpenCL extension 'cl_khr_subgroup_named_barrier' unknown or does not require pragma - ignoring}}
262+
#pragma OPENCL EXTENSION cl_khr_subgroup_named_barrier : enable
263+
252264
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
253265
#ifndef cl_khr_subgroup_non_uniform_arithmetic
254266
#error "Missing cl_khr_subgroup_non_uniform_arithmetic define"
@@ -332,16 +344,37 @@
332344
#pragma OPENCL EXTENSION cl_khr_depth_images : enable
333345

334346
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 100)
335-
#ifndef cl_intel_bfloat16_conversion
336-
#error "Missing cl_intel_bfloat16_conversion define"
347+
#ifndef cl_intel_bfloat16_conversions
348+
#error "Missing cl_intel_bfloat16_conversions define"
349+
#endif
350+
#else
351+
#ifdef cl_intel_bfloat16_conversions
352+
#error "Incorrect cl_intel_bfloat16_conversions define"
353+
#endif
354+
#endif
355+
// expected-warning@+1{{OpenCL extension 'cl_intel_bfloat16_conversions' unknown or does not require pragma - ignoring}}
356+
#pragma OPENCL EXTENSION cl_intel_bfloat16_conversions : enable
357+
358+
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
359+
#ifndef cl_intel_required_subgroup_size
360+
#error "Missing cl_intel_required_subgroup_size define"
361+
#endif
362+
#else
363+
#ifdef cl_intel_required_subgroup_size
364+
#error "Incorrect cl_intel_required_subgroup_size define"
337365
#endif
338366
#endif
367+
// expected-warning@+1{{OpenCL extension 'cl_intel_required_subgroup_size' unknown or does not require pragma - ignoring}}
368+
#pragma OPENCL EXTENSION cl_intel_required_subgroup_size : enable
339369

340370
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
341371
#ifndef cl_intel_subgroups
342372
#error "Missing cl_intel_subgroups define"
343373
#endif
344374
#else
375+
#ifdef cl_intel_subgroups
376+
#error "Incorrect cl_intel_subgroups define"
377+
#endif
345378
// expected-warning@+2{{unsupported OpenCL extension 'cl_intel_subgroups' - ignoring}}
346379
#endif
347380
#pragma OPENCL EXTENSION cl_intel_subgroups : enable
@@ -351,6 +384,9 @@
351384
#error "Missing cl_intel_subgroups_char define"
352385
#endif
353386
#else
387+
#ifdef cl_intel_subgroups_char
388+
#error "Incorrect cl_intel_subgroups_char define"
389+
#endif
354390
// expected-warning@+2{{unsupported OpenCL extension 'cl_intel_subgroups_char' - ignoring}}
355391
#endif
356392
#pragma OPENCL EXTENSION cl_intel_subgroups_char : enable
@@ -360,6 +396,9 @@
360396
#error "Missing cl_intel_subgroups_long define"
361397
#endif
362398
#else
399+
#ifdef cl_intel_subgroups_long
400+
#error "Incorrect cl_intel_subgroups_long define"
401+
#endif
363402
// expected-warning@+2{{unsupported OpenCL extension 'cl_intel_subgroups_long' - ignoring}}
364403
#endif
365404
#pragma OPENCL EXTENSION cl_intel_subgroups_long : enable
@@ -369,6 +408,9 @@
369408
#error "Missing cl_intel_subgroups_short define"
370409
#endif
371410
#else
411+
#ifdef cl_intel_subgroups_short
412+
#error "Incorrect cl_intel_subgroups_short define"
413+
#endif
372414
// expected-warning@+2{{unsupported OpenCL extension 'cl_intel_subgroups_short' - ignoring}}
373415
#endif
374416
#pragma OPENCL EXTENSION cl_intel_subgroups_short : enable
@@ -377,13 +419,25 @@
377419
#ifndef cl_intel_subgroup_buffer_prefetch
378420
#error "Missing cl_intel_subgroup_buffer_prefetch define"
379421
#endif
422+
#else
423+
#ifdef cl_intel_subgroup_buffer_prefetch
424+
#error "Incorrect cl_intel_subgroup_buffer_prefetch define"
425+
#endif
380426
#endif
427+
// expected-warning@+1{{OpenCL extension 'cl_intel_subgroup_buffer_prefetch' unknown or does not require pragma - ignoring}}
428+
#pragma OPENCL EXTENSION cl_intel_subgroup_buffer_prefetch : enable
381429

382430
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
383431
#ifndef cl_intel_subgroup_local_block_io
384432
#error "Missing cl_intel_subgroup_local_block_io define"
385433
#endif
434+
#else
435+
#ifdef cl_intel_subgroup_local_block_io
436+
#error "Incorrect cl_intel_subgroup_local_block_io define"
437+
#endif
386438
#endif
439+
// expected-warning@+1{{OpenCL extension 'cl_intel_subgroup_local_block_io' unknown or does not require pragma - ignoring}}
440+
#pragma OPENCL EXTENSION cl_intel_subgroup_local_block_io : enable
387441

388442
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
389443
#ifndef cl_intel_device_side_avc_motion_estimation
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// 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
2+
// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -finclude-default-header -cl-std=CL3.0 %s
3+
4+
#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)
5+
// expected-no-diagnostics
6+
#endif
7+
8+
uint test1(read_only image2d_t im, int2 i) {
9+
return intel_sub_group_block_read(im, i);
10+
}
11+
#if !defined(cl_intel_subgroups)
12+
// expected-error@-3{{use of undeclared identifier 'intel_sub_group_block_read'}}
13+
#endif
14+
15+
void test2(const __global uint *p) {
16+
return intel_sub_group_block_prefetch_ui(p);
17+
}
18+
#if !defined(cl_intel_subgroup_buffer_prefetch)
19+
// expected-error@-3{{use of undeclared identifier 'intel_sub_group_block_prefetch_ui'}}
20+
#endif
21+
22+
uchar test3(read_only image2d_t im, int2 i) {
23+
return intel_sub_group_block_read_uc(im, i);
24+
}
25+
#if !defined(cl_intel_subgroups_char)
26+
// expected-error@-3{{use of undeclared identifier 'intel_sub_group_block_read_uc'}}
27+
#endif
28+
29+
ushort test4(const __local ushort* p) {
30+
return intel_sub_group_block_read_us(p);
31+
}
32+
#if !defined(cl_intel_subgroups_short)
33+
// expected-error@-3{{use of undeclared identifier 'intel_sub_group_block_read_us'}}
34+
#endif
35+
36+
ulong test5(const __global ulong* p) {
37+
return intel_sub_group_block_read_ul(p);
38+
}
39+
#if !defined(cl_intel_subgroups_long)
40+
// expected-error@-3{{use of undeclared identifier 'intel_sub_group_block_read_ul'}}
41+
#endif
42+
43+
ushort test6(float f) {
44+
return intel_convert_bfloat16_as_ushort(f);
45+
}
46+
#if !defined(cl_intel_bfloat16_conversions)
47+
// expected-error@-3{{use of undeclared identifier 'intel_convert_bfloat16_as_ushort'}}
48+
#endif
49+
50+
uint test7(const __local uint* p) {
51+
return intel_sub_group_block_read(p);
52+
}
53+
#if !defined(cl_intel_subgroup_local_block_io)
54+
// expected-error@-3{{use of undeclared identifier 'intel_sub_group_block_read'}}
55+
#endif
56+
57+
uchar test8(uchar slice_type, uchar qp) {
58+
return intel_sub_group_avc_mce_get_default_inter_base_multi_reference_penalty(slice_type, qp);
59+
}
60+
#if !defined(cl_intel_device_side_avc_motion_estimation)
61+
// expected-error@-3{{use of undeclared identifier 'intel_sub_group_avc_mce_get_default_inter_base_multi_reference_penalty'}}
62+
#endif

0 commit comments

Comments
 (0)