[Beignet] [PATCH] backend: add double support to convert_u|char|short|int_rtp(double x) first convert double to u|long, then convert to smaller type And converting double directly to smaller type does not save any instructions

rander rander.wang at intel.com
Fri Mar 17 02:16:24 UTC 2017


Signed-off-by: rander <rander.wang at intel.com>
---
 backend/src/libocl/script/ocl_convert.sh | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/backend/src/libocl/script/ocl_convert.sh b/backend/src/libocl/script/ocl_convert.sh
index ed9abeb..b23022e 100755
--- a/backend/src/libocl/script/ocl_convert.sh
+++ b/backend/src/libocl/script/ocl_convert.sh
@@ -758,6 +758,7 @@ OVERLOADABLE long convert_long_rtp(double x)
 '
 fi
 
+# convert_u|char|short|int_rte(double x)
 ITYPES="int:4 uint:4 short:2 ushort:2 char:1 uchar:1"
 for ttype in $ITYPES; do
 	tbasetype=`IFS=:; set -- dummy $ttype; echo $2`
@@ -767,6 +768,7 @@ for ttype in $ITYPES; do
 	fi
 done
 
+# convert_u|char|short|int_rte(double x)
 IUTYPES="ulong:8 uint:4 ushort:2 uchar:1"
 for ttype in $IUTYPES; do
 	tbasetype=`IFS=:; set -- dummy $ttype; echo $2`
@@ -788,6 +790,25 @@ for ttype in $ITYPES; do
 	fi
 done
 
+# convert_u|char|short|int_rtp(double x)
+IUTYPES="uint:4 ushort:2 uchar:1"
+for ttype in $IUTYPES; do
+	tbasetype=`IFS=:; set -- dummy $ttype; echo $2`
+	if [ $1"a" != "-pa" ]; then
+	echo "OVERLOADABLE $tbasetype convert_${tbasetype}_rtp(double x)"
+	echo "{ return ($tbasetype)convert_ulong_rtp(x);}"
+	fi
+done
+
+ITYPES="int:4 short:2 char:1"
+for ttype in $ITYPES; do
+	tbasetype=`IFS=:; set -- dummy $ttype; echo $2`
+	if [ $1"a" != "-pa" ]; then
+	echo "OVERLOADABLE $tbasetype convert_${tbasetype}_rtp(double x)"
+	echo " { return ($tbasetype)convert_long_rtp(x);}"
+	fi
+done
+
 # convert_DSTTYPE_ROUNDING function
 for vector_length in $VECTOR_LENGTHS; do
     for ftype in $TYPES; do
-- 
2.7.4



More information about the Beignet mailing list