[Beignet] [PATCH] backend: add double support to fmax

Song, Ruiling ruiling.song at intel.com
Thu Mar 30 08:00:16 UTC 2017



> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> rander
> Sent: Monday, March 27, 2017 5:40 PM
> To: beignet at freedesktop.org
> Cc: Wang, Rander <rander.wang at intel.com>
> Subject: [Beignet] [PATCH] backend: add double support to fmax
> 
> Signed-off-by: rander <rander.wang at intel.com>
> ---
>  backend/src/libocl/tmpl/ocl_math.tmpl.cl    | 15 +++++++++++++++
>  backend/src/libocl/tmpl/ocl_math.tmpl.h     |  2 ++
>  backend/src/libocl/tmpl/ocl_math_20.tmpl.cl | 11 +++++++++++
>  backend/src/libocl/tmpl/ocl_math_20.tmpl.h  |  2 ++
>  4 files changed, 30 insertions(+)
> 
> diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.cl
> b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
> index d526d6c..6978c92 100644
> --- a/backend/src/libocl/tmpl/ocl_math.tmpl.cl
> +++ b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
> @@ -4333,3 +4333,18 @@ OVERLOADABLE double mad(double a, double b,
> double c)
>  	return __gen_ocl_mad(a, b, c);
>  }
> 
> +OVERLOADABLE double fmax(double a, double b)
> +{
> +	ulong ua = as_ulong(a);
> +	ulong ub =as_ulong(b);
> +
> +	if((ua & DF_ABS_MASK) > DF_MAX_NORMAL) return b;
> +	if((ub & DF_ABS_MASK) > DF_MAX_NORMAL) return a;
> +	if(ua == DF_POSITIVE_INF) return a;
> +	if(ub == DF_POSITIVE_INF) return b;
> +
Hardware cmp on double not conform to IEEE754?

> +	double c = a - b;
> +	return (c >= 0) ? a:b;
> +}
> +



More information about the Beignet mailing list