pacman.model.graphs.application package¶
Subpackages¶
Module contents¶
- class pacman.model.graphs.application.Application2DFPGAVertex(width: int, height: int, sub_width: int, sub_height: int, incoming_fpga_connections: List[FPGAConnection] | None = None, outgoing_fpga_connection: FPGAConnection | None = None, label: str | None = None)¶
Bases:
ApplicationFPGAVertex
,Abstract2DDeviceVertex
A device connected to an FPGA with input or output in two dimensions.
- Parameters:
width (int) – The width of the vertex in atoms
height (int) – The height of the vertex in atoms
sub_width (int) – The width of the sub-rectangle to break the vertex up into
sub_height (int) – The height of the sub-rectangle to break the vertex up into
incoming_fpga_connections (list(FPGAConnection) or None) – The connections from one or more FPGAs that that packets are expected to be received from for this device, or None if no incoming traffic is expected from the device
outgoing_fpga_connection (FPGAConnection or None) – The connection to an FPGA that packets to be sent to this device should be sent down, or None if no outgoing traffic is expected to be sent to the device.
label (str) – The optional name of the vertex.
- property atoms_shape: Tuple[int, ...]¶
The “shape” of the atoms in the vertex i.e. how the atoms are split between the dimensions of the vertex. By default everything is 1-dimensional, so the value will be a 1-tuple but can be overridden by a vertex that supports multiple dimensions.
- get_incoming_slice_for_link(link: FPGAConnection, index: int) Slice [source]¶
Get the slice to be given to the connection from the given link.
- Parameters:
link (FPGAConnection) – The FPGA connection to get the slice for
index (int) – The index of the connection on the FGPA link, for when n_machine_vertices_per_link > 1
- Return type:
- class pacman.model.graphs.application.Application2DSpiNNakerLinkVertex(width: int, height: int, sub_width: int, sub_height: int, spinnaker_link_id: int, board_address: str | None = None, label: str | None = None, incoming: bool = True, outgoing: bool = False)¶
Bases:
ApplicationSpiNNakerLinkVertex
,Abstract2DDeviceVertex
A 2D virtual application vertex that represents a device connected via a SpiNNaker link.
- Parameters:
width (int) – The width of the vertex in atoms
height (int) – The height of the vertex in atoms
sub_width (int) – The width of the sub-rectangle to break the vertex up into
sub_height (int) – The height of the sub-rectangle to break the vertex up into
spinnaker_link_id (int) – The index of the spinnaker link to which the device is connected
board_address (str) – The optional IP address of the board to which the device is connected e.g. in a multi-board system
label (str) – The optional name of the vertex.
incoming (bool) – Whether the device supports sending traffic into spinnaker
outgoing (bool) – Whether the device supports receiving traffic from spinnaker
- property atoms_shape: Tuple[int, ...]¶
The “shape” of the atoms in the vertex i.e. how the atoms are split between the dimensions of the vertex. By default everything is 1-dimensional, so the value will be a 1-tuple but can be overridden by a vertex that supports multiple dimensions.
- class pacman.model.graphs.application.ApplicationEdge(pre_vertex: ApplicationVertex, post_vertex: ApplicationVertex, label: str | None = None)¶
Bases:
AbstractEdge
[ApplicationVertex
]A simple implementation of an application edge.
- Parameters:
pre_vertex (ApplicationVertex) – The application vertex at the start of the edge.
post_vertex (ApplicationVertex) – The application vertex at the end of the edge.
label (str or None) – The name of the edge.
- property post_vertex: ApplicationVertex¶
The vertex at the end of the edge.
- Return type:
- property pre_vertex: ApplicationVertex¶
The vertex at the start of the edge.
- Return type:
- class pacman.model.graphs.application.ApplicationEdgePartition(identifier: str, pre_vertex: ApplicationVertex)¶
Bases:
AbstractSingleSourcePartition
[ApplicationVertex
,ApplicationEdge
]A simple implementation of an application edge partition that will communicate using SpiNNaker multicast packets. They have the same source(s) and semantics and so can share a single key.
- Parameters:
identifier (str) – The identifier of the partition
pre_vertex (ApplicationVertex) – The source of this partition
- add_edge(edge: ApplicationEdge)[source]¶
Add an edge to the edge partition.
- Parameters:
edge (AbstractEdge) – the edge to add
- Raises:
PacmanInvalidParameterException – If the edge does not belong in this edge partition
- class pacman.model.graphs.application.ApplicationFPGAVertex(n_atoms: int, incoming_fpga_connections: List[FPGAConnection] | None = None, outgoing_fpga_connection: FPGAConnection | None = None, label: str | None = None, n_machine_vertices_per_link: int = 1)¶
Bases:
ApplicationVirtualVertex
A virtual application vertex connected to one or more FPGA links.
- Parameters:
n_atoms (int) – The number of atoms in the vertex
incoming_fpga_connections (list(FPGAConnection) or None) – The connections from one or more FPGAs that that packets are expected to be received from for this device, or None if no incoming traffic is expected from the device
outgoing_fpga_connection (FPGAConnection or None) – The connection to an FPGA that packets to be sent to this device should be sent down, or None if no outgoing traffic is expected to be sent to the device.
label (str) – The optional name of the vertex.
n_machine_vertices_per_link (int) – The optional number of machine vertices to create for each FPGA link (1 by default)
- get_incoming_slice_for_link(link: FPGAConnection, index: int) Slice [source]¶
Get the slice to be given to the connection from the given link.
- Parameters:
link (FPGAConnection) – The FPGA connection to get the slice for
index (int) – The index of the connection on the FGPA link, for when n_machine_vertices_per_link > 1
- Return type:
- get_outgoing_link_data(machine: Machine) FPGALinkData [source]¶
Get the link data for outgoing connections from the machine.
- Parameters:
machine (Machine) – The machine to get the link data from
- Return type:
- get_outgoing_slice() Slice [source]¶
Get the slice to be given to the outgoing connection.
- Return type:
- property incoming_fpga_connections: Iterable[FPGAConnection]¶
The connections from one or more FPGAs that packets are expected to be received from for this device.
- Return type:
iterable(FPGAConnection)
- property n_machine_vertices_per_link: int¶
The number of machine vertices to create for each link of the FPGA.
- Return type:
- property outgoing_fpga_connection: FPGAConnection | None¶
The connection to one FPGA via one link to which packets are sent to this device.
- Return type:
FPGAConnection or None
- class pacman.model.graphs.application.ApplicationGraph¶
Bases:
object
An application-level abstraction of a graph.
- add_edge(edge: ApplicationEdge, outgoing_edge_partition_name: str) ApplicationEdgePartition [source]¶
Add an edge to the graph and its partition.
If required and possible will create a new partition in the graph
- Parameters:
edge (ApplicationEdge) – The edge to add
outgoing_edge_partition_name (str) – The name of the edge partition to add the edge to; each edge partition is the partition of edges that start at the same vertex
- Returns:
The partition the edge was added to.
- Return type:
- Raises:
PacmanInvalidParameterException – If the edge is not of a valid type or if edges have already been added to this partition that start at a different vertex to this one
- add_vertex(vertex: ApplicationVertex)[source]¶
Add a vertex to the graph.
- Parameters:
vertex (ApplicationVertex) – The vertex to add
- Raises:
PacmanInvalidParameterException – If the vertex is not of a valid type
PacmanConfigurationException – If there is an attempt to add the same vertex more than once
- property edges: Sequence[ApplicationEdge]¶
The edges in the graph.
- Return type:
iterable(ApplicationEdge)
- get_outgoing_edge_partition_starting_at_vertex(vertex: ApplicationVertex, outgoing_edge_partition_name: str) ApplicationEdgePartition | None [source]¶
Get the given outgoing edge partition that starts at the given vertex, or None if no such edge partition exists.
- Parameters:
vertex (AbstractVertex) – The vertex at the start of the edges in the partition
outgoing_edge_partition_name (str) – The name of the edge partition
- Returns:
The named edge partition, or None if no such partition exists
- Return type:
AbstractEdgePartition or None
- get_outgoing_edge_partitions_starting_at_vertex(vertex: ApplicationVertex) Iterable[ApplicationEdgePartition] [source]¶
Get all the edge partitions that start at the given vertex.
- Parameters:
vertex (AbstractVertex) – The vertex at which the edge partitions to find starts
- Return type:
iterable(AbstractEdgePartition)
- property n_outgoing_edge_partitions: int¶
The number of outgoing edge partitions in the graph.
- Return type:
- property outgoing_edge_partitions: Iterable[ApplicationEdgePartition]¶
The edge partitions in the graph.
- Return type:
iterable(AbstractEdgePartition)
- vertex_by_label(label: str) ApplicationVertex [source]¶
Looks up a vertex in the graph based on the label
- Parameters:
label (str)
- Return type:
- property vertices: Iterable[ApplicationVertex]¶
The vertices in the graph.
- Return type:
iterable(AbstractVertex)
- class pacman.model.graphs.application.ApplicationSpiNNakerLinkVertex(n_atoms: int, spinnaker_link_id: int, board_address: str | None = None, label: str | None = None, n_machine_vertices: int = 1, incoming: bool = True, outgoing: bool = True)¶
Bases:
ApplicationVirtualVertex
A virtual application vertex on a SpiNNaker Link.
- Parameters:
n_atoms (int) – The number of atoms in the vertex
spinnaker_link_id (int) – The index of the spinnaker link to which the device is connected
board_address (str) – The optional IP address of the board to which the device is connected e.g. in a multi-board system
label (str) – The optional name of the vertex.
incoming (bool)
outgoing (bool)
- property board_address: str | None¶
The board to which this device is connected, or None for the default board.
- Return type:
str or None
- get_max_atoms_per_core() int [source]¶
Gets the maximum number of atoms per core, which is either the number of atoms required across the whole application vertex, or a lower value set.
- Return type:
- get_outgoing_link_data(machine: Machine) SpinnakerLinkData [source]¶
Get the link data for outgoing connections from the machine.
- Parameters:
machine (Machine) – The machine to get the link data from
- Return type:
- class pacman.model.graphs.application.ApplicationVertex(label: str | None = None, max_atoms_per_core: int | Tuple[int, ...] | None = None, splitter: AbstractSplitterCommon[Self] | None = None)¶
Bases:
AbstractVertex
,Generic
[MV
]A vertex that can be broken down into a number of smaller vertices based on the resources that the vertex requires.
- Parameters:
label (str) – The optional name of the vertex.
max_atoms_per_core (None or int or tuple(int,...)) – The max number of atoms that can be placed on a core for each dimension, used in partitioning. If the vertex is n-dimensional, with n > 1, the value must be a tuple with a value for each dimension. If it is single-dimensional the value can be a 1-tuple or an int.
splitter (None or AbstractSplitterCommon) – The splitter object needed for this vertex. Leave as None to delegate the choice of splitter to the selector.
- add_incoming_edge(edge: ApplicationEdge, partition: ApplicationEdgePartition)[source]¶
Add an edge incoming to this vertex. This is ignored by default, but could be used to track incoming edges, and/or report faults.
- Parameters:
edge (ApplicationEdge) – The edge to add.
partition (ApplicationEdgePartition) – The partition to add the edge to.
- property atoms_shape: Tuple[int, ...]¶
The “shape” of the atoms in the vertex i.e. how the atoms are split between the dimensions of the vertex. By default everything is 1-dimensional, so the value will be a 1-tuple but can be overridden by a vertex that supports multiple dimensions.
- get_fixed_key_and_mask(partition_id: str) BaseKeyAndMask | None [source]¶
Get a fixed key and mask for the application vertex or None if not fixed (the default). See
get_machine_gixed_key_and_mask()
for the conditions.- Parameters:
partition_id (str) – The identifier of the partition to get the key for
- Return type:
BaseKeyAndMask or None
- get_key_ordered_indices(indices=None)[source]¶
Get indices of the vertex in the order that atoms appear when the vertex is split into cores as determined by max_atoms_per_core. When a multi-dimensional vertex is split into cores, the atoms on each vertex is not linear but rather a hyper-rectangle of the atoms, thus the order of the atoms in the vertex as a whole is not the same as the order of the vertex when scanning over the cores.
- Parameters:
indices (numpy.ndarray or None.) – Optional subset of indices to convert. If not provided all indices will be converted.
- Return type:
- get_machine_fixed_key_and_mask(machine_vertex: MachineVertex, partition_id: str) BaseKeyAndMask | None [source]¶
Get a fixed key and mask for the given machine vertex and partition identifier, or None if not fixed (the default).
If this doesn’t return None,
get_fixed_key_and_mask()
must also not return None, and the keys returned here must align with those such that for eachkey:mask
returned here,key & app_mask == app_key
. It is OK for this to return None andget_fixed_key_and_mask()
to return non-None if and only if there is only one machine vertex.- Parameters:
machine_vertex (MachineVertex) – A source machine vertex of this application vertex
partition_id (str) – The identifier of the partition to get the key for
- Return type:
BaseKeyAndMask or None
- get_max_atoms_per_core() int [source]¶
Gets the maximum number of atoms per core, which is either the number of atoms required across the whole application vertex, or a lower value set.
- Return type:
- get_max_atoms_per_dimension_per_core() Tuple[int, ...] [source]¶
Gets the maximum number of atoms per dimension per core. This will return a tuple with a number for each dimension of the vertex, which might be one if this is a single-dimension vertex.
- get_raster_ordered_indices(indices)[source]¶
Convert indices from key order to raster order.
- Parameters:
indices (numpy.ndarray) – The key-ordered indices to convert.
- Return type:
- has_fixed_location()[source]¶
Check if this vertex or any machine vertex has a fixed location.
- Return type:
- Returns:
True if the Application Vertex or any one of its
Machine Vertices has a fixed location False if None of the Vertices has a none None fixed location
- property machine_vertices: Collection[MV]¶
The machine vertices that this application vertex maps to.
- Return type:
iterable(MachineVertex)
- remember_machine_vertex(machine_vertex: MV)[source]¶
Adds the machine vertex to the iterable returned by machine_vertices
- Parameters:
machine_vertex (MachineVertex) – A pointer to a machine_vertex
- reset() None [source]¶
Forget all machine vertices in the application vertex, and reset the splitter (if any).
- round_n_atoms(n_atoms: int | float, label: str = 'n_atoms') int [source]¶
Utility function to allow superclasses to make sure n_atoms is an integer.
- Parameters:
n_atoms (int or float or numpy.) – Value convertible to int to be used for n_atoms
- Returns:
Number of atoms.
- Return type:
- Raises:
PacmanInvalidParameterException – If the value cannot be safely converted to an integer
- set_max_atoms_per_dimension_per_core(new_value: int | Tuple[int, ...] | None)[source]¶
Set the maximum number of atoms per dimension per core.
Can be used to raise or lower the maximum number of atoms per core or per dimension per core.
- property splitter: AbstractSplitterCommon[Self]¶
- Return type:
- class pacman.model.graphs.application.ApplicationVirtualVertex(label: str | None = None, max_atoms_per_core: int | Tuple[int, ...] | None = None, splitter: AbstractSplitterCommon[Self] | None = None)¶
Bases:
ApplicationVertex
An application vertex which is virtual.
- Parameters:
label (str) – The optional name of the vertex.
max_atoms_per_core (None or int or tuple(int,...)) – The max number of atoms that can be placed on a core for each dimension, used in partitioning. If the vertex is n-dimensional, with n > 1, the value must be a tuple with a value for each dimension. If it is single-dimensional the value can be a 1-tuple or an int.
splitter (None or AbstractSplitterCommon) – The splitter object needed for this vertex. Leave as None to delegate the choice of splitter to the selector.