Skip to content

Commit

Permalink
Merge pull request #464 from SpiNNakerManchester/fixed_location
Browse files Browse the repository at this point in the history
Fixed location
  • Loading branch information
rowleya committed Sep 27, 2022
2 parents ceb0414 + 6cd99eb commit e776117
Show file tree
Hide file tree
Showing 41 changed files with 151 additions and 690 deletions.
40 changes: 4 additions & 36 deletions pacman/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,6 @@
* Vertices in the Machine Graph must be able to fit on a single\
chip of the machine in terms of resource usage.
* A Vertex can have a number of constraints which must be\
respected by any algorithm which uses the graph. Algorithms\
must check that they can support the given constraints and must\
fail if they cannot. Provided constraints include support for:
* The maximum number of atoms which any Machine Graph Vertex\
can contain for a given Application Graph vertex
* The chip and/or processor on to which a Machine Graph\
Vertex should be placed.
* A set of Application Graph Vertices whose corresponding\
Machine Graph vertices should contain the same number of\
atoms.
* A set of Application Graph Vertices whose corresponding\
Machine Graph vertices should be placed on the same chip\
if they contain the same atom.
* It should be possible to create new constraints as the need\
arises.
* Multiple edges can exist between the same two vertices.
* It must be possible to build the Machine Graph directly without\
Expand Down Expand Up @@ -98,21 +76,14 @@
algorithms or provide one, although a default should be provided\
in the absence of such a choice .
* Any partitioning constraints should be met; if there are any\
* Any fixed_location should be met; if there are any\
that cannot, or that are not understood by the algorithm in use\
an exception should be thrown. Non-partitioning constraints can\
be ignored, although these can be used if it makes sense for\
the given algorithm.
an exception should be thrown.
* It must be possible to create at least one grouping of the\
generated Vertices so that each group fits within the\
resources provided by a single chip on the machine.
* It should not be assumed that a given grouping of Vertices\
will be the final grouping on the machine, although it is\
acceptable to make hints through additional constraints about\
what is likely to work.
* The machine itself must not be altered by the partitioning, so\
that it can be used in further processing.
Expand Down Expand Up @@ -142,11 +113,8 @@
algorithms or provide one, although a default should be provided\
in the absence of such a choice.
* Any placement constraints should be met; if there are any that\
cannot, or that are not understood by placement algorithm, an\
exception should be thrown. Non-placement constraints can be\
ignored, although these can be used if it makes sense for the\
given algorithm.
* Any fixed_location should be met; if not an\
exception should be thrown.
* The machine itself should not be altered by placement so that\
it can be used in further processing.
Expand Down
18 changes: 0 additions & 18 deletions pacman/model/constraints/__init__.py

This file was deleted.

23 changes: 0 additions & 23 deletions pacman/model/constraints/abstract_constraint.py

This file was deleted.

19 changes: 0 additions & 19 deletions pacman/model/constraints/placer_constraints/__init__.py

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions pacman/model/graphs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .abstract_single_source_partition import AbstractSingleSourcePartition
from .abstract_supports_sdram_edges import AbstractSupportsSDRAMEdges


