[Beignet] [V2 PATCH 4/4] Add the clGetMemObjectInfo options for sub-buffer and update the utest case
junyan.he at inbox.com
junyan.he at inbox.com
Thu Nov 7 00:44:53 PST 2013
From: Junyan He <junyan.he at linux.intel.com>
Signed-off-by: Junyan He <junyan.he at linux.intel.com>
---
src/cl_mem.c | 15 ++++++++++++---
utests/get_cl_info.cpp | 25 +++++++++++++++++++++++--
2 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/src/cl_mem.c b/src/cl_mem.c
index 00ef30d..8c9f8a8 100644
--- a/src/cl_mem.c
+++ b/src/cl_mem.c
@@ -116,12 +116,21 @@ cl_get_mem_object_info(cl_mem mem,
case CL_MEM_CONTEXT:
*((cl_context *)param_value) = mem->ctx;
break;
- // TODO: Need to implement sub buffer first.
case CL_MEM_ASSOCIATED_MEMOBJECT:
- NOT_IMPLEMENTED;
+ if(mem->type != CL_MEM_SUBBUFFER_TYPE) {
+ *((cl_mem *)param_value) = NULL;
+ } else {
+ struct _cl_mem_buffer* buf = (struct _cl_mem_buffer*)mem;
+ *((cl_mem *)param_value) = (cl_mem)(buf->parent);
+ }
break;
case CL_MEM_OFFSET:
- NOT_IMPLEMENTED;
+ if(mem->type != CL_MEM_SUBBUFFER_TYPE) {
+ *((size_t *)param_value) = 0;
+ } else {
+ struct _cl_mem_buffer* buf = (struct _cl_mem_buffer*)mem;
+ *((size_t *)param_value) = buf->sub_offset;
+ }
break;
}
diff --git a/utests/get_cl_info.cpp b/utests/get_cl_info.cpp
index ec02ce9..4148ce9 100644
--- a/utests/get_cl_info.cpp
+++ b/utests/get_cl_info.cpp
@@ -548,8 +548,18 @@ void get_mem_info(void)
{
map<cl_mem_info, void *> maps;
int expect_ref;
+ cl_mem sub_buf;
+ cl_int error;
+
+ OCL_CREATE_BUFFER(buf[1], 0, 4096, NULL);
+
+ cl_buffer_region region;
+ region.origin = 1024;
+ region.size = 2048;
+ sub_buf = clCreateSubBuffer(buf[1], 0, CL_BUFFER_CREATE_TYPE_REGION, ®ion, &error );
+ buf[0] = sub_buf;
+ OCL_ASSERT(error == CL_SUCCESS);
- OCL_CREATE_BUFFER(buf[0], 0, 64, NULL);
void * map_ptr = clEnqueueMapBuffer(queue, buf[0], 1, CL_MAP_READ, 0, 64, 0, NULL, NULL, NULL);
expect_ref = CL_MEM_OBJECT_BUFFER;
@@ -558,7 +568,7 @@ void get_mem_info(void)
expect_ref = 0;
maps.insert(make_pair(CL_MEM_FLAGS,
(void *)(new Info_Result<cl_mem_flags>(expect_ref))));
- expect_ref = 64;
+ expect_ref = 2048;
maps.insert(make_pair(CL_MEM_SIZE,
(void *)(new Info_Result<size_t>(((size_t)expect_ref)))));
expect_ref = 0;
@@ -572,6 +582,11 @@ void get_mem_info(void)
(void *)(new Info_Result<cl_uint>(((cl_uint)expect_ref)))));
maps.insert(make_pair(CL_MEM_CONTEXT,
(void *)(new Info_Result<cl_context>(((cl_context)ctx)))));
+ maps.insert(make_pair(CL_MEM_ASSOCIATED_MEMOBJECT,
+ (void *)(new Info_Result<cl_mem>(((cl_mem)buf[1])))));
+ expect_ref = 1024;
+ maps.insert(make_pair(CL_MEM_OFFSET,
+ (void *)(new Info_Result<size_t>(((size_t)expect_ref)))));
std::for_each(maps.begin(), maps.end(), [](pair<cl_mem_info, void *> x) {
switch (x.first) {
@@ -596,6 +611,12 @@ void get_mem_info(void)
case CL_MEM_CONTEXT:
CALL_GETMEMINFO_AND_RET(cl_context);
break;
+ case CL_MEM_ASSOCIATED_MEMOBJECT:
+ CALL_GETMEMINFO_AND_RET(cl_mem);
+ break;
+ case CL_MEM_OFFSET:
+ CALL_GETMEMINFO_AND_RET(size_t);
+ break;
default:
break;
--
1.7.9.5
More information about the Beignet
mailing list