[Libclc-dev] [PATCH 1/3] Add all(igentype) builtin

Tom Stellard tom at stellard.net
Thu Jun 12 14:18:22 PDT 2014


On Wed, Jun 11, 2014 at 04:59:57PM -0500, Aaron Watry wrote:
> Signed-off-by: Aaron Watry <awatry at gmail.com>
> ---
>  generic/include/clc/clc.h            |  1 +
>  generic/include/clc/relational/all.h | 16 ++++++++++++++++
>  generic/lib/SOURCES                  |  1 +
>  generic/lib/relational/all.cl        | 30 ++++++++++++++++++++++++++++++
>  4 files changed, 48 insertions(+)
>  create mode 100644 generic/include/clc/relational/all.h
>  create mode 100644 generic/lib/relational/all.cl
> 
> diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
> index 4aa9caa..0a1503a 100644
> --- a/generic/include/clc/clc.h
> +++ b/generic/include/clc/clc.h
> @@ -102,6 +102,7 @@
>  #include <clc/geometric/normalize.h>
>  
>  /* 6.11.6 Relational Functions */
> +#include <clc/relational/all.h>
>  #include <clc/relational/any.h>
>  #include <clc/relational/bitselect.h>
>  #include <clc/relational/isgreater.h>
> diff --git a/generic/include/clc/relational/all.h b/generic/include/clc/relational/all.h
> new file mode 100644
> index 0000000..f917419
> --- /dev/null
> +++ b/generic/include/clc/relational/all.h
> @@ -0,0 +1,16 @@
> +
> +#define _CLC_ALL_DECL(TYPE) \
> +  _CLC_OVERLOAD _CLC_DECL int all(TYPE v);
> +
> +#define _CLC_VECTOR_ALL_DECL(TYPE) \
> +  _CLC_ALL_DECL(TYPE)     \
> +  _CLC_ALL_DECL(TYPE##2)  \
> +  _CLC_ALL_DECL(TYPE##3)  \
> +  _CLC_ALL_DECL(TYPE##4)  \
> +  _CLC_ALL_DECL(TYPE##8)  \
> +  _CLC_ALL_DECL(TYPE##16)
> +
> +_CLC_VECTOR_ALL_DECL(char)
> +_CLC_VECTOR_ALL_DECL(short)
> +_CLC_VECTOR_ALL_DECL(int)
> +_CLC_VECTOR_ALL_DECL(long)
> diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
> index 45f7c4a..6a8e34d 100644
> --- a/generic/lib/SOURCES
> +++ b/generic/lib/SOURCES
> @@ -34,6 +34,7 @@ math/mad.cl
>  math/clc_nextafter.cl
>  math/nextafter.cl
>  math/sincos.cl
> +relational/all.cl
>  relational/any.cl
>  relational/isgreater.cl
>  relational/isgreaterequal.cl
> diff --git a/generic/lib/relational/all.cl b/generic/lib/relational/all.cl
> new file mode 100644
> index 0000000..6fcc318
> --- /dev/null
> +++ b/generic/lib/relational/all.cl
> @@ -0,0 +1,30 @@
> +#include <clc/clc.h>
> +
> +#define _CLC_ALL(v) (((v) >> ((sizeof(v) * 8) - 1)) & 0x1)
> +#define _CLC_ALL2(v) (_CLC_ALL((v).s0) & _CLC_ALL((v).s1))
> +#define _CLC_ALL3(v) (_CLC_ALL2((v)) & _CLC_ALL((v).s2))
> +#define _CLC_ALL4(v) (_CLC_ALL3((v)) & _CLC_ALL((v).s3))
> +#define _CLC_ALL8(v) (_CLC_ALL4((v)) & _CLC_ALL((v).s4) & _CLC_ALL((v).s5) \
> +                                     & _CLC_ALL((v).s6) & _CLC_ALL((v).s7))
> +#define _CLC_ALL16(v) (_CLC_ALL8((v)) & _CLC_ALL((v).s8) & _CLC_ALL((v).s9) \
> +                                      & _CLC_ALL((v).sA) & _CLC_ALL((v).sB) \
> +                                      & _CLC_ALL((v).sC) & _CLC_ALL((v).sD) \
> +                                      & _CLC_ALL((v).sE) & _CLC_ALL((v).sf))
> +
> +
> +#define ALL_ID(TYPE) \
> +  _CLC_OVERLOAD _CLC_DEF int all(TYPE v)
> +
> +#define ALL_VECTORIZE(TYPE) \
> +  ALL_ID(TYPE) { return _CLC_ALL(v); } \
> +  ALL_ID(TYPE##2) { return _CLC_ALL2(v); } \
> +  ALL_ID(TYPE##3) { return _CLC_ALL3(v); } \
> +  ALL_ID(TYPE##4) { return _CLC_ALL4(v); } \
> +  ALL_ID(TYPE##8) { return _CLC_ALL8(v); } \
> +  ALL_ID(TYPE##16) { return _CLC_ALL16(v); }
> +

Have you looked at the macros in generic/include/clc/clcmacro.h? Do you
think you would be able to use some of those here.

-Tom

> +ALL_VECTORIZE(char)
> +ALL_VECTORIZE(short)
> +ALL_VECTORIZE(int)
> +ALL_VECTORIZE(long)
> +
> -- 
> 1.9.1
> 
> 
> _______________________________________________
> Libclc-dev mailing list
> Libclc-dev at pcc.me.uk
> http://www.pcc.me.uk/cgi-bin/mailman/listinfo/libclc-dev




More information about the Libclc-dev mailing list