summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunyan He <junyan.he@linux.intel.com>2014-06-20 17:41:19 +0800
committerZhigang Gong <zhigang.gong@intel.com>2014-06-23 10:33:47 +0800
commit37eaf91688f65ed4b43f570a734908ca14d0149f (patch)
treef6a673a561d5c4e476031617e5546d7cd20eba17
parentaed86199bded8478070010386aea321b865e21a8 (diff)
downloadbeignet-37eaf91688f65ed4b43f570a734908ca14d0149f.tar.gz
Fix a crash bug when no %d appears in the printf fmt
If there no %d for all the printf statement, the curbe will ignore the content buffer ptr because no one use it. So when bind the buffer ptr in the run time, crash happens. Signed-off-by: Junyan He <junyan.he@linux.intel.com> Reviewed-by: Yang Rong <rong.r.yang@intel.com>
-rw-r--r--src/cl_command_queue.c10
-rw-r--r--src/cl_command_queue_gen7.c6
2 files changed, 12 insertions, 4 deletions
diff --git a/src/cl_command_queue.c b/src/cl_command_queue.c
index 41281f21..8426c4e1 100644
--- a/src/cl_command_queue.c
+++ b/src/cl_command_queue.c
@@ -432,11 +432,17 @@ cl_command_queue_flush(cl_command_queue queue)
if (printf_info && interp_get_printf_num(printf_info)) {
void *index_addr = cl_gpgpu_map_printf_buffer(gpgpu, 0);
- void *buf_addr = cl_gpgpu_map_printf_buffer(gpgpu, 1);
+ void *buf_addr = NULL;
+ if (interp_get_printf_sizeof_size(printf_info))
+ buf_addr = cl_gpgpu_map_printf_buffer(gpgpu, 1);
+
interp_output_printf(printf_info, index_addr, buf_addr, global_wk_sz[0],
global_wk_sz[1], global_wk_sz[2]);
+
cl_gpgpu_unmap_printf_buffer(gpgpu, 0);
- cl_gpgpu_unmap_printf_buffer(gpgpu, 1);
+ if (interp_get_printf_sizeof_size(printf_info))
+ cl_gpgpu_unmap_printf_buffer(gpgpu, 1);
+
interp_release_printf_info(printf_info);
global_wk_sz[0] = global_wk_sz[1] = global_wk_sz[2] = 0;
cl_gpgpu_set_printf_info(gpgpu, NULL, global_wk_sz);
diff --git a/src/cl_command_queue_gen7.c b/src/cl_command_queue_gen7.c
index 7f00a871..9af4829a 100644
--- a/src/cl_command_queue_gen7.c
+++ b/src/cl_command_queue_gen7.c
@@ -259,12 +259,14 @@ cl_bind_printf(cl_gpgpu gpgpu, cl_kernel ker, void* printf_info, int printf_num,
int32_t value = GBE_CURBE_PRINTF_INDEX_POINTER;
int32_t offset = interp_kernel_get_curbe_offset(ker->opaque, value, 0);
size_t buf_size = global_sz * sizeof(int) * printf_num;
- cl_gpgpu_set_printf_buffer(gpgpu, 0, buf_size, offset);
+ if (offset > 0)
+ cl_gpgpu_set_printf_buffer(gpgpu, 0, buf_size, offset);
value = GBE_CURBE_PRINTF_BUF_POINTER;
offset = interp_kernel_get_curbe_offset(ker->opaque, value, 0);
buf_size = interp_get_printf_sizeof_size(printf_info) * global_sz;
- cl_gpgpu_set_printf_buffer(gpgpu, 1, buf_size, offset);
+ if (offset > 0)
+ cl_gpgpu_set_printf_buffer(gpgpu, 1, buf_size, offset);
}
LOCAL cl_int