-
Notifications
You must be signed in to change notification settings - Fork 791
[SYCL] Fix asynchronous exception behavior #20274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: sycl
Are you sure you want to change the base?
Changes from all commits
0745316
b1dc735
b00c9e6
ab2e8d1
f8237d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,8 +211,9 @@ void event_impl::initHostProfilingInfo() { | |
MHostProfilingInfo->setDevice(&Device); | ||
} | ||
|
||
void event_impl::setSubmittedQueue(std::weak_ptr<queue_impl> SubmittedQueue) { | ||
MSubmittedQueue = std::move(SubmittedQueue); | ||
void event_impl::setSubmittedQueue(queue_impl *SubmittedQueue) { | ||
MSubmittedQueue = SubmittedQueue->weak_from_this(); | ||
MSubmittedDevice = &SubmittedQueue->getDeviceImpl(); | ||
} | ||
|
||
#ifdef XPTI_ENABLE_INSTRUMENTATION | ||
|
@@ -308,8 +309,28 @@ void event_impl::wait(bool *Success) { | |
void event_impl::wait_and_throw() { | ||
wait(); | ||
|
||
if (std::shared_ptr<queue_impl> SubmittedQueue = MSubmittedQueue.lock()) | ||
if (std::shared_ptr<queue_impl> SubmittedQueue = MSubmittedQueue.lock()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. event::wait_and_throw() description states Does it sound like we should somehow handle errors from more than 1 queue if we have some cross-queue/context dependencies? I get it as we should have even more complex algorithm. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good eye! I think your reading is right, though it may be overkill to handle it in this PR. In fact, I worry it'll be awkward to handle in general, but definitely something we should investigate if @gmlueck also agrees with that reading of the spec. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, it sounds pretty complex to handle. |
||
SubmittedQueue->throw_asynchronous(); | ||
return; | ||
} | ||
|
||
// If the queue has died, we rely on finding its exceptions through the | ||
// device. | ||
if (MSubmittedDevice == nullptr) | ||
return; | ||
|
||
// If MSubmittedQueue has died, get flush any exceptions associated with it | ||
// still, then user either the context async_handler or the default | ||
// async_handler. | ||
exception_list Exceptions = | ||
MSubmittedDevice->flushAsyncExceptions(MSubmittedQueue); | ||
if (Exceptions.size() == 0) | ||
return; | ||
|
||
if (MContext && MContext->get_async_handler()) | ||
MContext->get_async_handler()(std::move(Exceptions)); | ||
else | ||
defaultAsyncHandler(std::move(Exceptions)); | ||
} | ||
|
||
void event_impl::checkProfilingPreconditions() const { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please clarify why do you use device as storage for exceptions, not context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two reasons to go for device over context: