summaryrefslogtreecommitdiff
path: root/backend/src
diff options
context:
space:
mode:
authorrander <rander.wang@intel.com>2017-03-10 10:56:18 +0800
committerYang Rong <rong.r.yang@intel.com>2017-04-17 16:08:48 +0800
commit2b8061cec669c9e06676f70a31e77e5e67efa545 (patch)
treef872ac409cf7f0e6b9e8f375ecf8eac678ae8217 /backend/src
parent04ae0297b4fd692d9967670b7a4d328f74700548 (diff)
Backend: add double support to convert_u|long_rtp(double x)
Signed-off-by: rander <rander.wang@intel.com> Tested-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'backend/src')
-rwxr-xr-xbackend/src/libocl/script/ocl_convert.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/backend/src/libocl/script/ocl_convert.sh b/backend/src/libocl/script/ocl_convert.sh
index ffe93974..101fff6f 100755
--- a/backend/src/libocl/script/ocl_convert.sh
+++ b/backend/src/libocl/script/ocl_convert.sh
@@ -710,6 +710,51 @@ OVERLOADABLE ulong convert_ulong_rte(double x)
return ret;
}
+
+OVERLOADABLE ulong convert_ulong_rtp(double x)
+{
+ int iexp ;
+ ulong ret = 1;
+ long lval = as_long(x);
+
+ int exp = ((lval & DF_EXP_MASK) >> DF_EXP_OFFSET) - DF_EXP_BIAS;
+ long ma = (lval & DF_MAN_MASK);
+ int shift = abs(exp - 52);
+ ret = (ma |DF_IMPLICITE_ONE)<< shift;
+ ulong tmp = (ma |DF_IMPLICITE_ONE)>> shift;
+ long mask = (1L << shift) - 1;
+ tmp = (mask & ma) ? tmp+1:tmp;
+
+ ret = (exp > 52) ? ret:tmp;
+ ret = (exp < 0) ? 1:ret;
+ ret = (lval & DF_SIGN_MASK) ? 0:ret;
+ ret = (lval & DF_ABS_MASK) ? ret:0;
+
+ return ret;
+}
+
+OVERLOADABLE long convert_long_rtp(double x)
+{
+ int iexp ;
+ ulong ret;
+ long lval = as_long(x);
+
+ int exp = ((lval & DF_EXP_MASK) >> DF_EXP_OFFSET) - DF_EXP_BIAS;
+ long ma = (lval & DF_MAN_MASK);
+ int shift = abs(exp - 52);
+ ret = (ma |DF_IMPLICITE_ONE)<< shift;
+ ulong tmp = (ma |DF_IMPLICITE_ONE)>> shift;
+ long mask = (1L << shift) - 1;
+ int sign = ((lval & DF_SIGN_MASK) >> DF_SIGN_OFFSET);
+ tmp = ((mask & ma) && !sign) ? tmp+1:tmp;
+
+ ret = (exp > 52) ? ret:tmp;
+ ret = (exp < 0) ? 1 -sign:ret;
+ ret = (lval & DF_ABS_MASK) ? ret:0;
+ ret = sign ? -ret:ret;
+
+ return ret;
+}
'
fi