[Beignet] [PATCH] Fix atomic_xchg float type error.
Yang Rong
rong.r.yang at intel.com
Tue Sep 3 22:55:23 PDT 2013
Also refine the "\" of some atomic macro.
Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
backend/src/ocl_stdlib.tmpl.h | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/backend/src/ocl_stdlib.tmpl.h b/backend/src/ocl_stdlib.tmpl.h
index f3d2a8e..8e8c042 100644
--- a/backend/src/ocl_stdlib.tmpl.h
+++ b/backend/src/ocl_stdlib.tmpl.h
@@ -2022,10 +2022,10 @@ OVERLOADABLE uint __gen_ocl_atomic_umax(__local uint *p, uint val);
#define DECL_ATOMIC_OP_TYPE(NAME, TYPE, PREFIX) \
DECL_ATOMIC_OP_SPACE(NAME, TYPE, __global, PREFIX) \
- DECL_ATOMIC_OP_SPACE(NAME, TYPE, __local, PREFIX) \
+ DECL_ATOMIC_OP_SPACE(NAME, TYPE, __local, PREFIX)
#define DECL_ATOMIC_OP(NAME) \
- DECL_ATOMIC_OP_TYPE(NAME, uint, atomic_) \
+ DECL_ATOMIC_OP_TYPE(NAME, uint, atomic_) \
DECL_ATOMIC_OP_TYPE(NAME, int, atomic_)
DECL_ATOMIC_OP(add)
@@ -2034,12 +2034,20 @@ DECL_ATOMIC_OP(and)
DECL_ATOMIC_OP(or)
DECL_ATOMIC_OP(xor)
DECL_ATOMIC_OP(xchg)
-DECL_ATOMIC_OP_TYPE(xchg, float, atomic_)
DECL_ATOMIC_OP_TYPE(min, int, atomic_i)
DECL_ATOMIC_OP_TYPE(max, int, atomic_i)
DECL_ATOMIC_OP_TYPE(min, uint, atomic_u)
DECL_ATOMIC_OP_TYPE(max, uint, atomic_u)
+#undef DECL_ATOMIC_OP_SPACE
+
+#define DECL_ATOMIC_OP_SPACE(NAME, TYPE, SPACE, PREFIX) \
+ INLINE_OVERLOADABLE TYPE atomic_##NAME (volatile SPACE TYPE *p, TYPE val) { \
+ return as_float(__gen_ocl_##PREFIX##NAME((SPACE uint *)p, as_uint(val))); \
+ }
+DECL_ATOMIC_OP_SPACE(xchg, float, __global, atomic_)
+DECL_ATOMIC_OP_SPACE(xchg, float, __local, atomic_)
+
#undef DECL_ATOMIC_OP
#undef DECL_ATOMIC_OP_TYPE
#undef DECL_ATOMIC_OP_SPACE
--
1.8.1.2
More information about the Beignet
mailing list