From 07d99bae97f3542d458c2c7d7898a157155e9ac9 Mon Sep 17 00:00:00 2001 From: Sukrit Kalra Date: Mon, 20 May 2024 12:36:43 -0700 Subject: [PATCH] Clean up code and fix TetriSched scheduler. --- main.py | 22 ++++----- .../include/tetrisched/OptimizationPasses.hpp | 13 ++++-- .../include/tetrisched/Scheduler.hpp | 6 +-- schedulers/tetrisched/python/TetrischedPy.cpp | 14 +++--- .../tetrisched/src/CapacityConstraint.cpp | 41 ++++++++--------- .../tetrisched/src/OptimizationPasses.cpp | 34 +++----------- schedulers/tetrisched/src/Scheduler.cpp | 33 ++++++------- schedulers/tetrisched_scheduler.py | 46 ++++++++++--------- 8 files changed, 92 insertions(+), 117 deletions(-) diff --git a/main.py b/main.py index 39a73db6..77e21767 100644 --- a/main.py +++ b/main.py @@ -64,12 +64,6 @@ "Sets the mode in which the log file is opened. If 'append', the log file is " "opened in append mode, and if 'write', the log file is opened in write mode. ", ) -flags.DEFINE_multi_enum( - "opt_passes", - [], # default - ["CRITICAL_PATH_PASS", "DYNAMIC_DISCRETIZATION_PASS", "CAPACITY_CONSTRAINT_PURGE_PASS"], # choices - help="Specify the optimization passes that needs to be enabled once the STRL is generated, default: ['CRITICAL_PATH_PASS', 'CAPACITY_CONSTRAINT_PURGE_PASS']", -) flags.DEFINE_string( "csv_file_name", None, @@ -477,12 +471,6 @@ "If `True`, the scheduler is allowed to batch tasks " "that share a WorkProfile together.", ) -# flags.DEFINE_bool( -# "scheduler_enable_optimization_pass", -# False, -# "If `True`, the scheduler runs pre/post-translation optimization passes" -# "when registering STRL expression.", -# ) flags.DEFINE_bool( "scheduler_selective_rescheduling", False, @@ -501,6 +489,16 @@ "The percentage of critical path duration until which the scheduler will try " "placing the TaskGraph, and drop the TaskGraph if it cannot be placed after.", ) +flags.DEFINE_multi_enum( + "optimization_passes", + [], + [ + "CRITICAL_PATH_PASS", + "CAPACITY_CONSTRAINT_PURGE_PASS", + "DYNAMIC_DISCRETIZATION_PASS", + ], + "Specify the optimizations that needs to be enabled once the STRL is generated.", +) # Workload definition related flags. flags.DEFINE_integer( diff --git a/schedulers/tetrisched/include/tetrisched/OptimizationPasses.hpp b/schedulers/tetrisched/include/tetrisched/OptimizationPasses.hpp index 409d4101..49aec636 100644 --- a/schedulers/tetrisched/include/tetrisched/OptimizationPasses.hpp +++ b/schedulers/tetrisched/include/tetrisched/OptimizationPasses.hpp @@ -17,6 +17,7 @@ enum OptimizationPassType { POST_TRANSLATION_PASS = 1, }; +/// The types of OptimizationPasses implemented in the library. enum OptimizationPassCategory { CRITICAL_PATH_PASS = 0, DYNAMIC_DISCRETIZATION_PASS = 1, @@ -35,7 +36,11 @@ struct OptimizationPassConfig { Time finerDiscretizationWindow = 5; std::string toString() const { std::stringstream ss; - ss << "{minDisc: " << minDiscretization << ", maxDisc: " << maxDiscretization << ", maxOccupancyThreshold: " << maxOccupancyThreshold << ", finerDiscretizationAtPrevSolution: " << finerDiscretizationAtPrevSolution << ", finerDiscretizationWindow: " << finerDiscretizationWindow << "\n"; + ss << "{ minDisc: " << minDiscretization + << ", maxDisc: " << maxDiscretization + << ", maxOccupancyThreshold: " << maxOccupancyThreshold + << ", finerDiscretizationAtPrevSolution: " << finerDiscretizationAtPrevSolution + << ", finerDiscretizationWindow: " << finerDiscretizationWindow << std::endl; return ss.str(); } }; @@ -184,12 +189,12 @@ class OptimizationPassRunner { bool debug; /// A list of optimization passes to run. std::vector registeredPasses; - + OptimizationPassConfigPtr optConfig; public : /// Initialize the OptimizationPassRunner. - OptimizationPassRunner(bool debug = false, OptimizationPassConfigPtr optConfig = nullptr); + OptimizationPassRunner(OptimizationPassConfigPtr optConfig, bool debug = false); /// Run the pre-translation optimization passes on the given STRL expression. void runPreTranslationPasses(Time currentTime, ExpressionPtr strlExpression, @@ -200,7 +205,7 @@ class OptimizationPassRunner { CapacityConstraintMapPtr capacityConstraints); /// Add the optimization passes - void addOptimizationPass(OptimizationPassCategory optPass); + void addOptimizationPass(OptimizationPassCategory optPass); }; } // namespace tetrisched #endif // _TETRISCHED_OPTIMIZATION_PASSES_HPP_ diff --git a/schedulers/tetrisched/include/tetrisched/Scheduler.hpp b/schedulers/tetrisched/include/tetrisched/Scheduler.hpp index 015829a1..1eb08a1e 100644 --- a/schedulers/tetrisched/include/tetrisched/Scheduler.hpp +++ b/schedulers/tetrisched/include/tetrisched/Scheduler.hpp @@ -9,12 +9,8 @@ namespace tetrisched { /// The `SchedulerConfig` structure represents the configuration of the /// scheduler. This config is used to inform the choice of how the scheduler -/// should schedule the STRL expression. +/// should run the solver. struct SchedulerConfig { - /// If True, the scheduler will optimize the STRL expression. - bool optimize; - - /// The configuration for the solver backend. std::optional numThreads; std::optional