-
Notifications
You must be signed in to change notification settings - Fork 848
[SYCL] Implementation of discard_events #5026
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
Changes from 26 commits
adf4079
6905227
aaa71c8
04d798f
1b340b0
aa620d4
f5730c6
2b1a221
2f31823
b08c309
ebaa2a1
d325859
7f5de5b
107721c
16cf4c0
3fd916e
675a1a3
b0b1e0d
23271fd
1a67f7d
c996706
bf96adc
fa654d3
a85eec5
6e4468b
65ef8fe
4cd8233
9ec63ad
d55f3e5
f70f49d
fe6abbf
6617fc7
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 |
|---|---|---|
|
|
@@ -1351,6 +1351,12 @@ class __SYCL_EXPORT handler { | |
| /// | ||
| /// \param Event is a valid SYCL event to wait on. | ||
| void depends_on(event Event) { | ||
| if (info::event_command_status::ext_oneapi_unknown == | ||
| Event.get_info<info::event::command_execution_status>()) { | ||
|
Contributor
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. This looks very expensive. Since what we really would like to know here is whether the event is discarded, can we just check this field?
Contributor
Author
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. This code covers the case "when invalid event is passed into handler API" described in https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/DiscardQueueEvents/SYCL_EXT_ONEAPI_DISCARD_QUEUE_EVENTS.asciidoc Here we just want to check if the |
||
| throw sycl::exception(make_error_code(errc::invalid), | ||
| "Queue operation cannot depend on invalid event."); | ||
| } | ||
|
|
||
| MEvents.push_back(detail::getSyclObjImpl(Event)); | ||
| } | ||
|
|
||
|
|
@@ -1359,6 +1365,12 @@ class __SYCL_EXPORT handler { | |
| /// \param Events is a vector of valid SYCL events to wait on. | ||
| void depends_on(const std::vector<event> &Events) { | ||
| for (const event &Event : Events) { | ||
| if (info::event_command_status::ext_oneapi_unknown == | ||
| Event.get_info<info::event::command_execution_status>()) { | ||
| throw sycl::exception( | ||
| make_error_code(errc::invalid), | ||
| "Queue operation cannot depend on invalid event."); | ||
| } | ||
| MEvents.push_back(detail::getSyclObjImpl(Event)); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -287,7 +287,10 @@ enum class event : cl_event_info { | |||||||||
| enum class event_command_status : cl_int { | ||||||||||
| submitted = CL_SUBMITTED, | ||||||||||
| running = CL_RUNNING, | ||||||||||
| complete = CL_COMPLETE | ||||||||||
| complete = CL_COMPLETE, | ||||||||||
| ext_oneapi_unknown = | ||||||||||
| submitted + running + complete + | ||||||||||
| 1 // TODO: a more elegant way to ensure that the unique value is here | ||||||||||
|
Contributor
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.
Suggested change
Contributor
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. It would leave enough space for 1:1 mapping if BE supports more statuses.
Contributor
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. You are worried that the value of
Contributor
Author
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. Ok, I changed it to |
||||||||||
| }; | ||||||||||
|
|
||||||||||
| enum class event_profiling : cl_profiling_info { | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,11 @@ void event_impl::waitInternal() const { | |
| return; | ||
| } | ||
|
|
||
| if (MState == HES_Invalid) | ||
| throw sycl::exception( | ||
| make_error_code(errc::invalid), | ||
| "waitInternal method cannot be used for an invalid event."); | ||
|
|
||
| while (MState != HES_Complete) | ||
| ; | ||
| } | ||
|
|
@@ -93,7 +98,7 @@ void event_impl::setContextImpl(const ContextImplPtr &Context) { | |
| MState = HES_NotComplete; | ||
| } | ||
|
|
||
| event_impl::event_impl() : MState(HES_Complete) {} | ||
| event_impl::event_impl(HostEventState State) : MState(State) {} | ||
|
|
||
| event_impl::event_impl(RT::PiEvent Event, const context &SyclContext) | ||
| : MEvent(Event), MContext(detail::getSyclObjImpl(SyclContext)), | ||
|
|
@@ -187,6 +192,10 @@ void event_impl::instrumentationEpilog(void *TelemetryEvent, | |
|
|
||
| void event_impl::wait( | ||
| std::shared_ptr<cl::sycl::detail::event_impl> Self) const { | ||
| if (MState == HES_Invalid) | ||
| throw sycl::exception(make_error_code(errc::invalid), | ||
| "wait method cannot be used for an invalid event."); | ||
|
|
||
| #ifdef XPTI_ENABLE_INSTRUMENTATION | ||
| void *TelemetryEvent = nullptr; | ||
| uint64_t IId; | ||
|
|
@@ -303,6 +312,9 @@ template <> cl_uint event_impl::get_info<info::event::reference_count>() const { | |
| template <> | ||
| info::event_command_status | ||
| event_impl::get_info<info::event::command_execution_status>() const { | ||
| if (MState == HES_Invalid) | ||
|
Contributor
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. Maybe it's better to say
Contributor
Author
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. Ok, I will change |
||
| return info::event_command_status::ext_oneapi_unknown; | ||
|
|
||
| if (!MHostEvent && MEvent) { | ||
| return get_event_info<info::event::command_execution_status>::get( | ||
| this->getHandleRef(), this->getPlugin()); | ||
|
|
@@ -332,6 +344,11 @@ pi_native_handle event_impl::getNative() const { | |
| } | ||
|
|
||
| std::vector<EventImplPtr> event_impl::getWaitList() { | ||
| if (MState == HES_Invalid) | ||
| throw sycl::exception( | ||
| make_error_code(errc::invalid), | ||
| "get_wait_list() cannot be used for an invalid event."); | ||
|
|
||
| std::lock_guard<std::mutex> Lock(MMutex); | ||
|
|
||
| std::vector<EventImplPtr> Result; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.