[Beignet] [PATCH] support saturated converting from narrower type to wider type

Homer Hsing homer.xing at intel.com
Fri Oct 11 01:27:50 PDT 2013


This patch supports saturated converting from narrower type to wider type.
It simply returns the parameter.

Signed-off-by: Homer Hsing <homer.xing at intel.com>
---
 backend/src/ocl_stdlib.tmpl.h | 47 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/backend/src/ocl_stdlib.tmpl.h b/backend/src/ocl_stdlib.tmpl.h
index e1c4957..9bcdec4 100644
--- a/backend/src/ocl_stdlib.tmpl.h
+++ b/backend/src/ocl_stdlib.tmpl.h
@@ -282,6 +282,53 @@ INLINE_OVERLOADABLE ulong convert_ulong_sat(long x) {
   return x < 0 ? 0 : x;
 }
 
+#define DEF(DSTTYPE, SRCTYPE) \
+  INLINE_OVERLOADABLE DSTTYPE convert_ ## DSTTYPE ## _sat(SRCTYPE x) { \
+    return x; \
+  }
+DEF(char, char);
+DEF(uchar, uchar);
+DEF(short, char);
+DEF(short, uchar);
+DEF(short, short);
+DEF(ushort, char);
+DEF(ushort, uchar);
+DEF(ushort, ushort);
+DEF(int, char);
+DEF(int, uchar);
+DEF(int, short);
+DEF(int, ushort);
+DEF(int, int);
+DEF(uint, char);
+DEF(uint, uchar);
+DEF(uint, short);
+DEF(uint, ushort);
+DEF(uint, uint);
+DEF(long, char);
+DEF(long, uchar);
+DEF(long, short);
+DEF(long, ushort);
+DEF(long, int);
+DEF(long, uint);
+DEF(long, long);
+DEF(ulong, char);
+DEF(ulong, uchar);
+DEF(ulong, short);
+DEF(ulong, ushort);
+DEF(ulong, int);
+DEF(ulong, uint);
+DEF(ulong, ulong);
+DEF(float, char);
+DEF(float, uchar);
+DEF(float, short);
+DEF(float, ushort);
+DEF(float, int);
+DEF(float, uint);
+DEF(float, long);
+DEF(float, ulong);
+DEF(float, float);
+#undef DEF
+
 INLINE_OVERLOADABLE int isfinite(float x) { return __builtin_isfinite(x); }
 INLINE_OVERLOADABLE int isinf(float x) { return __builtin_isinf(x); }
 INLINE_OVERLOADABLE int isnan(float x) {
-- 
1.8.1.2



More information about the Beignet mailing list