[Beignet] [PATCH 2/3] libocl: Correctly handle -inf in exp10.

Ruiling Song ruiling.song at intel.com
Sun Dec 21 20:27:18 PST 2014


exp10(-inf) should return 0.0f

Signed-off-by: Ruiling Song <ruiling.song at intel.com>
---
 backend/src/libocl/tmpl/ocl_math.tmpl.cl |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.cl b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
index 5d73c16..3ec9af6 100644
--- a/backend/src/libocl/tmpl/ocl_math.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
@@ -2698,6 +2698,8 @@ OVERLOADABLE float __gen_ocl_internal_exp10(float x){
   short n;
   int i;
   float*p;
+  unsigned int hx;
+  int sx;
   float MAXL10 = 38.230809449325611792;
   float LOG210 = 3.32192809488736234787e0;
   float LG102A = 3.00781250000000000000E-1;
@@ -2709,10 +2711,10 @@ OVERLOADABLE float __gen_ocl_internal_exp10(float x){
   P[3] = 2.034649854009453E+000;
   P[4] = 2.650948748208892E+000;
   P[5] = 2.302585167056758E+000;
-  if( isinf(x))
-    return INFINITY;
 
-  if( x < -MAXL10 )return 0.0;
+  if( x < -MAXL10 ) return 0.0;
+
+  if( isinf(x))  return INFINITY;
   /* The following is necessary because range reduction blows up: */
   if( x == 0 )return 1.0;
 
-- 
1.7.10.4



More information about the Beignet mailing list