[Beignet] [PATCH] backend: add convert_double_rtz(ulong)
rander
rander.wang at intel.com
Tue Mar 21 01:54:50 UTC 2017
do bit operations according to IEEE754 spec
Signed-off-by: rander <rander.wang at intel.com>
---
backend/src/libocl/script/ocl_convert.sh | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/backend/src/libocl/script/ocl_convert.sh b/backend/src/libocl/script/ocl_convert.sh
index c9144c2..aa3ac6c 100755
--- a/backend/src/libocl/script/ocl_convert.sh
+++ b/backend/src/libocl/script/ocl_convert.sh
@@ -1270,7 +1270,19 @@ OVERLOADABLE double convert_double_rtp(ulong x)
OVERLOADABLE double convert_double_rtz(ulong x)
{
- return 0;
+ long exp;
+ long ret, ma, tmp;
+ int msbOne = 64 -clz(x);
+ exp = msbOne + DF_EXP_BIAS - 1;
+ ret = (exp << 52);
+
+ int shift = abs(53 - msbOne);
+ tmp = ret | ((x << shift) &DF_MAN_MASK);
+ ret |= (x >> shift) &DF_MAN_MASK;
+ ret = (msbOne < 54) ? tmp:ret;
+ ret = (!msbOne) ? 0:ret;
+
+ return as_double(ret);
}
OVERLOADABLE double convert_double_rtn(ulong x)
--
2.7.4
More information about the Beignet
mailing list