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

xionghu.luo at intel.com xionghu.luo at intel.com
Tue Nov 4 19:10:40 PST 2014


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



More information about the Beignet mailing list