Skip to content
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
2 changes: 1 addition & 1 deletion sycl/source/detail/scheduler/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ Command::getUrEventsBlocking(const std::vector<EventImplPtr> &EventImpls,
!EventImpl->getCommand()->producesPiEvent())
continue;
std::vector<Command *> AuxCmds;
Scheduler::getInstance().enqueueCommandForCG(EventImpl, AuxCmds,
Scheduler::getInstance().enqueueCommandForCG(*EventImpl, AuxCmds,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Known non-null due to dereference in line 283.

BLOCKING);
}
// Do not add redundant event dependencies for in-order queues.
Expand Down
10 changes: 4 additions & 6 deletions sycl/source/detail/scheduler/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,31 +144,29 @@ EventImplPtr Scheduler::addCG(
}
}

enqueueCommandForCG(NewEvent, AuxiliaryCmds);
enqueueCommandForCG(*NewEvent, AuxiliaryCmds);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Known non-null due to dereference at line 136. Closing } at line 145 is from the lock guard scope, so we do go through line 135 before making this call.


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

return NewEvent;
}

void Scheduler::enqueueCommandForCG(EventImplPtr NewEvent,
void Scheduler::enqueueCommandForCG(event_impl &Event,
std::vector<Command *> &AuxiliaryCmds,
BlockingT Blocking) {
std::vector<Command *> ToCleanUp;
{
ReadLockT Lock = acquireReadLock();

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

EnqueueResultT Res;
bool Enqueued;

auto CleanUp = [&]() {
if (NewCmd && (NewCmd->MDeps.size() == 0 && NewCmd->MUsers.size() == 0)) {
if (NewEvent) {
NewEvent->setCommand(nullptr);
}
Event.setCommand(nullptr);
delete NewCmd;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This delete is just bizarre, the ownership model is totally unclear here. Irrelevant to this PR though.

}
cleanupCommands(ToCleanUp);
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/scheduler/scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ class Scheduler {
void releaseResources(BlockingT Blocking = BlockingT::BLOCKING);
bool isDeferredMemObjectsEmpty();

void enqueueCommandForCG(EventImplPtr NewEvent,
void enqueueCommandForCG(event_impl &Event,
std::vector<Command *> &AuxilaryCmds,
BlockingT Blocking = NON_BLOCKING);

Expand Down