[Libclc-dev] [PATCH 1/2] relational: Add isless(floatN) builtin
Aaron Watry
awatry at gmail.com
Fri Aug 1 13:40:30 PDT 2014
On Thu, Jul 31, 2014 at 7:09 PM, Jan Vesely <jan.vesely at rutgers.edu> wrote:
> Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
> ---
>
> Based on Aaron's isgreater/isgreaterequal.
>
> generic/include/clc/clc.h | 1 +
> generic/include/clc/relational/isless.h | 9 +++++++++
> generic/lib/SOURCES | 1 +
> generic/lib/relational/isless.cl | 22 ++++++++++++++++++++++
> 4 files changed, 33 insertions(+)
> create mode 100644 generic/include/clc/relational/isless.h
> create mode 100644 generic/lib/relational/isless.cl
>
> diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
> index 60b5a6c..83bf8fa 100644
> --- a/generic/include/clc/clc.h
> +++ b/generic/include/clc/clc.h
> @@ -115,6 +115,7 @@
> #include <clc/relational/isequal.h>
> #include <clc/relational/isgreater.h>
> #include <clc/relational/isgreaterequal.h>
> +#include <clc/relational/isless.h>
> #include <clc/relational/isnan.h>
> #include <clc/relational/isnotequal.h>
> #include <clc/relational/select.h>
> diff --git a/generic/include/clc/relational/isless.h b/generic/include/clc/relational/isless.h
> new file mode 100644
> index 0000000..1954a59
> --- /dev/null
> +++ b/generic/include/clc/relational/isless.h
> @@ -0,0 +1,9 @@
> +#undef isless
> +
Many of the math built-ins require the #undef of the builtin function
name, but it turns out that this isn't the case for at least this
relational.
Get rid of the #undef isless and this patch is byte-identical to the
isless implementation that I hadn't yet gotten around to sending yet
and therefore would be:
Reviewed-by: Aaron Watry <awatry at gmail.com>
> +#define __CLC_FUNCTION isless
> +#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 7efe08c..7faba40 100644
> --- a/generic/lib/SOURCES
> +++ b/generic/lib/SOURCES
> @@ -48,6 +48,7 @@ relational/any.cl
> relational/isequal.cl
> relational/isgreater.cl
> relational/isgreaterequal.cl
> +relational/isless.cl
> relational/isnan.cl
> relational/isnotequal.cl
> relational/signbit.cl
> diff --git a/generic/lib/relational/isless.cl b/generic/lib/relational/isless.cl
> new file mode 100644
> index 0000000..56a3e13
> --- /dev/null
> +++ b/generic/lib/relational/isless.cl
> @@ -0,0 +1,22 @@
> +#include <clc/clc.h>
> +#include "relational.h"
> +
> +//Note: It would be nice to use __builtin_isless 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, isless, __builtin_isless, float, float)
> +
> +#ifdef cl_khr_fp64
> +
> +#pragma OPENCL EXTENSION cl_khr_fp64 : enable
> +
> +// The scalar version of isless(double, double) returns an int, but the vector versions
> +// return long.
> +
> +_CLC_DEF _CLC_OVERLOAD int isless(double x, double y){
> + return __builtin_isless(x, y);
> +}
> +
> +_CLC_DEFINE_RELATIONAL_BINARY_VEC_ALL(long, isless, 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
More information about the Libclc-dev
mailing list