diff options
author | Guo Yejun <yejun.guo@intel.com> | 2014-12-02 09:31:08 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2015-01-12 09:14:03 +0800 |
commit | 6b6fa16b874f34d54a161d0173c508938ec5a983 (patch) | |
tree | d8abf969aae64fe735b3b3744639dd5c1e6e071b | |
parent | c0075732314a6ffbcb9c265de3d96391bc4ca7fd (diff) |
add utest of CL_MEM_ALLOC_HOST_PTR
Signed-off-by: Guo Yejun <yejun.guo@intel.com>
Reviewed-by: "Yang, Rong R" <rong.r.yang@intel.com>
-rw-r--r-- | kernels/runtime_alloc_host_ptr_buffer.cl | 6 | ||||
-rw-r--r-- | utests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | utests/runtime_alloc_host_ptr_buffer.cpp | 25 |
3 files changed, 32 insertions, 0 deletions
diff --git a/kernels/runtime_alloc_host_ptr_buffer.cl b/kernels/runtime_alloc_host_ptr_buffer.cl new file mode 100644 index 00000000..290241d8 --- /dev/null +++ b/kernels/runtime_alloc_host_ptr_buffer.cl @@ -0,0 +1,6 @@ +__kernel void +runtime_alloc_host_ptr_buffer(__global int* buf) +{ + int id = (int)get_global_id(0); + buf[id] = id / 2; +} diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt index 453c3a06..931f6fdd 100644 --- a/utests/CMakeLists.txt +++ b/utests/CMakeLists.txt @@ -195,6 +195,7 @@ set (utests_sources compiler_assignment_operation_in_if.cpp vload_bench.cpp runtime_use_host_ptr_buffer.cpp + runtime_alloc_host_ptr_buffer.cpp utest_assert.cpp utest.cpp utest_file_map.cpp diff --git a/utests/runtime_alloc_host_ptr_buffer.cpp b/utests/runtime_alloc_host_ptr_buffer.cpp new file mode 100644 index 00000000..793682b7 --- /dev/null +++ b/utests/runtime_alloc_host_ptr_buffer.cpp @@ -0,0 +1,25 @@ +#include "utest_helper.hpp" + +static void runtime_alloc_host_ptr_buffer(void) +{ + const size_t n = 4096*100; + + // Setup kernel and buffers + OCL_CREATE_KERNEL("runtime_alloc_host_ptr_buffer"); + + OCL_CREATE_BUFFER(buf[0], CL_MEM_ALLOC_HOST_PTR, n * sizeof(uint32_t), NULL); + + // Run the kernel + OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]); + globals[0] = n; + locals[0] = 256; + OCL_NDRANGE(1); + + // Check result + uint32_t* mapptr = (uint32_t*)clEnqueueMapBuffer(queue, buf[0], CL_TRUE, CL_MAP_READ, 0, n*sizeof(uint32_t), 0, NULL, NULL, NULL); + for (uint32_t i = 0; i < n; ++i) + OCL_ASSERT(mapptr[i] == i / 2); + clEnqueueUnmapMemObject(queue, buf[0], mapptr, 0, NULL, NULL); +} + +MAKE_UTEST_FROM_FUNCTION(runtime_alloc_host_ptr_buffer); |