[Libclc-dev] [PATCH 1/5] add isfinite builtin

Aaron Watry awatry at gmail.com
Thu Sep 4 13:02:25 PDT 2014


For the series:
Reviewed-by: Aaron Watry <awatry at gmail.com>

--Aaron

On Thu, Sep 4, 2014 at 2:26 PM, Jan Vesely <jan.vesely at rutgers.edu> wrote:
> On Thu, 2014-09-04 at 12:56 -0500, Aaron Watry wrote:
>> On Thu, Sep 4, 2014 at 10:50 AM, Jan Vesely <jan.vesely at rutgers.edu> wrote:
>> > Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
>> > ---
>> >  generic/include/clc/clc.h                 |  1 +
>> >  generic/include/clc/relational/isfinite.h | 22 ++++++++++++++++++++++
>> >  generic/lib/SOURCES                       |  1 +
>> >  generic/lib/relational/isfinite.cl        | 19 +++++++++++++++++++
>> >  4 files changed, 43 insertions(+)
>> >  create mode 100644 generic/include/clc/relational/isfinite.h
>> >  create mode 100644 generic/lib/relational/isfinite.cl
>> >
>> > diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
>> > index 17d8454..f7085ce 100644
>> > --- a/generic/include/clc/clc.h
>> > +++ b/generic/include/clc/clc.h
>> > @@ -114,6 +114,7 @@
>> >  #include <clc/relational/any.h>
>> >  #include <clc/relational/bitselect.h>
>> >  #include <clc/relational/isequal.h>
>> > +#include <clc/relational/isfinite.h>
>> >  #include <clc/relational/isgreater.h>
>> >  #include <clc/relational/isgreaterequal.h>
>> >  #include <clc/relational/isinf.h>
>> > diff --git a/generic/include/clc/relational/isfinite.h b/generic/include/clc/relational/isfinite.h
>> > new file mode 100644
>> > index 0000000..60dea56
>> > --- /dev/null
>> > +++ b/generic/include/clc/relational/isfinite.h
>> > @@ -0,0 +1,22 @@
>> > +
>> > +#define _CLC_ISINF_DECL(RET_TYPE, ARG_TYPE) \
>> > +  _CLC_OVERLOAD _CLC_DECL RET_TYPE isfinite(ARG_TYPE);
>> > +
>>
>> Not that it matters (since it's UNDEF'd later), but you used ISINF for
>> the macro name (copied from isinfinite?).
>>
>> Also, you could simplify this by using <clc/relational/unary_decl.inc>
>>
>> Check out <clc/relational/signbit.h> for a pattern (minus the undef of
>> the function name at the beginning probably).
>>
>> I've tested this on evergreen successfully, so we're mostly just
>> talking maintainability of the code here.
>>
>> Also, the first 4 patches of this series have EOF whitespace errors
>> when applying:
>>
>> Applying: add isfinite builtin
>> /home/awatry/src/libclc/.git/rebase-apply/patch:49: new blank line at EOF.
>> +
>> /home/awatry/src/libclc/.git/rebase-apply/patch:86: new blank line at EOF.
>> +
>> warning: 2 lines add whitespace errors.
>> <etc>
>
> thanks for review. I should have cleaned the patches up before posting.
> v2 addresses all of the above.
>
> jan
>
>>
>> --Aaron
>>
>> > +#define _CLC_VECTOR_ISINF_DECL(RET_TYPE, ARG_TYPE) \
>> > +  _CLC_ISINF_DECL(RET_TYPE##2, ARG_TYPE##2) \
>> > +  _CLC_ISINF_DECL(RET_TYPE##3, ARG_TYPE##3) \
>> > +  _CLC_ISINF_DECL(RET_TYPE##4, ARG_TYPE##4) \
>> > +  _CLC_ISINF_DECL(RET_TYPE##8, ARG_TYPE##8) \
>> > +  _CLC_ISINF_DECL(RET_TYPE##16, ARG_TYPE##16)
>> > +
>> > +_CLC_ISINF_DECL(int, float)
>> > +_CLC_VECTOR_ISINF_DECL(int, float)
>> > +
>> > +#ifdef cl_khr_fp64
>> > +_CLC_ISINF_DECL(int, double)
>> > +_CLC_VECTOR_ISINF_DECL(long, double)
>> > +#endif
>> > +
>> > +#undef _CLC_ISINF_DECL
>> > +#undef _CLC_VECTOR_ISINF_DECL
>> > +
>> > diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
>> > index fb80124..3c02118 100644
>> > --- a/generic/lib/SOURCES
>> > +++ b/generic/lib/SOURCES
>> > @@ -49,6 +49,7 @@ math/sincos_helpers.cl
>> >  relational/all.cl
>> >  relational/any.cl
>> >  relational/isequal.cl
>> > +relational/isfinite.cl
>> >  relational/isgreater.cl
>> >  relational/isgreaterequal.cl
>> >  relational/isinf.cl
>> > diff --git a/generic/lib/relational/isfinite.cl b/generic/lib/relational/isfinite.cl
>> > new file mode 100644
>> > index 0000000..7d96e10
>> > --- /dev/null
>> > +++ b/generic/lib/relational/isfinite.cl
>> > @@ -0,0 +1,19 @@
>> > +#include <clc/clc.h>
>> > +#include "relational.h"
>> > +
>> > +_CLC_DEFINE_RELATIONAL_UNARY(int, isfinite, __builtin_isfinite, float)
>> > +
>> > +#ifdef cl_khr_fp64
>> > +
>> > +#pragma OPENCL EXTENSION cl_khr_fp64 : enable
>> > +
>> > +// The scalar version of isfinite(double) returns an int, but the vector versions
>> > +// return long.
>> > +_CLC_DEF _CLC_OVERLOAD int isfinite(double x) {
>> > +  return __builtin_isfinite(x);
>> > +}
>> > +
>> > +_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(long, isfinite, 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