From 8c7f3dad86409c49fd433b70d03b52c0f2bf2e82 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Wed, 6 Mar 2024 16:30:50 +0000 Subject: [PATCH 1/8] rename monitor cores to system cores --- pacman/data/pacman_data_view.py | 27 ++++++++++--------- pacman/data/pacman_data_writer.py | 14 +++++----- .../placer_algorithms/application_placer.py | 8 +++--- unittests/data/test_data.py | 18 ++++++------- .../test_application_placer.py | 10 +++---- 5 files changed, 40 insertions(+), 37 deletions(-) diff --git a/pacman/data/pacman_data_view.py b/pacman/data/pacman_data_view.py index 11f049f4d..9be997391 100644 --- a/pacman/data/pacman_data_view.py +++ b/pacman/data/pacman_data_view.py @@ -61,8 +61,8 @@ class _PacmanDataModel(object): "_placements", "_plan_n_timesteps", "_precompressed", - "_monitor_cores", - "_monitor_sdram", + "_system_cores", + "_system_sdram", "_routing_infos", "_routing_table_by_partition", "_tags", @@ -93,8 +93,8 @@ def _hard_reset(self) -> None: self._graph.reset() self._placements: Optional[Placements] = None self._precompressed: Optional[MulticastRoutingTables] = None - self._monitor_cores: int = 0 - self._monitor_sdram: int = 0 + self._system_cores: int = 0 + self._system_sdram: int = 0 self._uncompressed: Optional[MulticastRoutingTables] = None self._routing_infos: Optional[RoutingInfo] = None self._routing_table_by_partition: Optional[ @@ -534,25 +534,28 @@ def get_routing_table_by_partition( return cls.__pacman_data._routing_table_by_partition @classmethod - def get_monitor_cores(cls) -> int: + def get_system_cores(cls) -> int: """ - The number of cores on every chip reported to be used by monitors. + The number of cores on every chip reported to be used by system cores. + Ethernet-enabled chips may have more. - Does not include the system core reserved by the machine itself. + Does not include the core reserved by the scamp itself. :rtype: int """ - return cls.__pacman_data._monitor_cores + return cls.__pacman_data._system_cores @classmethod - def get_monitor_sdram(cls) -> int: + def get_system_sdram(cls) -> int: """ - The amount of SDRAM on every chip reported to be used by monitors. + The amount of SDRAM on every chip reported to be used by \ + system cores. + Ethernet-enabled chips may have more. - Does not include the system SDRAM reserved by the machine itself. + Does not include the SDRAM reserved by the scamp itself. :rtype: int """ - return cls.__pacman_data._monitor_sdram + return cls.__pacman_data._system_sdram diff --git a/pacman/data/pacman_data_writer.py b/pacman/data/pacman_data_writer.py index 518a0773b..35e13f9ec 100644 --- a/pacman/data/pacman_data_writer.py +++ b/pacman/data/pacman_data_writer.py @@ -179,19 +179,19 @@ def add_edge(cls, edge: ApplicationEdge, "This call is only expected if requires mapping is True") cls.__pacman_data._graph.add_edge(edge, outgoing_edge_partition_name) - def add_monitor_all_chips(self, vertex: MachineVertex): + def add_system_all_chips(self, vertex: MachineVertex): """ - Reports that a monitor has been added to every chip. - Should be called once for each monitor added to all chips. - Should not be called for monitors only added to Ethernet-enabled chips. + Reports that a system core has been added to every chip. + Should be called once for each ap added to all chips. + Should not be called for system only added to Ethernet-enabled chips. - Only affect is to change the numbers reported by the `get_monitor` + Only affect is to change the numbers reported by the `get_system` methods. :param ~pacman.model.graphs.machine.MachineVertex vertex: One of the vertices added to each core, assumed to be typical of all. """ - self.__pacman_data._monitor_cores += 1 - self.__pacman_data._monitor_sdram += \ + self.__pacman_data._system_cores += 1 + self.__pacman_data._system_sdram += \ vertex.sdram_required.get_total_sdram(self.get_plan_n_timestep()) diff --git a/pacman/operations/placer_algorithms/application_placer.py b/pacman/operations/placer_algorithms/application_placer.py index d7dd1c574..6fd261ee6 100644 --- a/pacman/operations/placer_algorithms/application_placer.py +++ b/pacman/operations/placer_algorithms/application_placer.py @@ -232,11 +232,11 @@ def _check_could_fit( :raises PacmanTooBigToPlace: """ version = PacmanDataView.get_machine_version() - max_sdram = ( - version.max_sdram_per_chip - PacmanDataView.get_monitor_sdram()) + max_sdram = (version.max_sdram_per_chip - + PacmanDataView.get_system_sdram()) max_cores = ( version.max_cores_per_chip - version.n_non_user_cores - - PacmanDataView.get_monitor_cores()) + PacmanDataView.get_system_cores()) n_cores = len(vertices_to_place) if sdram <= max_sdram and n_cores <= max_cores: # should fit somewhere @@ -263,7 +263,7 @@ def _check_could_fit( else: message += ( f"is more vertices than the {max_cores} cores available on a " - f"Chip once {PacmanDataView.get_monitor_cores()} " + f"Chip once {PacmanDataView.get_system_cores()} " "are reserved for monitors") raise PacmanTooBigToPlace(message) diff --git a/unittests/data/test_data.py b/unittests/data/test_data.py index 639a16514..01f091d66 100644 --- a/unittests/data/test_data.py +++ b/unittests/data/test_data.py @@ -346,16 +346,16 @@ def test_add_requires_mapping(self): writer.hard_reset() self.assertTrue(PacmanDataView.get_requires_mapping()) - def test_get_monitors(self): + def test_get_application(self): writer = PacmanDataWriter.setup() writer.set_plan_n_timesteps((45)) - self.assertEqual(0, PacmanDataView.get_monitor_cores()) - self.assertEqual(0, PacmanDataView.get_monitor_sdram()) - writer.add_monitor_all_chips(SimpleMachineVertex(ConstantSDRAM(200))) - self.assertEqual(1, PacmanDataView.get_monitor_cores()) - self.assertEqual(200, PacmanDataView.get_monitor_sdram()) - writer.add_monitor_all_chips(SimpleMachineVertex( + self.assertEqual(0, PacmanDataView.get_system_cores()) + self.assertEqual(0, PacmanDataView.get_system_sdram()) + writer.add_system_all_chips(SimpleMachineVertex(ConstantSDRAM(200))) + self.assertEqual(1, PacmanDataView.get_system_cores()) + self.assertEqual(200, PacmanDataView.get_system_sdram()) + writer.add_system_all_chips(SimpleMachineVertex( VariableSDRAM(100, 10))) - self.assertEqual(2, PacmanDataView.get_monitor_cores()) + self.assertEqual(2, PacmanDataView.get_system_cores()) target = 200 + 100 + 10 * 45 - self.assertEqual(target, PacmanDataView.get_monitor_sdram()) + self.assertEqual(target, PacmanDataView.get_system_sdram()) diff --git a/unittests/operations_tests/placer_algorithms_tests/test_application_placer.py b/unittests/operations_tests/placer_algorithms_tests/test_application_placer.py index d2b13eaec..6dec8fbc0 100644 --- a/unittests/operations_tests/placer_algorithms_tests/test_application_placer.py +++ b/unittests/operations_tests/placer_algorithms_tests/test_application_placer.py @@ -150,9 +150,9 @@ def test_sdram_bigger_monitors(): set_config("Machine", "version", 5) writer = PacmanDataWriter.mock() max_sdram = writer.get_machine_version().max_sdram_per_chip - monitor = SimpleMachineVertex(ConstantSDRAM(max_sdram // 2)) + system = SimpleMachineVertex(ConstantSDRAM(max_sdram // 2)) # This is purely an info call so test check directly - writer.add_monitor_all_chips(monitor) + writer.add_system_all_chips(system) try: _check_could_fit("app_test", ["m_vertex]"], sdram=max_sdram // 2 + 5) raise AssertionError("Error not raise") @@ -190,7 +190,7 @@ def test_more_cores_with_monitor(): writer = PacmanDataWriter.mock() monitor = SimpleMachineVertex(ConstantSDRAM(4000)) # This is purely an info call so test check directly - writer.add_monitor_all_chips(monitor) + writer.add_system_all_chips(monitor) m_vertexs = [f"m_v_{i}" for i in range(17)] try: _check_could_fit("app_test", m_vertexs, 500000) @@ -203,7 +203,7 @@ def test_could_fit(): unittest_setup() set_config("Machine", "version", 5) writer = PacmanDataWriter.mock() - monitor = SimpleMachineVertex(ConstantSDRAM(0)) - writer.add_monitor_all_chips(monitor) + system = SimpleMachineVertex(ConstantSDRAM(0)) + writer.add_system_all_chips(system) m_vertexs = [f"m_v_{i}" for i in range(16)] _check_could_fit("app_test", m_vertexs, 500000) From 655f3a497e5c689d1923d4086d2a25e89fe362fd Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Wed, 6 Mar 2024 17:06:55 +0000 Subject: [PATCH 2/8] rename non_user cores to scamp cores --- pacman/operations/placer_algorithms/application_placer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pacman/operations/placer_algorithms/application_placer.py b/pacman/operations/placer_algorithms/application_placer.py index 6fd261ee6..fc5267770 100644 --- a/pacman/operations/placer_algorithms/application_placer.py +++ b/pacman/operations/placer_algorithms/application_placer.py @@ -235,7 +235,7 @@ def _check_could_fit( max_sdram = (version.max_sdram_per_chip - PacmanDataView.get_system_sdram()) max_cores = ( - version.max_cores_per_chip - version.n_non_user_cores - + version.max_cores_per_chip - version.n_scamp_cores - PacmanDataView.get_system_cores()) n_cores = len(vertices_to_place) if sdram <= max_sdram and n_cores <= max_cores: @@ -255,7 +255,7 @@ def _check_could_fit( if n_cores > version.max_cores_per_chip: message += " is more vertices than the number of cores on a chip." raise PacmanTooBigToPlace(message) - user_cores = version.max_cores_per_chip - version.n_non_user_cores + user_cores = version.max_cores_per_chip - version.n_scamp_cores if n_cores > user_cores: message += ( f"is more vertices than the user cores ({user_cores}) " From 5d110769c24c400ea1755a786804d9d7d4be755d Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 7 Mar 2024 05:57:14 +0000 Subject: [PATCH 3/8] rename chip user processor(s) chip placable processor(s) --- pacman/operations/placer_algorithms/application_placer.py | 6 +++--- .../tag_allocator_tests/test_tags_board_addresses.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pacman/operations/placer_algorithms/application_placer.py b/pacman/operations/placer_algorithms/application_placer.py index fc5267770..163981256 100644 --- a/pacman/operations/placer_algorithms/application_placer.py +++ b/pacman/operations/placer_algorithms/application_placer.py @@ -208,7 +208,7 @@ def _place_error( n_placed = placements.n_placements_on_chip(x, y) system_placed = system_placements.n_placements_on_chip(x, y) if n_placed - system_placed == 0: - n_procs = machine[x, y].n_user_processors + n_procs = machine[x, y].n_placable_processors f.write(f" {x}, {y} ({n_procs - system_placed}" " free cores)\n") @@ -298,7 +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(chip.user_processors_ids) - cores_used + cores = set(chip.placable_processors_ids) - cores_used next_cores = iter(cores) for vertex in vertices: next_core = None @@ -551,7 +551,7 @@ def __init__( :param int used_sdram: """ self.chip = chip - self.cores = set(chip.user_processors_ids) + self.cores = set(chip.placable_processors_ids) self.cores -= used_processors self.sdram = chip.sdram - used_sdram 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 6be26963e..53a21053c 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,8 +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 = list(eth_chip.user_processors_ids) - procs = list(eth_chip_2.user_processors) + eth_procs = list(eth_chip.placable_processors_ids) + procs = list(eth_chip_2.placeable_processors) eth2_procs = [proc.processor_id for proc in procs] proc = procs[-1] eth_vertices = [ @@ -123,7 +123,7 @@ def test_fixed_tag(self): machine = virtual_machine(8, 8) writer.set_machine(machine) chip00 = machine.get_chip_at(0, 0) - procs = chip00.user_processors_ids + procs = chip00.placable_processors_ids placements = Placements() for i in range(5): vertex = SimpleMachineVertex( @@ -142,7 +142,7 @@ def do_fixed_repeat_tag(self, machine): writer = PacmanDataWriter.mock() writer.set_machine(machine) chip00 = machine.get_chip_at(0, 0) - procs = chip00.user_processors_ids + procs = chip00.placable_processors_ids placements = Placements() for i in range(3): vertex = SimpleMachineVertex( From 1c377111ac43a8f102d8441526403471074354c0 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 7 Mar 2024 06:14:42 +0000 Subject: [PATCH 4/8] only expose processor virtual ids --- .../tag_allocator_tests/test_tags_board_addresses.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6be26963e..cecda6611 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 @@ -74,7 +74,7 @@ def do_too_many_ip_tags_for_1_board(self, machine): eth_chip = eth_chips[0] eth_chip_2 = machine.get_chip_at(eth_chip.x + 1, eth_chip.y + 1) eth_procs = list(eth_chip.user_processors_ids) - procs = list(eth_chip_2.user_processors) + procs = list(eth_chip_2.user_processor_ids) eth2_procs = [proc.processor_id for proc in procs] proc = procs[-1] eth_vertices = [ From aa4813c544d9d757ddfdd0cd9e313ed75dc48d48 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 7 Mar 2024 06:45:22 +0000 Subject: [PATCH 5/8] fix test --- .../tag_allocator_tests/test_tags_board_addresses.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 cecda6611..d567a29df 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 @@ -74,9 +74,8 @@ def do_too_many_ip_tags_for_1_board(self, machine): eth_chip = eth_chips[0] eth_chip_2 = machine.get_chip_at(eth_chip.x + 1, eth_chip.y + 1) eth_procs = list(eth_chip.user_processors_ids) - procs = list(eth_chip_2.user_processor_ids) - eth2_procs = [proc.processor_id for proc in procs] - proc = procs[-1] + eth2_procs = list(eth_chip_2.user_processors_ids) + proc = eth2_procs[-1] eth_vertices = [ SimpleMachineVertex( sdram=ConstantSDRAM(0), From 528a7c1c1f8cef9d587e9c474099d866435d9f0f Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 12 Mar 2024 14:21:54 +0000 Subject: [PATCH 6/8] fix merge --- pacman/utilities/utility_objs/chip_counter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pacman/utilities/utility_objs/chip_counter.py b/pacman/utilities/utility_objs/chip_counter.py index ae3fcd843..73f87371a 100644 --- a/pacman/utilities/utility_objs/chip_counter.py +++ b/pacman/utilities/utility_objs/chip_counter.py @@ -43,7 +43,7 @@ class ChipCounter(object): def __init__(self): version = PacmanDataView.get_machine_version() self.__n_cores_per_chip = ( - version.max_cores_per_chip - version.n_non_user_cores - + version.max_cores_per_chip - version.n_scamp_cores - PacmanDataView.get_all_monitor_cores()) self.__sdram_per_chip = ( version.max_sdram_per_chip - From f5262756e4e6950f2bea4a59ff154efce824c7d3 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Wed, 13 Mar 2024 06:13:16 +0000 Subject: [PATCH 7/8] n_scamp_cores --- pacman/operations/placer_algorithms/application_placer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pacman/operations/placer_algorithms/application_placer.py b/pacman/operations/placer_algorithms/application_placer.py index 156fa083a..5d5e5d77a 100644 --- a/pacman/operations/placer_algorithms/application_placer.py +++ b/pacman/operations/placer_algorithms/application_placer.py @@ -237,7 +237,7 @@ def _check_could_fit( PacmanDataView.get_all_monitor_sdram().get_total_sdram( PacmanDataView.get_plan_n_timestep())) max_cores = ( - version.max_cores_per_chip - version.n_non_user_cores - + version.max_cores_per_chip - version.n_scamp_cores - PacmanDataView.get_all_monitor_cores()) n_cores = len(vertices_to_place) if sdram <= max_sdram and n_cores <= max_cores: From eaf5a2afa2e759f40d93a95160a2755ec608af0b Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Wed, 13 Mar 2024 06:13:43 +0000 Subject: [PATCH 8/8] adapt tests that processor_ids are a tuple --- .../tag_allocator_tests/test_tags_board_addresses.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 4560a25ea..190973db4 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 @@ -130,7 +130,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, next(procs))) + placements.add_placement(Placement(vertex, 0, 0, procs[i])) writer.set_placements(placements) writer.set_plan_n_timesteps(1000) tags = basic_tag_allocator() @@ -151,7 +151,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, next(procs))) + placements.add_placement(Placement(vertex, 0, 0, procs[i])) writer.set_placements(placements) writer.set_plan_n_timesteps(1000) tags = basic_tag_allocator() @@ -175,7 +175,7 @@ def do_reverse(self, machine): writer = PacmanDataWriter.mock() writer.set_machine(machine) chip00 = machine.get_chip_at(0, 0) - processor = chip00.get_first_none_monitor_processor() + processor = chip00.placable_processors_ids[0] placements = Placements() vertex = SimpleMachineVertex( sdram=ConstantSDRAM(0),