Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version #217

Merged
merged 25 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4dd9b5f
get n_cores from Version classes
Christian-B Jul 12, 2023
de20150
n_non_user_cores via Version
Christian-B Jul 12, 2023
2931318
max_sdram_per_chip via version
Christian-B Jul 12, 2023
9a99a8d
move remote_spinnaker_url and spalloc_server cfgs
Christian-B Jul 12, 2023
7a5958c
require something in cfg to dettermine version
Christian-B Jul 12, 2023
c2eb4ab
set_config("Machine", "version", 5)
Christian-B Jul 13, 2023
b8a566e
move verify machine size and pick Machine type to Version classes
Christian-B Jul 13, 2023
51d1ec1
minor fixes
Christian-B Jul 13, 2023
1ba147e
fix tests
Christian-B Jul 13, 2023
8165462
flake8
Christian-B Jul 13, 2023
d2a5394
Version n_chips_per_board
Christian-B Jul 13, 2023
5359dcc
Version n_chips_per_board
Christian-B Jul 13, 2023
6e8eae6
version.get_potential_ethernet_chip
Christian-B Jul 13, 2023
9a1cd3e
width heigt 8 constants moved to geometry
Christian-B Jul 13, 2023
77358ac
n_router_entries from Version and machine object
Christian-B Jul 14, 2023
d3bb69a
machine summary string
Christian-B Jul 14, 2023
9b98b98
test summary_string
Christian-B Jul 14, 2023
a6edd61
flake8
Christian-B Jul 14, 2023
4c5ab00
_clear is a defining-attr-methods
Christian-B Jul 18, 2023
0bb881e
pylint fixes
Christian-B Jul 18, 2023
e7b0679
f string and spelling
Christian-B Jul 18, 2023
1606a96
adds tests and fix bug
Christian-B Jul 19, 2023
3779f80
merged in master
Christian-B Jul 20, 2023
fbdeeaa
Version class tests
Christian-B Jul 20, 2023
1934485
flake8
Christian-B Jul 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ init-import=no
# List of method names used to declare (i.e. assign) instance attributes.
defining-attr-methods=__init__,
__new__,
_clear,
_hard_reset,
setUp

Expand Down
3 changes: 1 addition & 2 deletions spinn_machine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,9 @@
from .spinnaker_triad_geometry import SpiNNakerTriadGeometry
from .virtual_machine import virtual_machine
from .fixed_route_entry import FixedRouteEntry
from .machine_factory import machine_from_chips, machine_from_size


__all__ = ["Chip", "CoreSubset", "CoreSubsets", "FixedRouteEntry",
"Link", "Machine", "MulticastRoutingEntry",
"Processor", "Router", "SpiNNakerTriadGeometry",
"virtual_machine", "machine_from_chips", "machine_from_size"]
"virtual_machine"]
7 changes: 4 additions & 3 deletions spinn_machine/chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

from spinn_utilities.ordered_set import OrderedSet
from .machine import Machine
from spinn_machine.data import MachineDataView
from .processor import Processor

standard_processors = {}
Expand Down Expand Up @@ -112,8 +112,9 @@ def __generate_processors(self, n_processors, down_cores):
for i in range(1, n_processors):
if i not in down_cores:
processors[i] = Processor.factory(i)
self._n_user_processors = \
n_processors - Machine.NON_USER_CORES - len(down_cores)
self._n_user_processors = (
n_processors - len(down_cores) -
MachineDataView.get_machine_version().n_non_user_cores)
return processors

def is_processor_with_id(self, processor_id):
Expand Down
33 changes: 33 additions & 0 deletions spinn_machine/data/machine_data_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

from spinn_utilities.data import UtilsDataView
from spinn_machine.version.version_factory import version_factory
# pylint: disable=protected-access


Expand All @@ -37,6 +38,7 @@ class _MachineDataModel(object):
# Data values cached
"_machine",
"_machine_generator",
"_machine_version",
"_user_accessed_machine"
]

Expand All @@ -55,6 +57,7 @@ def _clear(self):
"""
self._hard_reset()
self._machine_generator = None
self._machine_version = None

def _hard_reset(self):
"""
Expand Down Expand Up @@ -94,11 +97,26 @@ def has_machine(cls):
"""
Reports if a machine is currently set or can be mocked.

Unlike has_existing_machine for unit tests this will return True even
if a Machine has not yet been created

:rtype: bool
"""
return (cls.__data._machine is not None or
cls._is_mocked())

@classmethod
def has_existing_machine(cls):
"""
Reports if a machine is currently already created.

Unlike has_machine this method returns false if a machine could be
mocked

:rtype: bool
"""
return cls.__data._machine

