From 735bc76608492bba3ecee115e8fbad0790dd5c4a Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 7 Jul 2023 07:15:06 +0100 Subject: [PATCH 1/3] emergency_routing is NEVER enabled --- spinn_machine/json_machine.py | 2 +- spinn_machine/machine_factory.py | 3 +-- spinn_machine/router.py | 20 +++----------------- spinn_machine/virtual_machine.py | 3 +-- unittests/test_chip.py | 2 +- unittests/test_machine.py | 2 +- unittests/test_router.py | 13 ++----------- unittests/test_virtual_machine.py | 2 +- 8 files changed, 11 insertions(+), 36 deletions(-) diff --git a/spinn_machine/json_machine.py b/spinn_machine/json_machine.py index 8770098a..34938bbe 100644 --- a/spinn_machine/json_machine.py +++ b/spinn_machine/json_machine.py @@ -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( diff --git a/spinn_machine/machine_factory.py b/spinn_machine/machine_factory.py index 771ce7be..32fe46ff 100644 --- a/spinn_machine/machine_factory.py +++ b/spinn_machine/machine_factory.py @@ -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, diff --git a/spinn_machine/router.py b/spinn_machine/router.py index b914d1b3..6552804e 100644 --- a/spinn_machine/router.py +++ b/spinn_machine/router.py @@ -35,18 +35,14 @@ class Router(object): MAX_CORES_PER_ROUTER = 18 - __slots__ = ( - "_emergency_routing_enabled", "_links", + __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: @@ -56,7 +52,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): @@ -137,15 +132,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): """ @@ -216,7 +202,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())}]") diff --git a/spinn_machine/virtual_machine.py b/spinn_machine/virtual_machine.py index 1fb86e3f..c3266a31 100644 --- a/spinn_machine/virtual_machine.py +++ b/spinn_machine/virtual_machine.py @@ -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)] diff --git a/unittests/test_chip.py b/unittests/test_chip.py index c8a25811..efcfce26 100644 --- a/unittests/test_chip.py +++ b/unittests/test_chip.py @@ -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" diff --git a/unittests/test_machine.py b/unittests/test_machine.py index c90fe7b6..5b732260 100644 --- a/unittests/test_machine.py +++ b/unittests/test_machine.py @@ -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) diff --git a/unittests/test_router.py b/unittests/test_router.py index 03e9d737..9bb1e97f 100644 --- a/unittests/test_router.py +++ b/unittests/test_router.py @@ -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): @@ -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)) @@ -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) diff --git a/unittests/test_virtual_machine.py b/unittests/test_virtual_machine.py index 8cfbca43..a4f46877 100644 --- a/unittests/test_virtual_machine.py +++ b/unittests/test_virtual_machine.py @@ -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) From aa4c590bdd8078720bdd49861feebe63abe50cdc Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 7 Jul 2023 08:59:57 +0100 Subject: [PATCH 2/3] fix tests --- unittests/test_chip.py | 2 +- unittests/test_router.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unittests/test_chip.py b/unittests/test_chip.py index efcfce26..cb277b45 100644 --- a/unittests/test_chip.py +++ b/unittests/test_chip.py @@ -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], " diff --git a/unittests/test_router.py b/unittests/test_router.py index 9bb1e97f..9835cd10 100644 --- a/unittests/test_router.py +++ b/unittests/test_router.py @@ -53,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], " From 0f4378497768976f83cb7059a014bfe8fbfcdf1f Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 7 Jul 2023 09:28:42 +0100 Subject: [PATCH 3/3] flake8 --- spinn_machine/router.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spinn_machine/router.py b/spinn_machine/router.py index 6552804e..18bf9ab9 100644 --- a/spinn_machine/router.py +++ b/spinn_machine/router.py @@ -35,9 +35,7 @@ class Router(object): MAX_CORES_PER_ROUTER = 18 - __slots__ = ("_links", - "_n_available_multicast_entries" - ) + __slots__ = ("_links", "_n_available_multicast_entries") def __init__( self, links, n_available_multicast_entries=Machine.ROUTER_ENTRIES):