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

Interdimensional compatibility #516

Merged
merged 53 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
aec9fd6
Split Slice Object into simple Slice and Multi Deminsional Slice
Christian-B Mar 10, 2023
4b29e56
better support for md slices
Christian-B Mar 13, 2023
6bd5549
flake8
Christian-B Mar 14, 2023
bdb1205
dont need atoms shape for 1d raster ids
Christian-B Mar 14, 2023
c5d4cea
merged in master
Christian-B Mar 16, 2023
5ab7669
merged in master
Christian-B Mar 28, 2023
8e80832
merge
Christian-B Mar 30, 2023
c04ca7f
merged in master
Christian-B Mar 30, 2023
280db5d
merged in master
Christian-B Apr 11, 2023
4590488
merged in master
Christian-B Apr 14, 2023
9ec66e0
merged in master
Christian-B Apr 18, 2023
910ca6f
merged in master
Christian-B Apr 18, 2023
330d8d2
merge
Christian-B Apr 20, 2023
6fc7489
merged in master
Christian-B Apr 21, 2023
9fcfc51
merged in master
Christian-B Apr 24, 2023
c696ef3
merged in master
Christian-B Apr 26, 2023
8d0050d
merged in master
Christian-B Apr 27, 2023
86a4207
merge
Christian-B May 2, 2023
585b77e
remove test for stuff removed
Christian-B May 3, 2023
597f9c7
fix overirde
Christian-B May 3, 2023
087851f
fix merge
Christian-B May 3, 2023
a27f321
Update functions for use without fields
rowleya May 24, 2023
16da918
No need for this any more
rowleya May 24, 2023
24ed9e3
Get power of 2 to a common place
rowleya May 24, 2023
6af032b
Make things public that help outside
rowleya May 24, 2023
af33f03
Avoid merging when the mask isn't right
rowleya May 26, 2023
3c968e2
Merge branch 'master' into interdimensional_compatibility
rowleya Jun 9, 2023
a8e0273
Merge remote-tracking branch 'github/md_slice' into
rowleya Jun 13, 2023
f3d4846
Ensure that nD vertices are divisible by max_atoms_per_core
rowleya Jun 13, 2023
a94d7a7
Merge branch 'master' into interdimensional_compatibility
rowleya Sep 15, 2023
7c9c3aa
Merge branch 'master' into interdimensional_compatibility
rowleya Sep 18, 2023
f1bb2b0
Merge branch 'interdimensional_compatibility' of https://github.com/S…
rowleya Sep 18, 2023
8dee34e
Merge branch 'master' into interdimensional_compatibility
rowleya Sep 18, 2023
efd1dd1
Merge branch 'master' into interdimensional_compatibility
rowleya Oct 11, 2023
6c8f9b9
Merge branch 'master' into interdimensional_compatibility
rowleya Oct 18, 2023
c91a37b
Merge branch 'master' into interdimensional_compatibility
rowleya Oct 24, 2023
bcf5a39
Move code here for vertices too
rowleya Oct 30, 2023
d000d6e
Fix doc
rowleya Oct 31, 2023
95ba9d1
Fix and test
rowleya Oct 31, 2023
c25b6f6
Add and test reversal functions
rowleya Oct 31, 2023
d7368d5
Merge branch 'master' into interdimensional_compatibility
rowleya Nov 3, 2023
4e6386c
Flake8
rowleya Nov 3, 2023
ea7491a
Fix typing
rowleya Nov 3, 2023
493fe1f
Fix here too
rowleya Nov 3, 2023
8d9aa2a
Remove unused
rowleya Nov 3, 2023
83799a2
More type fixes
rowleya Nov 3, 2023
4cdd87b
Merge branch 'master' into interdimensional_compatibility
rowleya Nov 10, 2023
13466bb
by default n_atoms == app_vertex.get_max_atoms_per_core
Christian-B Nov 23, 2023
cec0c80
Allow float to pass even though not technically allowed
rowleya Nov 27, 2023
8e4aaa2
Merge branch 'interdimensional_compatibility' of https://github.com/S…
rowleya Nov 27, 2023
3cdffda
Mypy makes things convoluted!
rowleya Nov 27, 2023
3f8a463
Duplicate here
rowleya Nov 27, 2023
699d909
Merge branch 'master' into interdimensional_compatibility
rowleya Nov 27, 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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from spinn_utilities.overrides import overrides
from spinn_utilities.typing.coords import XY
from pacman.exceptions import PacmanConfigurationException
from pacman.utilities.utility_calls import get_n_bits
from pacman.utilities.utility_calls import get_n_bits, is_power_of_2
from pacman.utilities.constants import BITS_IN_KEY
from pacman.model.routing_info.base_key_and_mask import BaseKeyAndMask
from pacman.model.graphs.application import ApplicationVertex
Expand All @@ -41,7 +41,7 @@ class Abstract2DDeviceVertex(object, metaclass=AbstractBase):

