Skip to content

Commit

Permalink
added a spin2 48 Chip version
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Apr 19, 2024
1 parent 008acdc commit 2dca096
Show file tree
Hide file tree
Showing 11 changed files with 1,181 additions and 659 deletions.
5 changes: 3 additions & 2 deletions spinn_machine/version/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .version_factory import FIVE, SPIN2_1CHIP, THREE, version_factory
from .version_factory import FIVE, SPIN2_1CHIP, SPIN2_48CHIP, THREE,\
version_factory

__all__ = ["FIVE", "SPIN2_1CHIP", "THREE", "version_factory"]
__all__ = ["FIVE", "SPIN2_1CHIP", "SPIN2_48CHIP", "THREE", "version_factory"]
58 changes: 15 additions & 43 deletions spinn_machine/version/version_201.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,99 +22,71 @@
from spinn_machine.no_wrap_machine import NoWrapMachine
from spinn_machine.machine import Machine

from .abstract_version import AbstractVersion
from .version_factory import SPIN2_1CHIP
from .version_spin2 import VersionSpin2

CHIPS_PER_BOARD: Final = {(0, 0): 152}


class Version201(AbstractVersion, metaclass=AbstractBase):
class Version201(VersionSpin2):
# pylint: disable=abstract-method
"""
Code for the 1 Chip test Spin2 board versions
"""

__slots__ = ()

def __init__(self) -> None:
super().__init__(max_cores_per_chip=152,
max_sdram_per_chip=1073741824)

@property
@overrides(AbstractVersion.n_scamp_cores)
def n_scamp_cores(self) -> int:
return 1

@property
@overrides(AbstractVersion.n_router_entries)
def n_router_entries(self) -> int:
return 16384

@property
@overrides(AbstractVersion.minimum_cores_expected)
def minimum_cores_expected(self) -> int:
return 100

@property
@overrides(AbstractVersion.clock_speeds_hz)
def clock_speeds_hz(self) -> List[int]:
return [150, 300]

@property
@overrides(AbstractVersion.dtcm_bytes)
def dtcm_bytes(self) -> int:
raise NotImplementedError

@property
@overrides(AbstractVersion.name)
@overrides(VersionSpin2.name)
def name(self) -> str:
return "Spin2 1 Chip"

@property
@overrides(AbstractVersion.number)
@overrides(VersionSpin2.number)
def number(self) -> int:
return 201
return SPIN2_1CHIP

@property
@overrides(AbstractVersion.board_shape)
@overrides(VersionSpin2.board_shape)
def board_shape(self) -> Tuple[int, int]:
return (1, 1)

@property
@overrides(AbstractVersion.chip_core_map)
@overrides(VersionSpin2.chip_core_map)
def chip_core_map(self) -> Mapping[XY, int]:
return CHIPS_PER_BOARD

@overrides(AbstractVersion.get_potential_ethernet_chips)
@overrides(VersionSpin2.get_potential_ethernet_chips)
def get_potential_ethernet_chips(
self, width: int, height: int) -> Sequence[XY]:
return [(0, 0)]

@overrides(AbstractVersion._verify_size)
@overrides(VersionSpin2._verify_size)
def _verify_size(self, width: int, height: int):
if width != 1:
raise SpinnMachineException(f"Unexpected {width=}")
if height != 1:
raise SpinnMachineException(f"Unexpected {height=}")

@overrides(AbstractVersion._create_machine)
@overrides(VersionSpin2._create_machine)
def _create_machine(self, width: int, height: int, origin: str) -> Machine:
return NoWrapMachine(width, height, CHIPS_PER_BOARD, origin)

@overrides(AbstractVersion.illegal_ethernet_message)
@overrides(VersionSpin2.illegal_ethernet_message)
def illegal_ethernet_message(self, x: int, y: int) -> Optional[str]:
if x != 0 or y != 0:
return "Only Chip 0, 0 may be an Ethernet Chip"
return None

@property
@overrides(AbstractVersion.supports_multiple_boards)
@overrides(VersionSpin2.supports_multiple_boards)
def supports_multiple_boards(self) -> bool:
return False

@overrides(AbstractVersion.spinnaker_links)
@overrides(VersionSpin2.spinnaker_links)
def spinnaker_links(self) -> List[Tuple[int, int, int]]:
return []

@overrides(AbstractVersion.fpga_links)
@overrides(VersionSpin2.fpga_links)
def fpga_links(self) -> List[Tuple[int, int, int, int, int]]:
return []
75 changes: 75 additions & 0 deletions spinn_machine/version/version_248.py
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 []
101 changes: 101 additions & 0 deletions spinn_machine/version/version_48_chips.py
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
Loading

0 comments on commit 2dca096

Please sign in to comment.