airlied created this revision.
airlied added a project: clang.
Herald added subscribers: ldrumm, jfb, Anastasia, yaxunl.
airlied requested review of this revision.
Herald added a subscriber: cfe-commits.

This adds the optional wrappers around things, however this isn't sufficient 
yet for CL 3.0 without generic address space, I've got one more additional 
patch to add all those APIs, but this is an easier to review precursor.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106111

Files:
  clang/lib/Headers/opencl-c.h

Index: clang/lib/Headers/opencl-c.h
===================================================================
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -13304,7 +13304,10 @@
 void __ovld atomic_work_item_fence(cl_mem_fence_flags flags, memory_order order, memory_scope scope);
 
 // atomic_fetch()
+// OpenCL v2.0 s6.13.11.7.5:
+// add/sub: atomic type argument can be uintptr_t/intptr_t, value type argument can be ptrdiff_t.
 
+#if defined(__opencl_c_atomic_order_seq_cst) && defined(__opencl_c_atomic_scope_device)
 int __ovld atomic_fetch_add(volatile atomic_int *object, int operand);
 uint __ovld atomic_fetch_add(volatile atomic_uint *object, uint operand);
 int __ovld atomic_fetch_sub(volatile atomic_int *object, int operand);
@@ -13335,16 +13338,12 @@
 ulong __ovld atomic_fetch_min(volatile atomic_ulong *object, ulong operand);
 long __ovld atomic_fetch_max(volatile atomic_long *object, long operand);
 ulong __ovld atomic_fetch_max(volatile atomic_ulong *object, ulong operand);
-#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
-
-// OpenCL v2.0 s6.13.11.7.5:
-// add/sub: atomic type argument can be uintptr_t/intptr_t, value type argument can be ptrdiff_t.
-
-#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
 uintptr_t __ovld atomic_fetch_add(volatile atomic_uintptr_t *object, ptrdiff_t operand);
 uintptr_t __ovld atomic_fetch_sub(volatile atomic_uintptr_t *object, ptrdiff_t operand);
+#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
 #endif
 
+#if defined(__opencl_c_atomic_scope_device)
 int __ovld atomic_fetch_add_explicit(volatile atomic_int *object, int operand, memory_order order);
 uint __ovld atomic_fetch_add_explicit(volatile atomic_uint *object, uint operand, memory_order order);
 int __ovld atomic_fetch_sub_explicit(volatile atomic_int *object, int operand, memory_order order);
@@ -13374,10 +13373,9 @@
 ulong __ovld atomic_fetch_min_explicit(volatile atomic_ulong *object, ulong operand, memory_order order);
 long __ovld atomic_fetch_max_explicit(volatile atomic_long *object, long operand, memory_order order);
 ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong *object, ulong operand, memory_order order);
-#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
-#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
 uintptr_t __ovld atomic_fetch_add_explicit(volatile atomic_uintptr_t *object, ptrdiff_t operand, memory_order order);
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object, ptrdiff_t operand, memory_order order);
+#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
 #endif
 
 int __ovld atomic_fetch_add_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope);
@@ -13417,6 +13415,7 @@
 
 // atomic_store()
 
+#if defined(__opencl_c_atomic_order_seq_cst) && defined(__opencl_c_atomic_scope_device)
 void __ovld atomic_store(volatile atomic_int *object, int desired);
 void __ovld atomic_store(volatile atomic_uint *object, uint desired);
 void __ovld atomic_store(volatile atomic_float *object, float desired);
@@ -13428,7 +13427,9 @@
 void __ovld atomic_store(volatile atomic_long *object, long desired);
 void __ovld atomic_store(volatile atomic_ulong *object, ulong desired);
 #endif
+#endif
 
+#if defined(__opencl_c_atomic_scope_device)
 void __ovld atomic_store_explicit(volatile atomic_int *object, int desired, memory_order order);
 void __ovld atomic_store_explicit(volatile atomic_uint *object, uint desired, memory_order order);
 void __ovld atomic_store_explicit(volatile atomic_float *object, float desired, memory_order order);
@@ -13439,6 +13440,7 @@
 void __ovld atomic_store_explicit(volatile atomic_long *object, long desired, memory_order order);
 void __ovld atomic_store_explicit(volatile atomic_ulong *object, ulong desired, memory_order order);
 #endif
+#endif
 
 void __ovld atomic_store_explicit(volatile atomic_int *object, int desired, memory_order order, memory_scope scope);
 void __ovld atomic_store_explicit(volatile atomic_uint *object, uint desired, memory_order order, memory_scope scope);
@@ -13452,7 +13454,7 @@
 #endif
 
 // atomic_load()
