Skip to content

Commit 8b445d6

Browse files
[NFC][SYCL] Return raw context_impl * from Command::getWorkerContext (#19123)
Continuation of the refactoring in #18795 #18877 #18966 #18979 #18980 #18981 #19007 #19030
1 parent 6f324ef commit 8b445d6

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

sycl/source/detail/scheduler/commands.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,6 @@ void Command::makeTraceEventEpilog() {
759759

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

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

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

793-
ContextImplPtr Command::getWorkerContext() const {
793+
context_impl *Command::getWorkerContext() const {
794794
if (!MQueue)
795795
return nullptr;
796-
return MQueue->getContextImplPtr();
796+
return &MQueue->getContextImpl();
797797
}
798798

799799
bool Command::producesPiEvent() const { return true; }
@@ -1547,10 +1547,10 @@ void MemCpyCommand::emitInstrumentationData() {
15471547
#endif
15481548
}
15491549

1550-
ContextImplPtr MemCpyCommand::getWorkerContext() const {
1550+
context_impl *MemCpyCommand::getWorkerContext() const {
15511551
if (!MWorkerQueue)
15521552
return nullptr;
1553-
return MWorkerQueue->getContextImplPtr();
1553+
return &MWorkerQueue->getContextImpl();
15541554
}
15551555

15561556
bool MemCpyCommand::producesPiEvent() const {
@@ -1720,10 +1720,10 @@ void MemCpyCommandHost::emitInstrumentationData() {
17201720
#endif
17211721
}
17221722

1723-
ContextImplPtr MemCpyCommandHost::getWorkerContext() const {
1723+
context_impl *MemCpyCommandHost::getWorkerContext() const {
17241724
if (!MWorkerQueue)
17251725
return nullptr;
1726-
return MWorkerQueue->getContextImplPtr();
1726+
return &MWorkerQueue->getContextImpl();
17271727
}
17281728

17291729
ur_result_t MemCpyCommandHost::enqueueImp() {

sycl/source/detail/scheduler/commands.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class Command {
221221

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

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

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

613613
private:
614614
ur_result_t enqueueImp() final;

sycl/source/detail/scheduler/graph_builder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ void Scheduler::GraphBuilder::removeRecordForMemObj(SYCLMemObjI *MemObject) {
12211221
Command *Scheduler::GraphBuilder::connectDepEvent(
12221222
Command *const Cmd, const EventImplPtr &DepEvent, const DepDesc &Dep,
12231223
std::vector<Command *> &ToCleanUp) {
1224-
assert(Cmd->getWorkerContext().get() != &DepEvent->getContextImpl());
1224+
assert(Cmd->getWorkerContext() != &DepEvent->getContextImpl());
12251225

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

0 commit comments

Comments
 (0)