Skip to content

Commit

Permalink
Merge branch 'master' into reduce-op-complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
dkfellows committed Jul 7, 2023
2 parents 37893e6 + bc2225e commit 7119cef
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 44 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
6 changes: 0 additions & 6 deletions spinn_machine/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,13 @@ class Machine(object, metaclass=AbstractBase):

# current opinions is that the Ethernet connected chip can handle 10
# UDP packets per millisecond
MAX_BANDWIDTH_PER_ETHERNET_CONNECTED_CHIP = 10 * 256
DEFAULT_MAX_CORES_PER_CHIP = 18
NON_USER_CORES = 1
DEFAULT_SDRAM_BYTES = 123469792
__max_cores: Optional[int] = None
MAX_CHIPS_PER_48_BOARD = 48
MAX_CHIPS_PER_4_CHIP_BOARD = 4
BOARD_VERSION_FOR_48_CHIPS = [4, 5]
BOARD_VERSION_FOR_4_CHIPS = [2, 3]

# other useful magic numbers for machines
MAX_CHIP_X_ID_ON_ONE_BOARD = 7
MAX_CHIP_Y_ID_ON_ONE_BOARD = 7
SIZE_X_OF_ONE_BOARD = 8
SIZE_Y_OF_ONE_BOARD = 8

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 @@ -153,8 +153,7 @@ def _machine_ignore(
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
23 changes: 4 additions & 19 deletions spinn_machine/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,13 @@ 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: Iterable[Link], emergency_routing_enabled=False,
n_available_multicast_entries=Machine.ROUTER_ENTRIES):
self, links: Iterable[Link],
n_available_multicast_entries: int = 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 @@ -62,7 +57,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: Link):
Expand Down Expand Up @@ -141,15 +135,6 @@ def __len__(self) -> int:
"""
return len(self._links)

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

@property
def n_available_multicast_entries(self) -> int:
"""
Expand Down Expand Up @@ -221,7 +206,7 @@ def get_neighbouring_chips_coords(self) -> List[Dict[str, int]]:

def __str__(self) -> str:
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
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, processor_ids=[4, 5, 7],
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 7119cef

Please sign in to comment.