Skip to content
Snippets Groups Projects
Commit bbbd6e40 authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Add assign to ProcessingElement

parent 1f4478cb
No related branches found
No related tags found
1 merge request!379Add assign to ProcessingElement
Pipeline #97174 passed
...@@ -225,6 +225,14 @@ class Resource(HardwareBlock): ...@@ -225,6 +225,14 @@ class Resource(HardwareBlock):
def is_assigned(self) -> bool: def is_assigned(self) -> bool:
return self._assignment is not None return self._assignment is not None
def assign(self, heuristic: str = 'left_edge'):
"""
Perform assignment of processes to resource.
See the specific resource types for more information.
"""
raise NotImplementedError()
@property @property
def content(self) -> plt.Figure: def content(self) -> plt.Figure:
""" """
...@@ -277,16 +285,31 @@ class ProcessingElement(Resource): ...@@ -277,16 +285,31 @@ class ProcessingElement(Resource):
self._type_name = op_type.type_name() self._type_name = op_type.type_name()
self._input_count = ops[0].input_count self._input_count = ops[0].input_count
self._output_count = ops[0].output_count self._output_count = ops[0].output_count
self._assignment = list( self.assign()
self._collection.split_on_execution_time(heuristic="left_edge")
)
if len(self._assignment) > 1:
raise ValueError("Cannot map ProcessCollection to single ProcessingElement")
@property @property
def processes(self) -> List[OperatorProcess]: def processes(self) -> List[OperatorProcess]:
return [cast(OperatorProcess, p) for p in self._collection] return [cast(OperatorProcess, p) for p in self._collection]
def assign(self, heuristic: str = "left_edge") -> None:
"""
Perform assignment of the processes.
Parameters
----------
heuristic : str, default: 'left_edge'
The assignment algorithm.
* 'left_edge': Left-edge algorithm.
* 'graph_color': Graph-coloring based on exclusion graph.
"""
self._assignment = list(
self._collection.split_on_execution_time(heuristic=heuristic)
)
if len(self._assignment) > 1:
self._assignment = None
raise ValueError("Cannot map ProcessCollection to single ProcessingElement")
class Memory(Resource): class Memory(Resource):
""" """
...@@ -347,26 +370,13 @@ class Memory(Resource): ...@@ -347,26 +370,13 @@ class Memory(Resource):
# Add information about the iterator type # Add information about the iterator type
return cast(Iterator[MemoryVariable], iter(self._collection)) return cast(Iterator[MemoryVariable], iter(self._collection))
def _assign_ram(self, heuristic: str = "left_edge"):
"""
Perform RAM-type assignment of MemoryVariables in this Memory.
Parameters
----------
heuristic : {'left_edge', 'graph_color'}
The underlying heuristic to use when performing RAM assignment.
"""
self._assignment = list(
self._collection.split_on_execution_time(heuristic=heuristic)
)
def assign(self, heuristic: str = "left_edge") -> None: def assign(self, heuristic: str = "left_edge") -> None:
""" """
Perform assignment of the memory variables. Perform assignment of the memory variables.
Parameters Parameters
---------- ----------
heuristic : str heuristic : str, default: 'left_edge'
The assignment algorithm. Depending on memory type the following are The assignment algorithm. Depending on memory type the following are
available: available:
...@@ -377,7 +387,9 @@ class Memory(Resource): ...@@ -377,7 +387,9 @@ class Memory(Resource):
* ... * ...
""" """
if self._memory_type == "RAM": if self._memory_type == "RAM":
self._assign_ram(heuristic=heuristic) self._assignment = self._collection.split_on_execution_time(
heuristic=heuristic
)
else: # "register" else: # "register"
raise NotImplementedError() raise NotImplementedError()
......
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