-
+#if defined(__opencl_c_atomic_order_seq_cst) && defined(__opencl_c_atomic_scope_device)
 int __ovld atomic_load(volatile atomic_int *object);
 uint __ovld atomic_load(volatile atomic_uint *object);
 float __ovld atomic_load(volatile atomic_float *object);
@@ -13463,7 +13465,9 @@
 long __ovld atomic_load(volatile atomic_long *object);
 ulong __ovld atomic_load(volatile atomic_ulong *object);
 #endif
+#endif
 
+#if defined(__opencl_c_atomic_scope_device)
 int __ovld atomic_load_explicit(volatile atomic_int *object, memory_order order);
 uint __ovld atomic_load_explicit(volatile atomic_uint *object, memory_order order);
 float __ovld atomic_load_explicit(volatile atomic_float *object, memory_order order);
@@ -13474,6 +13478,7 @@
 long __ovld atomic_load_explicit(volatile atomic_long *object, memory_order order);
 ulong __ovld atomic_load_explicit(volatile atomic_ulong *object, memory_order order);
 #endif
+#endif
 
 int __ovld atomic_load_explicit(volatile atomic_int *object, memory_order order, memory_scope scope);
 uint __ovld atomic_load_explicit(volatile atomic_uint *object, memory_order order, memory_scope scope);
@@ -13488,6 +13493,7 @@
 
 // atomic_exchange()
 
+#if defined(__opencl_c_atomic_order_seq_cst) && defined(__opencl_c_atomic_scope_device)
 int __ovld atomic_exchange(volatile atomic_int *object, int desired);
 uint __ovld atomic_exchange(volatile atomic_uint *object, uint desired);
 float __ovld atomic_exchange(volatile atomic_float *object, float desired);
@@ -13498,7 +13504,9 @@
 long __ovld atomic_exchange(volatile atomic_long *object, long desired);
 ulong __ovld atomic_exchange(volatile atomic_ulong *object, ulong desired);
 #endif
+#endif
 
+#if defined(__opencl_c_atomic_scope_device)
 int __ovld atomic_exchange_explicit(volatile atomic_int *object, int desired, memory_order order);
 uint __ovld atomic_exchange_explicit(volatile atomic_uint *object, uint desired, memory_order order);
 float __ovld atomic_exchange_explicit(volatile atomic_float *object, float desired, memory_order order);
@@ -13509,6 +13517,7 @@
 long __ovld atomic_exchange_explicit(volatile atomic_long *object, long desired, memory_order order);
 ulong __ovld atomic_exchange_explicit(volatile atomic_ulong *object, ulong desired, memory_order order);
 #endif
+#endif
 
 int __ovld atomic_exchange_explicit(volatile atomic_int *object, int desired, memory_order order, memory_scope scope);
 uint __ovld atomic_exchange_explicit(volatile atomic_uint *object, uint desired, memory_order order, memory_scope scope);
@@ -13522,7 +13531,7 @@
 #endif
 
 // atomic_compare_exchange_strong() and atomic_compare_exchange_weak()
-
+#if defined(__opencl_c_atomic_order_seq_cst) && defined(__opencl_c_atomic_scope_device)
 bool __ovld atomic_compare_exchange_strong(volatile atomic_int *object, int *expected, int desired);
 bool __ovld atomic_compare_exchange_strong(volatile atomic_uint *object, uint *expected, uint desired);
 bool __ovld atomic_compare_exchange_weak(volatile atomic_int *object, int *expected, int desired);
@@ -13540,6 +13549,7 @@
 bool __ovld atomic_compare_exchange_strong(volatile atomic_ulong *object, ulong *expected, ulong desired);
 bool __ovld atomic_compare_exchange_weak(volatile atomic_ulong *object, ulong *expected, ulong desired);
 #endif
+#endif
 
 bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_int *object, int *expected,
                                                                                  int desired, memory_order success, memory_order failure);
@@ -13600,12 +13610,15 @@
 #endif
 
 // atomic_flag_test_and_set() and atomic_flag_clear()
-
+#if defined(__opencl_c_atomic_order_seq_cst) && defined(__opencl_c_atomic_scope_device)
 bool __ovld atomic_flag_test_and_set(volatile atomic_flag *object);
 void __ovld atomic_flag_clear(volatile atomic_flag *object);
+#endif
 
+#if defined(__opencl_c_atomic_scope_device)
 bool __ovld atomic_flag_test_and_set_explicit(volatile atomic_flag *object, memory_order order);
 void __ovld atomic_flag_clear_explicit(volatile atomic_flag *object, memory_order order);
+#endif
 
 bool __ovld atomic_flag_test_and_set_explicit(volatile atomic_flag *object, memory_order order, memory_scope scope);
 void __ovld atomic_flag_clear_explicit(volatile atomic_flag *object, memory_order order, memory_scope scope);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to