Skip to content

Commit c01b093

Browse files
[NFCI][SYCL] Change scheduler::enqueueCommandForCG to accept event_impl & (#19599)
Before this PR, its implementation had code paths for `nullptr` argument, but it's never `nullptr` at any of the call sites. Originally, this method was added in #7531 and was called with `nullptr` argument from some fusion code (at least), but it doesn't seem to be the case anymore (and fusion support has been removed from the project). Also, for some reason it was accepting `std::shared_ptr<event_impl>` by value and not by reference (no idea why), and the name was `NewEvent` without any comments/documentation. The former is irrelevant after this change, and for the latter I'm changing the name to a neutral "Event". If someone has a better understanding, please let me know.
1 parent 24f54ea commit c01b093

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

sycl/source/detail/scheduler/commands.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ Command::getUrEventsBlocking(const std::vector<EventImplPtr> &EventImpls,
285285
!EventImpl->getCommand()->producesPiEvent())
286286
continue;
287287
std::vector<Command *> AuxCmds;
288-
Scheduler::getInstance().enqueueCommandForCG(EventImpl, AuxCmds,
288+
Scheduler::getInstance().enqueueCommandForCG(*EventImpl, AuxCmds,
289289
BLOCKING);
290290
}
291291
// Do not add redundant event dependencies for in-order queues.

sycl/source/detail/scheduler/scheduler.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,31 +144,29 @@ EventImplPtr Scheduler::addCG(
144144
}
145145
}
146146

147-
enqueueCommandForCG(NewEvent, AuxiliaryCmds);
147+
enqueueCommandForCG(*NewEvent, AuxiliaryCmds);
148148

149149
if (!AuxiliaryResources.empty())
150150
registerAuxiliaryResources(NewEvent, std::move(AuxiliaryResources));
151151

152152
return NewEvent;
153153
}
154154

155-
void Scheduler::enqueueCommandForCG(EventImplPtr NewEvent,
155+
void Scheduler::enqueueCommandForCG(event_impl &Event,
156156
std::vector<Command *> &AuxiliaryCmds,
157157
BlockingT Blocking) {
158158
std::vector<Command *> ToCleanUp;
159159
{
160160
ReadLockT Lock = acquireReadLock();
161161

162-
Command *NewCmd = (NewEvent) ? NewEvent->getCommand() : nullptr;
162+
Command *NewCmd = Event.getCommand();
163163

164164
EnqueueResultT Res;
165165
bool Enqueued;
166166

167167
auto CleanUp = [&]() {
168168
if (NewCmd && (NewCmd->MDeps.size() == 0 && NewCmd->MUsers.size() == 0)) {
169-
if (NewEvent) {
170-
NewEvent->setCommand(nullptr);
171-
}
169+
Event.setCommand(nullptr);
172170
delete NewCmd;
173171
}
174172
cleanupCommands(ToCleanUp);

sycl/source/detail/scheduler/scheduler.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ class Scheduler {
465465
void releaseResources(BlockingT Blocking = BlockingT::BLOCKING);
466466
bool isDeferredMemObjectsEmpty();
467467

468-
void enqueueCommandForCG(EventImplPtr NewEvent,
468+
void enqueueCommandForCG(event_impl &Event,
469469
std::vector<Command *> &AuxilaryCmds,
470470
BlockingT Blocking = NON_BLOCKING);
471471

0 commit comments

Comments
 (0)