LGTM - Ruiling
> -----Original Message----- > From: Beignet [mailto:beignet-boun...@lists.freedesktop.org] On Behalf Of > rander > Sent: Monday, March 6, 2017 5:48 PM > To: beig...@freedesktop.org > Cc: Wang, Rander <rander.w...@intel.com> > Subject: [Beignet] [PATCH 4/4] Backend:add double support for some relation > function > > Signed-off-by: rander <rander.w...@intel.com> > --- > backend/src/libocl/include/ocl_float.h | 7 +++ > backend/src/libocl/tmpl/ocl_relational.tmpl.cl | 65 > ++++++++++++++++++++++++++ > backend/src/libocl/tmpl/ocl_relational.tmpl.h | 15 ++++++ > 3 files changed, 87 insertions(+) > > diff --git a/backend/src/libocl/include/ocl_float.h > b/backend/src/libocl/include/ocl_float.h > index 6be6c7c..ff8bfed 100644 > --- a/backend/src/libocl/include/ocl_float.h > +++ b/backend/src/libocl/include/ocl_float.h > @@ -96,4 +96,11 @@ INLINE_OVERLOADABLE int __ocl_finitef (float x){ > #define FP_ILOGB0 (-0x7FFFFFFF-1) > #define FP_ILOGBNAN FP_ILOGB0 > > +#define DF_EXP_MASK 0x7FF0000000000000UL > +#define DF_MAX_NORMAL 0x7FF0000000000000UL > +#define DF_MAN_MASK 0xFFFFFFFFFFFFFUL > +#define DF_MIN_NORMAL 0x10000000000000UL > +#define DF_ABS_MASK 0x7FFFFFFFFFFFFFFFUL > +#define DF_POSITIVE_INF 0x7FF0000000000000UL > + > #endif /* __OCL_FLOAT_H__ */ > diff --git a/backend/src/libocl/tmpl/ocl_relational.tmpl.cl > b/backend/src/libocl/tmpl/ocl_relational.tmpl.cl > index f66b6c1..eb3ec7c 100644 > --- a/backend/src/libocl/tmpl/ocl_relational.tmpl.cl > +++ b/backend/src/libocl/tmpl/ocl_relational.tmpl.cl > @@ -16,6 +16,7 @@ > * > */ > #include "ocl_relational.h" > +#include "ocl_float.h" > > OVERLOADABLE int isequal(float x, float y) { > return x == y; > @@ -145,6 +146,70 @@ OVERLOADABLE int signbit(half x) { > return u.u >> 15; > } > > +OVERLOADABLE int isequal(double x, double y) { > + return x == y; > +} > + > +OVERLOADABLE int isnotequal(double x, double y) { > + return x != y; > +} > + > +OVERLOADABLE int isgreater(double x, double y) { > + return x > y; > +} > + > +OVERLOADABLE int isgreaterequal(double x, double y) { > + return x >= y; > +} > + > +OVERLOADABLE int isless(double x, double y) { > + return x < y; > +} > + > +OVERLOADABLE int islessequal(double x, double y) { > + return x <= y; > +} > + > +OVERLOADABLE int islessgreater(double x, double y) { > + return (x < y) || (x > y); > +} > + > +OVERLOADABLE int isfinite(double x) { > + union { ulong u; double f; } u; > + u.f = x; > + return (u.u & DF_ABS_MASK) < DF_POSITIVE_INF; > +} > + > +OVERLOADABLE int isinf(double x) { > + union { ulong u; double f; } u; > + u.f = x; > + return (u.u & DF_ABS_MASK) == DF_POSITIVE_INF; > +} > + > +OVERLOADABLE int isnan(double x) { > + long lx = as_long(x); > + return ((lx & DF_EXP_MASK) == DF_POSITIVE_INF) && (lx & DF_MAN_MASK); > +} > + > +OVERLOADABLE int isnormal(double x) { > + union { ulong u; double f; } u; > + u.f = x; > + u.u &= DF_ABS_MASK; > + return (u.u < DF_POSITIVE_INF) && (u.u >= DF_MIN_NORMAL); > +} > + > +OVERLOADABLE int isordered(double x, double y) { > + return isequal(x, x) && isequal(y, y); > +} > +OVERLOADABLE int isunordered(double x, double y) { > + return isnan(x) || isnan(y); > +} > +OVERLOADABLE int signbit(double x) { > + union { ulong u; double f; } u; > + u.f = x; > + return u.u >> 63; > +} > + > > // any > #define DEC1(type) OVERLOADABLE int any(type a) { return a<0; } > diff --git a/backend/src/libocl/tmpl/ocl_relational.tmpl.h > b/backend/src/libocl/tmpl/ocl_relational.tmpl.h > index 0ec0cbe..a4d67aa 100644 > --- a/backend/src/libocl/tmpl/ocl_relational.tmpl.h > +++ b/backend/src/libocl/tmpl/ocl_relational.tmpl.h > @@ -56,6 +56,21 @@ OVERLOADABLE int isordered(half x, half y); > OVERLOADABLE int isunordered(half x, half y); > OVERLOADABLE int signbit(half x); > > +OVERLOADABLE int isequal(double x, double y); > +OVERLOADABLE int isnotequal(double x, double y); > +OVERLOADABLE int isgreater(double x, double y); > +OVERLOADABLE int isgreaterequal(double x, double y); > +OVERLOADABLE int isless(double x, double y); > +OVERLOADABLE int islessequal(double x, double y); > +OVERLOADABLE int islessgreater(double x, double y); > + > +OVERLOADABLE int isfinite(double x); > +OVERLOADABLE int isinf(double x); > +OVERLOADABLE int isnan(double x); > +OVERLOADABLE int isnormal(double x); > + > +OVERLOADABLE int isordered(double x, double y); > +OVERLOADABLE int isunordered(double x, double y); > > // any > #define DEC1(type) OVERLOADABLE int any(type a); > -- > 2.7.4 > > _______________________________________________ > Beignet mailing list > Beignet@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/beignet _______________________________________________ Beignet mailing list Beignet@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/beignet