[Beignet] [PATCH 3/4] libocl: add get_fence() builtin.

xionghu.luo at intel.com xionghu.luo at intel.com
Mon Jan 18 19:29:08 PST 2016


From: Ruiling Song <ruiling.song at intel.com>

Signed-off-by: Ruiling Song <ruiling.song at intel.com>
---
 backend/src/libocl/include/ocl_sync.h | 2 +-
 backend/src/libocl/src/ocl_sync.cl    | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/backend/src/libocl/include/ocl_sync.h b/backend/src/libocl/include/ocl_sync.h
index 18090d5..3e62026 100644
--- a/backend/src/libocl/include/ocl_sync.h
+++ b/backend/src/libocl/include/ocl_sync.h
@@ -31,5 +31,5 @@ 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);
 void write_mem_fence(cl_mem_fence_flags flags);
-
+cl_mem_fence_flags get_fence(void *ptr);
 #endif  /* __OCL_SYNC_H__ */
diff --git a/backend/src/libocl/src/ocl_sync.cl b/backend/src/libocl/src/ocl_sync.cl
index d008639..f4459f4 100644
--- a/backend/src/libocl/src/ocl_sync.cl
+++ b/backend/src/libocl/src/ocl_sync.cl
@@ -16,6 +16,7 @@
  *
  */
 #include "ocl_sync.h"
+#include "ocl_misc.h"
 
 void __gen_ocl_barrier_local(void);
 void __gen_ocl_barrier_global(void);
@@ -29,3 +30,7 @@ void read_mem_fence(cl_mem_fence_flags flags) {
 
 void write_mem_fence(cl_mem_fence_flags flags) {
 }
+cl_mem_fence_flags get_fence(void *ptr) {
+  bool cond = __gen_ocl_in_local((size_t)ptr);
+  return cond ? CLK_LOCAL_MEM_FENCE : CLK_GLOBAL_MEM_FENCE;
+}
-- 
2.4.1



More information about the Beignet mailing list