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 – The width of the vertex in atoms

  • height – The height of the vertex in atoms

  • sub_width – The width of the sub-rectangle to break the vertex up into

  • sub_height – The height of the sub-rectangle to break the vertex up into

  • incoming_fpga_connections – 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 – 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 – 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 the slice to be given to the connection from the given link.

Parameters:
  • link – The FPGA connection to get the slice for

  • index – The index of the connection on the FGPA link, for when n_machine_vertices_per_link > 1

property height: int

The height of the device.

property sub_height: int

The height of the sub-rectangles to divide the input into.

property sub_width: int

The width of the sub-rectangles to divide the input into.

property width: int

The width of the device.

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 – The width of the vertex in atoms

  • height – The height of the vertex in atoms

  • sub_width – The width of the sub-rectangle to break the vertex up into

  • sub_height – The height of the sub-rectangle to break the vertex up into

  • spinnaker_link_id – The index of the spinnaker link to which the device is connected

  • board_address – The optional IP address of the board to which the device is connected e.g. in a multi-board system

  • label – The optional name of the vertex.

  • incoming – Whether the device supports sending traffic into spinnaker

  • outgoing – 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.

get_incoming_slice(index: int) Slice[source]

Get the slice to be given to the connection.

Parameters:

index – The index of the connection, for when n_machine_vertices > 1

property height: int

The height of the device.

property sub_height: int

The height of the sub-rectangles to divide the input into.

property sub_width: int

The width of the sub-rectangles to divide the input into.

property width: int

The width of the device.

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 – The application vertex at the start of the edge.

  • post_vertex – The application vertex at the end of the edge.

  • label – The name of the edge.

property label: str | None

The label of the edge.

property post_vertex: ApplicationVertex

The vertex at the end of the edge.

property pre_vertex: ApplicationVertex

The vertex at the start of the edge.

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 – The identifier of the partition

  • pre_vertex – The source of this partition

add_edge(edge: ApplicationEdge) None[source]

Add an edge to the edge partition.

Parameters:

edge – 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 – The number of atoms in the vertex

  • incoming_fpga_connections – 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 – 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 – The optional name of the vertex.

  • n_machine_vertices_per_link – The optional number of machine vertices to create for each FPGA link (1 by default)

Get the slice to be given to the connection from the given link.

Parameters:
  • link – The FPGA connection to get the slice for

  • index – The index of the connection on the FGPA link, for when n_machine_vertices_per_link > 1

Get the link data for outgoing connections from the machine.

Parameters:

machine – The machine to get the link data from

get_outgoing_slice() Slice[source]

Get the slice to be given to the outgoing connection.

property incoming_fpga_connections: Iterable[FPGAConnection]

The connections from one or more FPGAs that packets are expected to be received from for this device.

property n_atoms: int

The number of atoms in the vertex.

The number of machine vertices to create for each link of the FPGA.

property outgoing_fpga_connection: FPGAConnection | None

The connection to one FPGA via one link to which packets are sent to this device.

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 – The edge to add

  • outgoing_edge_partition_name – 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.

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) None[source]

Add a vertex to the graph.

Parameters:

vertex – The vertex to add

Raises:
property edges: Sequence[ApplicationEdge]

The edges in the graph.

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 – The vertex at the start of the edges in the partition

  • outgoing_edge_partition_name – The name of the edge partition

Returns:

The named edge partition, or None if no such partition exists

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 – The vertex at which the edge partitions to find starts

property n_outgoing_edge_partitions: int

The number of outgoing edge partitions in the graph.

property n_vertices: int

The number of vertices in the graph.

property outgoing_edge_partitions: Iterable[ApplicationEdgePartition]

The edge partitions in the graph.

reset() None[source]

Reset all the application vertices.

vertex_by_label(label: str) ApplicationVertex[source]

Looks up a vertex in the graph based on the label

Parameters:

label

property vertices: Iterable[ApplicationVertex]

The vertices in the graph.

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 – The number of atoms in the vertex

  • spinnaker_link_id – The index of the spinnaker link to which the device is connected

  • board_address – The optional IP address of the board to which the device is connected e.g. in a multi-board system

  • label – The optional name of the vertex.

  • incoming

  • outgoing

property board_address: str | None

The board to which this device is connected, or None for the default board.

get_incoming_slice(index: int) Slice[source]

Get the slice to be given to the connection.

Parameters:

index – The index of the connection, for when n_machine_vertices > 1

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.

Get the link data for outgoing connections from the machine.

Parameters:

machine – The machine to get the link data from

get_outgoing_slice() Slice[source]

Get the slice to be given to the outgoing connection.

property incoming: bool

Reports if this vertex supports incoming links

property n_atoms: int

The number of atoms in the vertex.

property n_machine_vertices: int

The number of machine vertices to create.

property outgoing: bool

Reports if this vertex supports incoming links

The SpiNNaker link to which this device is connected.

class pacman.model.graphs.application.ApplicationVertex(label: str | None = None, max_atoms_per_core: int | Tuple[int, ...] | None = None, splitter: AbstractSplitterCommon | 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 – The optional name of the vertex.

  • max_atoms_per_core – 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 – 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) None[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 – The edge to add.

  • partition – 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 – The identifier of the partition to get the key for

get_key_ordered_indices(indices: ndarray | None = None) ndarray[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 – Optional subset of indices to convert. If not provided all indices will be converted.

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 each key:mask returned here, key & app_mask == app_key. It is OK for this to return None and get_fixed_key_and_mask() to return non-None if and only if there is only one machine vertex.

Parameters:

machine_vertex – The identifier of the partition to get the key for

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.

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: ndarray) ndarray[source]

Convert indices from key order to raster order.

Parameters:

indices – The key-ordered indices to convert.

has_fixed_location() bool[source]

Check if this vertex or any machine vertex has a fixed location.

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 has_splitter: bool

Whether this vertex currently has a splitter defined.

property machine_vertices: Collection[MV]

The machine vertices that this application vertex maps to.

abstract property n_atoms: int

The number of atoms in the vertex.

remember_machine_vertex(machine_vertex: MV) None[source]

Adds the machine vertex to the iterable returned by machine_vertices

Parameters:

machine_vertex – 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 – Value convertible to int to be used for n_atoms

Returns:

Number of atoms.

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.

Parameters:

new_value – Value to set. If the vertex is n-dimensional where n > 1, a tuple of n values must be given. If the vertex is 1 dimensional, a 1-tuple or integer can be given.

property splitter: AbstractSplitterCommon

The splitter assigned to this vertex.

class pacman.model.graphs.application.ApplicationVirtualVertex(label: str | None = None, max_atoms_per_core: int | Tuple[int, ...] | None = None, splitter: AbstractSplitterCommon | None = None)

Bases: ApplicationVertex

An application vertex which is virtual.

Parameters:
  • label – The optional name of the vertex.

  • max_atoms_per_core – 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 – The splitter object needed for this vertex. Leave as None to delegate the choice of splitter to the selector.

Get the link data for outgoing connections from the machine.

Parameters:

machine – The machine to get the link data from

class pacman.model.graphs.application.FPGAConnection(fpga_id: int, fpga_link_id: int, board_address: str | None, chip_coords: XY | None)

Bases: NamedTuple

A connection from or to an FPGA.

Create new instance of FPGAConnection(fpga_id, fpga_link_id, board_address, chip_coords)

board_address: str | None

Alias for field number 2

chip_coords: XY | None

Alias for field number 3

fpga_id: int

Alias for field number 0

Alias for field number 1