pacman.model.graphs.application package

Subpackages

Module contents

class pacman.model.graphs.application.Application2DFPGAVertex(width, height, sub_width, sub_height, incoming_fpga_connections=None, outgoing_fpga_connection=None, label=None)[source]

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

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.

Return type:

tuple(int, …)

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:

Slice

class pacman.model.graphs.application.Application2DSpiNNakerLinkVertex(width, height, sub_width, sub_height, spinnaker_link_id, board_address=None, label=None, incoming=True, outgoing=False)[source]

Bases: ApplicationSpiNNakerLinkVertex, Abstract2DDeviceVertex

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

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.

Return type:

tuple(int, …)

get_incoming_slice(index)[source]

Get the slice to be given to the connection.

Parameters:

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

Return type:

Slice

class pacman.model.graphs.application.ApplicationEdge(pre_vertex, post_vertex, label=None)[source]

Bases: AbstractEdge

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 label

The label of the edge.

Return type:

str

property post_vertex

The vertex at the end of the edge.

Return type:

AbstractVertex

property pre_vertex

The vertex at the start of the edge.

Return type:

AbstractVertex

class pacman.model.graphs.application.ApplicationEdgePartition(identifier, pre_vertex)[source]

Bases: AbstractSingleSourcePartition

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)[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, incoming_fpga_connections=None, outgoing_fpga_connection=None, label=None, n_machine_vertices_per_link=1)[source]

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

Slice

Get the link data for outgoing connections from the machine.

Parameters:

machine (Machine) – The machine to get the link data from

Return type:

AbstractLinkData

get_outgoing_slice()[source]

Get the slice to be given to the outgoing connection.

Return type:

Slice

property incoming_fpga_connections

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

Return type:

iterable(FPGAConnection)

property n_atoms

The number of atoms in the vertex.

Return type:

int

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

Return type:

int

property outgoing_fpga_connection

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

Bases: object

An application-level abstraction of a graph.

add_edge(edge, outgoing_edge_partition_name)[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:

AbstractEdgePartition

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

Add a vertex to the graph.

Parameters:

vertex (ApplicationVertex) – The vertex to add

Raises:
property edges

The edges in the graph.

Return type:

iterable(AbstractEdge)

get_outgoing_edge_partition_starting_at_vertex(vertex, outgoing_edge_partition_name)[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)[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

The number of outgoing edge partitions in the graph.

Return type:

int

property n_vertices

The number of vertices in the graph.

Return type:

int

property outgoing_edge_partitions

The edge partitions in the graph.

Return type:

iterable(AbstractEdgePartition)

reset()[source]

Reset all the application vertices.

vertex_by_label(label)[source]
property vertices

The vertices in the graph.

Return type:

iterable(AbstractVertex)

class pacman.model.graphs.application.ApplicationSpiNNakerLinkVertex(n_atoms, spinnaker_link_id, board_address=None, label=None, n_machine_vertices=1, incoming=True, outgoing=True)[source]

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.

property board_address

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

Return type:

str or None

get_incoming_slice(index)[source]

Get the slice to be given to the connection.

Parameters:

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

Return type:

Slice

get_max_atoms_per_core()[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:

int

Get the link data for outgoing connections from the machine.

Parameters:

machine (Machine) – The machine to get the link data from

Return type:

AbstractLinkData

get_outgoing_slice()[source]

Get the slice to be given to the outgoing connection.

Return type:

Slice

property incoming
property n_atoms

The number of atoms in the vertex.

Return type:

int

property n_machine_vertices

The number of machine vertices to create.

Return type:

int

property outgoing

The SpiNNaker link to which this device is connected.

Return type:

int

class pacman.model.graphs.application.ApplicationVertex(label=None, max_atoms_per_core=None, splitter=None)[source]

Bases: AbstractVertex

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

add_incoming_edge(edge, partition)[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:
property atoms_shape

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.

Return type:

tuple(int, …)

get_fixed_key_and_mask(partition_id)[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_machine_fixed_key_and_mask(machine_vertex, partition_id)[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 (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()[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:

int

get_max_atoms_per_dimension_per_core()[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.

Return type:

tuple(int,…)

property machine_vertices

The machine vertices that this application vertex maps to.

Return type:

iterable(MachineVertex)

abstract property n_atoms

The number of atoms in the vertex.

Return type:

int

remember_machine_vertex(machine_vertex)[source]

Adds the machine vertex to the iterable returned by machine_vertices

Parameters:

machine_vertex (MachineVertex) – A pointer to a machine_vertex

reset()[source]

Forget all machine vertices in the application vertex, and reset the splitter (if any).

round_n_atoms(n_atoms, label='n_atoms')[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:

int

Raises:

PacmanInvalidParameterException – If the value cannot be safely converted to an integer

set_max_atoms_per_dimension_per_core(new_value)[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 (None or int or tuple(int,...)) – 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. If this is set to None the vertex will have atoms_shape as the maximum.

property splitter
Return type:

AbstractSplitterPartitioner

class pacman.model.graphs.application.ApplicationVirtualVertex(label=None, max_atoms_per_core=None, splitter=None)[source]

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 AbstractSplitterPartitioner) – 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 (Machine) – The machine to get the link data from

Return type:

AbstractLinkData

class pacman.model.graphs.application.FPGAConnection(fpga_id: int, fpga_link_id: int, board_address: str, chip_coords: tuple)[source]

Bases: tuple

A connection from or to an FPGA.

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

property board_address

The IP address of the board with the FPGA, or None for the default board or if using chip_coords

property chip_coords

The coordinates of the chip connected to the FPGA, or None for the default board or if using board_address

property expanded

Get a list of concrete FPGA connections, where fpga_id and fpga_link_id are not None.

Return type:

iterable(FPGAConnection)

property fpga_id

The ID of the FPGA on the board (0, 1 or 2), or None for all of them

The ID of the link of the FPGA (0-15), or None for all of them

property is_concrete

Whether the connection has the FPGA id and link id set.

Return type:

bool