Skip to content

Commit 8cd13a7

Browse files
authored
[SYCL][CL] Fix ownership of native handle in sycl::make_queue (#18309)
Level Zero is the only backend which has any explicit ownership transfer controls when creating SYCL objects from native handles. The CUDA and HIP backends already had the default to not transferring ownership of native handles. Up until this patch the OpenCL backend was transferring ownership when creating with a native handle, when combined with the changes to the OpenCL adapter in #17572 this caused crashes in existing workloads which expect to manage ownership of the OpenCL native handles. Fixes URT-905.
1 parent 20a7abc commit 8cd13a7

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

sycl/include/sycl/backend.hpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -327,18 +327,16 @@ std::enable_if_t<detail::InteropFeatureSupportMap<Backend>::MakeQueue == true,
327327
make_queue(const typename backend_traits<Backend>::template input_type<queue>
328328
&BackendObject,
329329
const context &TargetContext, const async_handler Handler = {}) {
330-
auto KeepOwnership =
331-
Backend == backend::ext_oneapi_cuda || Backend == backend::ext_oneapi_hip;
332330
if constexpr (Backend == backend::ext_oneapi_level_zero) {
333331
return detail::make_queue(
334332
detail::ur::cast<ur_native_handle_t>(
335333
std::get<ze_command_queue_handle_t>(BackendObject.NativeHandle)),
336-
false, TargetContext, nullptr, KeepOwnership, {}, Handler, Backend);
337-
}
338-
if constexpr (Backend != backend::ext_oneapi_level_zero) {
334+
false, TargetContext, nullptr, /*KeepOwnership*/ false, {}, Handler,
335+
Backend);
336+
} else {
339337
return detail::make_queue(
340338
detail::ur::cast<ur_native_handle_t>(BackendObject), false,
341-
TargetContext, nullptr, KeepOwnership, {}, Handler, Backend);
339+
TargetContext, nullptr, /*KeepOwnership*/ true, {}, Handler, Backend);
342340
}
343341
}
344342

0 commit comments

Comments
 (0)