[Beignet] [PATCH 3/3] libocl: Flush denorm input into zero in rootn()
Ruiling Song
ruiling.song at intel.com
Sun Dec 21 18:00:40 PST 2014
Gen does not support denorm. We have to flush input to zero.
Signed-off-by: Ruiling Song <ruiling.song at intel.com>
---
backend/src/libocl/tmpl/ocl_math.tmpl.cl | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.cl b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
index c7be47e..248ddd0 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;
--
1.7.10.4
More information about the Beignet
mailing list