[Libclc-dev] [PATCH] libclc: Fix mad24/mul24 definitions.

Tom Stellard tom at stellard.net
Thu Jul 11 15:13:21 PDT 2013


On Thu, Jul 11, 2013 at 11:02:00AM -0500, Aaron Watry wrote:
> clc/integer/integer-gentype.inc is really clc/integer/gentype.inc
>

integer-gentype.inc contains only 32-bit types, which is all that is
needed for mad24 and mul24.  I guess the name is a little confusing.
Maybe it should be renamed to integer32.inc

> And shifting by integer amounts requires that we cast that integer to the
> appropriate GENTYPE first.
> 
> Signed-off-by: Aaron Watry <awatry at gmail.com>
> ---
>  generic/include/clc/integer/mad24.h | 2 +-
>  generic/include/clc/integer/mul24.h | 2 +-
>  generic/lib/integer/mad24.cl        | 2 +-
>  generic/lib/integer/mul24.cl        | 2 +-
>  generic/lib/integer/mul24.inc       | 4 ++--
>  5 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/generic/include/clc/integer/mad24.h b/generic/include/clc/integer/mad24.h
> index 0c120fa..3508bf3 100644
> --- a/generic/include/clc/integer/mad24.h
> +++ b/generic/include/clc/integer/mad24.h
> @@ -1,3 +1,3 @@
>  #define __CLC_BODY <clc/integer/mad24.inc>
> -#include <clc/integer/integer-gentype.inc>
> +#include <clc/integer/gentype.inc>
>  #undef __CLC_BODY
> diff --git a/generic/include/clc/integer/mul24.h b/generic/include/clc/integer/mul24.h
> index 4f97098..b6dd322 100644
> --- a/generic/include/clc/integer/mul24.h
> +++ b/generic/include/clc/integer/mul24.h
> @@ -1,3 +1,3 @@
>  #define __CLC_BODY <clc/integer/mul24.inc>
> -#include <clc/integer/integer-gentype.inc>
> +#include <clc/integer/gentype.inc>
>  #undef __CLC_BODY
> diff --git a/generic/lib/integer/mad24.cl b/generic/lib/integer/mad24.cl
> index e29e99f..54d3010 100644
> --- a/generic/lib/integer/mad24.cl
> +++ b/generic/lib/integer/mad24.cl
> @@ -1,4 +1,4 @@
>  #include <clc/clc.h>
>  
>  #define __CLC_BODY <mad24.inc>
> -#include <clc/integer/integer-gentype.inc>
> +#include <clc/integer/gentype.inc>
> diff --git a/generic/lib/integer/mul24.cl b/generic/lib/integer/mul24.cl
> index 8aedca6..145a55d 100644
> --- a/generic/lib/integer/mul24.cl
> +++ b/generic/lib/integer/mul24.cl
> @@ -1,4 +1,4 @@
>  #include <clc/clc.h>
>  
>  #define __CLC_BODY <mul24.inc>
> -#include <clc/integer/integer-gentype.inc>
> +#include <clc/integer/gentype.inc>
> diff --git a/generic/lib/integer/mul24.inc b/generic/lib/integer/mul24.inc
> index 95a2f1d..bdd30b4 100644
> --- a/generic/lib/integer/mul24.inc
> +++ b/generic/lib/integer/mul24.inc
> @@ -2,10 +2,10 @@
>  // We need to use shifts here in order to mantain the sign bit for signed
>  // integers.  The compiler should optimize this to (x & 0x00FFFFFF) for
>  // unsigned integers.
> -#define CONVERT_TO_24BIT(x) (((x) << 8) >> 8)
> +#define CONVERT_TO_24BIT(x, y) (((x) << (y)8) >> (y)8)
>  
>  _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE mul24(__CLC_GENTYPE x, __CLC_GENTYPE y){
> -  return CONVERT_TO_24BIT(x) * CONVERT_TO_24BIT(y);
> +  return CONVERT_TO_24BIT(x, __CLC_GENTYPE) * CONVERT_TO_24BIT(y, __CLC_GENTYPE);
>  }
>  
>  #undef CONVERT_TO_24BIT
> -- 
> 1.8.1.2
> 
> 
> _______________________________________________
> 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