-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Make ur::getAdapter
return raw adapter pointer instead of shared_ptr
#19102
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
Conversation
Followup PR to pass adapter by ref instead of pointer: #19105 |
@@ -34,7 +34,7 @@ namespace detail { | |||
class context_impl; | |||
class event_impl; | |||
class Adapter; | |||
using AdapterPtr = std::shared_ptr<Adapter>; | |||
using AdapterPtr = Adapter *; |
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.
We have the AdapterPtr type still defined, so is there a reason to mix the use of AdapterPtr and Adapter *? Would it be possible to unify to one or the other? I think that typically, the *Ptr types are shared_ptrs in SYCL code, so maybe just remove this type and use a raw pointer everywhere?
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 have a follow-up PR (#19105) where I removed AdapterPtr
completely and returned Adapter reference instead of a pointer. Removing AdapterPtr
is a big, mostly-NFC change so I created a seperate PR.
std::weak_ptr<Adapter> AdapterWeakPtr; | ||
KernelBuildResult(const AdapterPtr &Adapter) : AdapterWeakPtr(Adapter) { | ||
AdapterPtr adapter; | ||
KernelBuildResult(const AdapterPtr &_adapter) : adapter(_adapter) { |
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.
Maybe just pass a raw pointer by value instead of reference?
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.
In the subsequent PR, I'll be replacing Adapter* with Adapter reference instead so, this change is aligned with it.
@intel/unified-runtime-reviewers ping |
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.
LGTM
Currently,
ur::getAdapter
returns a shared pointer to the adapter. However, that's unnecessary.This PR makes
ur::getAdapter
return a raw ptr instead and let global handler manage lifetime of the adapter object.