Skip to content

Update loaded_bin if reprogram is skipped at kernel launch #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/acl_hostch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down
7 changes: 7 additions & 0 deletions src/acl_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions test/acl_kernel_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 +
Expand Down