@@ -19,6 +19,24 @@ namespace sycl {
1919inline namespace _V1 {
2020namespace detail {
2121
22+ // / Constructs a SYCL device instance using the provided
23+ // / UR device instance.
24+ device_impl::device_impl (ur_device_handle_t Device, platform_impl &Platform,
25+ device_impl::private_tag, bool IsSubDevice)
26+ : MDevice(Device), MPlatform(Platform),
27+ // No need to set MRootDevice when MAlwaysRootDevice is true
28+ MRootDevice (Platform.MAlwaysRootDevice
29+ ? nullptr
30+ : get_info_impl<UR_DEVICE_INFO_PARENT_DEVICE>()),
31+ // TODO catch an exception and put it to list of asynchronous exceptions:
32+ MCache{*this } {
33+ if (!IsSubDevice) {
34+ // Interoperability Constructor already calls DeviceRetain in
35+ // urDeviceCreateWithNativeHandle.
36+ getAdapter ().call <UrApiKind::urDeviceRetain>(MDevice);
37+ }
38+ }
39+
2240// / Constructs a SYCL device instance using the provided
2341// / UR device instance.
2442device_impl::device_impl (ur_device_handle_t Device, platform_impl &Platform,
@@ -30,9 +48,7 @@ device_impl::device_impl(ur_device_handle_t Device, platform_impl &Platform,
3048 : get_info_impl<UR_DEVICE_INFO_PARENT_DEVICE>()),
3149 // TODO catch an exception and put it to list of asynchronous exceptions:
3250 MCache{*this } {
33- // Interoperability Constructor already calls DeviceRetain in
34- // urDeviceCreateWithNativeHandle.
35- getAdapter ().call <UrApiKind::urDeviceRetain>(MDevice);
51+ device_impl (Device, Platform, private_tag{}, false );
3652}
3753
3854device_impl::~device_impl () {
@@ -164,7 +180,7 @@ std::vector<device> device_impl::create_sub_devices(
164180 std::for_each (SubDevices.begin (), SubDevices.end (),
165181 [&res, this ](const ur_device_handle_t &a_ur_device) {
166182 device sycl_device = detail::createSyclObjFromImpl<device>(
167- MPlatform.getOrMakeDeviceImpl (a_ur_device));
183+ MPlatform.getOrMakeSubDeviceImpl (a_ur_device));
168184 res.push_back (sycl_device);
169185 });
170186 return res;
0 commit comments