Skip to content

Commit

Permalink
Merge pull request #213 from SpiNNakerManchester/emergency_routing
Browse files Browse the repository at this point in the history
remove Emergency routing
  • Loading branch information
rowleya authored Jul 7, 2023
2 parents 3a7438d + 0f43784 commit 0a4feda
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 40 deletions.
2 changes: 1 addition & 1 deletion spinn_machine/json_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def machine_from_json(j_machine):
links.append(Link(
source_x, source_y, source_link_id, destination_x,
destination_y))
router = Router(links, False, router_entries)
router = Router(links, router_entries)

# Create and add a chip with this router
chip = Chip(
Expand Down
3 changes: 1 addition & 2 deletions spinn_machine/machine_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ def _machine_ignore(original, dead_chips, dead_links):
for link in chip.router.links:
if link.source_link_id not in links_map[(chip.x, chip.y)]:
links.append(link)
router = Router(links, chip.router.emergency_routing_enabled,
chip.router.n_available_multicast_entries)
router = Router(links)
chip = Chip(
chip.x, chip.y, chip.n_processors, router, chip.sdram,
chip.nearest_ethernet_x, chip.nearest_ethernet_y,
Expand Down
22 changes: 3 additions & 19 deletions spinn_machine/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,12 @@ class Router(object):

MAX_CORES_PER_ROUTER = 18

__slots__ = (
"_emergency_routing_enabled", "_links",
"_n_available_multicast_entries"
)
__slots__ = ("_links", "_n_available_multicast_entries")

def __init__(
self, links, emergency_routing_enabled=False,
n_available_multicast_entries=Machine.ROUTER_ENTRIES):
self, links, n_available_multicast_entries=Machine.ROUTER_ENTRIES):
"""
:param iterable(~spinn_machine.Link) links: iterable of links
:param bool emergency_routing_enabled:
Determines if the router emergency routing is operating
:param int n_available_multicast_entries:
The number of entries available in the routing table
:raise ~spinn_machine.exceptions.SpinnMachineAlreadyExistsException:
Expand All @@ -56,7 +50,6 @@ def __init__(
for link in links:
self.add_link(link)

self._emergency_routing_enabled = emergency_routing_enabled
self._n_available_multicast_entries = n_available_multicast_entries

def add_link(self, link):
Expand Down Expand Up @@ -137,15 +130,6 @@ def __len__(self):
"""
return len(self._links)

@property
def emergency_routing_enabled(self):
"""
Whether emergency routing is enabled.
:rtype: bool
"""
return self._emergency_routing_enabled

@property
def n_available_multicast_entries(self):
"""
Expand Down Expand Up @@ -216,7 +200,7 @@ def get_neighbouring_chips_coords(self):

def __str__(self):
return (
f"[Router: emergency_routing={self._emergency_routing_enabled}, "
f"[Router: "
f"available_entries={self._n_available_multicast_entries}, "
f"links={list(self._links.values())}]")

Expand Down
3 changes: 1 addition & 2 deletions spinn_machine/virtual_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ def machine(self):

def _create_chip(self, x, y, configured_chips, ip_address=None):
chip_links = self._calculate_links(x, y, configured_chips)
chip_router = Router(
chip_links)
chip_router = Router(chip_links)

(eth_x, eth_y, n_cores) = configured_chips[(x, y)]

Expand Down
4 changes: 2 additions & 2 deletions unittests/test_chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def setUp(self):
links.append(Link(0, 1, 1, 1, 0))
links.append(Link(1, 1, 2, 0, 0))
links.append(Link(1, 0, 3, 0, 1))
self._router = Router(links, False, 1024)
self._router = Router(links, 1024)

self._sdram = 128
self._ip = "192.162.240.253"
Expand All @@ -58,7 +58,7 @@ def test_create_chip(self):
self.assertEqual(
new_chip.__repr__(),
"[Chip: x=0, y=1, sdram=0 MB, ip_address=192.162.240.253, "
"router=[Router: emergency_routing=False, "
"router=[Router: "
"available_entries=1024, links=["
"[Link: source_x=0, source_y=0, source_link_id=0, "
"destination_x=1, destination_y=1], "
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def setUp(self):
links.append(Link(0, 1, 1, 1, 0))
links.append(Link(1, 1, 2, 0, 0))
links.append(Link(1, 0, 3, 0, 1))
self._router = Router(links, False, 1024)
self._router = Router(links, 1024)

self._nearest_ethernet_chip = (0, 0)

Expand Down
15 changes: 3 additions & 12 deletions unittests/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_creating_new_router(self):
links.append(Link(0, 1, 1, 1, 0))
links.append(Link(1, 1, 2, 0, 0))
links.append(Link(1, 0, 3, 0, 1))
r = Router(links, False, 1024)
r = Router(links, 1024)

self.assertEqual(len(r), 4)
for i in range(4):
Expand All @@ -41,7 +41,6 @@ def test_creating_new_router(self):
self.assertEqual([link[0] for link in r], [0, 1, 2, 3])
self.assertEqual([link[1].source_link_id for link in r], [0, 1, 2, 3])

self.assertFalse(r.emergency_routing_enabled)
self.assertEqual(r.n_available_multicast_entries, 1024)

self.assertFalse(r.is_link(-1))
Expand All @@ -54,7 +53,7 @@ def test_creating_new_router(self):
{'x': 0, 'y': 0}, {'x': 0, 'y': 1}])
self.assertEqual(
r.__repr__(),
"[Router: emergency_routing=False, "
"[Router: "
"available_entries=1024, links=["
"[Link: source_x=0, source_y=0, source_link_id=0, "
"destination_x=1, destination_y=1], "
Expand All @@ -65,21 +64,13 @@ def test_creating_new_router(self):
"[Link: source_x=1, source_y=0, source_link_id=3, "
"destination_x=0, destination_y=1]]]")

def test_creating_new_router_with_emergency_routing_on(self):
links = list()
(e, ne, n, w, sw, s) = range(6)
links.append(Link(0, 0, 0, 0, 1))
links.append(Link(0, 1, 1, 0, 1))
r = Router(links, True, 1024)
self.assertTrue(r.emergency_routing_enabled)

def test_creating_new_router_with_duplicate_links(self):
links = list()
(e, ne, n, w, sw, s) = range(6)
links.append(Link(0, 0, 0, 0, 1))
links.append(Link(0, 1, 0, 0, 1))
with self.assertRaises(SpinnMachineAlreadyExistsException):
Router(links, False, 1024)
Router(links, 1024)

def test_convert_to_route(self):
e = MulticastRoutingEntry(28, 60, [4, 5, 7], [1, 3, 5], True)
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_virtual_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _create_chip(self, x, y):
links.append(Link(0, 1, 1, 1, 0))
links.append(Link(1, 1, 2, 0, 0))
links.append(Link(1, 0, 3, 0, 1))
_router = Router(links, False, 1024)
_router = Router(links, 1024)

_sdram = 128
nearest_ethernet_chip = (0, 0)
Expand Down

0 comments on commit 0a4feda

Please sign in to comment.