[clang] [libclc] [AMDGPU][libclc] Enable cl_khr_subgroup_non_uniform_arithmetic and use in libclc (PR #200747)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 1 01:02:06 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-amdgpu
Author: Wenju He (wenju-he)
<details>
<summary>Changes</summary>
Per OpenCL spec, sub_group_non_uniform_reduce_* functions requires support for the cl_khr_subgroup_non_uniform_arithmetic extension.
---
Full diff: https://github.com/llvm/llvm-project/pull/200747.diff
3 Files Affected:
- (modified) clang/lib/Basic/Targets/AMDGPU.h (+1)
- (modified) clang/test/Misc/amdgcn.languageOptsOpenCL.cl (+4)
- (modified) libclc/opencl/lib/generic/subgroup/sub_group_non_uniform_reduce.cl (+4)
``````````diff
diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h
index f1bfca4c42417..29327067dbbff 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -324,6 +324,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
Opts["cl_khr_mipmap_image"] = true;
Opts["cl_khr_mipmap_image_writes"] = true;
Opts["cl_khr_subgroups"] = true;
+ Opts["cl_khr_subgroup_non_uniform_arithmetic"] = true;
Opts["cl_amd_media_ops"] = true;
Opts["cl_amd_media_ops2"] = true;
diff --git a/clang/test/Misc/amdgcn.languageOptsOpenCL.cl b/clang/test/Misc/amdgcn.languageOptsOpenCL.cl
index 5e611329b518d..3971bb99b113d 100644
--- a/clang/test/Misc/amdgcn.languageOptsOpenCL.cl
+++ b/clang/test/Misc/amdgcn.languageOptsOpenCL.cl
@@ -158,6 +158,10 @@
#endif
#pragma OPENCL EXTENSION cl_khr_subgroups: enable
+#ifndef cl_khr_subgroup_non_uniform_arithmetic
+#error "Missing cl_khr_subgroup_non_uniform_arithmetic define"
+#endif
+
#ifndef cl_amd_media_ops
#error "Missing cl_amd_media_ops define"
#endif
diff --git a/libclc/opencl/lib/generic/subgroup/sub_group_non_uniform_reduce.cl b/libclc/opencl/lib/generic/subgroup/sub_group_non_uniform_reduce.cl
index e00717b979ea1..d46afb88afa59 100644
--- a/libclc/opencl/lib/generic/subgroup/sub_group_non_uniform_reduce.cl
+++ b/libclc/opencl/lib/generic/subgroup/sub_group_non_uniform_reduce.cl
@@ -8,6 +8,8 @@
#include "clc/subgroup/clc_sub_group_non_uniform_reduce.h"
+#ifdef cl_khr_subgroup_non_uniform_arithmetic
+
#define __CLC_BODY "sub_group_non_uniform_reduce.inc"
#include "clc/integer/gentype.inc"
@@ -28,3 +30,5 @@ _CLC_DEF _CLC_OVERLOAD int
sub_group_non_uniform_reduce_logical_xor(int predicate) {
return __clc_sub_group_non_uniform_reduce_logical_xor(predicate);
}
+
+#endif // cl_khr_subgroup_non_uniform_arithmetic
``````````
</details>
https://github.com/llvm/llvm-project/pull/200747
More information about the cfe-commits
mailing list