Skip to content

Commit 0e6d6ea

Browse files
[SYCL] Fix refcounting for kernel_bundle interop with OpenCL (#8465)
OpenCL interop spec basically says that each "conversion" must adjust reference counter of the underlying object. Many of the interop interfaces had been fixed in #3236 but the majority of the kernel_bundle feature was implemented after that and made the same omission. I'm not sure if that is the best way to fix it though. Another alternative would be to move all these retains into the OpenCL PI plugin.
1 parent fe12cab commit 0e6d6ea

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

sycl/source/backend.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ make_kernel_bundle(pi_native_handle NativeHandle, const context &TargetContext,
141141
pi::PiProgram PiProgram = nullptr;
142142
Plugin.call<PiApiKind::piextProgramCreateWithNativeHandle>(
143143
NativeHandle, ContextImpl->getHandleRef(), !KeepOwnership, &PiProgram);
144+
if (Plugin.getBackend() == backend::opencl)
145+
Plugin.call<PiApiKind::piProgramRetain>(PiProgram);
144146

145147
std::vector<pi::PiDevice> ProgramDevices;
146148
size_t NumDevices = 0;

sycl/source/detail/device_image_impl.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ class device_image_impl {
230230
const auto &ContextImplPtr = detail::getSyclObjImpl(MContext);
231231
const plugin &Plugin = ContextImplPtr->getPlugin();
232232

233+
if (Plugin.getBackend() == backend::opencl)
234+
Plugin.call<PiApiKind::piProgramRetain>(MProgram);
233235
pi_native_handle NativeProgram = 0;
234236
Plugin.call<PiApiKind::piextProgramGetNativeHandle>(MProgram,
235237
&NativeProgram);

0 commit comments

Comments
 (0)