Skip to content

Commit 99e6944

Browse files
committed
[SYCL][Graph] Error when immediate command lists are used (#277)
- Error when we detected immediate command lists - Throws exception with sycl::invalid - Test which uses property::queue::<no_>immediate_command_list to test errors.
1 parent 0598209 commit 99e6944

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

sycl/plugins/unified_runtime/ur/adapters/level_zero/command_buffer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferEnqueueExp(
661661
ur_exp_command_buffer_handle_t CommandBuffer, ur_queue_handle_t Queue,
662662
uint32_t NumEventsInWaitList, const ur_event_handle_t *EventWaitList,
663663
ur_event_handle_t *Event) {
664+
// There are issues with immediate command lists so return an error if the
665+
// queue is in that mode.
666+
if (Queue->UsingImmCmdLists) {
667+
return UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES;
668+
}
669+
664670
std::scoped_lock<ur_shared_mutex> lock(Queue->Mutex);
665671
// Use compute engine rather than copy engine
666672
const auto UseCopyEngine = false;

sycl/source/detail/graph_impl.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,14 @@ exec_graph_impl::enqueue(const std::shared_ptr<sycl::detail::queue_impl> &Queue,
528528
->call_nocheck<
529529
sycl::detail::PiApiKind::piextEnqueueCommandBuffer>(
530530
CommandBuffer, Queue->getHandleRef(), 0, nullptr, OutEvent);
531-
if (Res != pi_result::PI_SUCCESS) {
531+
if (Res == pi_result::PI_ERROR_INVALID_QUEUE_PROPERTIES) {
532+
throw sycl::exception(
533+
make_error_code(errc::invalid),
534+
"Graphs cannot be submitted to a queue which uses "
535+
"immediate command lists. Use "
536+
"sycl::ext::intel::property::queue::no_immediate_"
537+
"command_list to disable them.");
538+
} else if (Res != pi_result::PI_SUCCESS) {
532539
throw sycl::exception(
533540
errc::event,
534541
"Failed to enqueue event for command buffer submission");
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
5+
//
6+
// CHECK-NOT: LEAK
7+
8+
// Tests that graph submission will throw if the target queue is using immediate
9+
// command lists and not throw if they are using regular command queues.
10+
11+
#include "graph_common.hpp"
12+
13+
int main() {
14+
queue QueueImmediate{
15+
{sycl::ext::intel::property::queue::immediate_command_list{}}};
16+
queue QueueNoImmediate{
17+
QueueImmediate.get_context(),
18+
QueueImmediate.get_device(),
19+
{sycl::ext::intel::property::queue::no_immediate_command_list{}}};
20+
21+
exp_ext::command_graph Graph{QueueNoImmediate.get_context(),
22+
QueueNoImmediate.get_device()};
23+
24+
std::error_code ErrorCode = make_error_code(sycl::errc::success);
25+
try {
26+
auto GraphExec = Graph.finalize();
27+
QueueNoImmediate.submit(
28+
[&](handler &CGH) { CGH.ext_oneapi_graph(GraphExec); });
29+
} catch (sycl::exception &E) {
30+
ErrorCode = E.code();
31+
}
32+
33+
assert(ErrorCode == make_error_code(errc::success));
34+
35+
ErrorCode = make_error_code(sycl::errc::success);
36+
try {
37+
auto GraphExec = Graph.finalize();
38+
QueueImmediate.submit(
39+
[&](handler &CGH) { CGH.ext_oneapi_graph(GraphExec); });
40+
} catch (sycl::exception &E) {
41+
ErrorCode = E.code();
42+
}
43+
44+
assert(ErrorCode == make_error_code(errc::invalid));
45+
46+
return 0;
47+
}

0 commit comments

Comments
 (0)