[Beignet] [PATCH 2/2] change constant test case to cover short/long type.
Ruiling Song
ruiling.song at intel.com
Wed Sep 11 00:22:04 PDT 2013
Signed-off-by: Ruiling Song <ruiling.song at intel.com>
---
kernels/compiler_global_constant_2.cl | 13 ++++++++++++-
utests/compiler_global_constant.cpp | 1 +
utests/compiler_global_constant_2.cpp | 29 +++++++++++++++++++++++++++++
3 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/kernels/compiler_global_constant_2.cl b/kernels/compiler_global_constant_2.cl
index 353ebd7..04536c7 100644
--- a/kernels/compiler_global_constant_2.cl
+++ b/kernels/compiler_global_constant_2.cl
@@ -1,5 +1,9 @@
constant int m[3] = {0x15b,0x25b,0x35b};
-constant int t[5] = {0x45b,0x55b,0x65b,0x75b,0x85b};
+constant short t[5] = {0x45b,0x55b,0x65b,0x75b,0x85b};
+constant long n[3] = {0x15b,0x25b,0xFFFFFFFFF};
+constant long p[3] = {1,1,1};
+constant long s = 1;
+
__kernel void
compiler_global_constant_2(__global int *dst, int e, int r)
@@ -7,3 +11,10 @@ compiler_global_constant_2(__global int *dst, int e, int r)
int id = (int)get_global_id(0);
dst[id] = m[id%3] + t[id%5] + e + r;
}
+
+__kernel void
+compiler_global_constant_2_long(__global long *dst, int e, int r)
+{
+ int id = (int)get_global_id(0);
+ dst[id] = n[id%3]*p[1] + e*s + r;
+}
diff --git a/utests/compiler_global_constant.cpp b/utests/compiler_global_constant.cpp
index 1547020..c0bee4d 100644
--- a/utests/compiler_global_constant.cpp
+++ b/utests/compiler_global_constant.cpp
@@ -22,6 +22,7 @@ void compiler_global_constant(void)
// Check results
OCL_MAP_BUFFER(0);
for (uint32_t i = 0; i < n; ++i)
+// printf("%d result %d reference %d\n", i, ((uint32_t *)buf_data[0])[i], m[i%3] + e + r);
OCL_ASSERT(((uint32_t *)buf_data[0])[i] == m[i%3] + e + r);
OCL_UNMAP_BUFFER(0);
}
diff --git a/utests/compiler_global_constant_2.cpp b/utests/compiler_global_constant_2.cpp
index 56fccb5..cbe63ae 100644
--- a/utests/compiler_global_constant_2.cpp
+++ b/utests/compiler_global_constant_2.cpp
@@ -23,8 +23,37 @@ void compiler_global_constant_2(void)
// Check results
OCL_MAP_BUFFER(0);
for (uint32_t i = 0; i < n; ++i)
+// std::cout << ((uint32_t *)buf_data[0])[i] << std::endl;
OCL_ASSERT(((uint32_t *)buf_data[0])[i] == m[i%3] + t[i%5] + e + r);
OCL_UNMAP_BUFFER(0);
}
+void compiler_global_constant_2_long(void)
+{
+ const size_t n = 2048;
+ const uint32_t e = 34, r = 77;
+
+ // Setup kernel and buffers
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_global_constant_2", "compiler_global_constant_2_long");
+ OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(uint64_t), NULL);
+ OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
+ OCL_SET_ARG(1, sizeof(uint32_t), &e);
+ OCL_SET_ARG(2, sizeof(uint32_t), &r);
+
+ // Run the kernel
+ globals[0] = n;
+ locals[0] = 16;
+ OCL_NDRANGE(1);
+
+ uint64_t m[3] = {0x15b,0x25b,0xFFFFFFFFF};
+
+ // Check results
+ OCL_MAP_BUFFER(0);
+ for (uint32_t i = 0; i < n; ++i)
+// std::cout << ((uint64_t *)buf_data[0])[i] << std::endl;
+ OCL_ASSERT(((uint64_t *)buf_data[0])[i] == m[i%3] + e + r);
+ OCL_UNMAP_BUFFER(0);
+}
+
MAKE_UTEST_FROM_FUNCTION(compiler_global_constant_2);
+MAKE_UTEST_FROM_FUNCTION(compiler_global_constant_2_long);
--
1.7.9.5
More information about the Beignet
mailing list