Skip to content
Closed
Changes from 1 commit
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
35 changes: 29 additions & 6 deletions sycl/source/detail/scheduler/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class DispatchHostTask {
ExecCGCommand *MThisCmd;
std::vector<interop_handle::ReqToMem> MReqToMem;

void waitForEvents() const {
pi_result waitForEvents() const {
std::map<const detail::plugin *, std::vector<EventImplPtr>>
RequiredEventsPerPlugin;

Expand All @@ -185,14 +185,27 @@ class DispatchHostTask {
// other available job and resume once all required events are ready.
for (auto &PluginWithEvents : RequiredEventsPerPlugin) {
std::vector<RT::PiEvent> RawEvents = getPiEvents(PluginWithEvents.second);
PluginWithEvents.first->call<PiApiKind::piEventsWait>(RawEvents.size(),
RawEvents.data());
try {
PluginWithEvents.first->call<PiApiKind::piEventsWait>(RawEvents.size(),
RawEvents.data());
} catch (const sycl::exception &E) {
CGHostTask &HostTask = static_cast<CGHostTask &>(MThisCmd->getCG());
HostTask.MQueue->reportAsyncException(std::current_exception());
return (pi_result)E.get_cl_code();
} catch (...) {
CGHostTask &HostTask = static_cast<CGHostTask &>(MThisCmd->getCG());
HostTask.MQueue->reportAsyncException(std::current_exception());
Comment thread
romanovvlad marked this conversation as resolved.
Outdated
return PI_ERROR_UNKNOWN;
}
}

// wait for dependency host events
// Wait for dependency host events.
// Host events can't throw exceptions so don't try to catch it.
for (const EventImplPtr &Event : MThisCmd->MPreparedHostDepsEvents) {
Event->waitInternal();
}

return PI_SUCCESS;
}

public:
Expand All @@ -201,12 +214,22 @@ class DispatchHostTask {
: MThisCmd{ThisCmd}, MReqToMem(std::move(ReqToMem)) {}

void operator()() const {
waitForEvents();

assert(MThisCmd->getCG().getType() == CG::CGTYPE::CODEPLAY_HOST_TASK);

CGHostTask &HostTask = static_cast<CGHostTask &>(MThisCmd->getCG());

pi_result WaitResult = waitForEvents();
if (WaitResult != PI_SUCCESS) {
std::exception_ptr EPtr = std::make_exception_ptr(sycl::runtime_error(
std::string("Couldn't wait for host-task's dependencies"),
WaitResult));
HostTask.MQueue->reportAsyncException(EPtr);

// reset host-task's lambda and quit
Comment thread
s-kanaev marked this conversation as resolved.
Outdated
HostTask.MHostTask.reset();
return;
}

try {
// we're ready to call the user-defined lambda now
if (HostTask.MHostTask->isInteropTask()) {
Expand Down