From 9dbe0b71f9c780dd6888a5f154f58cf78d45ed1e Mon Sep 17 00:00:00 2001 From: Sophie Mao Date: Mon, 8 Apr 2024 10:04:51 -0700 Subject: [PATCH 1/2] Check if loaded_bin is null for hostch --- src/acl_hostch.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/acl_hostch.cpp b/src/acl_hostch.cpp index 1ca6cd38..cbb992d5 100644 --- a/src/acl_hostch.cpp +++ b/src/acl_hostch.cpp @@ -814,6 +814,8 @@ void acl_read_program_hostpipe(void *user_data, acl_device_op_t *op) { // The host_pipe_info stored in the dev_prog->program_hostpipe_map // Contains the static information of the pipe, like protocol + assert(event->command_queue->device->loaded_bin != NULL && + "No loaded binary for read hostpipe"); acl_device_program_info_t *dev_prog = event->command_queue->device->loaded_bin->get_dev_prog(); auto host_pipe_info = dev_prog->program_hostpipe_map.at( @@ -964,6 +966,8 @@ void acl_write_program_hostpipe(void *user_data, acl_device_op_t *op) { // The host_pipe_info stored in the dev_prog->program_hostpipe_map // Contains the static information of the pipe, like protocol + assert(event->command_queue->device->loaded_bin != NULL && + "No loaded binary for write hostpipe"); acl_device_program_info_t *dev_prog = event->command_queue->device->loaded_bin->get_dev_prog(); auto host_pipe_info = dev_prog->program_hostpipe_map.at( @@ -1196,6 +1200,8 @@ CL_API_ENTRY cl_int CL_API_CALL clEnqueueReadHostPipeINTEL( ERR_RET(CL_INVALID_VALUE, context, "Invalid Pipe Symbol"); } + assert(device->loaded_bin != NULL && + "No loaded binary for enqueue hostpipe read"); acl_device_program_info_t *dev_prog = device->loaded_bin->get_dev_prog(); auto search = dev_prog->program_hostpipe_map.find(std::string(pipe_symbol)); @@ -1269,6 +1275,8 @@ CL_API_ENTRY cl_int CL_API_CALL clEnqueueWriteHostPipeINTEL( ERR_RET(CL_INVALID_VALUE, context, "Invalid Pipe Symbol"); } + assert(device->loaded_bin != NULL && + "No loaded binary for enqueue hostpipe write"); acl_device_program_info_t *dev_prog = device->loaded_bin->get_dev_prog(); auto search = dev_prog->program_hostpipe_map.find(std::string(pipe_symbol)); From 24b4f92863611c10cb8c322cfa86778036329f4a Mon Sep 17 00:00:00 2001 From: Sophie Mao Date: Mon, 8 Apr 2024 10:05:21 -0700 Subject: [PATCH 2/2] Update loaded bin if the same binary is wrapped with different cl_program --- src/acl_kernel.cpp | 7 +++++++ test/acl_kernel_test.cpp | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/acl_kernel.cpp b/src/acl_kernel.cpp index ed237f94..1d05e992 100644 --- a/src/acl_kernel.cpp +++ b/src/acl_kernel.cpp @@ -3112,6 +3112,13 @@ int acl_submit_kernel_device_op(cl_event event) { // We managed to enqueue everything. cl_kernel kernel = event->cmd.info.ndrange_kernel.kernel; + // If current last bin is loaded on the board and we are going to update + // last bin pointer without any reprogram, we should update the loaded bin + // to reflect that as well. + if (!need_reprogram && device->last_bin == device->loaded_bin && + device->last_bin != event->cmd.info.ndrange_kernel.dev_bin) { + device->loaded_bin = event->cmd.info.ndrange_kernel.dev_bin; + } device->last_bin = event->cmd.info.ndrange_kernel.dev_bin; event->last_device_op = last_op; diff --git a/test/acl_kernel_test.cpp b/test/acl_kernel_test.cpp index 0558d60b..c7f05e8b 100644 --- a/test/acl_kernel_test.cpp +++ b/test/acl_kernel_test.cpp @@ -4651,9 +4651,8 @@ TEST(acl_kernel_reprogram_scheduler, skip_reprogram_on_start) { CHECK_EQUAL(CL_SUCCESS, clSetUserEventStatus(ue, CL_COMPLETE)); CHECK_EQUAL(CL_SUCCESS, clReleaseEvent(ue)); - // Since reprogram didn't occur, only last_bin should be updated CHECK_EQUAL(&(dp0->device_binary), m_device->last_bin); - CHECK(m_device->loaded_bin == NULL); + CHECK_EQUAL(&(dp0->device_binary), m_device->loaded_bin); // set MEM_MIGRATE 1 to RUNNING + // set MEM_MIGRATE 1 to COMPLETE +