From 7a9b48f4c3652efc544fdb5721896044b435c33e Mon Sep 17 00:00:00 2001 From: Olivier BICHLER <olivier.bichler@cea.fr> Date: Thu, 20 Feb 2025 16:06:25 +0100 Subject: [PATCH] Integrate a small fix for @raphaelmillet --- src/scheduler/Scheduler.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/scheduler/Scheduler.cpp b/src/scheduler/Scheduler.cpp index 18210a1f8..f65729d64 100644 --- a/src/scheduler/Scheduler.cpp +++ b/src/scheduler/Scheduler.cpp @@ -1165,8 +1165,14 @@ std::vector<std::shared_ptr<Aidge::Node>> Aidge::Scheduler::getStaticScheduling( [](const auto& lhs, const auto& rhs) { return ((lhs->early < rhs->early) || (lhs->early == rhs->early && lhs->late < rhs->late)); }); } else if (sorting == EarlyLateSort::AsLateAsPossible) { + // The last condition (lhs->early > rhs->early) ensures that when on a + // branch join, one does not switch branch just before the join if there + // is only a single node (scheduled as late as possible, since not in the + // critical path) in one of the branch. + // @raphaelmillet Required for PNeuro export. + // TODO: add branch-level sorting policies (shortest to longuest branch for example) std::stable_sort(staticSchedule.begin(), staticSchedule.end(), - [](const auto& lhs, const auto& rhs) { return ((lhs->late < rhs->late) || (lhs->late == rhs->late && lhs->early < rhs->early)); }); + [](const auto& lhs, const auto& rhs) { return ((lhs->late < rhs->late) || (lhs->late == rhs->late && lhs->early > rhs->early)); }); } std::vector<std::shared_ptr<Node>> schedule; -- GitLab