-
Notifications
You must be signed in to change notification settings - Fork 794
[SYCL] Extend the handler-less path to API functions with event dependencies #20461
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
186a811
ffab4b5
b769e49
4c82669
8c36583
256de78
0187376
7cd45e7
497ad12
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 |
|---|---|---|
|
|
@@ -611,6 +611,99 @@ bool event_impl::isCompleted() { | |
|
|
||
| void event_impl::setCommand(Command *Cmd) { MCommand = Cmd; } | ||
|
|
||
| template <bool LockQueue> | ||
| void registerEventDependency( | ||
| const detail::EventImplPtr &EventImpl, | ||
| std::vector<detail::EventImplPtr> &EventsRegistered, | ||
| detail::queue_impl *QueueImpl, const detail::context_impl &ContextImpl, | ||
| const detail::device_impl &DeviceImpl, | ||
| const std::shared_ptr<ext::oneapi::experimental::detail::graph_impl> &Graph, | ||
|
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. We do not need |
||
| sycl::detail::CGType CommandGroupType) { | ||
|
|
||
| if (!EventImpl) | ||
| return; | ||
| if (EventImpl->isDiscarded()) { | ||
| throw sycl::exception(make_error_code(errc::invalid), | ||
| "Queue operation cannot depend on discarded event."); | ||
| } | ||
|
|
||
| // Async alloc calls adapter immediately. Any explicit/implicit dependencies | ||
| // are handled at that point, including in order queue deps. Further calls to | ||
| // depends_on after an async alloc are explicitly disallowed. | ||
| if (CommandGroupType == CGType::AsyncAlloc) { | ||
| throw sycl::exception(make_error_code(errc::invalid), | ||
| "Cannot submit a dependency after an asynchronous " | ||
| "allocation has already been executed!"); | ||
| } | ||
|
|
||
| auto EventGraph = EventImpl->getCommandGraph(); | ||
| if (QueueImpl && EventGraph) { | ||
| auto QueueGraph = QueueImpl->getCommandGraph(); | ||
|
|
||
| if (&EventGraph->getContextImpl() != &ContextImpl) { | ||
| throw sycl::exception( | ||
| make_error_code(errc::invalid), | ||
| "Cannot submit to a queue with a dependency from a graph that is " | ||
| "associated with a different context."); | ||
| } | ||
|
|
||
| if (&EventGraph->getDeviceImpl() != &DeviceImpl) { | ||
| throw sycl::exception( | ||
| make_error_code(errc::invalid), | ||
| "Cannot submit to a queue with a dependency from a graph that is " | ||
| "associated with a different device."); | ||
| } | ||
|
|
||
| if (QueueGraph && QueueGraph != EventGraph) { | ||
| throw sycl::exception(sycl::make_error_code(errc::invalid), | ||
| "Cannot submit to a recording queue with a " | ||
| "dependency from a different graph."); | ||
| } | ||
|
|
||
| // If the event dependency has a graph, that means that the queue that | ||
| // created it was in recording mode. If the current queue is not recording, | ||
| // we need to set it to recording (implements the transitive queue recording | ||
| // feature). | ||
| if (!QueueGraph) { | ||
| if constexpr (LockQueue) { | ||
| EventGraph->beginRecording(*QueueImpl); | ||
| } else { | ||
| EventGraph->beginRecordingUnlockedQueue(*QueueImpl); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (Graph) { | ||
| if (EventGraph == nullptr) { | ||
| throw sycl::exception( | ||
| make_error_code(errc::invalid), | ||
| "Graph nodes cannot depend on events from outside the graph."); | ||
| } | ||
| if (EventGraph != Graph) { | ||
| throw sycl::exception( | ||
| make_error_code(errc::invalid), | ||
| "Graph nodes cannot depend on events from another graph."); | ||
| } | ||
| } | ||
| EventsRegistered.push_back(EventImpl); | ||
| } | ||
|
|
||
| template void registerEventDependency<true>( | ||
| const detail::EventImplPtr &EventImpl, | ||
| std::vector<detail::EventImplPtr> &EventsRegistered, | ||
| detail::queue_impl *QueueImpl, const detail::context_impl &ContextImpl, | ||
| const detail::device_impl &DeviceImpl, | ||
| const std::shared_ptr<ext::oneapi::experimental::detail::graph_impl> &Graph, | ||
| sycl::detail::CGType CommandGroupType); | ||
|
|
||
| template void registerEventDependency<false>( | ||
| const detail::EventImplPtr &EventImpl, | ||
| std::vector<detail::EventImplPtr> &EventsRegistered, | ||
| detail::queue_impl *QueueImpl, const detail::context_impl &ContextImpl, | ||
| const detail::device_impl &DeviceImpl, | ||
| const std::shared_ptr<ext::oneapi::experimental::detail::graph_impl> &Graph, | ||
| sycl::detail::CGType CommandGroupType); | ||
|
Comment on lines
+691
to
+705
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. Why do we need it? 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 meant why we cannot declare the template function in the header file? 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. Yeah, it is a circular dependency between the headers. |
||
|
|
||
| } // namespace detail | ||
| } // namespace _V1 | ||
| } // namespace sycl | ||
Uh oh!
There was an error while loading. Please reload this page.