-
Notifications
You must be signed in to change notification settings - Fork 768
[SYCL] Less shared_ptr
for platform_impl
#18143
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
d505db8
to
696c933
Compare
1e8d5a9
to
6964b35
Compare
6964b35
to
04c2ad7
Compare
04c2ad7
to
e27ad79
Compare
e27ad79
to
2ed9b26
Compare
2ed9b26
to
e588f8f
Compare
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.
Pull Request Overview
This PR refactors the SYCL runtime to reduce unnecessary use of std::shared_ptr for platform_impl objects by replacing them with raw references or pointers in critical parts of the code, thereby reducing ownership overhead. The changes update several interfaces and call sites throughout the codebase.
- Changed the platform interface in tests and source files (e.g. printers.cpp, platform.cpp) to use platform_impl references.
- Updated device and program manager implementations to adjust method calls and data access to the new raw reference API.
- Refactored platform_impl.hpp/.cpp and related files to expose getSharedPtrToSelf() and return references instead of smart pointers.
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
sycl/test/gdb/printers.cpp | Updated comments to reflect the change from shared_ptr to references for platform_impl. |
sycl/source/platform.cpp | Modified platform_impl acquisition to return a shared pointer via getSharedPtrToSelf() and updated related call sites. |
sycl/source/device.cpp | Adjusted device_impl initialization to use the new platform_impl API with references. |
sycl/source/detail/usm/usm_impl.cpp | Replaced arrow operator calls with dot operator calls on platform_impl references. |
sycl/source/detail/program_manager/program_manager.cpp | Refactored access to platform_impl from pointer to reference in option handling and backend option retrieval. |
sycl/source/detail/platform_impl.hpp/.cpp | Changed several methods in platform_impl to return references instead of shared_ptr, including updates to helper methods and caching. |
Other Files (global_handler.hpp/.cpp, device_impl.hpp/.cpp, context_impl.hpp/.cpp, backend files, etc.) | Updated all affected call sites and interface definitions to conform with the new ownership model. |
e588f8f
to
f12b017
Compare
f12b017
to
26cb6e7
Compare
26cb6e7
to
70a2a8f
Compare
shared_ptr
for platform_impl
shared_ptr
for platform_impl
`GlobalHandler::MPlatformCache` keeps (shared) ownership of `platform_impl` objects, so none of them could be destroyed until SYCL RT library shutdown/unload process. As such, using raw pointers/reference to `platform_impl` throughout the SYCL RT is totally fine and avoids extra costs of `std::shared_ptr` I'm relatively sure `sycl::platform` could avoid using `std::shared_ptr<detail::platform_impl> impl` as well, but that would be a breaking change so not being implemented at this moment.
70a2a8f
to
5b0eaa8
Compare
GlobalHandler::MPlatformCache
keeps (shared) ownership ofplatform_impl
objects, so none of them could be destroyed until SYCL RT library shutdown/unload process. As such, using raw pointers/reference toplatform_impl
throughout the SYCL RT is totally fine and avoids extra costs ofstd::shared_ptr
. On the other hand, extending lifetime of any object past that shutdown would mean that we have a SYCL object, but all the UR adapters have been unloaded already. As such, tying the lifetime to the exact moment library is unloaded seems to be the only reasonable choice.I'm relatively sure
sycl::platform
could avoid usingstd::shared_ptr<detail::platform_impl> impl
as well, but that would be a breaking change so not being implemented at this moment.This change means that
unittests/Extensions/CurrentDevice.cpp
can't work anymore because unittests/mock don't use libsycl.so and lifetimes aren't managed the same way as for the actual SYCL programs.