Skip to content

Commit

Permalink
rename chip user processor(s) chip placable processor(s)
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Mar 7, 2024
1 parent 07ffd69 commit 5d25dca
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 39 deletions.
44 changes: 22 additions & 22 deletions spinn_machine/chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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]:
Expand All @@ -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:
Expand All @@ -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]:
Expand Down Expand Up @@ -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]:
Expand Down Expand Up @@ -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:
"""
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions spinn_machine/json_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion spinn_machine/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions unittests/test_chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__())
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions unittests/test_json_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions unittests/test_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions unittests/test_virtual_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5d25dca

Please sign in to comment.