From 536a038c2d20afd0bd30be5ad358b743b82b1082 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 4 Mar 2024 07:34:09 +0000 Subject: [PATCH 1/3] user_processors_ids --- pacman/operations/placer_algorithms/application_placer.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pacman/operations/placer_algorithms/application_placer.py b/pacman/operations/placer_algorithms/application_placer.py index 0212634ba..4da8f8232 100644 --- a/pacman/operations/placer_algorithms/application_placer.py +++ b/pacman/operations/placer_algorithms/application_placer.py @@ -541,8 +541,7 @@ class _ChipWithSpace(object): def __init__( self, chip: Chip, used_processors: Set[int], used_sdram: int): self.chip = chip - self.cores = set(p.processor_id for p in chip.processors - if not p.is_monitor) + self.cores = set(chip.user_processors_ids) self.cores -= used_processors self.sdram = chip.sdram - used_sdram From d7d9c5e28c1edd472f0d429aee70b75d244da282 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 4 Mar 2024 08:06:31 +0000 Subject: [PATCH 2/3] typing --- .../fixed_route_router/fixed_route_router.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pacman/operations/fixed_route_router/fixed_route_router.py b/pacman/operations/fixed_route_router/fixed_route_router.py index 0491424f5..c34460431 100644 --- a/pacman/operations/fixed_route_router/fixed_route_router.py +++ b/pacman/operations/fixed_route_router/fixed_route_router.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Dict, List, Tuple +from typing import Dict, List, Tuple, Type from spinn_utilities.progress_bar import ProgressBar from spinn_machine import Chip, FixedRouteEntry from pacman.data import PacmanDataView @@ -22,12 +22,12 @@ def fixed_route_router( - destination_class) -> Dict[Tuple[int, int], FixedRouteEntry]: + destination_class: Type) -> Dict[Tuple[int, int], FixedRouteEntry]: """ Runs the fixed route generator for all boards on machine. :param destination_class: the destination class to route packets to - :type destination_class: type or tuple(type,...) + :type destination_class: type :return: router tables for fixed route paths :rtype: dict((int, int)), ~spinn_machine.FixedRouteEntry) :raises PacmanConfigurationException: if no placement processor found @@ -48,7 +48,12 @@ class _FixedRouteRouter(object): "_destination_class", "_fixed_route_tables", "_machine") - def __init__(self, destination_class): + def __init__(self, destination_class: Type): + """ + + :param destination_class: the destination class to route packets to + :type destination_class: type + """ self._machine = PacmanDataView.get_machine() self._destination_class = destination_class self._fixed_route_tables: Dict[Tuple[int, int], FixedRouteEntry] = \ From 882d93dab158e5f17b15eaeded39bb07cac26b73 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 5 Mar 2024 07:23:23 +0000 Subject: [PATCH 3/3] replace chip.processor with new efficient methods --- .../placer_algorithms/application_placer.py | 3 +-- .../test_tags_board_addresses.py | 24 +++++++------------ 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/pacman/operations/placer_algorithms/application_placer.py b/pacman/operations/placer_algorithms/application_placer.py index dc26b4e01..d7dd1c574 100644 --- a/pacman/operations/placer_algorithms/application_placer.py +++ b/pacman/operations/placer_algorithms/application_placer.py @@ -298,8 +298,7 @@ def _do_fixed_location( f"Constrained to chip {x, y} but no such chip") on_chip = placements.placements_on_chip(x, y) cores_used = {p.p for p in on_chip} - cores = set(p.processor_id for p in chip.processors - if not p.is_monitor) - cores_used + cores = set(chip.user_processors_ids) - cores_used next_cores = iter(cores) for vertex in vertices: next_core = None diff --git a/unittests/operations_tests/tag_allocator_tests/test_tags_board_addresses.py b/unittests/operations_tests/tag_allocator_tests/test_tags_board_addresses.py index b0a62ba04..6be26963e 100644 --- a/unittests/operations_tests/tag_allocator_tests/test_tags_board_addresses.py +++ b/unittests/operations_tests/tag_allocator_tests/test_tags_board_addresses.py @@ -73,10 +73,8 @@ def do_too_many_ip_tags_for_1_board(self, machine): eth_chips = machine.ethernet_connected_chips eth_chip = eth_chips[0] eth_chip_2 = machine.get_chip_at(eth_chip.x + 1, eth_chip.y + 1) - eth_procs = [ - proc.processor_id for proc in eth_chip.processors - if not proc.is_monitor] - procs = [proc for proc in eth_chip_2.processors if not proc.is_monitor] + eth_procs = list(eth_chip.user_processors_ids) + procs = list(eth_chip_2.user_processors) eth2_procs = [proc.processor_id for proc in procs] proc = procs[-1] eth_vertices = [ @@ -125,9 +123,7 @@ def test_fixed_tag(self): machine = virtual_machine(8, 8) writer.set_machine(machine) chip00 = machine.get_chip_at(0, 0) - procs = [ - proc.processor_id for proc in chip00.processors - if not proc.is_monitor] + procs = chip00.user_processors_ids placements = Placements() for i in range(5): vertex = SimpleMachineVertex( @@ -135,7 +131,7 @@ def test_fixed_tag(self): iptags=[IPtagResource( "127.0.0.1", port=10000 + i, strip_sdp=True, tag=1+i)], label="Vertex {i}") - placements.add_placement(Placement(vertex, 0, 0, procs[i])) + placements.add_placement(Placement(vertex, 0, 0, next(procs))) writer.set_placements(placements) writer.set_plan_n_timesteps(1000) tags = basic_tag_allocator() @@ -146,9 +142,7 @@ def do_fixed_repeat_tag(self, machine): writer = PacmanDataWriter.mock() writer.set_machine(machine) chip00 = machine.get_chip_at(0, 0) - procs = [ - proc.processor_id for proc in chip00.processors - if not proc.is_monitor] + procs = chip00.user_processors_ids placements = Placements() for i in range(3): vertex = SimpleMachineVertex( @@ -158,7 +152,7 @@ def do_fixed_repeat_tag(self, machine): IPtagResource("127.45.0.1", port=10000 + i, strip_sdp=True, tag=1+i)], label=f"Vertex {i}") - placements.add_placement(Placement(vertex, 0, 0, procs[i])) + placements.add_placement(Placement(vertex, 0, 0, next(procs))) writer.set_placements(placements) writer.set_plan_n_timesteps(1000) tags = basic_tag_allocator() @@ -182,14 +176,12 @@ def do_reverse(self, machine): writer = PacmanDataWriter.mock() writer.set_machine(machine) chip00 = machine.get_chip_at(0, 0) - procs = [ - proc.processor_id for proc in chip00.processors - if not proc.is_monitor] + processor = chip00.get_first_none_monitor_processor() placements = Placements() vertex = SimpleMachineVertex( sdram=ConstantSDRAM(0), reverse_iptags=[ReverseIPtagResource(port=10000, tag=1)]) - placements.add_placement(Placement(vertex, 0, 0, procs[1])) + placements.add_placement(Placement(vertex, 0, 0, processor)) writer.set_placements(placements) writer.set_plan_n_timesteps(1000) tags = basic_tag_allocator()