Skip to content

Commit

Permalink
Merge pull request #1172 from SpiNNakerManchester/single_routing_entry
Browse files Browse the repository at this point in the history
Single routing entry
  • Loading branch information
rowleya authored Apr 16, 2024
2 parents 1c43d66 + c57e6d7 commit bbb6d31
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 28 deletions.
8 changes: 4 additions & 4 deletions spinn_front_end_common/data/fec_data_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from spinn_utilities.socket_address import SocketAddress
from spinn_utilities.typing.coords import XY

from spinn_machine import Chip, CoreSubsets, FixedRouteEntry
from spinn_machine import Chip, CoreSubsets, RoutingEntry
from spinnman.data import SpiNNManDataView
from spinnman.model import ExecutableTargets
from spinnman.model.enums import ExecutableType
Expand Down Expand Up @@ -170,7 +170,7 @@ def _hard_reset(self) -> None:
self._ds_database_path: Optional[str] = None
self._next_ds_reference = 0
self._executable_targets: Optional[ExecutableTargets] = None
self._fixed_routes: Optional[Dict[XY, FixedRouteEntry]] = None
self._fixed_routes: Optional[Dict[XY, RoutingEntry]] = None
self._gatherer_map: \
Optional[Dict[Chip, DataSpeedUpPacketGatherMachineVertex]] = None
self._ipaddress: Optional[str] = None
Expand Down Expand Up @@ -743,11 +743,11 @@ def get_ipaddress(cls) -> str:

# fixed_routes
@classmethod
def get_fixed_routes(cls) -> Dict[XY, FixedRouteEntry]:
def get_fixed_routes(cls) -> Dict[XY, RoutingEntry]:
"""
Gets the fixed routes if they have been created.
:rtype: dict((int, int), ~spinn_machine.FixedRouteEntry)
:rtype: dict((int, int), ~spinn_machine.RoutingEntry)
:raises ~spinn_utilities.exceptions.SpiNNUtilsException:
If the fixed_routes is currently unavailable
"""
Expand Down
6 changes: 3 additions & 3 deletions spinn_front_end_common/data/fec_data_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from spinn_utilities.log import FormatAdapter
from spinn_utilities.overrides import overrides
from spinn_utilities.typing.coords import XY
from spinn_machine import Chip, FixedRouteEntry, CoreSubsets
from spinn_machine import Chip, CoreSubsets, RoutingEntry
from spinnman.data.spinnman_data_writer import SpiNNManDataWriter
from spinnman.messages.scp.enums.signal import Signal
from spinnman.model import ExecutableTargets
Expand Down Expand Up @@ -432,11 +432,11 @@ def set_ipaddress(self, ip_address: str):
self.__fec_data._ipaddress = ip_address

