Skip to content

[WIP][SYCL][LevelZero] Force reset of memcpy command-list #3941

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

Closed
wants to merge 2 commits into from
Closed
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
23 changes: 19 additions & 4 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,9 @@ template <> ze_result_t zeHostSynchronize(ze_event_handle_t Handle) {
template <> ze_result_t zeHostSynchronize(ze_command_queue_handle_t Handle) {
return zeHostSynchronizeImpl(zeCommandQueueSynchronize, Handle);
}
// template <>
// ze_result_t zeHostSynchronize(ze_fence_handle_t Handle) {
// return zeHostSynchronizeImpl(zeFenceHostSynchronize, Handle);
// }
template <> ze_result_t zeHostSynchronize(ze_fence_handle_t Handle) {
return zeHostSynchronizeImpl(zeFenceHostSynchronize, Handle);
}

template <typename T, typename Assign>
pi_result getInfoImpl(size_t param_value_size, void *param_value,
Expand Down Expand Up @@ -4229,6 +4228,22 @@ static pi_result cleanupAfterEvent(pi_event Event) {
if (it == Queue->ZeCommandListFenceMap.end()) {
die("Missing command-list completition fence");
}

// Workaround for VM_BIND mode.
// Make sure that the command-list doing memcpy is reset before non-USM
// host memory potentially involved in the memcpy is freed.
//
// NOTE: it is valid to wait for the fence here as long as we aren't
// doing batching on the involved command-list. Today memcpy goes by
// itself in a command list.
//
// TODO: this will unnecessarily(?) wait for non-USM memory buffers too,
// so we might need to add a new command type to differentiate.
//
if (Event->CommandType == PI_COMMAND_TYPE_MEM_BUFFER_COPY) {
ZE_CALL(zeHostSynchronize, (it->second.ZeFence));
}

ze_result_t ZeResult =
ZE_CALL_NOCHECK(zeFenceQueryStatus, (it->second.ZeFence));
if (ZeResult == ZE_RESULT_SUCCESS) {
Expand Down