From 01cd824598ba6d3377578148847858cf5dde3044 Mon Sep 17 00:00:00 2001 From: Artur Gainullin Date: Tue, 23 Dec 2025 23:39:52 +0100 Subject: [PATCH] [SYCL][ABI-break] Simplify interop_handle constructor Accrording to spec "The interop_handle class is an abstraction over the queue which is being used to invoke the host task and its associated device and context." and currently interop_handle object is created internally at the time of submission to the queue, so queue is always supposed to be available. Device and context are the ones associated with the queue, so it seems that those arguments are redundant. --- sycl/include/sycl/interop_handle.hpp | 16 ++++------------ sycl/source/detail/scheduler/commands.cpp | 11 +++-------- sycl/source/interop_handle.cpp | 11 +++++------ 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/sycl/include/sycl/interop_handle.hpp b/sycl/include/sycl/interop_handle.hpp index a380de47764d0..d2976eb09bdf6 100644 --- a/sycl/include/sycl/interop_handle.hpp +++ b/sycl/include/sycl/interop_handle.hpp @@ -205,19 +205,13 @@ class interop_handle { friend class detail::DispatchHostTask; using ReqToMem = std::pair; -#ifdef __INTEL_PREVIEW_BREAKING_CHANGES - // Clean this up (no shared pointers). Not doing it right now because I expect - // there will be several iterations of simplifications possible and it would - // be hard to track which of them made their way into a minor public release - // and which didn't. Let's just clean it up once during ABI breaking window. -#endif interop_handle(std::vector MemObjs, const std::shared_ptr &Queue, - detail::device_impl &Device, - const std::shared_ptr &Context, ur_exp_command_buffer_handle_t Graph = nullptr) - : MQueue(Queue), MDevice(Device), MContext(Context), MGraph(Graph), - MMemObjs(std::move(MemObjs)) {} + : MQueue(Queue), MGraph(Graph), MMemObjs(std::move(MemObjs)) { + assert(MQueue != nullptr && + "interop_handle must be associated with a valid queue"); + } template backend_return_t> @@ -243,8 +237,6 @@ class interop_handle { __SYCL_EXPORT ur_native_handle_t getNativeGraph() const; std::shared_ptr MQueue; - detail::device_impl &MDevice; - std::shared_ptr MContext; ur_exp_command_buffer_handle_t MGraph; std::vector MMemObjs; diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index 3b3fdb6a6042f..581b52a54b7c1 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -408,9 +408,7 @@ class DispatchHostTask { if (HostTask.MHostTask->isInteropTask()) { assert(HostTask.MQueue && "Host task submissions should have an associated queue"); - interop_handle IH{MReqToMem, HostTask.MQueue, - HostTask.MQueue->getDeviceImpl(), - HostTask.MQueue->getContextImpl().shared_from_this()}; + interop_handle IH{MReqToMem, HostTask.MQueue}; // TODO: should all the backends that support this entry point use this // for host task? auto &Queue = HostTask.MQueue; @@ -3113,8 +3111,7 @@ ur_result_t ExecCGCommand::enqueueImpCommandBuffer() { ur_exp_command_buffer_handle_t InteropCommandBuffer = ChildCommandBuffer ? ChildCommandBuffer : MCommandBuffer; - interop_handle IH{std::move(ReqToMem), MQueue, DeviceImpl, - ContextImpl.shared_from_this(), InteropCommandBuffer}; + interop_handle IH{std::move(ReqToMem), MQueue, InteropCommandBuffer}; CommandBufferNativeCommandData CustomOpData{ std::move(IH), HostTask->MHostTask->MInteropTask}; @@ -3487,9 +3484,7 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { } EnqueueNativeCommandData CustomOpData{ - interop_handle{std::move(ReqToMem), HostTask->MQueue, - HostTask->MQueue->getDeviceImpl(), - HostTask->MQueue->getContextImpl().shared_from_this()}, + interop_handle{std::move(ReqToMem), HostTask->MQueue}, HostTask->MHostTask->MInteropTask}; ur_bool_t NativeCommandSupport = false; diff --git a/sycl/source/interop_handle.cpp b/sycl/source/interop_handle.cpp index ccba78caa165d..db29227563b3d 100644 --- a/sycl/source/interop_handle.cpp +++ b/sycl/source/interop_handle.cpp @@ -38,25 +38,24 @@ interop_handle::getNativeMem(detail::Requirement *Req) const { } detail::adapter_impl &Adapter = MQueue->getAdapter(); + detail::device_impl &Device = MQueue->getDeviceImpl(); ur_native_handle_t Handle; Adapter.call( - Iter->second, MDevice.getHandleRef(), &Handle); + Iter->second, Device.getHandleRef(), &Handle); return Handle; } ur_native_handle_t interop_handle::getNativeDevice() const { - return MDevice.getNative(); + return MQueue->getDeviceImpl().getNative(); } ur_native_handle_t interop_handle::getNativeContext() const { - return MContext->getNative(); + return MQueue->getContextImpl().getNative(); } ur_native_handle_t interop_handle::getNativeQueue(int32_t &NativeHandleDesc) const { - if (MQueue != nullptr) - return MQueue->getNative(NativeHandleDesc); - return 0; + return MQueue->getNative(NativeHandleDesc); } ur_native_handle_t interop_handle::getNativeGraph() const {