[Libclc-dev] [PATCH 2/2] relational: Add islessequal(floatN) builtin

Aaron Watry awatry at gmail.com
Sun Aug 3 11:08:42 PDT 2014


We can actually remove them for isgreater and any other relational
functions (patch incoming).  I had originally patterned them after the
math/* functions, where quite a few do require that undef (due to
collisions with libm definitions?).  At least when working on some of
the math functions, I was getting redeclaration warnings/errors if I
tried to remove them...

--Aaron

On Fri, Aug 1, 2014 at 5:03 PM, Jan Vesely <jan.vesely at rutgers.edu> wrote:
> On Fri, 2014-08-01 at 15:44 -0500, Aaron Watry wrote:
>> On Thu, Jul 31, 2014 at 7:09 PM, Jan Vesely <jan.vesely at rutgers.edu> wrote:
>> > ---
>> >  generic/include/clc/clc.h                    |  1 +
>> >  generic/include/clc/relational/islessequal.h |  9 +++++++++
>> >  generic/lib/SOURCES                          |  1 +
>> >  generic/lib/relational/islessequal.cl        | 22 ++++++++++++++++++++++
>> >  4 files changed, 33 insertions(+)
>> >  create mode 100644 generic/include/clc/relational/islessequal.h
>> >  create mode 100644 generic/lib/relational/islessequal.cl
>> >
>> > diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
>> > index 83bf8fa..9815c56 100644
>> > --- a/generic/include/clc/clc.h
>> > +++ b/generic/include/clc/clc.h
>> > @@ -116,6 +116,7 @@
>> >  #include <clc/relational/isgreater.h>
>> >  #include <clc/relational/isgreaterequal.h>
>> >  #include <clc/relational/isless.h>
>> > +#include <clc/relational/islessequal.h>
>> >  #include <clc/relational/isnan.h>
>> >  #include <clc/relational/isnotequal.h>
>> >  #include <clc/relational/select.h>
>> > diff --git a/generic/include/clc/relational/islessequal.h b/generic/include/clc/relational/islessequal.h
>> > new file mode 100644
>> > index 0000000..a3215a2
>> > --- /dev/null
>> > +++ b/generic/include/clc/relational/islessequal.h
>> > @@ -0,0 +1,9 @@
>> > +#undef islessequal
>> > +
>>
>> Same comment about this one as with isless(floatn).  If we can get by
>> without it, let's remove this undef.
>>
>> Otherwise, looks good to me.
>
> Thanks. pushed.
> What is the rule behind those undefs? why do we keep them for isgreater
> and not isless?
>
> Jan
>
>>
>> --Aaron
>>
>> > +#define __CLC_FUNCTION islessequal
>> > +#define __CLC_BODY <clc/relational/binary_decl.inc>
>> > +
>> > +#include <clc/relational/floatn.inc>
>> > +
>> > +#undef __CLC_BODY
>> > +#undef __CLC_FUNCTION
>> > diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
>> > index 7faba40..bfdec7b 100644
>> > --- a/generic/lib/SOURCES
>> > +++ b/generic/lib/SOURCES
>> > @@ -49,6 +49,7 @@ relational/isequal.cl
>> >  relational/isgreater.cl
>> >  relational/isgreaterequal.cl
>> >  relational/isless.cl
>> > +relational/islessequal.cl
>> >  relational/isnan.cl
>> >  relational/isnotequal.cl
>> >  relational/signbit.cl
>> > diff --git a/generic/lib/relational/islessequal.cl b/generic/lib/relational/islessequal.cl
>> > new file mode 100644
>> > index 0000000..259c307
>> > --- /dev/null
>> > +++ b/generic/lib/relational/islessequal.cl
>> > @@ -0,0 +1,22 @@
>> > +#include <clc/clc.h>
>> > +#include "relational.h"
>> > +
>> > +//Note: It would be nice to use __builtin_islessequal with vector inputs, but it seems to only take scalar values as
>> > +//      input, which will produce incorrect output for vector input types.
>> > +
>> > +_CLC_DEFINE_RELATIONAL_BINARY(int, islessequal, __builtin_islessequal, float, float)
>> > +
>> > +#ifdef cl_khr_fp64
>> > +
>> > +#pragma OPENCL EXTENSION cl_khr_fp64 : enable
>> > +
>> > +// The scalar version of islessequal(double, double) returns an int, but the vector versions
>> > +// return long.
>> > +
>> > +_CLC_DEF _CLC_OVERLOAD int islessequal(double x, double y){
>> > +       return __builtin_islessequal(x, y);
>> > +}
>> > +
>> > +_CLC_DEFINE_RELATIONAL_BINARY_VEC_ALL(long, islessequal, double, double)
>> > +
>> > +#endif
>> > --
>> > 1.9.3
>> >
>> >
>> > _______________________________________________
>> > Libclc-dev mailing list
>> > Libclc-dev at pcc.me.uk
>> > http://www.pcc.me.uk/cgi-bin/mailman/listinfo/libclc-dev
>
> --
> Jan Vesely <jan.vesely at rutgers.edu>




More information about the Libclc-dev mailing list