[Beignet] [PATCH] support saturated converting from narrower type to wider type
Yang, Rong R
rong.r.yang at intel.com
Wed Oct 16 23:09:34 PDT 2013
According openCL spec:
Conversions to floating-point type shall conform to IEEE-754 rounding rules. The _sat
modifier may not be used for conversions to floating-point formats.
So we need not support convert_float_sat.
-----Original Message-----
From: beignet-bounces+rong.r.yang=intel.com at lists.freedesktop.org [mailto:beignet-bounces+rong.r.yang=intel.com at lists.freedesktop.org] On Behalf Of Homer Hsing
Sent: Friday, October 11, 2013 4:28 PM
To: beignet at lists.freedesktop.org
Subject: [Beignet] [PATCH] support saturated converting from narrower type to wider type
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
_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list