Skip to content

Commit

Permalink
Revert "[SYCL] Honor dependencies of empty command groups" (#16190)
Browse files Browse the repository at this point in the history
Reverts #16180
  • Loading branch information
aelovikov-intel authored Nov 26, 2024
1 parent 40e2e66 commit b5dfdc2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 20 deletions.
19 changes: 4 additions & 15 deletions sycl/source/detail/scheduler/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3592,21 +3592,10 @@ ur_result_t ExecCGCommand::enqueueImpQueue() {

return UR_RESULT_SUCCESS;
}
case CGType::None: {
if (RawEvents.empty()) {
// urEnqueueEventsWait with zero events acts like a barrier which is NOT
// what we want here. On the other hand, there is nothing to wait for, so
// we don't need to enqueue anything.
return UR_RESULT_SUCCESS;
}
const detail::AdapterPtr &Adapter = MQueue->getAdapter();
ur_event_handle_t Event;
ur_result_t Result = Adapter->call_nocheck<UrApiKind::urEnqueueEventsWait>(
MQueue->getHandleRef(), RawEvents.size(),
RawEvents.size() ? &RawEvents[0] : nullptr, &Event);
MEvent->setHandle(Event);
return Result;
}
case CGType::None:
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
"CG type not implemented. " +
codeToString(UR_RESULT_ERROR_INVALID_OPERATION));
}
return UR_RESULT_ERROR_INVALID_OPERATION;
}
Expand Down
17 changes: 15 additions & 2 deletions sycl/source/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,21 @@ event handler::finalize() {
MCodeLoc));
break;
case detail::CGType::None:
CommandGroup.reset(new detail::CG(detail::CGType::None,
std::move(impl->CGData), MCodeLoc));
if (detail::ur::trace(detail::ur::TraceLevel::TRACE_ALL)) {
std::cout << "WARNING: An empty command group is submitted." << std::endl;
}

// Empty nodes are handled by Graph like standard nodes
// For Standard mode (non-graph),
// empty nodes are not sent to the scheduler to save time
if (impl->MGraph || (MQueue && MQueue->getCommandGraph())) {
CommandGroup.reset(new detail::CG(detail::CGType::None,
std::move(impl->CGData), MCodeLoc));
} else {
detail::EventImplPtr Event = std::make_shared<sycl::detail::event_impl>();
MLastEvent = detail::createSyclObjFromImpl<event>(Event);
return MLastEvent;
}
break;
}

Expand Down
23 changes: 20 additions & 3 deletions sycl/test-e2e/Basic/empty_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,18 @@ void test_host_task_dep() {
auto empty_cg_event =
q.submit([&](handler &cgh) { cgh.depends_on(host_event); });

// FIXME: This should deadlock, but the dependency is ignored currently.
empty_cg_event.wait();

assert(x == 0);
start_execution.count_down();

empty_cg_event.wait();
assert(x == 42);
// FIXME: uncomment once the bug mentioned above is fixed.
// assert(x == 42);

// I'm seeing some weird hang without this:
host_event.wait();
}

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

// FIXME: This should deadlock, but the dependency is ignored currently.
empty_cg_event.wait();

assert(*p == 0);
start_execution.count_down();

empty_cg_event.wait();
assert(*p == 42);
// FIXME: uncomment once the bug mentioned above is fixed.
// assert(*p == 42);

q.wait();
sycl::free(p, q);
}

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

// FIXME: This should deadlock, but the dependency is ignored currently.
empty_cg_event.wait();

assert(*p == 0);
start_execution.count_down();

empty_cg_event.wait();
assert(*p == 42);
// FIXME: uncomment once the bug mentioned above is fixed.
// assert(*p == 42);

q.wait();
sycl::free(p, q);
}

Expand Down

0 comments on commit b5dfdc2

Please sign in to comment.