diff options
author | Guo Yejun <yejun.guo@intel.com> | 2014-12-02 09:31:08 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2014-12-02 17:17:01 +0800 |
commit | 07809dc3aac221663c32476a4f276da4b4e6b611 (patch) | |
tree | a97357eed938242fa6a99efcc2998b0b5a5b18cd | |
parent | befcef65ce5a87a91967974a53d5e77e2b16d136 (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 4551983b..d98c0ec2 100644 --- a/utests/CMakeLists.txt +++ b/utests/CMakeLists.txt @@ -196,6 +196,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); |