[Beignet] [PATCH 6/8] [OCL20]libocl: atomic_float support.

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


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

atomic_exchange, atomic_store, atomic_init, atomic_load functions with
atomic_float type.

Signed-off-by: Luo Xionghu <xionghu.luo at intel.com>
---
 backend/src/libocl/include/ocl_atom.h |  2 ++
 backend/src/libocl/src/ocl_atom.cl    | 12 ++++++++++++
 backend/src/libocl/src/ocl_atomic.ll  | 12 ++++++++++++
 3 files changed, 26 insertions(+)

diff --git a/backend/src/libocl/include/ocl_atom.h b/backend/src/libocl/include/ocl_atom.h
index f83e3c0..fe35943 100644
--- a/backend/src/libocl/include/ocl_atom.h
+++ b/backend/src/libocl/include/ocl_atom.h
@@ -115,6 +115,8 @@ CTYPE __gen_ocl_atomic_compare_exchange_weak##POSTFIX(volatile ATYPE* object, CT
 
 ATOMIC_GEN_FUNCTIONS(atomic_int, int, 32)
 ATOMIC_GEN_FUNCTIONS(atomic_long, long, 64)
+float __gen_ocl_atomic_exchangef(volatile atomic_int *p, float val, int order, int scope);
+float __gen_ocl_atomic_fetch_addf(volatile atomic_int *p, float val, int order, int scope);
 
 #undef ATOMIC_GEN_FUNCTIONS
 
diff --git a/backend/src/libocl/src/ocl_atom.cl b/backend/src/libocl/src/ocl_atom.cl
index 0f8377b..57f2792 100644
--- a/backend/src/libocl/src/ocl_atom.cl
+++ b/backend/src/libocl/src/ocl_atom.cl
@@ -204,6 +204,10 @@ DECL_ATOMIC_OP_TYPE(fetch_min, fetch_imin64, atomic_long, atomic_long, long)
 DECL_ATOMIC_OP_TYPE(fetch_min, fetch_umin64, atomic_ulong, atomic_long, ulong)
 DECL_ATOMIC_OP_TYPE(fetch_max, fetch_imax64, atomic_long, atomic_long, long)
 DECL_ATOMIC_OP_TYPE(fetch_max, fetch_umax64, atomic_ulong, atomic_long, ulong)
+DECL_ATOMIC_OP_TYPE(exchange, exchangef, atomic_float, atomic_int, float)
+DECL_ATOMIC_NO_RET_TYPE(init, exchangef, atomic_float, atomic_int, float)
+DECL_ATOMIC_NO_RET_TYPE(store, exchangef, atomic_float, atomic_int, float)
+DECL_ATOMIC_LOAD_TYPE(load, fetch_addf, atomic_float, atomic_int, float)
 
 #undef DECL_ATOMIC_OP_TYPE
 #undef DECL_ATOMIC_LOAD_TYPE
@@ -253,6 +257,10 @@ DECL_ATOMIC_OP_TYPE(fetch_min_explicit, fetch_imin64, atomic_long, atomic_long,
 DECL_ATOMIC_OP_TYPE(fetch_min_explicit, fetch_umin64, atomic_ulong, atomic_long, ulong)
 DECL_ATOMIC_OP_TYPE(fetch_max_explicit, fetch_imax64, atomic_long, atomic_long, long)
 DECL_ATOMIC_OP_TYPE(fetch_max_explicit, fetch_umax64, atomic_ulong, atomic_long, ulong)
+DECL_ATOMIC_OP_TYPE(exchange_explicit, exchangef, atomic_float, atomic_int, float)
+DECL_ATOMIC_NO_RET_TYPE(init_explicit, exchangef, atomic_float, atomic_int, float)
+DECL_ATOMIC_NO_RET_TYPE(store_explicit, exchangef, atomic_float, atomic_int, float)
+DECL_ATOMIC_LOAD_TYPE(load_explicit, fetch_addf, atomic_float, atomic_int, float)
 
 #undef DECL_ATOMIC_OP_TYPE
 #undef DECL_ATOMIC_LOAD_TYPE
@@ -301,6 +309,10 @@ DECL_ATOMIC_OP_TYPE(fetch_min_explicit, fetch_imin64, atomic_long, atomic_long,
 DECL_ATOMIC_OP_TYPE(fetch_min_explicit, fetch_umin64, atomic_ulong, atomic_long, ulong)
 DECL_ATOMIC_OP_TYPE(fetch_max_explicit, fetch_imax64, atomic_long, atomic_long, long)
 DECL_ATOMIC_OP_TYPE(fetch_max_explicit, fetch_umax64, atomic_ulong, atomic_long, ulong)
+DECL_ATOMIC_OP_TYPE(exchange_explicit, exchangef, atomic_float, atomic_int, float)
+DECL_ATOMIC_NO_RET_TYPE(init_explicit, exchangef, atomic_float, atomic_int, float)
+DECL_ATOMIC_NO_RET_TYPE(store_explicit, exchangef, atomic_float, atomic_int, float)
+DECL_ATOMIC_LOAD_TYPE(load_explicit, fetch_addf, atomic_float, atomic_int, float)
 
 #undef DECL_ATOMIC_OP_TYPE
 #undef DECL_ATOMIC_LOAD_TYPE
diff --git a/backend/src/libocl/src/ocl_atomic.ll b/backend/src/libocl/src/ocl_atomic.ll
index 6b789b3..38efac0 100644
--- a/backend/src/libocl/src/ocl_atomic.ll
+++ b/backend/src/libocl/src/ocl_atomic.ll
@@ -8,12 +8,24 @@ entry:
     ret i32 %0
 }
 
+define i32 @__gen_ocl_atomic_exchangef(i32 addrspace(4)* nocapture %ptr, i32 %value, i32 %order, i32 %scope) nounwind alwaysinline {
+entry:
+    %0 = atomicrmw volatile xchg i32 addrspace(4)* %ptr, i32 %value seq_cst
+    ret i32 %0
+}
+
 define i32 @__gen_ocl_atomic_fetch_add32(i32 addrspace(4)* nocapture %ptr, i32 %value, i32 %order, i32 %scope) nounwind alwaysinline {
 entry:
     %0 = atomicrmw volatile add i32 addrspace(4)* %ptr, i32 %value seq_cst
     ret i32 %0
 }
 
+define i32 @__gen_ocl_atomic_fetch_addf(i32 addrspace(4)* nocapture %ptr, i32 %value, i32 %order, i32 %scope) nounwind alwaysinline {
+entry:
+    %0 = atomicrmw volatile add i32 addrspace(4)* %ptr, i32 %value seq_cst
+    ret i32 %0
+}
+
 define i32 @__gen_ocl_atomic_fetch_sub32(i32 addrspace(4)* nocapture %ptr, i32 %value, i32 %order, i32 %scope) nounwind alwaysinline {
 entry:
     %0 = atomicrmw volatile sub i32 addrspace(4)* %ptr, i32 %value seq_cst
-- 
2.1.4



More information about the Beignet mailing list