Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new counter to Scheduler: events_fired; small Scheduler cleanup #449

Merged
2 commits merged into from
Oct 24, 2023
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
35 changes: 18 additions & 17 deletions sparta/sparta/kernel/Scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TickQuantum> tick_quantum_allocator_;
Expand Down Expand Up @@ -931,36 +931,36 @@ class Scheduler : public RootTreeNode
std::unique_ptr<DAG> dag_;

//! The number of groups in the DAG after finalization.
uint32_t dag_group_count_;
uint32_t dag_group_count_ = 0;

//! The number of firing groups (dag_group_count_ [+pre] [+post])
uint32_t firing_group_count_;
uint32_t firing_group_count_ = 0;

//! 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<Scheduleable> stop_event_;
Expand All @@ -969,13 +969,9 @@ class Scheduler : public RootTreeNode
std::unique_ptr<Scheduleable> 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<SpartaHandler> startup_events_;
Expand All @@ -985,10 +981,10 @@ class Scheduler : public RootTreeNode
std::vector<sparta::Clock*> 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;
Expand All @@ -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_;
Expand Down Expand Up @@ -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_;
Expand Down
28 changes: 11 additions & 17 deletions sparta/src/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_,
Expand Down Expand Up @@ -108,9 +94,17 @@ 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) in milliseconds",
Counter::COUNT_NORMAL, &user_time_),
system_time_cnt_ (&sset_, "host_system_time_count_ms",
"System scheduler performance (not simulated time) in milliseconds",
Counter::COUNT_NORMAL, &system_time_),
wall_time_cnt_ (&sset_, "host_wall_time_count_ms",
"Wall scheduler performance (not simulated time) in milliseconds",
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")
Expand Down
25 changes: 16 additions & 9 deletions sparta/test/Report/test_autopopulate.html.EXPECTED
Original file line number Diff line number Diff line change
Expand Up @@ -275,25 +275,32 @@ scheduler.stats.picoseconds' style='' >60</td>
<td class='expression'>Simulation wall clock runtime in seconds as measured on the host machine</td>
<tr>

<td class='name' title='User scheduler performance (not simulated time)
<td class='name' title='Scheduler events fired during simulation
scheduler.stats.events_fired'>events_fired</td>
<td class='value' title='Scheduler events fired during simulation
scheduler.stats.events_fired' style='' >&nbsp;0</td>
<td class='expression'>Scheduler events fired during simulation</td>
<tr>

<td class='name' title='User scheduler performance (not simulated time) in milliseconds
scheduler.stats.host_user_time_count_ms'>host_user_time_count_ms</td>
<td class='value' title='User scheduler performance (not simulated time)
<td class='value' title='User scheduler performance (not simulated time) in milliseconds
scheduler.stats.host_user_time_count_ms' style='' >&nbsp;0</td>
<td class='expression'>User scheduler performance (not simulated time)</td>
<td class='expression'>User scheduler performance (not simulated time) in milliseconds</td>
<tr>

<td class='name' title='System scheduler performance (not simulated time)
<td class='name' title='System scheduler performance (not simulated time) in milliseconds
scheduler.stats.host_system_time_count_ms'>host_system_time_count_ms</td>
<td class='value' title='System scheduler performance (not simulated time)
<td class='value' title='System scheduler performance (not simulated time) in milliseconds
scheduler.stats.host_system_time_count_ms' style='' >&nbsp;0</td>
<td class='expression'>System scheduler performance (not simulated time)</td>
<td class='expression'>System scheduler performance (not simulated time) in milliseconds</td>
<tr>

<td class='name' title='Wall scheduler performance (not simulated time)
<td class='name' title='Wall scheduler performance (not simulated time) in milliseconds
scheduler.stats.host_wall_time_count_ms'>host_wall_time_count_ms</td>
<td class='value' title='Wall scheduler performance (not simulated time)
<td class='value' title='Wall scheduler performance (not simulated time) in milliseconds
scheduler.stats.host_wall_time_count_ms' style='' >&nbsp;0</td>
<td class='expression'>Wall scheduler performance (not simulated time)</td>
<td class='expression'>Wall scheduler performance (not simulated time) in milliseconds</td>
</tr>
</tbody>
</table><br/></td></tr>
Expand Down
1 change: 1 addition & 0 deletions sparta/test/Report/test_autopopulate.txt.EXPECTED
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Report "Report Autopopulation Test" [0,61]
host_machine_user_runtime_seconds = 0
host_machine_system_runtime_seconds = 0
host_machine_wall_runtime_seconds = 0
events_fired = 0
host_user_time_count_ms = 0
host_system_time_count_ms = 0
host_wall_time_count_ms = 0
Expand Down
25 changes: 16 additions & 9 deletions sparta/test/Report/test_autopopulate_from_string.html.EXPECTED
Original file line number Diff line number Diff line change
Expand Up @@ -275,25 +275,32 @@ scheduler.stats.picoseconds' style='' >60</td>
<td class='expression'>Simulation wall clock runtime in seconds as measured on the host machine</td>
<tr>

<td class='name' title='User scheduler performance (not simulated time)
<td class='name' title='Scheduler events fired during simulation
scheduler.stats.events_fired'>events_fired</td>
<td class='value' title='Scheduler events fired during simulation
scheduler.stats.events_fired' style='' >&nbsp;0</td>
<td class='expression'>Scheduler events fired during simulation</td>
<tr>

<td class='name' title='User scheduler performance (not simulated time) in milliseconds
scheduler.stats.host_user_time_count_ms'>host_user_time_count_ms</td>
<td class='value' title='User scheduler performance (not simulated time)
<td class='value' title='User scheduler performance (not simulated time) in milliseconds
scheduler.stats.host_user_time_count_ms' style='' >&nbsp;0</td>
<td class='expression'>User scheduler performance (not simulated time)</td>
<td class='expression'>User scheduler performance (not simulated time) in milliseconds</td>
<tr>

<td class='name' title='System scheduler performance (not simulated time)
<td class='name' title='System scheduler performance (not simulated time) in milliseconds
scheduler.stats.host_system_time_count_ms'>host_system_time_count_ms</td>
<td class='value' title='System scheduler performance (not simulated time)
<td class='value' title='System scheduler performance (not simulated time) in milliseconds
scheduler.stats.host_system_time_count_ms' style='' >&nbsp;0</td>
<td class='expression'>System scheduler performance (not simulated time)</td>
<td class='expression'>System scheduler performance (not simulated time) in milliseconds</td>
<tr>

<td class='name' title='Wall scheduler performance (not simulated time)
<td class='name' title='Wall scheduler performance (not simulated time) in milliseconds
scheduler.stats.host_wall_time_count_ms'>host_wall_time_count_ms</td>
<td class='value' title='Wall scheduler performance (not simulated time)
<td class='value' title='Wall scheduler performance (not simulated time) in milliseconds
scheduler.stats.host_wall_time_count_ms' style='' >&nbsp;0</td>
<td class='expression'>Wall scheduler performance (not simulated time)</td>
<td class='expression'>Wall scheduler performance (not simulated time) in milliseconds</td>
</tr>
</tbody>
</table><br/></td></tr>
Expand Down
Loading