[Libclc-dev] [PATCH 3/3] Fix compilation warnings without cl_khr_fp64

Tom Stellard tom at stellard.net
Mon Apr 13 08:26:56 PDT 2015


On Sun, Apr 12, 2015 at 06:46:54PM -0400, Jan Vesely wrote:

LGTM.

> Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
> ---
>  generic/lib/math/acos.inc | 14 +++++++++++---
>  generic/lib/math/asin.inc | 13 +++++++++++--
>  generic/lib/math/tan.inc  | 11 ++++++++++-
>  3 files changed, 32 insertions(+), 6 deletions(-)
> 
> diff --git a/generic/lib/math/acos.inc b/generic/lib/math/acos.inc
> index 8612415..cac9499 100644
> --- a/generic/lib/math/acos.inc
> +++ b/generic/lib/math/acos.inc
> @@ -11,11 +11,19 @@
>   * precision of #4 may be better.
>   */
>  
> +#if __CLC_FPSIZE == 32
> +#define __CLC_CONST(x) x ## f
> +#else
> +#define __CLC_CONST(x) x
> +#endif
> +
>  _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE acos(__CLC_GENTYPE x) {
>    return (
> -    (__CLC_GENTYPE) 2.0 * atan2(
> -      sqrt((__CLC_GENTYPE) 1.0 - x),
> -      sqrt((__CLC_GENTYPE) 1.0 + x)
> +    (__CLC_GENTYPE) __CLC_CONST(2.0) * atan2(
> +      sqrt((__CLC_GENTYPE) __CLC_CONST(1.0) - x),
> +      sqrt((__CLC_GENTYPE) __CLC_CONST(1.0) + x)
>      )
>    );
>  }
> +
> +#undef __CLC_CONST
> diff --git a/generic/lib/math/asin.inc b/generic/lib/math/asin.inc
> index a109c36..4643cf8 100644
> --- a/generic/lib/math/asin.inc
> +++ b/generic/lib/math/asin.inc
> @@ -1,3 +1,12 @@
> +
> +#if __CLC_FPSIZE == 32
> +#define __CLC_CONST(x) x ## f
> +#else
> +#define __CLC_CONST(x) x
> +#endif
> +
>  _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE asin(__CLC_GENTYPE x) {
> -  return atan2(x, sqrt( (__CLC_GENTYPE)1.0 -(x*x) ));
> -}
> \ No newline at end of file
> +  return atan2(x, sqrt( (__CLC_GENTYPE)__CLC_CONST(1.0) -(x*x) ));
> +}
> +
> +#undef __CLC_CONST
> diff --git a/generic/lib/math/tan.inc b/generic/lib/math/tan.inc
> index 8d9d9fe..b9ce33e 100644
> --- a/generic/lib/math/tan.inc
> +++ b/generic/lib/math/tan.inc
> @@ -2,7 +2,16 @@
>   * Note: tan(x) = sin(x)/cos(x) also, but the final assembly ends up being
>   *       twice as long for R600 (maybe for others as well).
>   */
> +
> +#if __CLC_FPSIZE == 32
> +#define __CLC_CONST(x) x ## f
> +#else
> +#define __CLC_CONST(x) x
> +#endif
> +
>  _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE tan(__CLC_GENTYPE x) {
>    __CLC_GENTYPE sinx = sin(x);
> -  return sinx / sqrt( (__CLC_GENTYPE) 1.0 - (sinx*sinx) );
> +  return sinx / sqrt( (__CLC_GENTYPE) __CLC_CONST(1.0) - (sinx*sinx) );
>  }
> +
> +#undef __CLC_CONST
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> 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