Skip to content

Commit 8bdac05

Browse files
committed
Fix major issue with the scheduler.
1 parent 9302bd6 commit 8bdac05

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

SerialPrograms/Source/Controllers/SuperscalarScheduler.cpp

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,30 @@ void SuperscalarScheduler::clear() noexcept{
5151
m_pending_clear.store(false, std::memory_order_release);
5252
}
5353

54+
void SuperscalarScheduler::update_busy_states(){
55+
WallClock device_sent_time = m_device_sent_time;
56+
for (ExecutionResource* resource : m_resources){
57+
resource->m_is_busy = resource->m_busy_time <= device_sent_time && device_sent_time < resource->m_done_time;
58+
59+
#if 0
60+
if (resource->m_done_time >m_local_start){
61+
cout << "------------" << endl;
62+
cout << "m_busy_time = " << std::chrono::duration_cast<Milliseconds>(resource->m_busy_time - m_local_start) << endl;
63+
cout << "m_done_time = " << std::chrono::duration_cast<Milliseconds>(resource->m_done_time - m_local_start) << endl;
64+
cout << "m_device_sent_time = " << std::chrono::duration_cast<Milliseconds>(m_device_sent_time - m_local_start) << endl;
65+
cout << "m_is_busy = " << resource->m_is_busy << endl;
66+
}
67+
#endif
68+
}
69+
}
5470
bool SuperscalarScheduler::iterate_schedule(const Cancellable* cancellable){
5571
if (cancellable){
5672
cancellable->throw_if_cancelled();
5773
}
5874

75+
// cout << "----------------------------> " << m_state_changes.size() << endl;
76+
// cout << "m_device_sent_time = " << std::chrono::duration_cast<Milliseconds>(m_device_sent_time - m_local_start) << endl;
77+
5978
if (m_state_changes.empty()){
6079
// cout << "State is empty." << endl;
6180
m_device_sent_time = m_device_issue_time;
@@ -92,12 +111,10 @@ bool SuperscalarScheduler::iterate_schedule(const Cancellable* cancellable){
92111
}
93112

94113
// Compute the resource state at this timestamp.
95-
for (ExecutionResource* resource : m_resources){
96-
resource->m_is_busy = resource->m_busy_time <= m_device_sent_time && m_device_sent_time < resource->m_done_time;
97-
}
114+
update_busy_states();
98115

99116
m_device_sent_time = next_state_change;
100-
if (next_state_change >= *iter){
117+
if (next_state_change > *iter){
101118
m_state_changes.erase(iter);
102119
}
103120

@@ -224,13 +241,15 @@ void SuperscalarScheduler::issue_to_resource(
224241
hold = std::max(hold, WallDuration::zero());
225242
cooldown = std::max(cooldown, WallDuration::zero());
226243

227-
// cout << "issue_to_resource(): delay = " << std::chrono::duration_cast<Milliseconds>(delay).count()
228-
// << ", hold = " << std::chrono::duration_cast<Milliseconds>(hold).count()
229-
// << ", cooldown = " << std::chrono::duration_cast<Milliseconds>(cooldown).count()
230-
// << endl;
231-
// cout << "issue_time = " << std::chrono::duration_cast<Milliseconds>((m_device_issue_time - m_local_start)).count()
232-
// << ", sent_time = " << std::chrono::duration_cast<Milliseconds>((m_device_sent_time - m_local_start)).count()
233-
// << endl;
244+
#if 0
245+
cout << "issue_to_resource(): delay = " << std::chrono::duration_cast<Milliseconds>(delay).count()
246+
<< ", hold = " << std::chrono::duration_cast<Milliseconds>(hold).count()
247+
<< ", cooldown = " << std::chrono::duration_cast<Milliseconds>(cooldown).count()
248+
<< endl;
249+
cout << "issue_time = " << std::chrono::duration_cast<Milliseconds>((m_device_issue_time - m_local_start)).count()
250+
<< ", sent_time = " << std::chrono::duration_cast<Milliseconds>((m_device_sent_time - m_local_start)).count()
251+
<< endl;
252+
#endif
234253

235254
WallClock release_time = m_device_issue_time + hold;
236255
WallClock free_time = release_time + cooldown;

SerialPrograms/Source/Controllers/SuperscalarScheduler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class SuperscalarScheduler{
107107

108108
private:
109109
void clear() noexcept;
110+
void update_busy_states();
110111
bool iterate_schedule(const Cancellable* cancellable);
111112
void process_schedule(const Cancellable* cancellable);
112113

0 commit comments

Comments
 (0)