-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
008acdc
commit 2dca096
Showing
11 changed files
with
1,181 additions
and
659 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Copyright (c) 2024 The University of Manchester | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from typing import Final, List, Mapping, Optional, Sequence, Tuple | ||
|
||
from spinn_utilities.abstract_base import AbstractBase | ||
from spinn_utilities.typing.coords import XY | ||
from spinn_utilities.overrides import overrides | ||
|
||
from spinn_machine.exceptions import SpinnMachineException | ||
from spinn_machine.no_wrap_machine import NoWrapMachine | ||
from spinn_machine.machine import Machine | ||
from spinn_machine import SpiNNakerTriadGeometry | ||
|
||
from .version_48_chips import Version48Chips | ||
from .version_factory import SPIN2_48CHIP | ||
from .version_spin2 import VersionSpin2 | ||
|
||
# TODO get real values | ||
CHIPS_PER_BOARD: Final = { | ||
(0, 0): 152, (0, 1): 152, (0, 2): 152, (0, 3): 152, (1, 0): 152, | ||
(1, 1): 151, (1, 2): 152, (1, 3): 151, (1, 4): 152, (2, 0): 152, | ||
(2, 1): 152, (2, 2): 152, (2, 3): 152, (2, 4): 152, (2, 5): 152, | ||
(3, 0): 152, (3, 1): 151, (3, 2): 152, (3, 3): 151, (3, 4): 152, | ||
(3, 5): 150, (3, 6): 152, (4, 0): 152, (4, 1): 152, (4, 2): 152, | ||
(4, 3): 150, (4, 4): 152, (4, 5): 152, (4, 6): 152, (4, 7): 152, | ||
(5, 1): 152, (5, 2): 151, (5, 3): 152, (5, 4): 151, (5, 5): 152, | ||
(5, 6): 151, (5, 7): 152, (6, 2): 151, (6, 3): 151, (6, 4): 152, | ||
(6, 5): 152, (6, 6): 152, (6, 7): 152, (7, 3): 152, (7, 4): 152, | ||
(7, 5): 152, (7, 6): 152, (7, 7): 152 | ||
} | ||
|
||
class Version248(VersionSpin2, Version48Chips): | ||
# pylint: disable=abstract-method | ||
""" | ||
Code for the 48 Chip Spin2 board versions | ||
""" | ||
|
||
__slots__ = () | ||
|
||
@property | ||
@overrides(VersionSpin2.name) | ||
def name(self) -> str: | ||
return "Spin2 48 Chips" | ||
|
||
@property | ||
@overrides(VersionSpin2.number) | ||
def number(self) -> int: | ||
return SPIN2_48CHIP | ||
|
||
@property | ||
@overrides(VersionSpin2.chip_core_map) | ||
def chip_core_map(self) -> Mapping[XY, int]: | ||
return CHIPS_PER_BOARD | ||
|
||
@overrides(VersionSpin2.spinnaker_links) | ||
def spinnaker_links(self) -> List[Tuple[int, int, int]]: | ||
# TODO | ||
return [] | ||
|
||
@overrides(VersionSpin2.fpga_links) | ||
def fpga_links(self) -> List[Tuple[int, int, int, int, int]]: | ||
# TODO | ||
return [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# Copyright (c) 2023 The University of Manchester | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import math | ||
from typing import Optional, Sequence, Tuple | ||
from spinn_utilities.overrides import overrides | ||
from spinn_utilities.typing.coords import XY | ||
from spinn_machine.exceptions import SpinnMachineException | ||
from spinn_machine.machine import Machine | ||
from spinn_machine.full_wrap_machine import FullWrapMachine | ||
from spinn_machine.horizontal_wrap_machine import HorizontalWrapMachine | ||
from spinn_machine.no_wrap_machine import NoWrapMachine | ||
from spinn_machine.vertical_wrap_machine import VerticalWrapMachine | ||
from spinn_machine import SpiNNakerTriadGeometry | ||
from .abstract_version import AbstractVersion | ||
|
||
|
||
class Version48Chips(AbstractVersion): | ||
""" | ||
Code shared by 48 Chip boards | ||
""" | ||
__slots__ = () | ||
|
||
@property | ||
@overrides(AbstractVersion.board_shape) | ||
def board_shape(self) -> Tuple[int, int]: | ||
return (8, 8) | ||
|
||
|
||
@overrides(AbstractVersion.get_potential_ethernet_chips) | ||
def get_potential_ethernet_chips( | ||
self, width: int, height: int) -> Sequence[XY]: | ||
geometry = SpiNNakerTriadGeometry.get_spinn5_geometry() | ||
return geometry.get_potential_ethernet_chips(width, height) | ||
|
||
@overrides(AbstractVersion._verify_size) | ||
def _verify_size(self, width: int, height: int): | ||
if width == height == 8: | ||
# 1 board | ||
return | ||
if width % 12 not in [0, 4]: | ||
raise SpinnMachineException( | ||
f"{width=} must be a multiple of 12 " | ||
f"or a multiple of 12 plus 4") | ||
if height % 12 not in [0, 4]: | ||
raise SpinnMachineException( | ||
f"{height=} must be a multiple of 12 " | ||
f"or a multiple of 12 plus 4") | ||
|
||
@overrides(AbstractVersion._create_machine) | ||
def _create_machine(self, width: int, height: int, origin: str) -> Machine: | ||
if width % 12 == 0: | ||
if height % 12 == 0: | ||
return FullWrapMachine( | ||
width, height, self.chip_core_map, origin) | ||
else: | ||
return HorizontalWrapMachine( | ||
width, height, self.chip_core_map, origin) | ||
else: | ||
if height % 12 == 0: | ||
return VerticalWrapMachine( | ||
width, height, self.chip_core_map, origin) | ||
else: | ||
return NoWrapMachine(width, height, self.chip_core_map, origin) | ||
|
||
@overrides(AbstractVersion.illegal_ethernet_message) | ||
def illegal_ethernet_message(self, x: int, y: int) -> Optional[str]: | ||
if x % 4 != 0: | ||
return "Only Chip with X divisible by 4 may be an Ethernet Chip" | ||
if (x + y) % 12 != 0: | ||
return "Only Chip with x + y divisible by 12 " \ | ||
"may be an Ethernet Chip" | ||
return None | ||
|
||
@overrides(AbstractVersion.size_from_n_boards) | ||
def size_from_n_boards(self, n_boards: int) -> Tuple[int, int]: | ||
if n_boards <= 1: | ||
return 8, 8 | ||
# This replicates how spalloc does it | ||
# returning a rectangle of triads | ||
triads = math.ceil(n_boards / 3) | ||
width = math.ceil(math.sqrt(triads)) | ||
height = math.ceil(triads / width) | ||
return width * 12 + 4, height * 12 + 4 | ||
|
||
@property | ||
@overrides(AbstractVersion.supports_multiple_boards) | ||
def supports_multiple_boards(self) -> bool: | ||
return True |
Oops, something went wrong.