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

added docstrings for scheduler

parent 4303787c
No related branches found
No related tags found
1 merge request!461Finalize earliest deadline scheduler
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, cast
from typing import TYPE_CHECKING, Optional, cast
from b_asic.port import OutputPort
from b_asic.special_operations import Delay, Output
......@@ -9,17 +9,16 @@ if TYPE_CHECKING:
from b_asic.schedule import Schedule
# class SchedulingAlgorithm(Enum):
# ASAP = "ASAP"
# ALAP = "ALAP"
# EARLIEST_DEADLINE = "earliest_deadline"
# # LEAST_SLACK = "least_slack" # to be implemented
# PROVIDED = "provided"
class Scheduler(ABC):
@abstractmethod
def apply_scheduling(self, schedule: "Schedule") -> None:
"""Applies the scheduling algorithm on the given Schedule.
Parameters
----------
schedule : Schedule
Schedule to apply the scheduling algorithm on.
"""
pass
def _handle_outputs(self, schedule, non_schedulable_ops) -> None:
......@@ -41,7 +40,16 @@ class Scheduler(ABC):
class ASAPScheduler(Scheduler):
"""Scheduler that implements the as-soon-as-possible (ASAP) algorithm."""
def apply_scheduling(self, schedule: "Schedule") -> None:
"""Applies the scheduling algorithm on the given Schedule.
Parameters
----------
schedule : Schedule
Schedule to apply the scheduling algorithm on.
"""
prec_list = schedule.sfg.get_precedence_list()
if len(prec_list) < 2:
raise ValueError("Empty signal flow graph cannot be scheduled.")
......@@ -114,8 +122,16 @@ class ASAPScheduler(Scheduler):
class ALAPScheduler(Scheduler):
"""Scheduler that implements the as-late-as-possible (ALAP) algorithm."""
def apply_scheduling(self, schedule: "Schedule") -> None:
# self.schedule_asap()
"""Applies the scheduling algorithm on the given Schedule.
Parameters
----------
schedule : Schedule
Schedule to apply the scheduling algorithm on.
"""
ASAPScheduler().apply_scheduling(schedule)
max_end_time = schedule.get_max_end_time()
......@@ -137,10 +153,29 @@ class ALAPScheduler(Scheduler):
class EarliestDeadlineScheduler(Scheduler):
def __init__(self, max_resources: dict[TypeName, int]) -> None:
"""
Scheduler that implements the earliest-deadline-first algorithm.
Parameters
----------
max_resources : dict, optional
Dictionary like ``{Addition.type_name(): 2}`` denoting the maximum number of
resources for a given operation type if the scheduling algorithm considers
that. If not provided, or an operation type is not provided, at most one
resource is used.
"""
def __init__(self, max_resources: Optional[dict[TypeName, int]]) -> None:
self._max_resources = max_resources
def apply_scheduling(self, schedule: "Schedule") -> None:
"""Applies the scheduling algorithm on the given Schedule.
Parameters
----------
schedule : Schedule
Schedule to apply the scheduling algorithm on.
"""
# ACT BASED ON THE NUMBER OF PEs!
prec_list = schedule.sfg.get_precedence_list()
if len(prec_list) < 2:
......
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