[PATCH] D118999: [OpenCL] Adjust diagnostic for subgroup support.
Anton Zabaznov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 4 07:32:52 PST 2022
azabaznov created this revision.
azabaznov added reviewers: Anastasia, svenvh.
Herald added subscribers: Naghasan, ldrumm, yaxunl.
azabaznov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D118999
Files:
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaChecking.cpp
clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
Index: clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
===================================================================
--- clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
+++ clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
@@ -236,12 +236,12 @@
kernel void foo1(global unsigned int *buf)
{
ndrange_t n;
- 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}}
+ 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 support of cl_khr_subgroups extension or __opencl_c_subgroups OpenCL C 3.0 feature}}
}
kernel void bar1(global unsigned int *buf)
{
ndrange_t n;
- 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}}
+ buf[0] = get_kernel_sub_group_count_for_ndrange(n, ^(){}); // expected-error {{use of declaration 'get_kernel_sub_group_count_for_ndrange' requires support of cl_khr_subgroups extension or __opencl_c_subgroups OpenCL C 3.0 feature}}
}
#endif // ifdef cl_khr_subgroups
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1042,9 +1042,11 @@
}
static bool checkOpenCLSubgroupExt(Sema &S, CallExpr *Call) {
- if (!S.getOpenCLOptions().isSupported("cl_khr_subgroups", S.getLangOpts())) {
- S.Diag(Call->getBeginLoc(), diag::err_opencl_requires_extension)
- << 1 << Call->getDirectCallee() << "cl_khr_subgroups";
+ if (!S.getOpenCLOptions().isSupported("cl_khr_subgroups", S.getLangOpts()) &&
+ !S.getOpenCLOptions().isSupported("__opencl_c_subgroups",
+ S.getLangOpts())) {
+ S.Diag(Call->getBeginLoc(), diag::err_opencl_requires_subgroups)
+ << 1 << Call->getDirectCallee();
return true;
}
return false;
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10175,6 +10175,9 @@
"invalid prototype, variadic arguments are not allowed in OpenCL">;
def err_opencl_requires_extension : Error<
"use of %select{type|declaration}0 %1 requires %2 support">;
+def err_opencl_requires_subgroups : Error<
+ "use of %select{type|declaration}0 %1 requires support of cl_khr_subgroups extension "
+ "or __opencl_c_subgroups OpenCL C 3.0 feature">;
def ext_opencl_double_without_pragma : Extension<
"Clang permits use of type 'double' regardless pragma if 'cl_khr_fp64' is"
" supported">;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118999.405965.patch
Type: text/x-patch
Size: 2873 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220204/2e441cb5/attachment.bin>
More information about the cfe-commits
mailing list