diff options
author | Ruiling Song <ruiling.song@intel.com> | 2014-12-22 10:00:40 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2015-01-09 14:13:58 +0800 |
commit | 9a8ae9983fef0113550b92dfd1540aeedcc1df6f (patch) | |
tree | 22258038749b7951a82dce674aab8e7f9b1185f2 /backend/src/libocl | |
parent | 92950b7f402177ec8cc334727f86eb7eeff45650 (diff) |
libocl: Flush denorm input into zero in rootn()
Gen does not support denorm. We have to flush input to zero.
Signed-off-by: Ruiling Song <ruiling.song@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'backend/src/libocl')
-rw-r--r-- | backend/src/libocl/tmpl/ocl_math.tmpl.cl | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.cl b/backend/src/libocl/tmpl/ocl_math.tmpl.cl index c7be47e7..248ddd05 100644 --- a/backend/src/libocl/tmpl/ocl_math.tmpl.cl +++ b/backend/src/libocl/tmpl/ocl_math.tmpl.cl @@ -3414,7 +3414,15 @@ OVERLOADABLE float pow(float x, float y) { OVERLOADABLE float rootn(float x, int n) { float ax,re; int sign = 0; + int hx; if( n == 0 )return NAN; + + GEN_OCL_GET_FLOAT_WORD(hx, x); + // Gen does not support denorm, flush to zero + if ((hx & 0x7fffffff) < 0x00800000) { + x = hx < 0 ? -0.0f : 0.0f; + } + //rootn ( x, n ) returns a NaN for x < 0 and n is even. if( x < 0 && 0 == (n&1) ) return NAN; |