[clang] [OpenCL] Add cl_khr_fp64 guard for atomic_double/double in cl_ext_float_atomics functions (PR #169252)
Wenju He via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 23 14:51:02 PST 2025
https://github.com/wenju-he created https://github.com/llvm/llvm-project/pull/169252
Fix kernel build when cl_khr_fp64 is not enabled:
opencl-c.h:13785:50: error: unknown type name 'atomic_double'
13785 | double __ovld atomic_fetch_min(volatile __global atomic_double *, double);
opencl-c.h:13785:67: error: use of type 'double' requires cl_khr_fp64 and __opencl_c_fp64 support
13785 | double __ovld atomic_fetch_min(volatile __global atomic_double *, double);
This is a regression introduced by 423bdb2b. Before that commit, __opencl_c_ext_fp64_global_atomic_add was guarded by cl_khr_fp64 in opencl-c-base.h.
>From 9dddf5de8a06b30bfb2647045a328e9d12fd9567 Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Sun, 23 Nov 2025 14:50:16 -0800
Subject: [PATCH] [OpenCL] Add cl_khr_fp64 guard for atomic_double/double in
cl_ext_float_atomics functions
Fix kernel build when cl_khr_fp64 is not enabled:
opencl-c.h:13785:50: error: unknown type name 'atomic_double'
13785 | double __ovld atomic_fetch_min(volatile __global atomic_double *, double);
opencl-c.h:13785:67: error: use of type 'double' requires cl_khr_fp64 and __opencl_c_fp64 support
13785 | double __ovld atomic_fetch_min(volatile __global atomic_double *, double);
This is a regression introduced by 423bdb2b. Before that commit,
__opencl_c_ext_fp64_global_atomic_add was guarded by cl_khr_fp64 in opencl-c-base.h.
---
clang/lib/Headers/opencl-c.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index f65b4b314cffd..39f91c139496e 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -13781,6 +13781,7 @@ float __ovld atomic_fetch_max_explicit(volatile atomic_float *,
defined(__opencl_c_ext_fp32_local_atomic_min_max)
#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
+#ifdef cl_khr_fp64
#if defined(__opencl_c_ext_fp64_global_atomic_min_max)
double __ovld atomic_fetch_min(volatile __global atomic_double *, double);
double __ovld atomic_fetch_max(volatile __global atomic_double *, double);
@@ -13821,6 +13822,7 @@ double __ovld atomic_fetch_max_explicit(volatile atomic_double *,
double, memory_order, memory_scope);
#endif // defined(__opencl_c_ext_fp64_global_atomic_min_max) && \
defined(__opencl_c_ext_fp64_local_atomic_min_max)
+#endif // cl_khr_fp64
#endif // defined(cl_khr_int64_base_atomics) && \
defined(cl_khr_int64_extended_atomics)
@@ -13907,6 +13909,7 @@ float __ovld atomic_fetch_sub_explicit(volatile atomic_float *,
defined(__opencl_c_ext_fp32_local_atomic_add)
#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
+#ifdef cl_khr_fp64
#if defined(__opencl_c_ext_fp64_global_atomic_add)
double __ovld atomic_fetch_add(volatile __global atomic_double *, double);
double __ovld atomic_fetch_sub(volatile __global atomic_double *, double);
@@ -13947,6 +13950,7 @@ double __ovld atomic_fetch_sub_explicit(volatile atomic_double *,
double, memory_order, memory_scope);
#endif // defined(__opencl_c_ext_fp64_global_atomic_add) && \
defined(__opencl_c_ext_fp64_local_atomic_add)
+#endif // cl_khr_fp64
#endif // defined(cl_khr_int64_base_atomics) && \
defined(cl_khr_int64_extended_atomics)
More information about the cfe-commits
mailing list