[clang] a7d0177 - [OpenCL] Add cl_khr_subgroup_clustered_reduce to TableGen BIFs
Sven van Haastregt via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 10 01:45:23 PST 2021
Author: Sven van Haastregt
Date: 2021-02-10T09:44:52Z
New Revision: a7d01772ac370bfc5ef1838c8d18b7be070edfbe
URL: https://github.com/llvm/llvm-project/commit/a7d01772ac370bfc5ef1838c8d18b7be070edfbe
DIFF: https://github.com/llvm/llvm-project/commit/a7d01772ac370bfc5ef1838c8d18b7be070edfbe.diff
LOG: [OpenCL] Add cl_khr_subgroup_clustered_reduce to TableGen BIFs
Add the builtin functions brought by the
cl_khr_subgroup_clustered_reduce extension to
`-fdeclare-opencl-builtins`.
Added:
Modified:
clang/lib/Sema/OpenCLBuiltins.td
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
Removed:
################################################################################
diff --git a/clang/lib/Sema/OpenCLBuiltins.td b/clang/lib/Sema/OpenCLBuiltins.td
index 1a58747c4017..0e10722eee34 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -58,6 +58,7 @@ def FuncExtKhrSubgroupBallot : FunctionExtension<"cl_khr_subgroup_ba
def FuncExtKhrSubgroupNonUniformArithmetic: FunctionExtension<"cl_khr_subgroup_non_uniform_arithmetic">;
def FuncExtKhrSubgroupShuffle : FunctionExtension<"cl_khr_subgroup_shuffle">;
def FuncExtKhrSubgroupShuffleRelative : FunctionExtension<"cl_khr_subgroup_shuffle_relative">;
+def FuncExtKhrSubgroupClusteredReduce : FunctionExtension<"cl_khr_subgroup_clustered_reduce">;
def FuncExtKhrGlobalInt32BaseAtomics : FunctionExtension<"cl_khr_global_int32_base_atomics">;
def FuncExtKhrGlobalInt32ExtendedAtomics : FunctionExtension<"cl_khr_global_int32_extended_atomics">;
def FuncExtKhrLocalInt32BaseAtomics : FunctionExtension<"cl_khr_local_int32_base_atomics">;
@@ -1551,7 +1552,17 @@ let Extension = FuncExtKhrSubgroupShuffleRelative in {
}
// Section 38.10.1 - cl_khr_subgroup_clustered_reduce
-// TODO
+let Extension = FuncExtKhrSubgroupClusteredReduce in {
+ foreach op = ["add", "min", "max", "mul"] in {
+ def : Builtin<"sub_group_clustered_reduce_" # op, [AGenType1, AGenType1, UInt]>;
+ }
+ foreach op = ["and", "or", "xor"] in {
+ def : Builtin<"sub_group_clustered_reduce_" # op, [AIGenType1, AIGenType1, UInt]>;
+ }
+ foreach op = ["and", "or", "xor"] in {
+ def : Builtin<"sub_group_clustered_reduce_logical_" # op, [Int, Int, UInt]>;
+ }
+}
//--------------------------------------------------------------------
// Arm extensions.
diff --git a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
index 93dd6fcc0a0d..6b9be37eadaf 100644
--- a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -38,6 +38,7 @@ typedef long long2 __attribute__((ext_vector_type(2)));
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
#define cl_khr_subgroup_ballot 1
#define cl_khr_subgroup_non_uniform_arithmetic 1
+#define cl_khr_subgroup_clustered_reduce 1
#endif
#endif
@@ -144,10 +145,12 @@ kernel void basic_subgroup(global uint *out) {
kernel void extended_subgroup(global uint4 *out, global int *scalar) {
out[0] = get_sub_group_eq_mask();
scalar[0] = sub_group_non_uniform_scan_inclusive_or(3);
+ scalar[1] = sub_group_clustered_reduce_logical_xor(2, 4);
#if __OPENCL_C_VERSION__ < CL_VERSION_2_0 && !defined(__OPENCL_CPP_VERSION__)
- // expected-error at -3{{implicit declaration of function 'get_sub_group_eq_mask' is invalid in OpenCL}}
- // expected-error at -4{{implicit conversion changes signedness}}
- // expected-error at -4{{implicit declaration of function 'sub_group_non_uniform_scan_inclusive_or' is invalid in OpenCL}}
+ // expected-error at -4{{implicit declaration of function 'get_sub_group_eq_mask' is invalid in OpenCL}}
+ // expected-error at -5{{implicit conversion changes signedness}}
+ // expected-error at -5{{implicit declaration of function 'sub_group_non_uniform_scan_inclusive_or' is invalid in OpenCL}}
+ // expected-error at -5{{implicit declaration of function 'sub_group_clustered_reduce_logical_xor' is invalid in OpenCL}}
#endif
}
More information about the cfe-commits
mailing list