From 477bc8e8b9311fdac4c360b1fe7d29d0d10aac6c Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Wed, 16 Feb 2022 10:07:35 +0000 Subject: [PATCH] [OpenCL] Guard atomic_double with cl_khr_int64_* It is necessary to guard atomic_double type according to https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_C.html#_footnotedef_54. Platform that disable cl_khr_int64_base_atomics and cl_khr_int64_extended_atomics will have compiling errors even if atomic_double is not used. Patch by Haonan Yang. Differential Revision: https://reviews.llvm.org/D119398 --- clang/lib/Headers/opencl-c.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h index 7a2ddc4..bf3f012 100644 --- a/clang/lib/Headers/opencl-c.h +++ b/clang/lib/Headers/opencl-c.h @@ -13832,6 +13832,7 @@ float __ovld atomic_fetch_max_explicit(volatile atomic_float *object, #endif // defined(__opencl_c_ext_fp32_global_atomic_min_max) && \ defined(__opencl_c_ext_fp32_local_atomic_min_max) +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) #if defined(__opencl_c_ext_fp64_global_atomic_min_max) double __ovld atomic_fetch_min(volatile __global atomic_double *object, double operand); @@ -13882,6 +13883,8 @@ double __ovld atomic_fetch_max_explicit(volatile atomic_double *object, memory_scope scope); #endif // defined(__opencl_c_ext_fp64_global_atomic_min_max) && \ defined(__opencl_c_ext_fp64_local_atomic_min_max) +#endif // defined(cl_khr_int64_base_atomics) && \ + defined(cl_khr_int64_extended_atomics) #if defined(__opencl_c_ext_fp16_global_atomic_add) half __ovld atomic_fetch_add(volatile __global atomic_half *object, @@ -13985,6 +13988,7 @@ float __ovld atomic_fetch_sub_explicit(volatile atomic_float *object, #endif // defined(__opencl_c_ext_fp32_global_atomic_add) && \ defined(__opencl_c_ext_fp32_local_atomic_add) +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) #if defined(__opencl_c_ext_fp64_global_atomic_add) double __ovld atomic_fetch_add(volatile __global atomic_double *object, double operand); @@ -14035,6 +14039,8 @@ double __ovld atomic_fetch_sub_explicit(volatile atomic_double *object, memory_scope scope); #endif // defined(__opencl_c_ext_fp64_global_atomic_add) && \ defined(__opencl_c_ext_fp64_local_atomic_add) +#endif // defined(cl_khr_int64_base_atomics) && \ + defined(cl_khr_int64_extended_atomics) #endif // cl_ext_float_atomics -- 2.7.4