Skip to content

Commit

Permalink
Modified mapper to handle disconnected lif components connected to sa… (
Browse files Browse the repository at this point in the history
lava-nc#294)

* Modified mapper to handle disconnected lif components connected to same cproc
  • Loading branch information
ysingh7 authored Aug 15, 2022
1 parent 4aa83a3 commit 3b265f4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/lava/magma/compiler/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class Mapper:
Assigns virtual addresses to different processes, mappable by mapping
logical addresses to virtual addresses.
"""
def __init__(self):
self.mapper_core_offset: LogicalCoreId = 0
self.mapper_core_dict: ty.Dict[LogicalCoreId, LogicalCoreId] = {}

def _set_virtual_address_nc(self, mappable: Mappable, num_cores: int) \
-> None:
Expand All @@ -50,6 +53,12 @@ def _set_virtual_address_nc(self, mappable: Mappable, num_cores: int) \
l_addrs: ty.List[NcLogicalAddress] = mappable.get_logical()
p_addrs: ty.List[NcVirtualAddress] = []
for l_addr in l_addrs:
if l_addr.core_id not in self.mapper_core_dict:
self.mapper_core_dict[l_addr.core_id] = self.mapper_core_offset
l_addr.core_id = self.mapper_core_offset
self.mapper_core_offset += 1
else:
l_addr.core_id = self.mapper_core_dict[l_addr.core_id]
chip_idx = l_addr.core_id // num_cores
core_idx = l_addr.core_id % num_cores
p_addrs.append(
Expand Down Expand Up @@ -80,6 +89,13 @@ def map_cores(self, executable: Executable,
p_addrs: ty.List[ResourceAddress] = []
for resource in ncb.compiled_resources:
l_addr: ResourceAddress = resource.l_address
if l_addr.core_id not in self.mapper_core_dict:
self.mapper_core_dict[
l_addr.core_id] = self.mapper_core_offset
l_addr.core_id = self.mapper_core_offset
self.mapper_core_offset += 1
else:
l_addr.core_id = self.mapper_core_dict[l_addr.core_id]
chip_idx = l_addr.core_id // num_cores
core_idx = l_addr.core_id % num_cores
p_addrs.append(
Expand All @@ -96,6 +112,7 @@ def map_cores(self, executable: Executable,

for var_port_initializer in ncb.var_ports.values():
self._set_virtual_address_nc(var_port_initializer, num_cores)
self.mapper_core_dict.clear()

# Iterate over all the cbuilder and map them
for cb in c_builders.values():
Expand Down

0 comments on commit 3b265f4

Please sign in to comment.