Skip to content

Commit

Permalink
[OpenCL] Guard atomic_double with cl_khr_int64_*
Browse files Browse the repository at this point in the history
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

(cherry picked from commit 477bc8e)
  • Loading branch information
svenvh authored and tstellar committed Feb 17, 2022
1 parent 880717c commit 1e348e6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions clang/lib/Headers/opencl-c.h
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 1e348e6

Please sign in to comment.