Skip to content

Commit 92e2a76

Browse files
authored
[SYCL] Handle PI_EVENT_STATUS_QUEUED return value (#13024)
#9944 introduced a hack in the OpenCL PI plugin which maps PI_EVENT_QUEUED to PI_EVENT_SUBMITTED. This hack is problematic because it will make SYCL-RT assume that an event has been flushed when it might not have been. At the moment, this could result in buggy behaviour on the OpenCL backend when using multiple queues. The OpenCL specification states: > "To use event objects that refer to commands enqueued in a command-queue as event objects to wait on by commands enqueued in a different command-queue, the application must call a clFlush or any blocking commands that perform an implicit flush of the command-queue where the commands that refer to these event objects are enqueued." This PR, moves the mapping from UR to `get_event_info()` inside sycl-rt which avoids the issue because it is a separate code path from `flush_if_needed()` Corresponding UR PR: oneapi-src/unified-runtime#1440
1 parent b1c514a commit 92e2a76

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

sycl/plugins/unified_runtime/CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ if(SYCL_PI_UR_USE_FETCH_CONTENT)
110110

111111
fetch_adapter_source(opencl
112112
${UNIFIED_RUNTIME_REPO}
113-
# commit 85b7559033e329389452cb87615ad42fbb644d59 (HEAD -> main, origin/main, origin/HEAD)
114-
# Merge: a7c202b4 5c300799
113+
# commit 0d2a972c71ba4dd5935478c7b7124a372a1eeca0
114+
# Merge: ac89abfe 44aef877
115115
# Author: Kenneth Benzie (Benie) <[email protected]>
116-
# Date: Tue Apr 9 14:06:49 2024 +0100
117-
# Merge pull request #1496 from steffenlarsen/steffen/revert_memory_lookup_error
118-
# [OpenCL] Revert urMemBufferCreate extension function lookup error
119-
85b7559033e329389452cb87615ad42fbb644d59
116+
# Date: Thu Apr 11 10:24:19 2024 +0100
117+
# Merge pull request #1440 from fabiomestre/fabio/opencl_remove_queued_hack
118+
# [OPENCL] Remove EVENT_STATUS_QUEUED workaround
119+
0d2a972c71ba4dd5935478c7b7124a372a1eeca0
120120
)
121121

122122
fetch_adapter_source(cuda

sycl/source/detail/event_info.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ typename Param::return_type get_event_info(sycl::detail::pi::PiEvent Event,
4040
// TODO catch an exception and put it to list of asynchronous exceptions
4141
Plugin->call<PiApiKind::piEventGetInfo>(Event, PiInfoCode<Param>::value,
4242
sizeof(Result), &Result, nullptr);
43+
44+
// If the status is PI_EVENT_QUEUED We need to change it since QUEUE is
45+
// not a valid status in sycl.
46+
if constexpr (std::is_same<Param,
47+
info::event::command_execution_status>::value) {
48+
Result = static_cast<pi_event_status>(Result) == PI_EVENT_QUEUED
49+
? sycl::info::event_command_status::submitted
50+
: Result;
51+
}
52+
4353
return Result;
4454
}
4555

0 commit comments

Comments
 (0)