LGTM.

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Homer Hsing
Sent: Tuesday, November 12, 2013 1:13 PM
To: [email protected]
Subject: [Beignet] [PATCH] fix builtin function "fdim"

check whether input is NaN. fix the code if input is inf

Signed-off-by: Homer Hsing <[email protected]>
---
 backend/src/ocl_stdlib.tmpl.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/backend/src/ocl_stdlib.tmpl.h b/backend/src/ocl_stdlib.tmpl.h 
index 3f642b7..bedfe02 100644
--- a/backend/src/ocl_stdlib.tmpl.h
+++ b/backend/src/ocl_stdlib.tmpl.h
@@ -1747,7 +1747,11 @@ INLINE_OVERLOADABLE float 
__gen_ocl_internal_minmag(float x, float y) {  }  INLINE_OVERLOADABLE float 
mix(float x, float y, float a) { return x + (y-x)*a;}  INLINE_OVERLOADABLE 
float __gen_ocl_internal_fdim(float x, float y) {
-  return __gen_ocl_internal_fmax(x, y) - y;
+  if(isnan(x))
+    return x;
+  if(isnan(y))
+    return y;
+  return x > y ? (x - y) : +0.f;
 }
 #define BODY \
   if (isnan(x)) { \
--
1.8.3.2

_______________________________________________
Beignet mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/beignet
_______________________________________________
Beignet mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/beignet

Reply via email to