From 61f0c6142ff5e09526d09912b3f3120024b805bb Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Wed, 25 Jun 2025 08:27:51 -0700 Subject: [PATCH] [NFC][SYCL] Pass `context_impl` by raw ptr in `CGHostTask` ctor Continuation of the refactoring in https://github.com/intel/llvm/pull/18795 https://github.com/intel/llvm/pull/18877 https://github.com/intel/llvm/pull/18966 https://github.com/intel/llvm/pull/18979 https://github.com/intel/llvm/pull/18980 https://github.com/intel/llvm/pull/18981 https://github.com/intel/llvm/pull/19007 https://github.com/intel/llvm/pull/19030 https://github.com/intel/llvm/pull/19123 https://github.com/intel/llvm/pull/19126 --- sycl/source/detail/cg.hpp | 6 +++--- sycl/source/detail/graph/graph_impl.cpp | 2 +- sycl/source/detail/graph/node_impl.hpp | 4 ++-- sycl/source/detail/scheduler/commands.cpp | 6 +++--- sycl/source/handler.cpp | 4 ++-- sycl/unittests/scheduler/SchedulerTestUtils.hpp | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sycl/source/detail/cg.hpp b/sycl/source/detail/cg.hpp index d33d65c3b90e9..15f962294cb6a 100644 --- a/sycl/source/detail/cg.hpp +++ b/sycl/source/detail/cg.hpp @@ -726,9 +726,9 @@ class CGHostTask : public CG { std::vector MArgs; CGHostTask(std::shared_ptr HostTask, detail::queue_impl *Queue, - std::shared_ptr Context, - std::vector Args, CG::StorageInitHelper CGData, - CGType Type, detail::code_location loc = {}); + detail::context_impl *Context, std::vector Args, + CG::StorageInitHelper CGData, CGType Type, + detail::code_location loc = {}); }; } // namespace detail diff --git a/sycl/source/detail/graph/graph_impl.cpp b/sycl/source/detail/graph/graph_impl.cpp index 9744dfcb1a19d..85e608f3ad9b1 100644 --- a/sycl/source/detail/graph/graph_impl.cpp +++ b/sycl/source/detail/graph/graph_impl.cpp @@ -1043,7 +1043,7 @@ EventImplPtr exec_graph_impl::enqueueHostTaskPartition( // dependencies for the current execution. std::unique_ptr CommandGroup = std::make_unique(sycl::detail::CGHostTask( - NodeCommandGroup->MHostTask, &Queue, NodeCommandGroup->MContext, + NodeCommandGroup->MHostTask, &Queue, NodeCommandGroup->MContext.get(), NodeCommandGroup->MArgs, std::move(CGData), NodeCommandGroup->getType())); diff --git a/sycl/source/detail/graph/node_impl.hpp b/sycl/source/detail/graph/node_impl.hpp index 0f769a0de09e9..5bd2d75a09fa7 100644 --- a/sycl/source/detail/graph/node_impl.hpp +++ b/sycl/source/detail/graph/node_impl.hpp @@ -287,8 +287,8 @@ class node_impl : public std::enable_shared_from_this { return std::make_unique( sycl::detail::CGHostTask( std::move(HostTaskSPtr), CommandGroupPtr->MQueue.get(), - CommandGroupPtr->MContext, std::move(NewArgs), std::move(Data), - CommandGroupPtr->getType(), Loc)); + CommandGroupPtr->MContext.get(), std::move(NewArgs), + std::move(Data), CommandGroupPtr->getType(), Loc)); } case sycl::detail::CGType::Barrier: case sycl::detail::CGType::BarrierWaitlist: diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index 835fdc535f6b7..0f6ca707ee5cd 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -3875,13 +3875,13 @@ void UpdateCommandBufferCommand::emitInstrumentationData() {} bool UpdateCommandBufferCommand::producesPiEvent() const { return false; } CGHostTask::CGHostTask(std::shared_ptr HostTask, - detail::queue_impl *Queue, - std::shared_ptr Context, + detail::queue_impl *Queue, detail::context_impl *Context, std::vector Args, CG::StorageInitHelper CGData, CGType Type, detail::code_location loc) : CG(Type, std::move(CGData), std::move(loc)), MHostTask(std::move(HostTask)), - MQueue(Queue ? Queue->shared_from_this() : nullptr), MContext(Context), + MQueue(Queue ? Queue->shared_from_this() : nullptr), + MContext(Context ? Context->shared_from_this() : nullptr), MArgs(std::move(Args)) {} } // namespace detail } // namespace _V1 diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index e6b646a1343e9..73ad399974671 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -733,8 +733,8 @@ event handler::finalize() { detail::context_impl &Context = impl->get_context(); detail::queue_impl *Queue = impl->get_queue_or_null(); CommandGroup.reset(new detail::CGHostTask( - std::move(impl->MHostTask), Queue, Context.shared_from_this(), - std::move(impl->MArgs), std::move(impl->CGData), getType(), MCodeLoc)); + std::move(impl->MHostTask), Queue, &Context, std::move(impl->MArgs), + std::move(impl->CGData), getType(), MCodeLoc)); break; } case detail::CGType::Barrier: diff --git a/sycl/unittests/scheduler/SchedulerTestUtils.hpp b/sycl/unittests/scheduler/SchedulerTestUtils.hpp index 61c7a82c764ae..c4b1afcf6f78e 100644 --- a/sycl/unittests/scheduler/SchedulerTestUtils.hpp +++ b/sycl/unittests/scheduler/SchedulerTestUtils.hpp @@ -310,7 +310,7 @@ class MockHandlerCustomFinalize : public MockHandler { } case sycl::detail::CGType::CodeplayHostTask: { CommandGroup.reset(new sycl::detail::CGHostTask( - std::move(getHostTask()), getQueue(), getQueue()->getContextImplPtr(), + std::move(getHostTask()), getQueue(), &getQueue()->getContextImpl(), getArgs(), std::move(CGData), getType(), getCodeLoc())); break; }