[Libclc-dev] [PATCH 2/5] add isnormal builtin

Aaron Watry awatry at gmail.com
Thu Sep 4 10:57:09 PDT 2014


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/isnormal.h | 22 ++++++++++++++++++++++
>  generic/lib/SOURCES                       |  1 +
>  generic/lib/relational/isnormal.cl        | 19 +++++++++++++++++++
>  4 files changed, 43 insertions(+)
>  create mode 100644 generic/include/clc/relational/isnormal.h
>  create mode 100644 generic/lib/relational/isnormal.cl
>
> diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
> index f7085ce..148a83b 100644
> --- a/generic/include/clc/clc.h
> +++ b/generic/include/clc/clc.h
> @@ -121,6 +121,7 @@
>  #include <clc/relational/isless.h>
>  #include <clc/relational/islessequal.h>
>  #include <clc/relational/isnan.h>
> +#include <clc/relational/isnormal.h>
>  #include <clc/relational/isnotequal.h>
>  #include <clc/relational/select.h>
>  #include <clc/relational/signbit.h>
> diff --git a/generic/include/clc/relational/isnormal.h b/generic/include/clc/relational/isnormal.h
> new file mode 100644
> index 0000000..9efda7c
> --- /dev/null
> +++ b/generic/include/clc/relational/isnormal.h
> @@ -0,0 +1,22 @@
> +
> +#define _CLC_ISNAN_DECL(RET_TYPE, ARG_TYPE) \
> +  _CLC_OVERLOAD _CLC_DECL RET_TYPE isnormal(ARG_TYPE);
> +

Same comment here as in patch 1.  copy/paste macro name which doesn't
really break anything since it's undef'd at the end.  Same comment
about floatn.inc and EOF whitespace as well.

--Aaron

> +#define _CLC_VECTOR_ISNAN_DECL(RET_TYPE, ARG_TYPE) \
> +  _CLC_ISNAN_DECL(RET_TYPE##2, ARG_TYPE##2) \
> +  _CLC_ISNAN_DECL(RET_TYPE##3, ARG_TYPE##3) \
> +  _CLC_ISNAN_DECL(RET_TYPE##4, ARG_TYPE##4) \
> +  _CLC_ISNAN_DECL(RET_TYPE##8, ARG_TYPE##8) \
> +  _CLC_ISNAN_DECL(RET_TYPE##16, ARG_TYPE##16)
> +
> +_CLC_ISNAN_DECL(int, float)
> +_CLC_VECTOR_ISNAN_DECL(int, float)
> +
> +#ifdef cl_khr_fp64
> +_CLC_ISNAN_DECL(int, double)
> +_CLC_VECTOR_ISNAN_DECL(long, double)
> +#endif
> +
> +#undef _CLC_ISNAN_DECL
> +#undef _CLC_VECTOR_ISNAN_DECL
> +
> diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
> index 3c02118..115cbee 100644
> --- a/generic/lib/SOURCES
> +++ b/generic/lib/SOURCES
> @@ -56,6 +56,7 @@ relational/isinf.cl
>  relational/isless.cl
>  relational/islessequal.cl
>  relational/isnan.cl
> +relational/isnormal.cl
>  relational/isnotequal.cl
>  relational/signbit.cl
>  shared/clamp.cl
> diff --git a/generic/lib/relational/isnormal.cl b/generic/lib/relational/isnormal.cl
> new file mode 100644
> index 0000000..3ff4f73
> --- /dev/null
> +++ b/generic/lib/relational/isnormal.cl
> @@ -0,0 +1,19 @@
> +#include <clc/clc.h>
> +#include "relational.h"
> +
> +_CLC_DEFINE_RELATIONAL_UNARY(int, isnormal, __builtin_isnormal, float)
> +
> +#ifdef cl_khr_fp64
> +
> +#pragma OPENCL EXTENSION cl_khr_fp64 : enable
> +
> +// The scalar version of isnormal(double) returns an int, but the vector versions
> +// return long.
> +_CLC_DEF _CLC_OVERLOAD int isnormal(double x) {
> +  return __builtin_isnormal(x);
> +}
> +
> +_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(long, isnormal, 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