[Beignet] [PATCH 3/8] [OCL20]cl_mem_fence_flags definiton change from MACRO to enum

xionghu.luo at intel.com xionghu.luo at intel.com
Tue Mar 1 11:26:51 UTC 2016


From: Luo Xionghu <xionghu.luo at intel.com>

also add definition for memory_order and memory_scope.
v2: still use MACRO to define cl_mem_fence_flags as the value could be
combined like (CLK_GLOBAL_MEM_FENCE|CLK_LOCAL_MEM_FENCE) that the enum
not supported
v3: move the EXTENSION definition to another patch.

Signed-off-by: Luo Xionghu <xionghu.luo at intel.com>
---
 backend/src/libocl/include/ocl_sync.h  |  4 ----
 backend/src/libocl/include/ocl_types.h | 28 ++++++++++++++++++++++++++++
 backend/src/ocl_common_defines.h       |  6 +-----
 3 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/backend/src/libocl/include/ocl_sync.h b/backend/src/libocl/include/ocl_sync.h
index 3e62026..2ea1183 100644
--- a/backend/src/libocl/include/ocl_sync.h
+++ b/backend/src/libocl/include/ocl_sync.h
@@ -23,10 +23,6 @@
 /////////////////////////////////////////////////////////////////////////////
 // Synchronization functions
 /////////////////////////////////////////////////////////////////////////////
-#define CLK_LOCAL_MEM_FENCE  (1 << 0)
-#define CLK_GLOBAL_MEM_FENCE (1 << 1)
-
-typedef uint cl_mem_fence_flags;
 OVERLOADABLE void barrier(cl_mem_fence_flags flags);
 void mem_fence(cl_mem_fence_flags flags);
 void read_mem_fence(cl_mem_fence_flags flags);
diff --git a/backend/src/libocl/include/ocl_types.h b/backend/src/libocl/include/ocl_types.h
index eb4c3b4..736e4ce 100644
--- a/backend/src/libocl/include/ocl_types.h
+++ b/backend/src/libocl/include/ocl_types.h
@@ -84,6 +84,34 @@ DEF(half);
 #undef DEF
 
 /////////////////////////////////////////////////////////////////////////////
+// OpenCL atomic related types
+/////////////////////////////////////////////////////////////////////////////
+//atomic flags
+#define CLK_LOCAL_MEM_FENCE  (1 << 0)
+#define CLK_GLOBAL_MEM_FENCE (1 << 1)
+#define  CLK_IMAGE_MEM_FENCE (1 << 2)
+
+typedef uint cl_mem_fence_flags;
+
+//memory order
+typedef enum {
+	memory_order_relaxed,
+	memory_order_acquire,
+	memory_order_release,
+	memory_order_acq_rel,
+	memory_order_seq_cst
+} memory_order;
+
+//memory scope
+typedef enum {
+	memory_scope_work_item,
+	memory_scope_work_group,
+	memory_scope_device,
+	memory_scope_all_svm_devices,
+	memory_scope_sub_group,
+} memory_scope;
+
+/////////////////////////////////////////////////////////////////////////////
 // OpenCL built-in event types
 /////////////////////////////////////////////////////////////////////////////
 // FIXME:
diff --git a/backend/src/ocl_common_defines.h b/backend/src/ocl_common_defines.h
index 52f5365..cb9190a 100644
--- a/backend/src/ocl_common_defines.h
+++ b/backend/src/ocl_common_defines.h
@@ -119,8 +119,4 @@ typedef enum clk_sampler_type {
 
 } clk_sampler_type;
 
-// Memory synchronization
-#define CLK_LOCAL_MEM_FENCE     (1 << 0)
-#define CLK_GLOBAL_MEM_FENCE    (1 << 1)
-
-#endif   /* __OCL_COMMON_DEFINES__ */
\ No newline at end of file
+#endif   /* __OCL_COMMON_DEFINES__ */
-- 
2.1.4



More information about the Beignet mailing list