@@ -150,33 +150,35 @@ class context_impl {
150150 KernelProgramCache &getKernelProgramCache () const ;
151151
152152 // / Returns true if and only if context contains the given device.
153- bool hasDevice (std::shared_ptr< detail::device_impl> Device) const ;
153+ bool hasDevice (const detail::device_impl & Device) const ;
154154
155155 // / Returns true if and only if the device can be used within this context.
156156 // / For OpenCL this is currently equivalent to hasDevice, for other backends
157157 // / it returns true if the device is either a member of the context or a
158158 // / descendant of a member.
159- bool isDeviceValid (DeviceImplPtr Device) {
160- while (!hasDevice (Device)) {
161- if (Device->isRootDevice ()) {
162- if (Device->has (aspect::ext_oneapi_is_component)) {
159+ bool isDeviceValid (detail::device_impl &Device) {
160+ detail::device_impl *CurrDevice = &Device;
161+ while (!hasDevice (*CurrDevice)) {
162+ if (CurrDevice->isRootDevice ()) {
163+ if (CurrDevice->has (aspect::ext_oneapi_is_component)) {
163164 // Component devices should be implicitly usable in context created
164165 // for a composite device they belong to.
165- auto CompositeDevice = Device ->get_info <
166+ auto CompositeDevice = CurrDevice ->get_info <
166167 ext::oneapi::experimental::info::device::composite_device>();
167- return hasDevice (detail::getSyclObjImpl (CompositeDevice));
168+ return hasDevice (* detail::getSyclObjImpl (CompositeDevice));
168169 }
169170
170171 return false ;
171- } else if (Device ->getBackend () == backend::opencl) {
172+ } else if (CurrDevice ->getBackend () == backend::opencl) {
172173 // OpenCL does not support using descendants of context members within
173174 // that context yet. We make the exception in case it supports
174175 // component/composite devices.
175176 // TODO remove once this limitation is lifted
176177 return false ;
177178 }
178- Device = detail::getSyclObjImpl (
179- Device->get_info <info::device::parent_device>());
179+ CurrDevice = detail::getSyclObjImpl (
180+ CurrDevice->get_info <info::device::parent_device>())
181+ .get ();
180182 }
181183
182184 return true ;
@@ -190,7 +192,7 @@ class context_impl {
190192
191193 // / Given a UR device, returns the matching shared_ptr<device_impl>
192194 // / within this context. May return nullptr if no match discovered.
193- DeviceImplPtr findMatchingDeviceImpl (ur_device_handle_t &DeviceUR) const ;
195+ device_impl * findMatchingDeviceImpl (ur_device_handle_t &DeviceUR) const ;
194196
195197 // / Gets the native handle of the SYCL context.
196198 // /
@@ -216,16 +218,16 @@ class context_impl {
216218 initializeDeviceGlobals (ur_program_handle_t NativePrg,
217219 const std::shared_ptr<queue_impl> &QueueImpl);
218220
219- void memcpyToHostOnlyDeviceGlobal (
220- const std::shared_ptr<device_impl> &DeviceImpl,
221- const void *DeviceGlobalPtr, const void *Src, size_t DeviceGlobalTSize,
222- bool IsDeviceImageScoped, size_t NumBytes, size_t Offset);
221+ void memcpyToHostOnlyDeviceGlobal (device_impl &DeviceImpl,
222+ const void *DeviceGlobalPtr,
223+ const void *Src, size_t DeviceGlobalTSize,
224+ bool IsDeviceImageScoped, size_t NumBytes,
225+ size_t Offset);
223226
224- void
225- memcpyFromHostOnlyDeviceGlobal (const std::shared_ptr<device_impl> &DeviceImpl,
226- void *Dest, const void *DeviceGlobalPtr,
227- bool IsDeviceImageScoped, size_t NumBytes,
228- size_t Offset);
227+ void memcpyFromHostOnlyDeviceGlobal (device_impl &DeviceImpl, void *Dest,
228+ const void *DeviceGlobalPtr,
229+ bool IsDeviceImageScoped, size_t NumBytes,
230+ size_t Offset);
229231
230232 // / Gets a program associated with a device global from the cache.
231233 std::optional<ur_program_handle_t >
0 commit comments