Skip to content

[NFC][SYCL] Return raw context_impl * from Command::getWorkerContext #19123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions sycl/source/detail/scheduler/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,6 @@ void Command::makeTraceEventEpilog() {

Command *Command::processDepEvent(EventImplPtr DepEvent, const DepDesc &Dep,
std::vector<Command *> &ToCleanUp) {
const ContextImplPtr &WorkerContext = getWorkerContext();

// 1. Non-host events can be ignored if they are not fully initialized.
// 2. Some types of commands do not produce UR events after they are
Expand All @@ -780,8 +779,9 @@ Command *Command::processDepEvent(EventImplPtr DepEvent, const DepDesc &Dep,
Command *ConnectionCmd = nullptr;

context_impl &DepEventContext = DepEvent->getContextImpl();
context_impl *WorkerContext = getWorkerContext();
// If contexts don't match we'll connect them using host task
if (&DepEventContext != WorkerContext.get() && WorkerContext) {
if (&DepEventContext != WorkerContext && WorkerContext) {
Scheduler::GraphBuilder &GB = Scheduler::getInstance().MGraphBuilder;
ConnectionCmd = GB.connectDepEvent(this, DepEvent, Dep, ToCleanUp);
} else
Expand All @@ -790,10 +790,10 @@ Command *Command::processDepEvent(EventImplPtr DepEvent, const DepDesc &Dep,
return ConnectionCmd;
}

ContextImplPtr Command::getWorkerContext() const {
context_impl *Command::getWorkerContext() const {
if (!MQueue)
return nullptr;
return MQueue->getContextImplPtr();
return &MQueue->getContextImpl();
}

bool Command::producesPiEvent() const { return true; }
Expand Down Expand Up @@ -1547,10 +1547,10 @@ void MemCpyCommand::emitInstrumentationData() {
#endif
}

ContextImplPtr MemCpyCommand::getWorkerContext() const {
context_impl *MemCpyCommand::getWorkerContext() const {
if (!MWorkerQueue)
return nullptr;
return MWorkerQueue->getContextImplPtr();
return &MWorkerQueue->getContextImpl();
}

bool MemCpyCommand::producesPiEvent() const {
Expand Down Expand Up @@ -1720,10 +1720,10 @@ void MemCpyCommandHost::emitInstrumentationData() {
#endif
}

ContextImplPtr MemCpyCommandHost::getWorkerContext() const {
context_impl *MemCpyCommandHost::getWorkerContext() const {
if (!MWorkerQueue)
return nullptr;
return MWorkerQueue->getContextImplPtr();
return &MWorkerQueue->getContextImpl();
}

ur_result_t MemCpyCommandHost::enqueueImp() {
Expand Down
6 changes: 3 additions & 3 deletions sycl/source/detail/scheduler/commands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class Command {

/// Get the context of the queue this command will be submitted to. Could
/// differ from the context of MQueue for memory copy commands.
virtual ContextImplPtr getWorkerContext() const;
virtual context_impl *getWorkerContext() const;

/// Returns true iff the command produces a UR event on non-host devices.
virtual bool producesPiEvent() const;
Expand Down Expand Up @@ -584,7 +584,7 @@ class MemCpyCommand : public Command {
void printDot(std::ostream &Stream) const final;
const Requirement *getRequirement() const final { return &MDstReq; }
void emitInstrumentationData() final;
ContextImplPtr getWorkerContext() const final;
context_impl *getWorkerContext() const final;
bool producesPiEvent() const final;

private:
Expand All @@ -608,7 +608,7 @@ class MemCpyCommandHost : public Command {
void printDot(std::ostream &Stream) const final;
const Requirement *getRequirement() const final { return &MDstReq; }
void emitInstrumentationData() final;
ContextImplPtr getWorkerContext() const final;
context_impl *getWorkerContext() const final;

private:
ur_result_t enqueueImp() final;
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/scheduler/graph_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ void Scheduler::GraphBuilder::removeRecordForMemObj(SYCLMemObjI *MemObject) {
Command *Scheduler::GraphBuilder::connectDepEvent(
Command *const Cmd, const EventImplPtr &DepEvent, const DepDesc &Dep,
std::vector<Command *> &ToCleanUp) {
assert(Cmd->getWorkerContext().get() != &DepEvent->getContextImpl());
assert(Cmd->getWorkerContext() != &DepEvent->getContextImpl());

// construct Host Task type command manually and make it depend on DepEvent
ExecCGCommand *ConnectCmd = nullptr;
Expand Down