def set_fixed_routes(
self, fixed_routes: Dict[Tuple[int, int], FixedRouteEntry]):
self, fixed_routes: Dict[Tuple[int, int], RoutingEntry]):
"""
:param fixed_routes:
:type fixed_routes:
dict((int, int), ~spinn_machine.FixedRouteEntry)
dict((int, int), ~spinn_machine.RoutingEntry)
"""
if not isinstance(fixed_routes, dict):
raise TypeError("fixed_routes must be a dict")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
from spinn_utilities.find_max_success import find_max_success
from spinn_utilities.progress_bar import ProgressBar
from spinn_utilities.ordered_set import OrderedSet
from spinn_machine import MulticastRoutingEntry, Chip
from spinn_machine import Chip, MulticastRoutingEntry, RoutingEntry
from pacman.exceptions import (
PacmanAlgorithmFailedToGenerateOutputsException,
PacmanElementAllocationException, MinimisationFailedError)
from pacman.model.routing_tables import (
AbstractMulticastRoutingTable, MulticastRoutingTables,
UnCompressedMulticastRoutingTable, CompressedMulticastRoutingTable)
from pacman.utilities.algorithm_utilities.routes_format import format_route
from pacman.operations.router_compressors import RTEntry
from pacman.operations.router_compressors.pair_compressor import (
_PairCompressor)
from spinn_front_end_common.abstract_models import (
Expand Down Expand Up @@ -249,7 +248,7 @@ def __init__(self, key_to_n_atom_map: Dict[int, int],
:param dict(Chip,dict(int,int)) most_costly_cores:
Map of chip to processors to count of incoming on processor
"""
self._best_routing_entries: List[RTEntry] = []
self._best_routing_entries: List[MulticastRoutingEntry] = []
self._best_midpoint = -1
self._bit_fields_by_key: Dict[int, List[_BitFieldData]] = {}
self._compression_attempts: Dict[int, str] = dict()
Expand Down Expand Up @@ -314,8 +313,7 @@ def compress_bitfields(

if self._best_routing_entries:
for entry in self._best_routing_entries:
best_router_table.add_multicast_routing_entry(
entry.to_multicast_routing_entry())
best_router_table.add_multicast_routing_entry(entry)

compressed_pacman_router_tables.add_routing_table(best_router_table)

Expand Down Expand Up @@ -354,7 +352,7 @@ def _convert_bitfields_into_router_table(

# go through the routing tables and convert when needed
for original_entry in router_table.multicast_routing_entries:
base_key = original_entry.routing_entry_key
base_key = original_entry.key
if base_key not in self._bit_fields_by_key:
continue
n_neurons = self.__key_atom_map[base_key]
Expand All @@ -372,13 +370,15 @@ def _convert_bitfields_into_router_table(
# Add an Entry for each neuron
for neuron in range(n_neurons):
# build new entry for this neuron and add to table
processor_ids: List[int] = [
processor_id
for processor_id in original_entry.processor_ids
if core_map[processor_id][neuron]]
routing_entry = RoutingEntry(
link_ids=entry_links, processor_ids=processor_ids)
new_table.add_multicast_routing_entry(MulticastRoutingEntry(
routing_entry_key=base_key + neuron,
mask=self._NEURON_LEVEL_MASK, link_ids=entry_links,
defaultable=False, processor_ids=(
processor_id
for processor_id in original_entry.processor_ids
if core_map[processor_id][neuron])))
key=base_key + neuron,
mask=self._NEURON_LEVEL_MASK, routing_entry=routing_entry))

# return the bitfield tables and the reduced original table
return new_table
Expand Down Expand Up @@ -572,15 +572,15 @@ def _binary_search_check(

def _run_algorithm(
self, router_table: AbstractMulticastRoutingTable
) -> List[RTEntry]:
) -> List[MulticastRoutingEntry]:
"""
Attempts to covert the mega router tables into 1 router table.
:param list(~.AbstractMulticastRoutingTable) router_table:
the set of router tables that together need to
be merged into 1 router table
:return: compressor router table
:rtype: list(~.RoutingTableEntry)
:rtype: list(MulticastRoutingEntry)
:throws MinimisationFailedError: if it fails to
compress to the correct length.
"""
Expand Down Expand Up @@ -684,7 +684,7 @@ def _create_table_report(
# Note: _best_routing_table is a list(), router_table is not
for entry in self._best_routing_entries:
index = entry_count & self._LOWER_16_BITS
entry_str = format_route(entry.to_multicast_routing_entry())
entry_str = format_route(entry)
entry_count += 1
if entry.defaultable:
n_defaultable += 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def _build_data(self, table: AbstractMulticastRoutingTable) -> bytes:

for entry in table.multicast_routing_entries:
data += _FOUR_WORDS.pack(
entry.routing_entry_key, entry.mask,
entry.key, entry.mask,
Router.convert_routing_table_entry_to_spinnaker_route(entry),
get_defaultable_source_id(entry))
return bytearray(data)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from spinn_utilities.typing.coords import XY
from spinn_utilities.progress_bar import ProgressBar

from spinn_machine import MulticastRoutingEntry, Chip
from spinn_machine import Chip, MulticastRoutingEntry, RoutingEntry

from pacman.exceptions import (PacmanRoutingException)
from pacman.model.routing_tables import (
Expand Down Expand Up @@ -196,9 +196,11 @@ def _add_routing_entry(
processor_ids = [processor_id]
if link_ids is None:
link_ids = []
routing_entry = RoutingEntry(
processor_ids=processor_ids, link_ids=link_ids)
entry = MulticastRoutingEntry(
routing_entry_key=key, mask=ROUTING_MASK,
processor_ids=processor_ids, link_ids=link_ids, defaultable=False)
key=key, mask=ROUTING_MASK,
routing_entry=routing_entry)
table.add_multicast_routing_entry(entry)

def _add_routing_entries(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,6 @@ def _locate_routing_entry(
"""
if current_router is not None:
for entry in current_router.multicast_routing_entries:
if entry.mask & key == entry.routing_entry_key:
if entry.mask & key == entry.key:
return entry
return None
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def _generate_data_speed_up_in_config(
assert table is not None
spec.write_value(table.number_of_entries)
for entry in table.multicast_routing_entries:
spec.write_value(entry.routing_entry_key)
spec.write_value(entry.key)
spec.write_value(entry.mask)
spec.write_value(self.__encode_route(entry))

Expand Down

0 comments on commit bbb6d31

Please sign in to comment.