[Beignet] [PATCH] fix bswap kernel function type issue.

Zhigang Gong zhigang.gong at linux.intel.com
Wed Nov 5 03:28:56 PST 2014


LGTM, pushed, thanks.
On Wed, Nov 05, 2014 at 11:10:40AM +0800, xionghu.luo at intel.com wrote:
> From: Luo Xionghu <xionghu.luo at intel.com>
> 
> use MACRO to define the corresponding function.
> 
> Signed-off-by: Luo Xionghu <xionghu.luo at intel.com>
> ---
>  kernels/compiler_bswap.cl |   15 ++++++++++-----
>  utests/compiler_bswap.cpp |    4 ++--
>  2 files changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/kernels/compiler_bswap.cl b/kernels/compiler_bswap.cl
> index d6ed91a..9ef0e6b 100644
> --- a/kernels/compiler_bswap.cl
> +++ b/kernels/compiler_bswap.cl
> @@ -1,7 +1,12 @@
> -kernel void compiler_bswap_short(global short* src, global short* dst){
> -   dst[get_global_id(0)]= __builtin_bswap16(src[get_global_id(0)]);
> +#define TEST_TYPE(TYPE, LENGTH)                                       \
> +kernel void compiler_bswap_##TYPE(global TYPE * src, global TYPE * dst){ \
> +   dst[get_global_id(0)]= __builtin_bswap##LENGTH(src[get_global_id(0)]); \
>  }
>  
> -kernel void compiler_bswap_int(global int* src, global int* dst){
> -   dst[get_global_id(0)]= __builtin_bswap32(src[get_global_id(0)]);
> -}
> +
> +TEST_TYPE(short, 16)
> +TEST_TYPE(ushort, 16)
> +TEST_TYPE(int, 32)
> +TEST_TYPE(uint, 32)
> +
> +#undef TEST_TYPE
> diff --git a/utests/compiler_bswap.cpp b/utests/compiler_bswap.cpp
> index 2ce8d49..b5986b9 100644
> --- a/utests/compiler_bswap.cpp
> +++ b/utests/compiler_bswap.cpp
> @@ -104,6 +104,6 @@ static void compiler_bswap_ ##type(void)\
>  MAKE_UTEST_FROM_FUNCTION(compiler_bswap_ ## type);
>  
>  compiler_bswap(int16_t, compiler_bswap_short)
> -compiler_bswap(uint16_t, compiler_bswap_short)
> +compiler_bswap(uint16_t, compiler_bswap_ushort)
>  compiler_bswap(int32_t, compiler_bswap_int)
> -compiler_bswap(uint32_t, compiler_bswap_int)
> +compiler_bswap(uint32_t, compiler_bswap_uint)
> -- 
> 1.7.9.5
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list