From 5d25dca5625e425328410ba45f491355f8ad9cf8 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 7 Mar 2024 05:57:14 +0000 Subject: [PATCH] rename chip user processor(s) chip placable processor(s) --- spinn_machine/chip.py | 44 +++++++++++++++---------------- spinn_machine/json_machine.py | 12 ++++----- spinn_machine/machine.py | 2 +- unittests/test_chip.py | 8 +++--- unittests/test_json_machine.py | 4 +-- unittests/test_machine.py | 4 +-- unittests/test_virtual_machine.py | 4 +-- 7 files changed, 39 insertions(+), 39 deletions(-) diff --git a/spinn_machine/chip.py b/spinn_machine/chip.py index 4a6b916b..ecf03eea 100644 --- a/spinn_machine/chip.py +++ b/spinn_machine/chip.py @@ -42,7 +42,7 @@ class Chip(object): __slots__ = ( "_x", "_y", "_router", "_sdram", "_ip_address", "_tag_ids", "_nearest_ethernet_x", "_nearest_ethernet_y", - "_user_processors", "_scamp_processors", "_parent_link", + "_placable_processors", "_scamp_processors", "_parent_link", "_v_to_p_map" ) @@ -89,7 +89,7 @@ def __init__(self, x: int, y: int, n_processors: int, router: Router, self._x = x self._y = y self._scamp_processors = self.__generate_scamp() - self._user_processors = self.__generate_processors( + self._placable_processors = self.__generate_processors( n_processors, down_cores) self._router = router self._sdram = sdram @@ -150,7 +150,7 @@ def is_processor_with_id(self, processor_id: int) -> bool: :return: Whether the processor with the given ID exists :rtype: bool """ - if processor_id in self._user_processors: + if processor_id in self._placable_processors: return True return processor_id in self._scamp_processors @@ -165,8 +165,8 @@ def get_processor_with_id(self, processor_id: int) -> Optional[Processor]: or ``None`` if no such processor :rtype: Processor or None """ - if processor_id in self._user_processors: - return self._user_processors[processor_id] + if processor_id in self._placable_processors: + return self._placable_processors[processor_id] return self._scamp_processors.get(processor_id) @property @@ -205,7 +205,7 @@ def processors(self) -> Iterator[Processor]: :rtype: iterable(Processor) """ yield from self._scamp_processors.values() - yield from self._user_processors.values() + yield from self._placable_processors.values() @property def all_processor_ids(self) -> Iterator[int]: @@ -215,7 +215,7 @@ def all_processor_ids(self) -> Iterator[int]: :rtype: iterable(int) """ yield from self._scamp_processors.keys() - yield from self._user_processors.keys() + yield from self._placable_processors.keys() @property def n_processors(self) -> int: @@ -224,34 +224,34 @@ def n_processors(self) -> int: :rtype: int """ - return len(self._scamp_processors) + len(self._user_processors) + return len(self._scamp_processors) + len(self._placable_processors) @property - def user_processors(self) -> Iterator[Processor]: + def placeable_processors(self) -> Iterator[Processor]: """ - An iterable of available user processors. + An iterable of available placable/ none scamp processors. :rtype: iterable(Processor) """ - yield from self._user_processors.values() + yield from self._placable_processors.values() @property - def user_processors_ids(self) -> Iterator[int]: + def placable_processors_ids(self) -> Iterator[int]: """ - An iterable of available user processors. + An iterable of available placable/ non scamp processor ids. :rtype: iterable(Processor) """ - yield from self._user_processors + yield from self._placable_processors @property - def n_user_processors(self) -> int: + def n_placable_processors(self) -> int: """ - The total number of processors that are not used by scamp. + The total number of processors that are placable / not used by scamp. :rtype: int """ - return len(self._user_processors) + return len(self._placable_processors) @property def scamp_processors(self) -> Iterator[Processor]: @@ -342,7 +342,7 @@ def get_first_none_monitor_processor(self) -> Processor: :rtype: Processor ;raises StopIteration: If there is no user processor """ - return next(iter(self._user_processors.values())) + return next(iter(self._placable_processors.values())) @property def parent_link(self) -> Optional[int]: @@ -390,7 +390,7 @@ def __iter__(self) -> Iterator[Tuple[int, Processor]]: :rtype: iterable(tuple(int,Processor)) """ yield from self._scamp_processors.items() - yield from self._user_processors.items() + yield from self._placable_processors.items() def __len__(self) -> int: """ @@ -399,11 +399,11 @@ def __len__(self) -> int: :return: The number of items in the underlying iterator. :rtype: int """ - return len(self._scamp_processors) + len(self._user_processors) + return len(self._scamp_processors) + len(self._placable_processors) def __getitem__(self, processor_id: int) -> Processor: - if processor_id in self._user_processors: - return self._user_processors[processor_id] + if processor_id in self._placable_processors: + return self._placable_processors[processor_id] if processor_id in self._scamp_processors: return self._scamp_processors[processor_id] # Note difference from get_processor_with_id(); this is to conform to diff --git a/spinn_machine/json_machine.py b/spinn_machine/json_machine.py index e0d34c9e..122b7705 100644 --- a/spinn_machine/json_machine.py +++ b/spinn_machine/json_machine.py @@ -204,9 +204,9 @@ def _describe_chip(chip: Chip, standard, ethernet) -> JsonArray: if chip.ip_address is not None: details['ipAddress'] = chip.ip_address # Write the Resources ONLY if different from the e_values - if (chip.n_processors - chip.n_user_processors) != ethernet.monitors: + if (chip.n_processors - chip.n_placable_processors) != ethernet.monitors: exceptions["monitors"] = \ - chip.n_processors - chip.n_user_processors + chip.n_processors - chip.n_placable_processors if router_entries != ethernet.router_entries: exceptions["routerEntries"] = router_entries if chip.sdram != ethernet.sdram: @@ -215,9 +215,9 @@ def _describe_chip(chip: Chip, standard, ethernet) -> JsonArray: exceptions["tags"] = tags else: # Write the Resources ONLY if different from the s_values - if (chip.n_processors - chip.n_user_processors) != standard.monitors: + if (chip.n_processors - chip.n_placable_processors) != standard.monitors: exceptions["monitors"] = \ - chip.n_processors - chip.n_user_processors + chip.n_processors - chip.n_placable_processors if router_entries != standard.router_entries: exceptions["routerEntries"] = router_entries if chip.sdram != standard.sdram: @@ -243,7 +243,7 @@ def to_json() -> JsonObject: for chip in machine.chips: if chip.ip_address is None: std = _Desc( - monitors=chip.n_processors - chip.n_user_processors, + monitors=chip.n_processors - chip.n_placable_processors, router_entries=_int_value( chip.router.n_available_multicast_entries), sdram=chip.sdram, @@ -255,7 +255,7 @@ def to_json() -> JsonObject: # find the nth values to use for Ethernet chips chip = machine.boot_chip eth = _Desc( - monitors=chip.n_processors - chip.n_user_processors, + monitors=chip.n_processors - chip.n_placable_processors, router_entries=_int_value( chip.router.n_available_multicast_entries), sdram=chip.sdram, diff --git a/spinn_machine/machine.py b/spinn_machine/machine.py index 167616cf..1ca54375 100644 --- a/spinn_machine/machine.py +++ b/spinn_machine/machine.py @@ -1084,7 +1084,7 @@ def total_available_user_cores(self) -> int: :rtype: int """ - return sum(chip.n_user_processors for chip in self.chips) + return sum(chip.n_placable_processors for chip in self.chips) @property def total_cores(self) -> int: diff --git a/unittests/test_chip.py b/unittests/test_chip.py index a3a34d3f..62a9980d 100644 --- a/unittests/test_chip.py +++ b/unittests/test_chip.py @@ -53,7 +53,7 @@ def test_create_chip(self): self.assertEqual(new_chip.ip_address, self._ip) self.assertEqual(new_chip.sdram, self._sdram) self.assertEqual(new_chip.router, self._router) - self.assertEqual(new_chip.n_user_processors, self.n_processors - 1) + self.assertEqual(new_chip.n_placable_processors, self.n_processors - 1) with self.assertRaises(KeyError): self.assertIsNone(new_chip[42]) print(new_chip.__repr__()) @@ -117,9 +117,9 @@ def test_processors(self): for id in new_chip.all_processor_ids: all_p.add(new_chip[id]) self.assertEqual(len(all_p), new_chip.n_processors) - users = set(new_chip.user_processors) - self.assertEqual(len(users), new_chip.n_user_processors) - self.assertEqual(len(users), len(set(new_chip.user_processors_ids))) + users = set(new_chip.placeable_processors) + self.assertEqual(len(users), new_chip.n_placable_processors) + self.assertEqual(len(users), len(set(new_chip.placable_processors_ids))) monitors = set(new_chip.scamp_processors) self.assertEqual(users.union(monitors), all_p) self.assertEqual(len(monitors), diff --git a/unittests/test_json_machine.py b/unittests/test_json_machine.py index 3485c5d8..0b140ec5 100644 --- a/unittests/test_json_machine.py +++ b/unittests/test_json_machine.py @@ -63,11 +63,11 @@ def test_monitor_exceptions(self): MachineDataWriter.mock().set_machine(vm) chip02 = vm[0, 2] # Hack in an extra monitor - users = dict(chip02._user_processors) + users = dict(chip02._placable_processors) monitors = dict(chip02._scamp_processors) monitors[1] = users.pop(1) chip02._scamp_processors = monitors - chip02._user_processors = users + chip02._placable_processors = users jpath = mktemp("json") # Should still be able to write json even with more than one monitor to_json_path(jpath) diff --git a/unittests/test_machine.py b/unittests/test_machine.py index a58ded1d..b5415a5e 100644 --- a/unittests/test_machine.py +++ b/unittests/test_machine.py @@ -390,8 +390,8 @@ def test_too_few_cores(self): machine = virtual_machine(8, 8) # Hack to get n_processors return a low number chip01 = machine.get_chip_at(0, 1) - chip01._user_processors = dict( - list(chip01._user_processors.items())[:2]) + chip01._placable_processors = dict( + list(chip01._placable_processors.items())[:2]) with self.assertRaises(SpinnMachineException): machine.validate() diff --git a/unittests/test_virtual_machine.py b/unittests/test_virtual_machine.py index 247689a5..36b3b3ec 100644 --- a/unittests/test_virtual_machine.py +++ b/unittests/test_virtual_machine.py @@ -176,9 +176,9 @@ def test_new_vm_with_max_cores(self): vm = virtual_machine(2, 2, validate=True) _chip = vm[1, 1] self.assertEqual(n_cpus, _chip.n_processors) - self.assertEqual(n_cpus - 1, _chip.n_user_processors) + self.assertEqual(n_cpus - 1, _chip.n_placable_processors) self.assertEqual(1, _chip.n_monitor_processors) - self.assertEqual(n_cpus - 1, len(list(_chip.user_processors))) + self.assertEqual(n_cpus - 1, len(list(_chip.placeable_processors))) self.assertEqual(1, len(list(_chip.scamp_processors))) count = sum(_chip.n_processors for _chip in vm.chips) self.assertEqual(count, 4 * n_cpus)