Skip to content

Commit

Permalink
rename monitor processor to scamp processors
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Mar 6, 2024
1 parent 4ae4a89 commit 07ffd69
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
56 changes: 28 additions & 28 deletions spinn_machine/chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# One dict for each number of processors (none dead)
standard_processors = {}
# One dict for the standard monitor processors
standard_monitor_processors = None # pylint: disable=invalid-name
standard_scamp_processors = None # pylint: disable=invalid-name


class Chip(object):
Expand All @@ -42,7 +42,7 @@ class Chip(object):
__slots__ = (
"_x", "_y", "_router", "_sdram", "_ip_address",
"_tag_ids", "_nearest_ethernet_x", "_nearest_ethernet_y",
"_user_processors", "_monitor_processors", "_parent_link",
"_user_processors", "_scamp_processors", "_parent_link",
"_v_to_p_map"
)

Expand Down Expand Up @@ -88,7 +88,7 @@ def __init__(self, x: int, y: int, n_processors: int, router: Router,
"""
self._x = x
self._y = y
self._monitor_processors = self.__generate_monitors()
self._scamp_processors = self.__generate_scamp()
self._user_processors = self.__generate_processors(
n_processors, down_cores)
self._router = router
Expand All @@ -105,19 +105,19 @@ def __init__(self, x: int, y: int, n_processors: int, router: Router,
self._parent_link = parent_link
self._v_to_p_map = v_to_p_map

def __generate_monitors(self):
def __generate_scamp(self):
"""
Generates the monitors assuming all Chips have the same monitor cores
Generates the scamp assuming all Chips have the same scamp cores
:return: Dict[int, Processor]
"""
global standard_monitor_processors # pylint: disable=global-statement
if standard_monitor_processors is None:
standard_monitor_processors = dict()
global standard_scamp_processors # pylint: disable=global-statement
if standard_scamp_processors is None:
standard_scamp_processors = dict()
for i in range(
MachineDataView.get_machine_version().n_scamp_cores):
standard_monitor_processors[i] = Processor.factory(i, True)
return standard_monitor_processors
standard_scamp_processors[i] = Processor.factory(i, True)
return standard_scamp_processors

def __generate_processors(
self, n_processors: int,
Expand Down Expand Up @@ -152,7 +152,7 @@ def is_processor_with_id(self, processor_id: int) -> bool:
"""
if processor_id in self._user_processors:
return True
return processor_id in self._monitor_processors
return processor_id in self._scamp_processors

def get_processor_with_id(self, processor_id: int) -> Optional[Processor]:
"""
Expand All @@ -167,7 +167,7 @@ def get_processor_with_id(self, processor_id: int) -> Optional[Processor]:
"""
if processor_id in self._user_processors:
return self._user_processors[processor_id]
return self._monitor_processors.get(processor_id)
return self._scamp_processors.get(processor_id)

@property
def x(self) -> int:
Expand Down Expand Up @@ -204,7 +204,7 @@ def processors(self) -> Iterator[Processor]:
:rtype: iterable(Processor)
"""
yield from self._monitor_processors.values()
yield from self._scamp_processors.values()
yield from self._user_processors.values()

@property
Expand All @@ -214,7 +214,7 @@ def all_processor_ids(self) -> Iterator[int]:
:rtype: iterable(int)
"""
yield from self._monitor_processors.keys()
yield from self._scamp_processors.keys()
yield from self._user_processors.keys()

@property
Expand All @@ -224,7 +224,7 @@ def n_processors(self) -> int:
:rtype: int
"""
return len(self._monitor_processors) + len(self._user_processors)
return len(self._scamp_processors) + len(self._user_processors)

@property
def user_processors(self) -> Iterator[Processor]:
Expand All @@ -247,38 +247,38 @@ def user_processors_ids(self) -> Iterator[int]:
@property
def n_user_processors(self) -> int:
"""
The total number of processors that are not monitors.
The total number of processors that are not used by scamp.
:rtype: int
"""
return len(self._user_processors)

@property
def monitor_processors(self) -> Iterator[Processor]:
def scamp_processors(self) -> Iterator[Processor]:
"""
An iterable of available monitor processors.
An iterable of available scamp processors.
:rtype: iterable(Processor)
"""
return self._monitor_processors.values()
return self._scamp_processors.values()

@property
def monitor_processors_ids(self) -> Iterator[int]:
def scamp_processors_ids(self) -> Iterator[int]:
"""
An iterable of available user processors.
An iterable of available scamp processors.
:rtype: iterable(Processor)
"""
yield from self._monitor_processors
yield from self._scamp_processors

@property
def n_monitor_processors(self) -> int:
"""
The total number of processors that are not monitors.
The total number of processors that are used by scamp.
:rtype: int
"""
return len(self._monitor_processors)
return len(self._scamp_processors)

@property
def router(self) -> Router:
Expand Down Expand Up @@ -389,7 +389,7 @@ def __iter__(self) -> Iterator[Tuple[int, Processor]]:
* ``processor`` is the processor with the ID
:rtype: iterable(tuple(int,Processor))
"""
yield from self._monitor_processors.items()
yield from self._scamp_processors.items()
yield from self._user_processors.items()

def __len__(self) -> int:
Expand All @@ -399,13 +399,13 @@ def __len__(self) -> int:
:return: The number of items in the underlying iterator.
:rtype: int
"""
return len(self._monitor_processors) + len(self._user_processors)
return len(self._scamp_processors) + len(self._user_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._monitor_processors:
return self._monitor_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
# standard Python semantics
raise KeyError(processor_id)
Expand Down
4 changes: 2 additions & 2 deletions unittests/test_chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ def test_processors(self):
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)))
monitors = set(new_chip.monitor_processors)
monitors = set(new_chip.scamp_processors)
self.assertEqual(users.union(monitors), all_p)
self.assertEqual(len(monitors),
len(set(new_chip.monitor_processors_ids)))
len(set(new_chip.scamp_processors_ids)))


if __name__ == '__main__':
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 @@ -64,9 +64,9 @@ def test_monitor_exceptions(self):
chip02 = vm[0, 2]
# Hack in an extra monitor
users = dict(chip02._user_processors)
monitors = dict(chip02._monitor_processors)
monitors = dict(chip02._scamp_processors)
monitors[1] = users.pop(1)
chip02._monitor_processors = monitors
chip02._scamp_processors = monitors
chip02._user_processors = users
jpath = mktemp("json")
# Should still be able to write json even with more than one monitor
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_virtual_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def test_new_vm_with_max_cores(self):
self.assertEqual(n_cpus - 1, _chip.n_user_processors)
self.assertEqual(1, _chip.n_monitor_processors)
self.assertEqual(n_cpus - 1, len(list(_chip.user_processors)))
self.assertEqual(1, len(list(_chip.monitor_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 07ffd69

Please sign in to comment.