Skip to content

Commit

Permalink
Fix scheduler.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mysticial committed Feb 2, 2025
1 parent cbb64a7 commit 4827dce
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions SerialPrograms/Source/Controllers/SuperscalarScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ bool SuperscalarScheduler::iterate_schedule(const Cancellable* cancellable){
}

if (m_state_changes.empty()){
// cout << "State is empty." << endl;
m_device_sent_time = m_device_issue_time;
return false;
}
Expand Down Expand Up @@ -149,7 +150,7 @@ void SuperscalarScheduler::issue_wait_for_all(const Cancellable* cancellable){
process_schedule(cancellable);
}
void SuperscalarScheduler::issue_nop(const Cancellable* cancellable, WallDuration delay){
if (delay == WallDuration::zero()){
if (delay <= WallDuration::zero()){
return;
}
if (m_pending_clear.load(std::memory_order_acquire)){
Expand All @@ -160,8 +161,9 @@ void SuperscalarScheduler::issue_nop(const Cancellable* cancellable, WallDuratio
// << ", sent_time = " << std::chrono::duration_cast<Milliseconds>((m_device_sent_time - m_local_start)).count()
// << ", max_free_time = " << std::chrono::duration_cast<Milliseconds>((m_max_free_time - m_local_start)).count()
// << endl;
m_state_changes.insert(m_device_issue_time);
m_device_issue_time += delay;
WallClock next_issue_time = m_device_issue_time + delay;
m_state_changes.insert(next_issue_time);
m_device_issue_time = next_issue_time;
m_max_free_time = std::max(m_max_free_time, m_device_issue_time);
m_local_last_activity = current_time();
process_schedule(cancellable);
Expand Down Expand Up @@ -200,6 +202,10 @@ void SuperscalarScheduler::issue_to_resource(
);
}

delay = std::max(delay, WallDuration::zero());
hold = std::max(hold, WallDuration::zero());
cooldown = std::max(cooldown, WallDuration::zero());

// cout << "issue_to_resource(): delay = " << std::chrono::duration_cast<Milliseconds>(delay).count()
// << ", hold = " << std::chrono::duration_cast<Milliseconds>(hold).count()
// << ", cooldown = " << std::chrono::duration_cast<Milliseconds>(cooldown).count()
Expand Down

0 comments on commit 4827dce

Please sign in to comment.