[Beignet] [PATCH] backend: add convert_double_rte(long)
rander
rander.wang at intel.com
Tue Mar 21 07:34:54 UTC 2017
enable long convert to double
Signed-off-by: rander <rander.wang at intel.com>
---
backend/src/libocl/script/ocl_convert.sh | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/backend/src/libocl/script/ocl_convert.sh b/backend/src/libocl/script/ocl_convert.sh
index b9b3b78..3b517bd 100755
--- a/backend/src/libocl/script/ocl_convert.sh
+++ b/backend/src/libocl/script/ocl_convert.sh
@@ -1395,10 +1395,35 @@ OVERLOADABLE double convert_double_rtz(long x)
ret |= (x & DF_SIGN_MASK);
return as_double(ret);
}
+
+OVERLOADABLE double convert_double_rte(long x)
+{
+ long exp;
+ long ret, ma, tmp;
+
+ long absX = abs(x);
+ int msbOne = 64 -clz(absX);
+ exp = msbOne + DF_EXP_BIAS - 1;
+ ret = (exp << 52);
+ int shift = abs(53 - msbOne);
+ tmp = ret | ((absX << shift) &DF_MAN_MASK);
+
+ ma = (absX& ((0x1L << shift) - 1));
+ int lastBit = (absX >> shift) & 0x1;
+ ret |= (absX>> shift) &DF_MAN_MASK;
+ ret = (ma > (0x1L << (msbOne -54))) ? ret+1:ret;
+ ret = (ma == (0x1L << (msbOne -54)) && lastBit) ? ret+1:ret;
+
+ ret = (msbOne < 54) ? tmp:ret;
+ ret = (!msbOne) ? 0:ret;
+
+ ret |= (x & DF_SIGN_MASK);
+ return as_double(ret);
+}
'
fi
-TTYPES=" ulong:8"
+TTYPES=" ulong:8 long:8"
for vector_length in $VECTOR_LENGTHS; do
for ftype in $TTYPES; do
fbasetype=`IFS=:; set -- dummy $ftype; echo $2`
--
2.7.4
More information about the Beignet
mailing list