[Libclc-dev] [PATCH 4/6] select: add vector implementation
Aaron Watry via Libclc-dev
libclc-dev at lists.llvm.org
Mon Mar 5 19:02:15 PST 2018
On Wed, Feb 28, 2018 at 1:50 PM, Jan Vesely via Libclc-dev
<libclc-dev at lists.llvm.org> wrote:
> Passes CTS on Carrizo
>
> Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
> ---
> generic/include/clc/relational/select.h | 12 +++++++-
> generic/include/clc/relational/select.inc | 25 ++++++++++++++++
> generic/lib/SOURCES | 1 +
> generic/lib/relational/select.cl | 7 +++++
> generic/lib/relational/select.inc | 47 +++++++++++++++++++++++++++++++
> 5 files changed, 91 insertions(+), 1 deletion(-)
> create mode 100644 generic/include/clc/relational/select.inc
> create mode 100644 generic/lib/relational/select.cl
> create mode 100644 generic/lib/relational/select.inc
>
> diff --git a/generic/include/clc/relational/select.h b/generic/include/clc/relational/select.h
> index 33a6909..d20deae 100644
> --- a/generic/include/clc/relational/select.h
> +++ b/generic/include/clc/relational/select.h
> @@ -1 +1,11 @@
> -#define select(a, b, c) ((c) ? (b) : (a))
> +/* Duplciate these so we don't have to distribute utils.h */
> +#define __CLC_CONCAT(x, y) x ## y
> +#define __CLC_XCONCAT(x, y) __CLC_CONCAT(x, y)
> +
> +#define __CLC_BODY <clc/relational/select.inc>
> +#include <clc/math/gentype.inc>
> +#define __CLC_BODY <clc/relational/select.inc>
> +#include <clc/integer/gentype.inc>
> +
> +#undef __CLC_CONCAT
> +#undef __CLC_XCONCAT
I don't mind the previous patches where you removed the #undef
__CLC_BODY lines (those were all in lib/*), but
don't we want to clean up after ourselves in the installed headers?
I'd prefer to undef __CLC_BODY here, if possible.
--Aaron
> diff --git a/generic/include/clc/relational/select.inc b/generic/include/clc/relational/select.inc
> new file mode 100644
> index 0000000..2911009
> --- /dev/null
> +++ b/generic/include/clc/relational/select.inc
> @@ -0,0 +1,25 @@
> +#ifdef __CLC_SCALAR
> +#define __CLC_VECSIZE
> +#endif
> +
> +#if __CLC_FPSIZE == 64
> +#define __CLC_S_GENTYPE __CLC_XCONCAT(long, __CLC_VECSIZE)
> +#define __CLC_U_GENTYPE __CLC_XCONCAT(ulong, __CLC_VECSIZE)
> +#elif __CLC_FPSIZE == 32
> +#define __CLC_S_GENTYPE __CLC_XCONCAT(int, __CLC_VECSIZE)
> +#define __CLC_U_GENTYPE __CLC_XCONCAT(uint, __CLC_VECSIZE)
> +#elif __CLC_FPSIZE == 16
> +#define __CLC_S_GENTYPE __CLC_XCONCAT(char, __CLC_VECSIZE)
> +#define __CLC_U_GENTYPE __CLC_XCONCAT(uchar, __CLC_VECSIZE)
> +#endif
> +
> +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE select(__CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_S_GENTYPE z);
> +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE select(__CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_U_GENTYPE z);
> +
> +#ifdef __CLC_FPSIZE
> +#undef __CLC_S_GENTYPE
> +#undef __CLC_U_GENTYPE
> +#endif
> +#ifdef __CLC_SCALAR
> +#undef __CLC_VECSIZE
> +#endif
> diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
> index 13fe4fa..f9104a3 100644
> --- a/generic/lib/SOURCES
> +++ b/generic/lib/SOURCES
> @@ -189,6 +189,7 @@ relational/isnormal.cl
> relational/isnotequal.cl
> relational/isordered.cl
> relational/isunordered.cl
> +relational/select.cl
> relational/signbit.cl
> shared/clamp.cl
> shared/max.cl
> diff --git a/generic/lib/relational/select.cl b/generic/lib/relational/select.cl
> new file mode 100644
> index 0000000..dc2e273
> --- /dev/null
> +++ b/generic/lib/relational/select.cl
> @@ -0,0 +1,7 @@
> +#include <clc/clc.h>
> +#include <utils.h>
> +
> +#define __CLC_BODY <select.inc>
> +#include <clc/math/gentype.inc>
> +#define __CLC_BODY <select.inc>
> +#include <clc/integer/gentype.inc>
> diff --git a/generic/lib/relational/select.inc b/generic/lib/relational/select.inc
> new file mode 100644
> index 0000000..b990d26
> --- /dev/null
> +++ b/generic/lib/relational/select.inc
> @@ -0,0 +1,47 @@
> +#ifdef __CLC_SCALAR
> +#define __CLC_VECSIZE
> +#endif
> +
> +#if __CLC_FPSIZE == 64
> +#define __CLC_S_GENTYPE __CLC_XCONCAT(long, __CLC_VECSIZE)
> +#define __CLC_U_GENTYPE __CLC_XCONCAT(ulong, __CLC_VECSIZE)
> +#elif __CLC_FPSIZE == 32
> +#define __CLC_S_GENTYPE __CLC_XCONCAT(int, __CLC_VECSIZE)
> +#define __CLC_U_GENTYPE __CLC_XCONCAT(uint, __CLC_VECSIZE)
> +#elif __CLC_FPSIZE == 16
> +#define __CLC_S_GENTYPE __CLC_XCONCAT(char, __CLC_VECSIZE)
> +#define __CLC_U_GENTYPE __CLC_XCONCAT(uchar, __CLC_VECSIZE)
> +#endif
> +#ifdef __CLC_FPSIZE
> +#define __CLC_GENSIZE __CLC_FPSIZE
> +#endif
> +
> +#define __CLC_AS_S_GENTYPE __CLC_XCONCAT(as_, __CLC_S_GENTYPE)
> +#define __CLC_AS_GENTYPE __CLC_XCONCAT(as_, __CLC_GENTYPE)
> +
> +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE select(__CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_S_GENTYPE z)
> +{
> +#ifdef __CLC_SCALAR
> + return z ? y : x;
> +#else
> + __CLC_S_GENTYPE bitmask = z >> (__CLC_GENSIZE - 1);
> + return __CLC_AS_GENTYPE(bitselect(__CLC_AS_S_GENTYPE(x), __CLC_AS_S_GENTYPE(y), bitmask));
> +#endif
> +}
> +
> +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE select(__CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_U_GENTYPE z)
> +{
> + return select(x, y, __CLC_AS_S_GENTYPE(z));
> +}
> +
> +#undef __CLC_AS_S_GENTYPE
> +#undef __CLC_AS_GENTYPE
> +
> +#ifdef __CLC_FPSIZE
> +#undef __CLC_S_GENTYPE
> +#undef __CLC_U_GENTYPE
> +#undef __CLC_GENSIZE
> +#endif
> +#ifdef __CLC_SCALAR
> +#undef __CLC_VECSIZE
> +#endif
> --
> 2.14.3
>
> _______________________________________________
> Libclc-dev mailing list
> Libclc-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/libclc-dev
More information about the Libclc-dev
mailing list