[PATCH] D100984: [OpenCL] Remove the need for subgroupd extension pragma in enqueue kernel builtins

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 21 11:39:02 PDT 2021


Anastasia created this revision.
Anastasia added reviewers: svenvh, azabaznov, mantognini.
Herald added subscribers: ebevhan, yaxunl.
Anastasia requested review of this revision.

There is no extension pragma requirement in the spec for these functions and all other builtin functions are available without the pragama.

This patch simplifies the parser and makes the language semantics consistent.


https://reviews.llvm.org/D100984

Files:
  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
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS=
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS= -cl-ext=-cl_khr_subgroups
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS="const volatile"
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS=
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS="const volatile"
@@ -212,8 +213,8 @@
   size = get_kernel_preferred_work_group_size_multiple(block_A, 1); // expected-error{{too many arguments to function call, expected 1, have 2}}
 }
 
+#ifdef cl_khr_subgroups
 #pragma OPENCL EXTENSION cl_khr_subgroups : enable
-
 kernel void foo(global unsigned int *buf)
 {
   ndrange_t n;
@@ -231,7 +232,7 @@
 }
 
 #pragma OPENCL EXTENSION cl_khr_subgroups : disable
-
+#else
 kernel void foo1(global unsigned int *buf)
 {
   ndrange_t n;
@@ -243,3 +244,4 @@
   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}}
 }
+#endif // ifdef cl_khr_subgroups
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -838,8 +838,7 @@
 }
 
 static bool checkOpenCLSubgroupExt(Sema &S, CallExpr *Call) {
-  if (!S.getOpenCLOptions().isAvailableOption("cl_khr_subgroups",
-                                              S.getLangOpts())) {
+  if (!S.getOpenCLOptions().isSupported("cl_khr_subgroups", S.getLangOpts())) {
     S.Diag(Call->getBeginLoc(), diag::err_opencl_requires_extension)
         << 1 << Call->getDirectCallee() << "cl_khr_subgroups";
     return true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100984.339333.patch
Type: text/x-patch
Size: 2263 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210421/93fe8167/attachment.bin>


More information about the cfe-commits mailing list