Skip to content

Commit 4827dce

Browse files
committed
Fix scheduler.
1 parent cbb64a7 commit 4827dce

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

SerialPrograms/Source/Controllers/SuperscalarScheduler.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ bool SuperscalarScheduler::iterate_schedule(const Cancellable* cancellable){
5757
}
5858

5959
if (m_state_changes.empty()){
60+
// cout << "State is empty." << endl;
6061
m_device_sent_time = m_device_issue_time;
6162
return false;
6263
}
@@ -149,7 +150,7 @@ void SuperscalarScheduler::issue_wait_for_all(const Cancellable* cancellable){
149150
process_schedule(cancellable);
150151
}
151152
void SuperscalarScheduler::issue_nop(const Cancellable* cancellable, WallDuration delay){
152-
if (delay == WallDuration::zero()){
153+
if (delay <= WallDuration::zero()){
153154
return;
154155
}
155156
if (m_pending_clear.load(std::memory_order_acquire)){
@@ -160,8 +161,9 @@ void SuperscalarScheduler::issue_nop(const Cancellable* cancellable, WallDuratio
160161
// << ", sent_time = " << std::chrono::duration_cast<Milliseconds>((m_device_sent_time - m_local_start)).count()
161162
// << ", max_free_time = " << std::chrono::duration_cast<Milliseconds>((m_max_free_time - m_local_start)).count()
162163
// << endl;
163-
m_state_changes.insert(m_device_issue_time);
164-
m_device_issue_time += delay;
164+
WallClock next_issue_time = m_device_issue_time + delay;
165+
m_state_changes.insert(next_issue_time);
166+
m_device_issue_time = next_issue_time;
165167
m_max_free_time = std::max(m_max_free_time, m_device_issue_time);
166168
m_local_last_activity = current_time();
167169
process_schedule(cancellable);
@@ -200,6 +202,10 @@ void SuperscalarScheduler::issue_to_resource(
200202
);
201203
}
202204

205+
delay = std::max(delay, WallDuration::zero());
206+
hold = std::max(hold, WallDuration::zero());
207+
cooldown = std::max(cooldown, WallDuration::zero());
208+
203209
// cout << "issue_to_resource(): delay = " << std::chrono::duration_cast<Milliseconds>(delay).count()
204210
// << ", hold = " << std::chrono::duration_cast<Milliseconds>(hold).count()
205211
// << ", cooldown = " << std::chrono::duration_cast<Milliseconds>(cooldown).count()

0 commit comments

Comments
 (0)