[Beignet] [PATCH 2/2] Add some OpenCL1.2 new buffer flags handle.
Yang Rong
rong.r.yang at intel.com
Fri Jun 20 04:39:09 PDT 2014
And mem_base_addr_align' unit is bit, and origin's is byte, correct it when compare.
Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
src/cl_api.c | 10 ++++++++++
src/cl_mem.c | 21 ++++++++++++++++++---
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/src/cl_api.c b/src/cl_api.c
index c4a8730..d4d8d7c 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -1600,6 +1600,11 @@ clEnqueueReadBufferRect(cl_command_queue command_queue,
goto error;
}
+ if (buffer->flags & (CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_NO_ACCESS)) {
+ err = CL_INVALID_OPERATION;
+ goto error;
+ }
+
if (!ptr || !region || region[0] == 0 || region[1] == 0 || region[2] == 0) {
err = CL_INVALID_VALUE;
goto error;
@@ -1735,6 +1740,11 @@ clEnqueueWriteBufferRect(cl_command_queue command_queue,
goto error;
}
+ if (buffer->flags & (CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS)) {
+ err = CL_INVALID_OPERATION;
+ goto error;
+ }
+
if (!ptr || !region || region[0] == 0 || region[1] == 0 || region[2] == 0) {
err = CL_INVALID_VALUE;
goto error;
diff --git a/src/cl_mem.c b/src/cl_mem.c
index b4a5d81..ae63137 100644
--- a/src/cl_mem.c
+++ b/src/cl_mem.c
@@ -299,9 +299,13 @@ cl_mem_new_buffer(cl_context ctx,
|| ((flags & CL_MEM_READ_ONLY) && (flags & (CL_MEM_WRITE_ONLY)))
|| ((flags & CL_MEM_ALLOC_HOST_PTR) && (flags & CL_MEM_USE_HOST_PTR))
|| ((flags & CL_MEM_COPY_HOST_PTR) && (flags & CL_MEM_USE_HOST_PTR))
+ || ((flags & CL_MEM_HOST_READ_ONLY) && (flags & CL_MEM_HOST_NO_ACCESS))
+ || ((flags & CL_MEM_HOST_READ_ONLY) && (flags & CL_MEM_HOST_WRITE_ONLY))
+ || ((flags & CL_MEM_HOST_WRITE_ONLY) && (flags & CL_MEM_HOST_NO_ACCESS))
|| ((flags & (~(CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY
| CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR
- | CL_MEM_USE_HOST_PTR))) != 0))) {
+ | CL_MEM_USE_HOST_PTR | CL_MEM_HOST_WRITE_ONLY
+ | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS))) != 0))) {
err = CL_INVALID_VALUE;
goto error;
}
@@ -390,11 +394,22 @@ cl_mem_new_sub_buffer(cl_mem buffer,
if (flags && (((buffer->flags & CL_MEM_WRITE_ONLY) && (flags & (CL_MEM_READ_WRITE|CL_MEM_READ_ONLY)))
|| ((buffer->flags & CL_MEM_READ_ONLY) && (flags & (CL_MEM_READ_WRITE|CL_MEM_WRITE_ONLY)))
- || (flags & (CL_MEM_USE_HOST_PTR | CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR)))) {
+ || (flags & (CL_MEM_USE_HOST_PTR | CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR))
+ || ((flags & CL_MEM_HOST_READ_ONLY) && (flags & CL_MEM_HOST_NO_ACCESS))
+ || ((flags & CL_MEM_HOST_READ_ONLY) && (flags & CL_MEM_HOST_WRITE_ONLY))
+ || ((flags & CL_MEM_HOST_WRITE_ONLY) && (flags & CL_MEM_HOST_NO_ACCESS)))) {
err = CL_INVALID_VALUE;
goto error;
}
+ if((flags & (CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY | CL_MEM_READ_WRITE)) == 0) {
+ flags |= buffer->flags & (CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY | CL_MEM_READ_WRITE);
+ }
+ flags |= buffer->flags & (CL_MEM_USE_HOST_PTR | CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR);
+ if((flags & (CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS)) == 0) {
+ flags |= buffer->flags & (CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS);
+ }
+
if (create_type != CL_BUFFER_CREATE_TYPE_REGION) {
err = CL_INVALID_VALUE;
goto error;
@@ -417,7 +432,7 @@ cl_mem_new_sub_buffer(cl_mem buffer,
goto error;
}
- if (info->origin & (buffer->ctx->device->mem_base_addr_align - 1)) {
+ if (info->origin & (buffer->ctx->device->mem_base_addr_align / 8 - 1)) {
err = CL_MISALIGNED_SUB_BUFFER_OFFSET;
goto error;
}
--
1.8.3.2
More information about the Beignet
mailing list