Skip to content

[NFCI][SYCL] Change device_image_impl::MDevices to store raw device_impl * #19459

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

Merged
merged 1 commit into from
Jul 16, 2025

Conversation

aelovikov-intel
Copy link
Contributor

#18251 extended device_impls' lifetimes until shutdown and #18270 started to pass devices as raw pointers in some of the APIs.

This PR builds on top of that and extends usage of raw pointers/references/device_range as the devices are known to be alive and extra std::shared_ptr's atomic increments aren't necessary and could be avoided.

Since we change the type of device_image_impl::MDevices, other APIs in that class and in program_manager don't need to operate in terms of sycl::device or std::shared_ptr<device_impl> and we can switch them to use devices_range instead. A small number of other modifications are caused by these APIs' changes and are necessary to keep the code buildable.

One extra change is the addition of a minor devices_range::to<std::vector<ur_device_handle_t>>() helper that we can use now that most of the arguments are device_range. Technically, could go in another PR but then we'd just be modifying the exact same lines two times, so I decided to fuse it here.

@aelovikov-intel aelovikov-intel requested a review from a team as a code owner July 15, 2025 21:22
@aelovikov-intel aelovikov-intel requested a review from againull July 15, 2025 21:22
@@ -1138,6 +1138,29 @@ class kernel_bundle_impl
DeviceGlobalMap MDeviceGlobals{/*OwnerControlledCleanup=*/false};
};

inline bool is_compatible(const std::vector<kernel_id> &KernelIDs,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

source/kernel_bundle.cpp provides bool is_compatible(const std::vector<kernel_id> &KernelIDs, const device &Dev) and is a public SYCL API, but we don't have sycl::device inside program_manager anymore, so what I'm doing here is moving implementation to here and modifying that public API to be just a thin wrapper about this method. That way program_manager can call this without creating sycl::device object.

…e_impl *`

intel#18251 extended `device_impl`s' lifetimes
until shutdown and intel#18270 started to pass
devices as raw pointers in some of the APIs.

This PR builds on top of that and extends usage of raw
pointers/references/`device_range` as the devices are known to be alive
and extra `std::shared_ptr`'s atomic increments aren't necessary and
could be avoided.

This change mostly touches `device_image_impl` and `program_manager` and
switches most of the APIs to use `devices_range`. A few number of other
modifications are caused by these APIs' changes and are necessary to
keep the code buildable.
@againull againull merged commit fd89ae4 into intel:sycl Jul 16, 2025
28 of 29 checks passed
@aelovikov-intel aelovikov-intel deleted the device_image_impl branch July 16, 2025 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants