[Libclc-dev] [PATCH 1/2] Fix implementation of copysign

Aaron Watry awatry at gmail.com
Tue Sep 2 13:49:56 PDT 2014


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

This fixes the atan2 issue I was running into on evergreen as well, so
feel free to add:
Tested-by: Aaron Watry <awatry at gmail.com>

--Aaron

On Tue, Sep 2, 2014 at 2:12 PM, Tom Stellard <thomas.stellard at amd.com> wrote:
> This was previously implemented with a macro and we were using
> __builtin_copysign(), which takes double inputs for the float
> version of copysign().
> ---
>  generic/include/clc/math/copysign.h   |  3 ++-
>  generic/include/clc/math/copysign.inc |  1 +
>  generic/lib/SOURCES                   |  1 +
>  generic/lib/math/copysign.cl          | 12 ++++++++++++
>  4 files changed, 16 insertions(+), 1 deletion(-)
>  create mode 100644 generic/include/clc/math/copysign.inc
>  create mode 100644 generic/lib/math/copysign.cl
>
> diff --git a/generic/include/clc/math/copysign.h b/generic/include/clc/math/copysign.h
> index 9d6cf76..8f0742e 100644
> --- a/generic/include/clc/math/copysign.h
> +++ b/generic/include/clc/math/copysign.h
> @@ -1 +1,2 @@
> -#define copysign(x, y) __builtin_copysign(x, y)
> +#define __CLC_BODY <clc/math/copysign.inc>
> +#include <clc/math/gentype.inc>
> diff --git a/generic/include/clc/math/copysign.inc b/generic/include/clc/math/copysign.inc
> new file mode 100644
> index 0000000..6091abc
> --- /dev/null
> +++ b/generic/include/clc/math/copysign.inc
> @@ -0,0 +1 @@
> +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE copysign(__CLC_GENTYPE a, __CLC_GENTYPE b);
> diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
> index ffc9c5d..ced53f3 100644
> --- a/generic/lib/SOURCES
> +++ b/generic/lib/SOURCES
> @@ -32,6 +32,7 @@ integer/upsample.cl
>  math/acos.cl
>  math/atan.cl
>  math/atan2.cl
> +math/copysign.cl
>  math/cos.cl
>  math/exp.cl
>  math/exp10.cl
> diff --git a/generic/lib/math/copysign.cl b/generic/lib/math/copysign.cl
> new file mode 100644
> index 0000000..4e0c51b
> --- /dev/null
> +++ b/generic/lib/math/copysign.cl
> @@ -0,0 +1,12 @@
> +#include <clc/clc.h>
> +#include "../clcmacro.h"
> +
> +_CLC_DEFINE_BINARY_BUILTIN(float, copysign, __builtin_copysignf, float, float)
> +
> +#ifdef cl_khr_fp64
> +
> +#pragma OPENCL EXTENSION cl_khr_fp64 : enable
> +
> +_CLC_DEFINE_BINARY_BUILTIN(double, copysign, __builtin_copysign, double, double)
> +
> +#endif
> --
> 1.8.5.5
>
>
> _______________________________________________
> 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