From: Junyan He <[email protected]> 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 <[email protected]> --- src/cl_command_queue.c | 10 ++++++++-- src/cl_command_queue_gen7.c | 6 ++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/cl_command_queue.c b/src/cl_command_queue.c index 41281f2..8426c4e 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 978650a..b228563 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 -- 1.8.3.2 _______________________________________________ Beignet mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/beignet
