Skip to content

Commit b5dfdc2

Browse files
Revert "[SYCL] Honor dependencies of empty command groups" (#16190)
Reverts #16180
1 parent 40e2e66 commit b5dfdc2

File tree

3 files changed

+39
-20
lines changed

3 files changed

+39
-20
lines changed

sycl/source/detail/scheduler/commands.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3592,21 +3592,10 @@ ur_result_t ExecCGCommand::enqueueImpQueue() {
35923592

35933593
return UR_RESULT_SUCCESS;
35943594
}
3595-
case CGType::None: {
3596-
if (RawEvents.empty()) {
3597-
// urEnqueueEventsWait with zero events acts like a barrier which is NOT
3598-
// what we want here. On the other hand, there is nothing to wait for, so
3599-
// we don't need to enqueue anything.
3600-
return UR_RESULT_SUCCESS;
3601-
}
3602-
const detail::AdapterPtr &Adapter = MQueue->getAdapter();
3603-
ur_event_handle_t Event;
3604-
ur_result_t Result = Adapter->call_nocheck<UrApiKind::urEnqueueEventsWait>(
3605-
MQueue->getHandleRef(), RawEvents.size(),
3606-
RawEvents.size() ? &RawEvents[0] : nullptr, &Event);
3607-
MEvent->setHandle(Event);
3608-
return Result;
3609-
}
3595+
case CGType::None:
3596+
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
3597+
"CG type not implemented. " +
3598+
codeToString(UR_RESULT_ERROR_INVALID_OPERATION));
36103599
}
36113600
return UR_RESULT_ERROR_INVALID_OPERATION;
36123601
}

sycl/source/handler.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,21 @@ event handler::finalize() {
496496
MCodeLoc));
497497
break;
498498
case detail::CGType::None:
499-
CommandGroup.reset(new detail::CG(detail::CGType::None,
500-
std::move(impl->CGData), MCodeLoc));
499+
if (detail::ur::trace(detail::ur::TraceLevel::TRACE_ALL)) {
500+
std::cout << "WARNING: An empty command group is submitted." << std::endl;
501+
}
502+
503+
// Empty nodes are handled by Graph like standard nodes
504+
// For Standard mode (non-graph),
505+
// empty nodes are not sent to the scheduler to save time
506+
if (impl->MGraph || (MQueue && MQueue->getCommandGraph())) {
507+
CommandGroup.reset(new detail::CG(detail::CGType::None,
508+
std::move(impl->CGData), MCodeLoc));
509+
} else {
510+
detail::EventImplPtr Event = std::make_shared<sycl::detail::event_impl>();
511+
MLastEvent = detail::createSyclObjFromImpl<event>(Event);
512+
return MLastEvent;
513+
}
501514
break;
502515
}
503516

sycl/test-e2e/Basic/empty_command.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,18 @@ void test_host_task_dep() {
2626
auto empty_cg_event =
2727
q.submit([&](handler &cgh) { cgh.depends_on(host_event); });
2828

29+
// FIXME: This should deadlock, but the dependency is ignored currently.
30+
empty_cg_event.wait();
31+
2932
assert(x == 0);
3033
start_execution.count_down();
3134

3235
empty_cg_event.wait();
33-
assert(x == 42);
36+
// FIXME: uncomment once the bug mentioned above is fixed.
37+
// assert(x == 42);
38+
39+
// I'm seeing some weird hang without this:
40+
host_event.wait();
3441
}
3542

3643
void test_device_event_dep() {
@@ -46,12 +53,17 @@ void test_device_event_dep() {
4653
auto empty_cg_event =
4754
q.submit([&](handler &cgh) { cgh.depends_on(device_event); });
4855

56+
// FIXME: This should deadlock, but the dependency is ignored currently.
57+
empty_cg_event.wait();
58+
4959
assert(*p == 0);
5060
start_execution.count_down();
5161

5262
empty_cg_event.wait();
53-
assert(*p == 42);
63+
// FIXME: uncomment once the bug mentioned above is fixed.
64+
// assert(*p == 42);
5465

66+
q.wait();
5567
sycl::free(p, q);
5668
}
5769

@@ -78,12 +90,17 @@ void test_accessor_dep() {
7890
auto empty_cg_event =
7991
q.submit([&](handler &cgh) { sycl::accessor a{b, cgh}; });
8092

93+
// FIXME: This should deadlock, but the dependency is ignored currently.
94+
empty_cg_event.wait();
95+
8196
assert(*p == 0);
8297
start_execution.count_down();
8398

8499
empty_cg_event.wait();
85-
assert(*p == 42);
100+
// FIXME: uncomment once the bug mentioned above is fixed.
101+
// assert(*p == 42);
86102

103+
q.wait();
87104
sycl::free(p, q);
88105
}
89106

0 commit comments

Comments
 (0)