Skip to content

Commit

Permalink
Merge branch 'master' into interdimensional_compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
rowleya committed Sep 18, 2023
2 parents f1bb2b0 + e9ab535 commit 8dee34e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 19 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/python_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Checkout SupportScripts
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: SpiNNakerManchester/SupportScripts
path: support
Expand Down Expand Up @@ -85,9 +85,9 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Checkout SupportScripts
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: SpiNNakerManchester/SupportScripts
path: support
Expand Down
29 changes: 21 additions & 8 deletions pacman/model/routing_tables/multicast_routing_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class MulticastRoutingTables(object):
__slots__ = [
# dict of (x,y) -> routing table
"_routing_tables_by_chip",
# maximum value for number_of_entries in all tables
"_max_number_of_entries"
]

def __init__(self, routing_tables=None):
Expand All @@ -40,7 +38,6 @@ def __init__(self, routing_tables=None):
If any two routing tables are for the same chip
"""
self._routing_tables_by_chip = dict()
self._max_number_of_entries = 0

if routing_tables is not None:
for routing_table in routing_tables:
Expand All @@ -62,8 +59,6 @@ def add_routing_table(self, routing_table):
str(routing_table))
self._routing_tables_by_chip[(routing_table.x, routing_table.y)] = \
routing_table
self._max_number_of_entries = max(
self._max_number_of_entries, routing_table.number_of_entries)

@property
def routing_tables(self):
Expand All @@ -75,8 +70,7 @@ def routing_tables(self):
"""
return self._routing_tables_by_chip.values()

@property
def max_number_of_entries(self):
def get_max_number_of_entries(self):
"""
The maximum number of multicast routing entries there are in any
multicast routing table.
Expand All @@ -85,7 +79,26 @@ def max_number_of_entries(self):
:rtype: int
"""
return self._max_number_of_entries
if self._routing_tables_by_chip:
return max(map((lambda x: x.number_of_entries),
self._routing_tables_by_chip.values()))
else:
return 0

def get_total_number_of_entries(self):
"""
The total number of multicast routing entries there are in all
multicast routing table.
Will return zero if there are no routing tables
:rtype: int
"""
if self._routing_tables_by_chip:
return sum(map((lambda x: x.number_of_entries),
self._routing_tables_by_chip.values()))
else:
return 0

def get_routing_table_for_chip(self, x, y):
"""
Expand Down
2 changes: 1 addition & 1 deletion pacman/operations/router_compressors/ranged_compressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def range_compressor(accept_overflow=True):
f"still has {new_table.number_of_entries} so will not fit")
compressed_tables.add_routing_table(new_table)
logger.info(f"Ranged compressor resulted with the largest table of size "
f"{compressed_tables.max_number_of_entries}")
f"{compressed_tables.get_max_number_of_entries()}")
return compressed_tables


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_empty(self):
writer = PacmanDataWriter.mock()
self.make_infos(writer)
data = basic_routing_table_generator()
self.assertEqual(0, data.max_number_of_entries)
self.assertEqual(0, data.get_max_number_of_entries())
self.assertEqual(0, len(list(data.routing_tables)))

def test_graph3_with_system(self):
Expand All @@ -81,5 +81,6 @@ def test_graph3_with_system(self):
system_plaements.add_placement(Placement(mv, 1, 2, 3))
self.make_infos(writer, system_plaements)
data = basic_routing_table_generator()
self.assertEqual(34, data.max_number_of_entries)
self.assertEqual(34, data.get_max_number_of_entries())
self.assertEqual(114, data.get_total_number_of_entries())
self.assertEqual(4, len(list(data.routing_tables)))
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,23 @@ def test_empty(self):
writer = PacmanDataWriter.mock()
self.make_infos(writer)
data = merged_routing_table_generator()
self.assertEqual(0, data.max_number_of_entries)
self.assertEqual(0, data.get_max_number_of_entries())
self.assertEqual(0, len(list(data.routing_tables)))

def test_graph1(self):
writer = PacmanDataWriter.mock()
self.create_graphs1(writer)
self.make_infos(writer)
data = merged_routing_table_generator()
self.assertEqual(1, data.max_number_of_entries)
self.assertEqual(1, data.get_max_number_of_entries())
self.assertEqual(1, len(list(data.routing_tables)))

def test_graph2(self):
writer = PacmanDataWriter.mock()
self.create_graphs3(writer)
self.make_infos(writer)
data = merged_routing_table_generator()
self.assertEqual(10, data.max_number_of_entries)
self.assertEqual(10, data.get_max_number_of_entries())
self.assertEqual(4, len(list(data.routing_tables)))

def test_graph3_with_system(self):
Expand All @@ -125,7 +125,7 @@ def test_graph3_with_system(self):
system_plaements.add_placement(Placement(mv, 1, 2, 3))
self.make_infos(writer, system_plaements)
data = merged_routing_table_generator()
self.assertEqual(10, data.max_number_of_entries)
self.assertEqual(10, data.get_max_number_of_entries())
self.assertEqual(4, len(list(data.routing_tables)))

def test_bad_infos(self):
Expand Down

0 comments on commit 8dee34e

Please sign in to comment.