[Beignet] [PATCH] fix builtin function "fdim"
Yang, Rong R
rong.r.yang at intel.com
Tue Nov 12 22:04:49 PST 2013
LGTM.
-----Original Message-----
From: beignet-bounces at lists.freedesktop.org [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Homer Hsing
Sent: Tuesday, November 12, 2013 1:13 PM
To: beignet at lists.freedesktop.org
Subject: [Beignet] [PATCH] fix builtin function "fdim"
check whether input is NaN. fix the code if input is inf
Signed-off-by: Homer Hsing <homer.xing at intel.com>
---
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
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list