[Libclc-dev] [PATCH 1/1] Make min follow the OCL 1.0 specs

Jan Vesely via Libclc-dev libclc-dev at lists.llvm.org
Mon Jul 25 15:56:55 PDT 2016


On Mon, 2016-07-25 at 14:26 -0700, Matt Arsenault wrote:
> On 07/22/2016 11:18 AM, Jan Vesely via Libclc-dev wrote:
> > 
> > OpenCL 1.0: "Returns y if y < x, otherwise it returns x. If x *and*
> > y
> > are infinite or NaN, the return values are undefined."
> > 
> > OpenCL 1.1+: "Returns y if y < x, otherwise it returns x. If x *or*
> > y
> > are infinite or NaN, the return values are undefined."
> > 
> > The 1.0 version is stricter so use that one.
> > 
> > Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
> > ---
> >   generic/lib/shared/min.inc | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/generic/lib/shared/min.inc
> > b/generic/lib/shared/min.inc
> > index fe42864..e15e055 100644
> > --- a/generic/lib/shared/min.inc
> > +++ b/generic/lib/shared/min.inc
> > @@ -1,9 +1,9 @@
> >   _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE min(__CLC_GENTYPE a,
> > __CLC_GENTYPE b) {
> > -  return (a < b ? a : b);
> > +  return (b < a ? b : a);
> >   }
> >   
> >   #ifndef __CLC_SCALAR
> >   _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE min(__CLC_GENTYPE a,
> > __CLC_SCALAR_GENTYPE b) {
> > -  return (a < (__CLC_GENTYPE)b ? a : (__CLC_GENTYPE)b);
> > +  return (b < (__CLC_GENTYPE)a ? (__CLC_GENTYPE)b : a);
> >   }
> >   #endif
> LGTM, I don't think the change in definedness matters here though

thanks, pushed.
maybe not in practise, but the 1.0 version allows one NaN operand, so
min(x, NaN) should return x, and min(NaN, x) should return NaN. later
versions don't care.

Jan

-- 
Jan Vesely <jan.vesely at rutgers.edu>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.llvm.org/pipermail/libclc-dev/attachments/20160725/63f32bbd/attachment.sig>


More information about the Libclc-dev mailing list