summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorrander <rander.wang@intel.com>2017-04-06 09:58:35 +0800
committerYang Rong <rong.r.yang@intel.com>2017-05-04 19:08:31 +0800
commitacd4388c6c85c4a7bf1ef7ab570dd2d5355e742e (patch)
tree329ca51726b16976aee438c478d616dc7d2c8190 /backend
parente04f8daf110215b9b4de0f0d9baf76245cfef626 (diff)
backend: refine min|max mag
do it according to spec to make cft pass Signed-off-by: rander.wang <rander.wang@intel.com> Tested-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'backend')
-rw-r--r--backend/src/libocl/tmpl/ocl_math_common.tmpl.cl26
1 files changed, 6 insertions, 20 deletions
diff --git a/backend/src/libocl/tmpl/ocl_math_common.tmpl.cl b/backend/src/libocl/tmpl/ocl_math_common.tmpl.cl
index f7828946..7f99a752 100644
--- a/backend/src/libocl/tmpl/ocl_math_common.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math_common.tmpl.cl
@@ -1450,32 +1450,18 @@ OVERLOADABLE double fdim(double x, double y)
OVERLOADABLE double maxmag(double x, double y)
{
- ulong ua = as_ulong(x);
- ulong ub =as_ulong(y);
+ if(fabs(x) > fabs(y)) return x;
+ if(fabs(y) > fabs(x)) return y;
- if((ua & DF_ABS_MASK) > DF_MAX_NORMAL) return y;
- if((ub & DF_ABS_MASK) > DF_MAX_NORMAL) return x;
- if(ua == DF_POSITIVE_INF) return x;
- if(ub == DF_POSITIVE_INF) return y;
-
- double retVal = (fabs(x) > fabs(y)) ? x:y;
-
- return retVal;
+ return fmax(x, y);
}
OVERLOADABLE double minmag(double x, double y)
{
- ulong ua = as_ulong(x);
- ulong ub =as_ulong(y);
-
- if((ua & DF_ABS_MASK) > DF_MAX_NORMAL) return y;
- if((ub & DF_ABS_MASK) > DF_MAX_NORMAL) return x;
- if(ua == DF_NEGTIVE_INF) return x;
- if(ub == DF_NEGTIVE_INF) return y;
-
- double retVal = (fabs(x) < fabs(y)) ? x:y;
+ if(fabs(x) < fabs(y)) return x;
+ if(fabs(y) < fabs(x)) return y;
- return retVal;
+ return fmin(x, y);
}
OVERLOADABLE double ldexp(double x, int n)