Skip to content
Snippets Groups Projects
Commit f36057d7 authored by Simon Bjurek's avatar Simon Bjurek
Browse files

there is a bug that can occur when an op is scheduled before predecessors

parent 87268b64
No related branches found
No related tags found
1 merge request!461Finalize earliest deadline scheduler
......@@ -181,7 +181,7 @@ class EarliestDeadlineScheduler(Scheduler):
Schedule to apply the scheduling algorithm on.
"""
# TODO: Take the execution time into consideration!
# TODO: Solve bug where operation (ADD) is scheduled before proceeding (MUL) -> pipelining
ALAPScheduler().apply_scheduling(schedule)
......@@ -190,9 +190,15 @@ class EarliestDeadlineScheduler(Scheduler):
input_op = cast(Input, input_op)
schedule.move_operation_asap(input_op.graph_id)
# construct the set of remaining operations, excluding inputs
remaining_ops = set(schedule.start_times.keys())
remaining_ops = {elem for elem in remaining_ops if not elem.startswith("in")}
# construct a dictionarry for storing how many times until a resource is available again
used_resources_ready_times = {}
# iterate through all remaining operations and schedule them
# while not exceeding the available resources
remaining_resources = self._max_resources.copy()
current_time = 0
while remaining_ops:
......@@ -202,13 +208,23 @@ class EarliestDeadlineScheduler(Scheduler):
if not best_candidate:
current_time += 1
remaining_resources = self._max_resources.copy()
# update available operators
for operation, ready_time in used_resources_ready_times.items():
print(ready_time, current_time)
if ready_time == current_time:
remaining_resources[operation.type_name()] += 1
# remaining_resources = self._max_resources.copy()
continue
# update remaining resources
# if the resource is constrained, update remaining resources
if best_candidate.type_name() in remaining_resources:
remaining_resources[best_candidate.type_name()] -= 1
used_resources_ready_times[best_candidate] = (
current_time + best_candidate.execution_time
)
# schedule the best candidate to the current time
remaining_ops.remove(best_candidate.graph_id)
schedule.start_times[best_candidate.graph_id] = current_time
......@@ -222,11 +238,16 @@ class EarliestDeadlineScheduler(Scheduler):
def _find_best_candidate(
schedule, remaining_ops, remaining_resources, current_time
):
# precompute source end times for faster checks
sfg = schedule.sfg
source_end_times = defaultdict(float)
# find the best candidate
best_candidate = None
best_deadline = float('inf')
for op_id in remaining_ops:
operation = sfg.find_by_id(op_id)
# compute maximum end times of preceding operations
for op_input in operation.inputs:
source_op = op_input.signals[0].source.operation
if not isinstance(source_op, Delay):
......@@ -235,11 +256,6 @@ class EarliestDeadlineScheduler(Scheduler):
schedule.start_times[source_op.graph_id] + source_op.latency,
)
best_candidate = None
best_deadline = float('inf')
for op_id in remaining_ops:
operation = sfg.find_by_id(op_id)
# check resource constraints
if operation.type_name() in remaining_resources:
if remaining_resources[operation.type_name()] == 0:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment