-
Notifications
You must be signed in to change notification settings - Fork 788
[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
base: sycl
Are you sure you want to change the base?
Conversation
Followup PR to pass adapter by ref instead of pointer: #19105 |
@@ -230,12 +230,22 @@ std::mutex &GlobalHandler::getFilterMutex() { | |||
return FilterMutex; | |||
} | |||
|
|||
std::vector<AdapterPtr> &GlobalHandler::getAdapters() { | |||
static std::vector<AdapterPtr> &adapters = getOrCreate(MAdapters); | |||
std::vector<std::unique_ptr<Adapter>> &GlobalHandler::getAdapters() { |
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.
Do we still need this method? Why is the getAdapterRawPtrs
not enough?
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.
IIUC, GlobalHandler::getAdapters()
is still required. It is used in ur::initializeUr
to pass by reference the MAdapter
data member, which is later used to initialize this variable in initializeAdapters()
.
@@ -126,7 +126,7 @@ class GlobalHandler { | |||
InstWithLock<std::mutex> MPlatformToDefaultContextCacheMutex; | |||
InstWithLock<std::mutex> MPlatformMapMutex; | |||
InstWithLock<std::mutex> MFilterMutex; | |||
InstWithLock<std::vector<AdapterPtr>> MAdapters; | |||
InstWithLock<std::vector<std::unique_ptr<Adapter>>> MAdapters; |
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.
If we agree that we do not need the getAdapters
and keep only the getAdapterRawPtrs
, which returns std::vector<Adapter *>
, then this line can be changed to the InstWithLock<std::vector<Adapter*>>
and we can use a custom deleter when constructing the MAdapters
.
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.
And you will not need to change the signature of the ur::initializeUr()
to return std::vector
by copy
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.