Skip to content

Commit 1580c39

Browse files
authored
[SYCL][Fusion] Avoid deferred cleanup for fusion (intel#11598)
Full cleanup for fusion placeholder commands is handled by specialized scheduler entry points (`start_fusion`, `cleanUPCmdFusion`). To avoid interference with that mechanism, fusion commands should not be added to the deferred cleanup list. Signed-off-by: Lukas Sommer <[email protected]>
1 parent 9286183 commit 1580c39

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

sycl/source/detail/scheduler/scheduler.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,15 @@ void Scheduler::cleanupCommands(const std::vector<Command *> &Cmds) {
456456

457457
} else {
458458
std::lock_guard<std::mutex> Lock{MDeferredCleanupMutex};
459-
MDeferredCleanupCommands.insert(MDeferredCleanupCommands.end(),
460-
Cmds.begin(), Cmds.end());
459+
// Full cleanup for fusion placeholder commands is handled by the entry
460+
// points for fusion (start_fusion, ...). To avoid double free or access to
461+
// objects after their lifetime, fusion commands should therefore never be
462+
// added to the deferred command list.
463+
std::copy_if(Cmds.begin(), Cmds.end(),
464+
std::back_inserter(MDeferredCleanupCommands),
465+
[](const Command *Cmd) {
466+
return Cmd->getType() != Command::CommandType::FUSION;
467+
});
461468
}
462469
}
463470

0 commit comments

Comments
 (0)