You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`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 would avoid extra costs of `std::shared_ptr`. However, our
unittests don't work the same way and lifetimes are actually managed by
all the data member `std::shared_ptr`s (e.g., see `CurrentDevice.cpp` as
the most obvious case), so simply switching all `PlatformImplPtr` to raw
pointer/reference doesn't work right now. I think it will be possible
with an ABI break if we'd remove all the shared pointers but the one in
the `GlobalHandler`.
What I'm doing here instead is the following:
* Try to keep lifetime management the same, i.e., all data member
pointers are still "smart"
* Inherit from `std::enable_shared_from_this()` so that we could pass
raw references around and only actually create smart pointers when
absolutely necessary.
* Change internal APIs to operate more using plain references
This should make it much harder to write something like this:
```
// BAD: Should have been `auto &`, extra atomic counter
// increment/decrement without it.
auto PlatformImpl = d.getPlatformImplPtr();
```
0 commit comments