@property
@abstractmethod
def _width(self) -> int:
def width(self) -> int:
"""
The width of the device.

Expand All @@ -51,7 +51,7 @@ def _width(self) -> int:

@property
@abstractmethod
def _height(self) -> int:
def height(self) -> int:
"""
The height of the device.

Expand All @@ -61,7 +61,7 @@ def _height(self) -> int:

@property
@abstractmethod
def _sub_width(self) -> int:
def sub_width(self) -> int:
"""
The width of the sub-rectangles to divide the input into.

Expand All @@ -71,7 +71,7 @@ def _sub_width(self) -> int:

@property
@abstractmethod
def _sub_height(self) -> int:
def sub_height(self) -> int:
"""
The height of the sub-rectangles to divide the input into.

Expand All @@ -85,33 +85,24 @@ def _sub_height(self) -> int:
def atoms_shape(self) -> Tuple[int, ...]:
raise NotImplementedError

def __is_power_of_2(self, v: int) -> bool:
"""
Determine if a value is a power of 2.

:param int v: The value to test
:rtype: bool
"""
return (v & (v - 1) == 0) and (v != 0)

def _verify_sub_size(self) -> None:
"""
Ensure the sub width and height are within restrictions.
"""
if not self.__is_power_of_2(self._sub_width):
if not is_power_of_2(self.sub_width):
raise PacmanConfigurationException(
f"sub_width ({self._sub_width}) must be a power of 2")
if not self.__is_power_of_2(self._sub_height):
f"sub_width ({self.sub_width}) must be a power of 2")
if not is_power_of_2(self.sub_height):
raise PacmanConfigurationException(
f"sub_height ({self._sub_height}) must be a power of 2")
if self._sub_width > self._width:
f"sub_height ({self.sub_height}) must be a power of 2")
if self.sub_width > self.width:
raise PacmanConfigurationException(
f"sub_width ({self._sub_width}) must not be greater than "
f"width ({self._width})")
if self._sub_height > self._height:
f"sub_width ({self.sub_width}) must not be greater than "
f"width ({self.width})")
if self.sub_height > self.height:
raise PacmanConfigurationException(
f"sub_height ({self._sub_height}) must not be greater than "
f"height ({self._height})")
f"sub_height ({self.sub_height}) must not be greater than "
f"height ({self.height})")

@property
def _n_sub_rectangles(self) -> int:
Expand All @@ -120,8 +111,8 @@ def _n_sub_rectangles(self) -> int:

:rtype: int
"""
return (int(math.ceil(self._width / self._sub_width)) *
int(math.ceil(self._height / self._sub_height)))
return (int(math.ceil(self.width / self.sub_width)) *
int(math.ceil(self.height / self.sub_height)))

def _sub_square_from_index(self, index: int) -> XY:
"""
Expand All @@ -131,7 +122,7 @@ def _sub_square_from_index(self, index: int) -> XY:
:rtype: tuple(int, int)
"""
n_squares_per_row = int(math.ceil(
self._width / self._sub_width))
self.width / self.sub_width))
x_index = index % n_squares_per_row
y_index = index // n_squares_per_row

Expand All @@ -146,13 +137,13 @@ def _get_slice(self, index: int) -> MDSlice:
:rtype: Slice
"""
x_index, y_index = self._sub_square_from_index(index)
lo_atom_x = x_index * self._sub_width
lo_atom_y = y_index * self._sub_height
n_atoms_per_subsquare = self._sub_width * self._sub_height
lo_atom_x = x_index * self.sub_width
lo_atom_y = y_index * self.sub_height
n_atoms_per_subsquare = self.sub_width * self.sub_height
lo_atom = index * n_atoms_per_subsquare
hi_atom = (lo_atom + n_atoms_per_subsquare) - 1
return MDSlice(
lo_atom, hi_atom, (self._sub_width, self._sub_height),
lo_atom, hi_atom, (self.sub_width, self.sub_height),
(lo_atom_x, lo_atom_y), self.atoms_shape)

