From 91f1a46cf1cc5fced47e0393812fe986a286f244 Mon Sep 17 00:00:00 2001 From: Knute Lingaard Date: Mon, 23 Oct 2023 20:53:49 -0500 Subject: [PATCH 1/2] Added new counter to Scheduler: events_fired; small Scheduler cleanup --- sparta/sparta/kernel/Scheduler.hpp | 35 ++++++++++--------- sparta/src/Scheduler.cpp | 21 +++-------- .../Report/test_autopopulate.html.EXPECTED | 7 ++++ .../Report/test_autopopulate.txt.EXPECTED | 1 + ...est_autopopulate_from_string.html.EXPECTED | 7 ++++ 5 files changed, 37 insertions(+), 34 deletions(-) diff --git a/sparta/sparta/kernel/Scheduler.hpp b/sparta/sparta/kernel/Scheduler.hpp index 5925a9ce5f..796d35c376 100644 --- a/sparta/sparta/kernel/Scheduler.hpp +++ b/sparta/sparta/kernel/Scheduler.hpp @@ -288,7 +288,7 @@ class Scheduler : public RootTreeNode }; //! The current time quantum - TickQuantum * current_tick_quantum_; + TickQuantum * current_tick_quantum_ = nullptr; //! The ObjectAllocator used to create time quantum structures ObjectAllocator tick_quantum_allocator_; @@ -931,36 +931,36 @@ class Scheduler : public RootTreeNode std::unique_ptr dag_; //! The number of groups in the DAG after finalization. - uint32_t dag_group_count_; + uint32_t dag_group_count_ = 1; //! The number of firing groups (dag_group_count_ [+pre] [+post]) - uint32_t firing_group_count_; + uint32_t firing_group_count_ = {dag_group_count_ + 2}; //! Identifier for group zero -- index of the array that represents it uint32_t group_zero_; //! A boolean for asserting whether or not the scheduler has //! called finalize on the dag - bool dag_finalized_; + bool dag_finalized_ = false; //! Are we at the very first tick? bool first_tick_ = true; //! The current time of the scheduler - Tick current_tick_; + Tick current_tick_ = 0; //init tick 0 //! Elapsed ticks - Tick elapsed_ticks_; + Tick elapsed_ticks_ = 0; //! Previous tick that someone kicked the WDT - Tick prev_wdt_tick_; + Tick prev_wdt_tick_ = 0; //! Tickout period in ticks for the WDT; a value of 0 indicates //! WDT is disabled - Tick wdt_period_ticks_; + Tick wdt_period_ticks_ = 0; //! Is the scheduler running. True = yes - bool running_; + bool running_ = false; //! A callback delegate to stop running the scheduler std::unique_ptr stop_event_; @@ -969,13 +969,9 @@ class Scheduler : public RootTreeNode std::unique_ptr cancelled_event_; void cancelCallback_() {} - //! A count of the number of events fired since this scheduler's - //! creation - Tick events_fired_; - //! A count of the number of non-continuing events scheduled since //! this scheduler's creation - bool is_finished_; + bool is_finished_ = false; //! A list of events that are zero priority to be fired std::vector startup_events_; @@ -985,10 +981,10 @@ class Scheduler : public RootTreeNode std::vector registered_clocks_; //! The current dag group priority being fired. - uint32_t current_group_firing_; + uint32_t current_group_firing_ = 0; //! The current event being fired. - uint32_t current_event_firing_; + uint32_t current_event_firing_ = 0; //! The current SchedulingPhase SchedulingPhase current_scheduling_phase_ = SchedulingPhase::Trigger; @@ -1003,7 +999,7 @@ class Scheduler : public RootTreeNode std::ostringstream call_trace_stream_; //! Furthest continuing event in the future. Used to determine when to stop the simulation - Tick latest_continuing_event_; + Tick latest_continuing_event_ = 0; //! Set of counters & stats for the Scheduler StatisticSet sset_; @@ -1052,6 +1048,11 @@ class Scheduler : public RootTreeNode //! Timer used to calculate runtime boost::timer::cpu_timer timer_; + //! A count of the number of events fired since this scheduler's + //! creation + uint64_t events_fired_ = 0; + ReadOnlyCounter events_fired_cnt_; + //! User, System, and Wall clock counts uint64_t user_time_ = 0; ReadOnlyCounter user_time_cnt_; diff --git a/sparta/src/Scheduler.cpp b/sparta/src/Scheduler.cpp index 090e01669e..8c28fa6475 100644 --- a/sparta/src/Scheduler.cpp +++ b/sparta/src/Scheduler.cpp @@ -44,27 +44,13 @@ Scheduler::Scheduler() : Scheduler::Scheduler(const std::string& name, GlobalTreeNode* search_scope) : RootTreeNode(name, "DES Scheduler", search_scope), - current_tick_quantum_(nullptr), - dag_group_count_(1), - firing_group_count_(dag_group_count_ + 2), - dag_finalized_(false), - current_tick_(0), //init tick 0 - elapsed_ticks_(0), - prev_wdt_tick_(0), - wdt_period_ticks_(0), - running_(false), stop_event_(new Scheduleable(CREATE_SPARTA_HANDLER(Scheduler, stopRunning), 0, SchedulingPhase::Trigger)), cancelled_event_(new Scheduleable(CREATE_SPARTA_HANDLER(Scheduler, cancelCallback_), 0, SchedulingPhase::Tick)), - events_fired_(0), - is_finished_(false), - current_group_firing_(0), - current_event_firing_(0), debug_(this, sparta::log::categories::DEBUG, "Scheduler debug messages including queue dump"), call_trace_logger_(this, (std::string)"calltrace", "Scheduler Event Call Trace"), - latest_continuing_event_(0), sset_(this), scheduler_internal_clk_(new sparta::Clock("_internal_scheduler_clk", this)), ticks_roctr_(&sset_, @@ -108,9 +94,10 @@ Scheduler::Scheduler(const std::string& name, GlobalTreeNode* search_scope) : "Simulation wall clock runtime in seconds as measured on the host machine", &sset_, "host_wall_time_count_ms/1000.0"), - user_time_cnt_ (&sset_, "host_user_time_count_ms", "User scheduler performance (not simulated time)", Counter::COUNT_NORMAL, &user_time_), - system_time_cnt_(&sset_, "host_system_time_count_ms", "System scheduler performance (not simulated time)", Counter::COUNT_NORMAL, &system_time_), - wall_time_cnt_ (&sset_, "host_wall_time_count_ms", "Wall scheduler performance (not simulated time)", Counter::COUNT_NORMAL, &wall_time_), + events_fired_cnt_(&sset_, "events_fired", "Scheduler events fired during simulation", Counter::COUNT_NORMAL, &events_fired_), + user_time_cnt_ (&sset_, "host_user_time_count_ms", "User scheduler performance (not simulated time)", Counter::COUNT_NORMAL, &user_time_), + system_time_cnt_ (&sset_, "host_system_time_count_ms", "System scheduler performance (not simulated time)", Counter::COUNT_NORMAL, &system_time_), + wall_time_cnt_ (&sset_, "host_wall_time_count_ms", "Wall scheduler performance (not simulated time)", Counter::COUNT_NORMAL, &wall_time_), es_uptr_(new EventSet(this)) #ifdef SYSTEMC_SUPPORT , item_scheduled_(this, "item_scheduled", "Broadcasted when something is scheduled", "item_scheduled") diff --git a/sparta/test/Report/test_autopopulate.html.EXPECTED b/sparta/test/Report/test_autopopulate.html.EXPECTED index de6443b24e..b18195370d 100644 --- a/sparta/test/Report/test_autopopulate.html.EXPECTED +++ b/sparta/test/Report/test_autopopulate.html.EXPECTED @@ -275,6 +275,13 @@ scheduler.stats.picoseconds' style='' >60 Simulation wall clock runtime in seconds as measured on the host machine +events_fired + 0 +Scheduler events fired during simulation + + host_user_time_count_ms 60 Simulation wall clock runtime in seconds as measured on the host machine +events_fired + 0 +Scheduler events fired during simulation + + host_user_time_count_ms  0 Scheduler events fired during simulation -host_user_time_count_ms - 0 -User scheduler performance (not simulated time) +User scheduler performance (not simulated time) in milliseconds -host_system_time_count_ms - 0 -System scheduler performance (not simulated time) +System scheduler performance (not simulated time) in milliseconds -host_wall_time_count_ms - 0 -Wall scheduler performance (not simulated time) +Wall scheduler performance (not simulated time) in milliseconds
diff --git a/sparta/test/Report/test_autopopulate_from_string.html.EXPECTED b/sparta/test/Report/test_autopopulate_from_string.html.EXPECTED index 410d6cc6d1..cbbb1bb536 100644 --- a/sparta/test/Report/test_autopopulate_from_string.html.EXPECTED +++ b/sparta/test/Report/test_autopopulate_from_string.html.EXPECTED @@ -282,25 +282,25 @@ scheduler.stats.events_fired' style='' > 0 Scheduler events fired during simulation -host_user_time_count_ms - 0 -User scheduler performance (not simulated time) +User scheduler performance (not simulated time) in milliseconds -host_system_time_count_ms - 0 -System scheduler performance (not simulated time) +System scheduler performance (not simulated time) in milliseconds -host_wall_time_count_ms - 0 -Wall scheduler performance (not simulated time) +Wall scheduler performance (not simulated time) in milliseconds