From 99ff07d83b9b7d433459de920101100a6dc2e36b Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Wed, 27 Mar 2024 07:16:52 +0000 Subject: [PATCH 1/4] replace FixedRoueEntry with Shared RoutingEntry class --- spinnman/messages/scp/impl/fixed_route_read.py | 8 ++++---- .../processes/load_fixed_route_routing_entry_process.py | 6 +++--- .../processes/read_fixed_route_routing_entry_process.py | 8 ++++---- spinnman/transceiver/base_transceiver.py | 6 +++--- spinnman/transceiver/mockable_transceiver.py | 6 +++--- spinnman/transceiver/transceiver.py | 8 ++++---- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/spinnman/messages/scp/impl/fixed_route_read.py b/spinnman/messages/scp/impl/fixed_route_read.py index 8ddfa7a5c..5b31746c4 100644 --- a/spinnman/messages/scp/impl/fixed_route_read.py +++ b/spinnman/messages/scp/impl/fixed_route_read.py @@ -15,7 +15,7 @@ import struct from typing import List from spinn_utilities.overrides import overrides -from spinn_machine import FixedRouteEntry +from spinn_machine import RoutingEntry from spinnman.exceptions import SpinnmanUnexpectedResponseCodeException from spinnman.messages.scp import SCPRequestHeader from spinnman.messages.scp.abstract_messages import ( @@ -48,11 +48,11 @@ def read_data_bytestring(self, data: bytes, offset: int): self._route = _ONE_WORD.unpack_from(data, offset)[0] @property - def route(self) -> FixedRouteEntry: + def route(self) -> RoutingEntry: """ Converts this response into a Route - :rtype: FixedRouteEntry + :rtype: RoutingEntry """ processor_ids: List[int] = list() for processor_id in range(26): @@ -62,7 +62,7 @@ def route(self) -> FixedRouteEntry: for link_id in range(6): if self._route & (1 << link_id) != 0: link_ids.append(link_id) - return FixedRouteEntry(processor_ids, link_ids) + return RoutingEntry(processor_ids=processor_ids, link_ids=link_ids) class FixedRouteRead(AbstractSCPRequest[_FixedRouteResponse]): diff --git a/spinnman/processes/load_fixed_route_routing_entry_process.py b/spinnman/processes/load_fixed_route_routing_entry_process.py index 42f7f2c15..b9c24fb12 100644 --- a/spinnman/processes/load_fixed_route_routing_entry_process.py +++ b/spinnman/processes/load_fixed_route_routing_entry_process.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from spinn_machine import FixedRouteEntry, Router +from spinn_machine import Router, RoutingEntry from spinnman.messages.scp.impl import FixedRouteInit from spinnman.processes import AbstractMultiConnectionProcess @@ -24,14 +24,14 @@ class LoadFixedRouteRoutingEntryProcess(AbstractMultiConnectionProcess): __slots__ = () def load_fixed_route( - self, x: int, y: int, fixed_route: FixedRouteEntry, + self, x: int, y: int, fixed_route: RoutingEntry, app_id: int = 0): """ :param int x: The x-coordinate of the chip, between 0 and 255; this is not checked due to speed restrictions. :param int y: The y-coordinate of the chip, between 0 and 255; this is not checked due to speed restrictions. - :param ~spinn_machine.FixedRouteEntry fixed_route: + :param ~spinn_machine.RoutingEntry fixed_route: the fixed route entry :param int app_id: The ID of the application with which to associate the routes. If not specified, defaults to 0. diff --git a/spinnman/processes/read_fixed_route_routing_entry_process.py b/spinnman/processes/read_fixed_route_routing_entry_process.py index 15e125c8b..9c9b8b9c8 100644 --- a/spinnman/processes/read_fixed_route_routing_entry_process.py +++ b/spinnman/processes/read_fixed_route_routing_entry_process.py @@ -14,7 +14,7 @@ from typing import Optional -from spinn_machine.fixed_route_entry import FixedRouteEntry +from spinn_machine import RoutingEntry from spinnman.messages.scp.impl.fixed_route_read import ( FixedRouteRead, _FixedRouteResponse) @@ -39,13 +39,13 @@ def __init__(self, connection_selector: ConnectionSelector): the SC&MP connection selector """ super().__init__(connection_selector) - self._route: Optional[FixedRouteEntry] = None + self._route: Optional[RoutingEntry] = None def __handle_read_response(self, response: _FixedRouteResponse): self._route = response.route def read_fixed_route( - self, x: int, y: int, app_id: int = 0) -> FixedRouteEntry: + self, x: int, y: int, app_id: int = 0) -> RoutingEntry: """ Read the fixed route entry installed on a particular chip's router. @@ -56,7 +56,7 @@ def read_fixed_route( :param int app_id: The ID of the application with which to associate the routes. If not specified, defaults to 0. - :rtype: ~spinn_machine.FixedRouteEntry + :rtype: ~spinn_machine.RoutingEntry """ with self._collect_responses(): self._send_request(FixedRouteRead(x, y, app_id), diff --git a/spinnman/transceiver/base_transceiver.py b/spinnman/transceiver/base_transceiver.py index fa0b83ad7..89c5bf8d6 100644 --- a/spinnman/transceiver/base_transceiver.py +++ b/spinnman/transceiver/base_transceiver.py @@ -34,7 +34,7 @@ from spinn_utilities.progress_bar import ProgressBar from spinn_utilities.typing.coords import XY from spinn_machine import ( - CoreSubsets, FixedRouteEntry, Machine, MulticastRoutingEntry) + CoreSubsets, Machine, MulticastRoutingEntry, RoutingEntry) from spinn_machine.tags import AbstractTag, IPTag, ReverseIPTag from spinnman.connections.abstract_classes import Connection from spinnman.connections.udp_packet_connections import SDPConnection @@ -1251,7 +1251,7 @@ def load_multicast_routes( @overrides(Transceiver.load_fixed_route) def load_fixed_route( - self, x: int, y: int, fixed_route: FixedRouteEntry, app_id: int): + self, x: int, y: int, fixed_route: RoutingEntry, app_id: int): try: process = LoadFixedRouteRoutingEntryProcess( self._scamp_connection_selector) @@ -1261,7 +1261,7 @@ def load_fixed_route( raise @overrides(Transceiver.read_fixed_route) - def read_fixed_route(self, x: int, y: int, app_id: int) -> FixedRouteEntry: + def read_fixed_route(self, x: int, y: int, app_id: int) -> RoutingEntry: try: process = ReadFixedRouteRoutingEntryProcess( self._scamp_connection_selector) diff --git a/spinnman/transceiver/mockable_transceiver.py b/spinnman/transceiver/mockable_transceiver.py index 126ee9732..496a3a23b 100644 --- a/spinnman/transceiver/mockable_transceiver.py +++ b/spinnman/transceiver/mockable_transceiver.py @@ -21,7 +21,7 @@ from spinn_utilities.progress_bar import ProgressBar from spinn_utilities.typing.coords import XY from spinn_machine import ( - CoreSubsets, FixedRouteEntry, Machine, MulticastRoutingEntry) + CoreSubsets, Machine, MulticastRoutingEntry, RoutingEntry) from spinn_machine.tags import AbstractTag, IPTag, ReverseIPTag from spinnman.data import SpiNNManDataView from spinnman.connections.abstract_classes import Connection @@ -208,11 +208,11 @@ def load_multicast_routes( @overrides(Transceiver.load_fixed_route) def load_fixed_route( - self, x: int, y: int, fixed_route: FixedRouteEntry, app_id: int): + self, x: int, y: int, fixed_route: RoutingEntry, app_id: int): pass @overrides(Transceiver.read_fixed_route) - def read_fixed_route(self, x: int, y: int, app_id: int) -> FixedRouteEntry: + def read_fixed_route(self, x: int, y: int, app_id: int) -> RoutingEntry: raise NotImplementedError("Needs to be mocked") @overrides(Transceiver.get_multicast_routes) diff --git a/spinnman/transceiver/transceiver.py b/spinnman/transceiver/transceiver.py index d33103274..b02c129a6 100644 --- a/spinnman/transceiver/transceiver.py +++ b/spinnman/transceiver/transceiver.py @@ -21,7 +21,7 @@ from spinn_utilities.progress_bar import ProgressBar from spinn_utilities.typing.coords import XY from spinn_machine import ( - CoreSubsets, FixedRouteEntry, Machine, MulticastRoutingEntry) + CoreSubsets, Machine, MulticastRoutingEntry, RoutingEntry) from spinn_machine.tags import AbstractTag, IPTag, ReverseIPTag from spinnman.connections.abstract_classes import Connection from spinnman.connections.udp_packet_connections import ( @@ -779,7 +779,7 @@ def load_multicast_routes( @abstractmethod def load_fixed_route( - self, x: int, y: int, fixed_route: FixedRouteEntry, app_id: int): + self, x: int, y: int, fixed_route: RoutingEntry, app_id: int): """ Loads a fixed route routing table entry onto a chip's router. @@ -787,7 +787,7 @@ def load_fixed_route( The x-coordinate of the chip onto which to load the routes :param int y: The y-coordinate of the chip onto which to load the routes - :param ~spinn_machine.FixedRouteEntry fixed_route: + :param ~spinn_machine.RoutingEntry fixed_route: the route for the fixed route entry on this chip :param int app_id: The ID of the application with which to associate the routes. If not specified, defaults to 0. @@ -804,7 +804,7 @@ def load_fixed_route( raise NotImplementedError("abstractmethod") @abstractmethod - def read_fixed_route(self, x: int, y: int, app_id: int) -> FixedRouteEntry: + def read_fixed_route(self, x: int, y: int, app_id: int) -> RoutingEntry: """ Reads a fixed route routing table entry from a chip's router. From 65d18a29032ade1306db7429fe995b72b860093a Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 28 Mar 2024 07:41:07 +0000 Subject: [PATCH 2/4] MulticastRoutingEntry wraps a RoutingEntry --- spinnman/processes/get_routes_process.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/spinnman/processes/get_routes_process.py b/spinnman/processes/get_routes_process.py index ce30b8fde..f3b8f3be0 100644 --- a/spinnman/processes/get_routes_process.py +++ b/spinnman/processes/get_routes_process.py @@ -16,7 +16,7 @@ from functools import partial from typing import List, Optional -from spinn_machine import MulticastRoutingEntry, Router +from spinn_machine import MulticastRoutingEntry, Router, RoutingEntry from spinnman.messages.scp.impl.read_memory import ReadMemory, Response from spinnman.constants import UDP_MESSAGE_MAX_SIZE @@ -64,13 +64,8 @@ def _add_routing_entry( if self._app_id is not None and self._app_id != app_id: return - # Convert bit-set into list of (set) IDs - processor_ids, link_ids = \ - Router.convert_spinnaker_route_to_routing_ids(route) - self._entries[route_no + offset] = MulticastRoutingEntry( - key, mask, processor_ids=processor_ids, link_ids=link_ids, - defaultable=False) + key, mask, RoutingEntry(spinnaker_route=route)) def __handle_response(self, offset: int, response: Response): for route_no in range(_ENTRIES_PER_READ): From 60be30b4e289956b8768ec32ef743c90e2674951 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 28 Mar 2024 10:51:46 +0000 Subject: [PATCH 3/4] use MulticastRoutingEntry instead of RTEntry --- spinnman/processes/load_routes_process.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spinnman/processes/load_routes_process.py b/spinnman/processes/load_routes_process.py index 3985e6a46..50bacd523 100644 --- a/spinnman/processes/load_routes_process.py +++ b/spinnman/processes/load_routes_process.py @@ -67,7 +67,7 @@ def load_routes( _ROUTE_PATTERN.pack_into( routing_data, n_entries * 16, n_entries, - route_entry, route.routing_entry_key, route.mask) + route_entry, route.key, route.mask) n_entries += 1 # Add an entry to mark the end From 58713dd2cc6eff969543ac0572fd51fd5762a7c2 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 28 Mar 2024 13:42:29 +0000 Subject: [PATCH 4/4] remove unused import --- spinnman/processes/get_routes_process.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spinnman/processes/get_routes_process.py b/spinnman/processes/get_routes_process.py index f3b8f3be0..971c41f91 100644 --- a/spinnman/processes/get_routes_process.py +++ b/spinnman/processes/get_routes_process.py @@ -16,7 +16,7 @@ from functools import partial from typing import List, Optional -from spinn_machine import MulticastRoutingEntry, Router, RoutingEntry +from spinn_machine import MulticastRoutingEntry, RoutingEntry from spinnman.messages.scp.impl.read_memory import ReadMemory, Response from spinnman.constants import UDP_MESSAGE_MAX_SIZE