Skip to content

Commit 7bb1dfe

Browse files
azabaznotstellar
authored andcommitted
[OpenCL] Adjust diagnostic for subgroup support.
OpenCL C 3.0 __opencl_c_subgroups feature is slightly different then other equivalent features and extensions (fp64 and 3d image writes): OpenCL C 3.0 device can support the extension but not the feature. cl_khr_subgroups requires subgroup independent forward progress. This patch adjusts the check which is used when translating language builtins to check either the extension or feature is supported. Reviewed By: Anastasia Differential Revision: https://reviews.llvm.org/D118999 (cherry picked from commit bfb1a33)
1 parent 95dd9c5 commit 7bb1dfe

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

clang/lib/Sema/SemaChecking.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,9 +1042,15 @@ static bool checkOpenCLBlockArgs(Sema &S, Expr *BlockArg) {
10421042
}
10431043

10441044
static bool checkOpenCLSubgroupExt(Sema &S, CallExpr *Call) {
1045-
if (!S.getOpenCLOptions().isSupported("cl_khr_subgroups", S.getLangOpts())) {
1045+
// OpenCL device can support extension but not the feature as extension
1046+
// requires subgroup independent forward progress, but subgroup independent
1047+
// forward progress is optional in OpenCL C 3.0 __opencl_c_subgroups feature.
1048+
if (!S.getOpenCLOptions().isSupported("cl_khr_subgroups", S.getLangOpts()) &&
1049+
!S.getOpenCLOptions().isSupported("__opencl_c_subgroups",
1050+
S.getLangOpts())) {
10461051
S.Diag(Call->getBeginLoc(), diag::err_opencl_requires_extension)
1047-
<< 1 << Call->getDirectCallee() << "cl_khr_subgroups";
1052+
<< 1 << Call->getDirectCallee()
1053+
<< "cl_khr_subgroups or __opencl_c_subgroups";
10481054
return true;
10491055
}
10501056
return false;

clang/test/SemaOpenCL/cl20-device-side-enqueue.cl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS=
55
// RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS="const volatile"
66
// RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS=
7-
// RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS= -cl-ext=-cl_khr_subgroups
7+
// RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS= -cl-ext=-cl_khr_subgroups,-__opencl_c_subgroups
88
// RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS="const volatile"
99
// RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS=
1010
// RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS="const volatile"
@@ -241,12 +241,12 @@ kernel void bar(global unsigned int *buf)
241241
kernel void foo1(global unsigned int *buf)
242242
{
243243
ndrange_t n;
244-
buf[0] = get_kernel_max_sub_group_size_for_ndrange(n, ^(){}); // expected-error {{use of declaration 'get_kernel_max_sub_group_size_for_ndrange' requires cl_khr_subgroups support}}
244+
buf[0] = get_kernel_max_sub_group_size_for_ndrange(n, ^(){}); // expected-error {{use of declaration 'get_kernel_max_sub_group_size_for_ndrange' requires cl_khr_subgroups or __opencl_c_subgroups support}}
245245
}
246246

247247
kernel void bar1(global unsigned int *buf)
248248
{
249249
ndrange_t n;
250-
buf[0] = get_kernel_sub_group_count_for_ndrange(n, ^(){}); // expected-error {{use of declaration 'get_kernel_sub_group_count_for_ndrange' requires cl_khr_subgroups support}}
250+
buf[0] = get_kernel_sub_group_count_for_ndrange(n, ^(){}); // expected-error {{use of declaration 'get_kernel_sub_group_count_for_ndrange' requires cl_khr_subgroups or __opencl_c_subgroups support}}
251251
}
252252
#endif // ifdef cl_khr_subgroups

0 commit comments

Comments
 (0)