-
Notifications
You must be signed in to change notification settings - Fork 787
[NFCI][SYCL] Prefer raw ptr/ref for queue_impl
#18874
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 all commits
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 |
---|---|---|
|
@@ -650,9 +650,12 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> { | |
// for in order ones. | ||
void revisitUnenqueuedCommandsState(const EventImplPtr &CompletedHostTask); | ||
|
||
static ContextImplPtr getContext(const QueueImplPtr &Queue) { | ||
static ContextImplPtr getContext(queue_impl *Queue) { | ||
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. getContextImplPtr is const method. Why can't we declare Queue as pointer to const queue_impl then? To emphasize that the object doesn't change. Applicable to other places where it is possible. 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.
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 was not referring to the old impl, I saw that we have const for pointer only, but since we have another type now - probably we can do better. |
||
return Queue ? Queue->getContextImplPtr() : nullptr; | ||
} | ||
static ContextImplPtr getContext(const std::shared_ptr<queue_impl> &Queue) { | ||
return getContext(Queue.get()); | ||
} | ||
|
||
// Must be called under MMutex protection | ||
void doUnenqueuedCommandCleanup( | ||
|
@@ -689,7 +692,7 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> { | |
protected: | ||
template <typename HandlerType = handler> | ||
EventImplPtr insertHelperBarrier(const HandlerType &Handler) { | ||
auto &Queue = Handler.impl->get_queue(); | ||
queue_impl &Queue = Handler.impl->get_queue(); | ||
auto ResEvent = detail::event_impl::create_device_event(Queue); | ||
ur_event_handle_t UREvent = nullptr; | ||
getAdapter()->call<UrApiKind::urEnqueueEventsWaitWithBarrier>( | ||
|
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.
why do we need to get rid of QueueImplPtr? When it comes to code reading & understanding it is much easier to understand what type variable "Queue" is if it is declared as specific type. In this case I do not see any benefits in usage of "auto".
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.
Copying from my reply in #18983 (comment):
This alias was created because we had almost all APIs using it. The idea behind the ongoing refactoring is to have as little APIs operating on shared_ptr as possible (and avoid accidental copies as a byproduct). As such, having the alias in future won't be improving readability but reducing it, because the usage of that alias would be very rare.
As such, I'm simply removing the aliases from the headers that were [mostly] cleaned of excessive shared_ptr usage.
Uh oh!
There was an error while loading. Please reload this page.
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.
I would suggest to use shared_ptr explicitly here. I am ok with alias removal but I don't like its replacement with auto.