Skip to content

Commit

Permalink
Executable explicitly contains a flat list of *all* Processes after P…
Browse files Browse the repository at this point in the history
…rocGroups are created (#714)

* Explicitly keep track of all Processes in the Executable to make sure all Processes are assigned the Runtime

Signed-off-by: Risbud, Sumedh <[email protected]>

* A utility to measure the size of a python object recursively. Useful for example, to measure the size of NxBoard object after compilation

Signed-off-by: Risbud, Sumedh <[email protected]>

* Removed the utility to estimate Python object size

Signed-off-by: Risbud, Sumedh <[email protected]>

* Fixed Runtime unittest to accommodate passing an explicit ProcessList to the Executable

Signed-off-by: Risbud, Sumedh <[email protected]>

* Removed unused import

Signed-off-by: Risbud, Sumedh <[email protected]>

---------

Signed-off-by: Risbud, Sumedh <[email protected]>
  • Loading branch information
srrisbud authored Jun 16, 2023
1 parent f07e65a commit 5d8bd3e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/lava/magma/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ def compile(
# ProcGroups.
proc_group_digraph = ProcGroupDiGraphs(process, run_cfg)
proc_groups: ty.List[ProcGroup] = proc_group_digraph.get_proc_groups()
# Get a flattened list of all AbstractProcesses
process_list = list(itertools.chain.from_iterable(proc_groups))
channel_map = ChannelMap.from_proc_groups(proc_groups)
proc_builders, channel_map = self._compile_proc_groups(
proc_groups, channel_map
Expand Down Expand Up @@ -161,6 +163,7 @@ def compile(

# Package all Builders and NodeConfigs into an Executable.
executable = Executable(
process_list,
proc_builders,
channel_builders,
node_configs,
Expand Down
3 changes: 2 additions & 1 deletion src/lava/magma/compiler/executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Executable:
# py_builders: ty.Dict[AbstractProcess, NcProcessBuilder]
# c_builders: ty.Dict[AbstractProcess, CProcessBuilder]
# nc_builders: ty.Dict[AbstractProcess, PyProcessBuilder]
process_list: ty.List[AbstractProcess] # All leaf processes, flat list.
proc_builders: ty.Dict[AbstractProcess, 'AbstractProcessBuilder']
channel_builders: ty.List[ChannelBuilderMp]
node_configs: ty.List[NodeConfig]
Expand All @@ -43,5 +44,5 @@ class Executable:
ty.Iterable[AbstractChannelBuilder]] = None

def assign_runtime_to_all_processes(self, runtime):
for p in self.proc_builders.keys():
for p in self.process_list:
p.runtime = runtime
6 changes: 4 additions & 2 deletions tests/lava/magma/runtime/test_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def test_runtime_creation(self):

def test_executable_node_config_assertion(self):
"""Tests runtime constructions with expected constraints"""
exe: Executable = Executable(proc_builders={},
exe: Executable = Executable(process_list=[],
proc_builders={},
channel_builders=[],
node_configs=[],
sync_domains=[])
Expand All @@ -45,7 +46,8 @@ def test_executable_node_config_assertion(self):
f"Expected type {expected_type} doesn't match {(type(runtime2))}")
runtime2.stop()

exe1: Executable = Executable(proc_builders={},
exe1: Executable = Executable(process_list=[],
proc_builders={},
channel_builders=[],
node_configs=[],
sync_domains=[])
Expand Down

0 comments on commit 5d8bd3e

Please sign in to comment.