summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZhigang Gong <zhigang.gong@intel.com>2015-10-10 09:10:35 +0800
committerYang Rong <rong.r.yang@intel.com>2015-10-12 10:10:33 +0800
commitad733c0efea62f92ab5f00cd09d03d36a524f87e (patch)
tree414e4e93ca0485359ffd846cd75e457b5a3f5066 /src
parent208ffc2153568bf3f1bbce744b10d8f97fb87da6 (diff)
GBE: fix kernel arguments uploading bug.
After the curbe allocation refactor, not all kernel arguments will be allocated unconditional. If some kernel arguments haven't been used at all, the corresponding arguments will be ignored at backend thus we may get a -1 offset. On the runtime driver side, we need check this situation. Signed-off-by: Zhigang Gong <zhigang.gong@intel.com> Reviewed-by: "Yang, Rong R" <rong.r.yang@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/cl_command_queue_gen7.c6
-rw-r--r--src/cl_kernel.c8
2 files changed, 9 insertions, 5 deletions
diff --git a/src/cl_command_queue_gen7.c b/src/cl_command_queue_gen7.c
index 8c096156..2edc3be4 100644
--- a/src/cl_command_queue_gen7.c
+++ b/src/cl_command_queue_gen7.c
@@ -173,7 +173,8 @@ cl_upload_constant_buffer(cl_command_queue queue, cl_kernel ker)
uint32_t alignment = interp_kernel_get_arg_align(ker->opaque, arg);
offset = ALIGN(offset, alignment);
curbe_offset = interp_kernel_get_curbe_offset(ker->opaque, GBE_CURBE_KERNEL_ARGUMENT, arg);
- assert(curbe_offset >= 0);
+ if (curbe_offset < 0)
+ continue;
*(uint32_t *) (ker->curbe + curbe_offset) = offset;
cl_buffer_map(mem->bo, 1);
@@ -228,7 +229,8 @@ cl_curbe_fill(cl_kernel ker,
assert(align != 0);
slm_offset = ALIGN(slm_offset, align);
offset = interp_kernel_get_curbe_offset(ker->opaque, GBE_CURBE_KERNEL_ARGUMENT, arg);
- assert(offset >= 0);
+ if (offset < 0)
+ continue;
uint32_t *slmptr = (uint32_t *) (ker->curbe + offset);
*slmptr = slm_offset;
slm_offset += ker->args[arg].local_sz;
diff --git a/src/cl_kernel.c b/src/cl_kernel.c
index 5d170c6b..58a1224e 100644
--- a/src/cl_kernel.c
+++ b/src/cl_kernel.c
@@ -153,9 +153,10 @@ cl_kernel_set_arg(cl_kernel k, cl_uint index, size_t sz, const void *value)
/* Copy the structure or the value directly into the curbe */
if (arg_type == GBE_ARG_VALUE) {
offset = interp_kernel_get_curbe_offset(k->opaque, GBE_CURBE_KERNEL_ARGUMENT, index);
- assert(offset + sz <= k->curbe_sz);
- if (offset >= 0)
+ if (offset >= 0) {
+ assert(offset + sz <= k->curbe_sz);
memcpy(k->curbe + offset, value, sz);
+ }
k->args[index].local_sz = 0;
k->args[index].is_set = 1;
k->args[index].mem = NULL;
@@ -193,7 +194,8 @@ cl_kernel_set_arg(cl_kernel k, cl_uint index, size_t sz, const void *value)
if(value == NULL || mem == NULL) {
/* for buffer object GLOBAL_PTR CONSTANT_PTR, it maybe NULL */
int32_t offset = interp_kernel_get_curbe_offset(k->opaque, GBE_CURBE_KERNEL_ARGUMENT, index);
- *((uint32_t *)(k->curbe + offset)) = 0;
+ if (offset >= 0)
+ *((uint32_t *)(k->curbe + offset)) = 0;
assert(arg_type == GBE_ARG_GLOBAL_PTR || arg_type == GBE_ARG_CONSTANT_PTR);
if (k->args[index].mem)