__all__ = [
"AbstractEdge", "AbstractEdgePartition",
"AbstractMultiplePartition", "AbstractSingleSourcePartition",
Expand Down
2 changes: 0 additions & 2 deletions pacman/model/graphs/abstract_edge_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
from pacman.exceptions import (
PacmanInvalidParameterException, PacmanAlreadyExistsException)

_REPR_TEMPLATE = "{}(identifier={}, edges={}, constraints={}, label={})"


class AbstractEdgePartition(object, metaclass=AbstractBase):
""" A collection of edges which start at a single vertex which have the\
Expand Down
47 changes: 36 additions & 11 deletions pacman/model/graphs/abstract_vertex.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,32 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from pacman.exceptions import PacmanConfigurationException
from pacman.model.graphs.common import ConstrainedObject
from pacman.model.graphs.common import ChipAndCore


class AbstractVertex(ConstrainedObject):
class AbstractVertex(object):
""" A vertex in a graph.
"""

# Because of diamond inheritance slots must be empty
__slots__ = [
# Indicates if the Vertex has been added to a graph
"_added_to_graph",
# Label for the vertex. Changable until added to graph
"_label"]
"_label",
# the x, y (and p) this vertex MUST be placed on
"_fixed_location"
]

def __init__(self, label=None, constraints=None):
def __init__(self, label=None):
"""
:param str label: The optional name of the vertex
:param iterable(AbstractConstraint) constraints:
The optional initial constraints of the vertex
:raise PacmanInvalidParameterException:
If one of the constraints is not valid
:param fixed_location:
The optional fixed location of the vertex.
Only if the Vertex is fixed before placement.
"""

super().__init__(constraints)
self._label = label
self._added_to_graph = False
self._fixed_location = None

@property
def label(self):
Expand Down Expand Up @@ -71,3 +71,28 @@ def addedToGraph(self):
If there is an attempt to add the same vertex more than once
"""
self._added_to_graph = True

def get_fixed_location(self):
"""
The x, y and possibly p the vertex MUST be placed on.
Typically NONE! Does not have the value of a normal placememts.
Used instead of ChipAndCoreConstraint
:rtype: None or ChipAndCore
"""
return self._fixed_location

def set_fixed_location(self, x, y, p=None):
"""
:param ChipAndCore fixed_location:
"""
fixed_location = ChipAndCore(x, y, p)
if self._fixed_location is not None:
if fixed_location == self._fixed_location:
return
raise PacmanConfigurationException(
"Once set to a value fixed_location can not be changed")
self._fixed_location = fixed_location
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __is_power_of_2(self, v):
return (v & (v - 1) == 0) and (v != 0)

def _verify_sub_size(self):
""" Ensure the sub width and height are within constraints
""" Ensure the sub width and height are within restrictions
"""
if not self.__is_power_of_2(self._sub_width):
raise PacmanConfigurationException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,15 @@ class AbstractOneAppOneMachineVertex(ApplicationVertex):
# A pointer to the machine vertex set at init time
"_machine_vertex"]

def __init__(self, machine_vertex, label, constraints, n_atoms=1):
def __init__(self, machine_vertex, label, n_atoms=1):
"""
Creates an ApplicationVertex which has exactly one predefined \
MachineVertex
:param machine_vertex: MachineVertex
:param str label: The optional name of the vertex.
:param iterable(AbstractConstraint) constraints:
The optional initial constraints of the vertex.
:raise PacmanInvalidParameterException:
If one of the constraints is not valid
"""
super().__init__(label, constraints, n_atoms)
super().__init__(label, n_atoms)
self._machine_vertex = machine_vertex
super().remember_machine_vertex(machine_vertex)

Expand Down
6 changes: 2 additions & 4 deletions pacman/model/graphs/application/application_2d_fpga_vertex.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Application2DFPGAVertex(ApplicationFPGAVertex, Abstract2DDeviceVertex):
def __init__(
self, width, height, sub_width, sub_height,
incoming_fpga_connections=None, outgoing_fpga_connection=None,
label=None, constraints=None):
label=None):
"""
:param int width: The width of the vertex in atoms
Expand All @@ -52,8 +52,6 @@ def __init__(
be sent to the device.
:type outgoing_fpga_connection: FPGAConnection or None
:param str label: The optional name of the vertex.
:param iterable(AbstractConstraint) constraints:
The optional initial constraints of the vertex.
"""
# Set variables first as this lets us call properties
self.__width = width
Expand All @@ -62,7 +60,7 @@ def __init__(
self.__sub_height = sub_height
super(Application2DFPGAVertex, self).__init__(
width * height, incoming_fpga_connections,
outgoing_fpga_connection, label, constraints,
outgoing_fpga_connection, label,
n_machine_vertices_per_link=self._n_sub_rectangles)
self._verify_sub_size()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Application2DSpiNNakerLinkVertex(
def __init__(
self, width, height, sub_width, sub_height,
spinnaker_link_id, board_address=None, label=None,
constraints=None, incoming=True, outgoing=False):
incoming=True, outgoing=False):
"""
:param int width: The width of the vertex in atoms
:param int height: The height of the vertex in atoms
Expand All @@ -47,8 +47,6 @@ def __init__(
The optional IP address of the board to which the device is
connected e.g. in a multi-board system
:param str label: The optional name of the vertex.
:param iterable(AbstractConstraint) constraints:
The optional initial constraints of the vertex.
:param bool incoming:
Whether the device supports sending traffic into spinnaker
:param bool outgoing:
Expand All @@ -61,7 +59,7 @@ def __init__(
self.__sub_height = sub_height
super(Application2DSpiNNakerLinkVertex, self).__init__(
width * height, spinnaker_link_id, board_address,
label, constraints, n_machine_vertices=self._n_sub_rectangles,
label, n_machine_vertices=self._n_sub_rectangles,
incoming=incoming, outgoing=outgoing)
self._verify_sub_size()

Expand Down
6 changes: 2 additions & 4 deletions pacman/model/graphs/application/application_fpga_vertex.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ApplicationFPGAVertex(ApplicationVirtualVertex):

def __init__(
self, n_atoms, incoming_fpga_connections=None,
outgoing_fpga_connection=None, label=None, constraints=None,
outgoing_fpga_connection=None, label=None,
n_machine_vertices_per_link=1):
"""
Expand All @@ -47,13 +47,11 @@ def __init__(
be sent to the device.
:type outgoing_fpga_connection: FPGAConnection or None
:param str label: The optional name of the vertex.
:param iterable(AbstractConstraint) constraints:
The optional initial constraints of the vertex.
:param int n_machine_vertices_per_link:
The optional number of machine vertices to create for each FPGA
link (1 by default)
"""
super().__init__(label=label, constraints=constraints)
super().__init__(label=label)
self._n_atoms = n_atoms
self._incoming_fpga_connections = incoming_fpga_connections
self._outgoing_fpga_connection = outgoing_fpga_connection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class ApplicationSpiNNakerLinkVertex(ApplicationVirtualVertex):

def __init__(
self, n_atoms, spinnaker_link_id, board_address=None, label=None,
constraints=None, n_machine_vertices=1,
incoming=True, outgoing=True):
n_machine_vertices=1, incoming=True, outgoing=True):
"""
:param int n_atoms: The number of atoms in the vertex
:param int spinnaker_link_id:
Expand All @@ -42,10 +41,8 @@ def __init__(
The optional IP address of the board to which the device is
connected e.g. in a multi-board system
:param str label: The optional name of the vertex.
:param iterable(AbstractConstraint) constraints:
The optional initial constraints of the vertex.
"""
super().__init__(label=label, constraints=constraints)
super().__init__(label=label)
self._n_atoms = self.round_n_atoms(n_atoms)
self._spinnaker_link_id = spinnaker_link_id
self._board_address = board_address
Expand Down

0 comments on commit e776117

Please sign in to comment.