def _get_key_and_mask(self, base_key: int, index: int) -> BaseKeyAndMask:
Expand Down Expand Up @@ -185,26 +176,14 @@ def _mask(self) -> int:
(sub_y_mask << self._y_index_shift) +
(sub_x_mask << self._x_index_shift))

@property
def _key_fields(self) -> Tuple[
Tuple[int, int, int, int], Tuple[int, int, int, int]]:
"""
The fields in the key for X and Y.

:return: (start, size, mask, shift) for each of X and Y
:rtype: tuple(tuple(int, int, int int), tuple(int, int, int, int))
"""
return ((0, self._width, self._source_x_mask, self._source_x_shift),
(0, self._height, self._source_y_mask, self._source_y_shift))

@property
def _x_bits(self) -> int:
"""
The number of bits to use for X.

:rtype: int
"""
return get_n_bits(self._width)
return get_n_bits(self.width)

@property
def _y_bits(self) -> int:
Expand All @@ -213,7 +192,7 @@ def _y_bits(self) -> int:

:rtype: int
"""
return get_n_bits(self._height)
return get_n_bits(self.height)

@property
def _sub_x_bits(self) -> int:
Expand All @@ -222,7 +201,7 @@ def _sub_x_bits(self) -> int:

:rtype: int
"""
n_per_row = int(math.ceil(self._width / self._sub_width))
n_per_row = int(math.ceil(self.width / self.sub_width))
return get_n_bits(n_per_row)

@property
Expand All @@ -232,7 +211,7 @@ def _sub_y_bits(self) -> int:

:rtype: int
"""
n_per_col = int(math.ceil(self._height / self._sub_height))
n_per_col = int(math.ceil(self.height / self.sub_height))
return get_n_bits(n_per_col)

@property
Expand Down
16 changes: 8 additions & 8 deletions pacman/model/graphs/application/application_2d_fpga_vertex.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,23 @@ def __init__(
self._verify_sub_size()

@property
@overrides(Abstract2DDeviceVertex._width)
def _width(self) -> int:
@overrides(Abstract2DDeviceVertex.width)
def width(self) -> int:
return self.__width

@property
@overrides(Abstract2DDeviceVertex._height)
def _height(self) -> int:
@overrides(Abstract2DDeviceVertex.height)
def height(self) -> int:
return self.__height

@property
@overrides(Abstract2DDeviceVertex._sub_width)
def _sub_width(self) -> int:
@overrides(Abstract2DDeviceVertex.sub_width)
def sub_width(self) -> int:
return self.__sub_width

@property
@overrides(Abstract2DDeviceVertex._sub_height)
def _sub_height(self) -> int:
@overrides(Abstract2DDeviceVertex.sub_height)
def sub_height(self) -> int:
return self.__sub_height

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,23 @@ def __init__(
self._verify_sub_size()

@property
@overrides(Abstract2DDeviceVertex._width)
def _width(self) -> int:
@overrides(Abstract2DDeviceVertex.width)
def width(self) -> int:
return self.__width

@property
@overrides(Abstract2DDeviceVertex._height)
def _height(self) -> int:
@overrides(Abstract2DDeviceVertex.height)
def height(self) -> int:
return self.__height

@property
@overrides(Abstract2DDeviceVertex._sub_width)
def _sub_width(self) -> int:
@overrides(Abstract2DDeviceVertex.sub_width)
def sub_width(self) -> int:
return self.__sub_width

@property
@overrides(Abstract2DDeviceVertex._sub_height)
def _sub_height(self) -> int:
@overrides(Abstract2DDeviceVertex.sub_height)
def sub_height(self) -> int:
return self.__sub_height

@property
Expand Down
Loading