@classmethod
def get_machine(cls):
"""
Expand Down Expand Up @@ -217,3 +235,18 @@ def where_is_chip(cls, chip):
if cls.__data._machine is None:
return "Chip is from a previous machine"
return str(ex)

@classmethod
def get_machine_version(cls):
"""
Returns the Machine Version if it has or can be set.

` May call version_factory to create the version

:return: A superclass of AbstractVersion
:rtype: ~spinn_machine.version.abstract_version.py
:raises SpinnMachineException: If the cfg version is not set correctly
"""
if cls.__data._machine_version is None:
cls.__data._machine_version = version_factory()
return cls.__data._machine_version
18 changes: 6 additions & 12 deletions spinn_machine/full_wrap_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,28 @@ def multiple_48_chip_boards(self):

@overrides(Machine.get_xys_by_ethernet)
def get_xys_by_ethernet(self, ethernet_x, ethernet_y):
for (x, y) in self._local_xys:
for (x, y) in self._chip_core_map:
chip_x = (x + ethernet_x) % self._width
chip_y = (y + ethernet_y) % self._height
yield (chip_x, chip_y)

@overrides(Machine.get_xy_cores_by_ethernet)
def get_xy_cores_by_ethernet(self, ethernet_x, ethernet_y):
if (self._width == self._height == 2):
n_cores = Machine.max_cores_per_chip()
for (x, y) in self._local_xys:
# if ethernet_x/y != 0 GIGO mode so ignore ethernet
yield (x, y), n_cores
else:
for (x, y), n_cores in self.CHIPS_PER_BOARD.items():
yield (((x + ethernet_x) % self._width,
(y + ethernet_y) % self._height), n_cores)
for (x, y), n_cores in self._chip_core_map.items():
yield (((x + ethernet_x) % self._width,
(y + ethernet_y) % self._height), n_cores)

@overrides(Machine.get_existing_xys_by_ethernet)
def get_existing_xys_by_ethernet(self, ethernet_x, ethernet_y):
for (x, y) in self._local_xys:
for (x, y) in self._chip_core_map:
chip_xy = ((x + ethernet_x) % self._width,
(y + ethernet_y) % self._height)
if chip_xy in self._chips:
yield chip_xy

@overrides(Machine.get_down_xys_by_ethernet)
def get_down_xys_by_ethernet(self, ethernet_x, ethernet_y):
for (x, y) in self._local_xys:
for (x, y) in self._chip_core_map:
chip_xy = ((x + ethernet_x) % self._width,
(y + ethernet_y) % self._height)
if (chip_xy) not in self._chips:
Expand Down
8 changes: 4 additions & 4 deletions spinn_machine/horizontal_wrap_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,27 @@ def multiple_48_chip_boards(self):

@overrides(Machine.get_xys_by_ethernet)
def get_xys_by_ethernet(self, ethernet_x, ethernet_y):
for (x, y) in self._local_xys:
for (x, y) in self._chip_core_map:
chip_x = (x + ethernet_x) % self._width
chip_y = (y + ethernet_y)
yield (chip_x, chip_y)

@overrides(Machine.get_xy_cores_by_ethernet)
def get_xy_cores_by_ethernet(self, ethernet_x, ethernet_y):
for (x, y), n_cores in self.CHIPS_PER_BOARD.items():
for (x, y), n_cores in self._chip_core_map.items():
yield ((x + ethernet_x) % self._width, (y + ethernet_y)), n_cores

@overrides(Machine.get_existing_xys_by_ethernet)
def get_existing_xys_by_ethernet(self, ethernet_x, ethernet_y):
for (x, y) in self._local_xys:
for (x, y) in self._chip_core_map:
chip_xy = ((x + ethernet_x) % self._width,
(y + ethernet_y))
if chip_xy in self._chips:
yield chip_xy

@overrides(Machine.get_down_xys_by_ethernet)
def get_down_xys_by_ethernet(self, ethernet_x, ethernet_y):
for (x, y) in self._local_xys:
for (x, y) in self._chip_core_map:
chip_xy = ((x + ethernet_x) % self._width,
(y + ethernet_y))
if (chip_xy) not in self._chips:
Expand Down
4 changes: 2 additions & 2 deletions spinn_machine/json_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from .chip import Chip
from .router import Router
from .link import Link
from .machine_factory import machine_from_size


logger = FormatAdapter(logging.getLogger(__name__))
Expand Down Expand Up @@ -58,7 +57,8 @@ def machine_from_json(j_machine):
width = j_machine["width"]
height = j_machine["height"]

machine = machine_from_size(width, height, origin="Json")
machine = MachineDataView.get_machine_version().create_machine(
width, height, origin="Json")
s_monitors = j_machine["standardResources"]["monitors"]
s_router_entries = j_machine["standardResources"]["routerEntries"]
s_sdram = j_machine["standardResources"]["sdram"]
Expand Down
Loading