pacman.utilities.algorithm_utilities package

Submodules

pacman.utilities.algorithm_utilities.partition_algorithm_utilities module

A collection of methods which support partitioning algorithms.

pacman.utilities.algorithm_utilities.partition_algorithm_utilities.get_multidimensional_slices(app_vertex: ApplicationVertex) List[Slice][source]

Get the multi-dimensional slices of an application vertex such that each is sized to the maximum atoms per dimension per core except the last, which might be smaller in one or more dimensions.

Parameters:

app_vertex – The vertex to get the slices of

Returns:

The slices

pacman.utilities.algorithm_utilities.partition_algorithm_utilities.get_single_dimension_slices(app_vertex: ApplicationVertex) List[Slice][source]
Get the single dimension slices of an application vertex

such that each is sized to the maximum atoms per dimension per core except the last which might be smaller in one or more dimensions

Parameters:

app_vertex – The vertex to get the slices of

Returns:

A slice for each Machine vertex in the application vertex.

pacman.utilities.algorithm_utilities.routes_format module

pacman.utilities.algorithm_utilities.routes_format.format_route(entry: MulticastRoutingEntry) str[source]

How to render a single routing entry.

Parameters:

entry

Returns:

A string representing the route

pacman.utilities.algorithm_utilities.routing_algorithm_utilities module

pacman.utilities.algorithm_utilities.routing_algorithm_utilities.get_app_partitions() List[ApplicationEdgePartition][source]

Find all application partitions.

Note

Where a vertex splitter indicates that it has internal partitions but is not the source of an external partition, a “fake” empty application partition is added. This allows the calling algorithm to loop over the returned list and look at the set of edges and internal partitions to get a complete picture of all targets for each source machine vertex at once.

Returns:

list of partitions

Note

Where there are only internal multicast partitions, the partition will have no edges. Caller should use vertex.splitter.get_internal_multicast_partitions for details.

pacman.utilities.algorithm_utilities.routing_algorithm_utilities.longest_dimension_first(vector: Tuple[int, int, int], start: Tuple[int, int]) List[Tuple[int, Tuple[int, int]]][source]

List the (x, y) steps on a longest-dimension first route.

Parameters:
  • vector – (x, y, z) The vector which the path should cover.

  • start

    (x, y) The coordinates from which the path should start.

    Note

    This is a 2D coordinate.

Returns:

min route

pacman.utilities.algorithm_utilities.routing_algorithm_utilities.vector_to_nodes(dm_vector: List[Tuple[int, int]], start: Tuple[int, int]) List[Tuple[int, Tuple[int, int]]][source]

Convert a vector to a set of nodes.

Parameters:
  • dm_vector – A vector made up of a list of (dimension, magnitude), where dimensions are x=0, y=1, z=diagonal=2

  • start – The x, y coordinates of the start

Returns:

A list of (link_id, (target_x, target_y)) of nodes on a route

pacman.utilities.algorithm_utilities.routing_algorithm_utilities.vertex_chip(vertex: MachineVertex) Chip[source]
Parameters:

vertex

Returns:

The Chip where the vertex is placed of linked to.

pacman.utilities.algorithm_utilities.routing_algorithm_utilities.vertex_xy(vertex: MachineVertex) Tuple[int, int][source]
Parameters:

vertex

Returns:

the location where this vertex is placed or linked to

pacman.utilities.algorithm_utilities.routing_algorithm_utilities.vertex_xy_and_route(vertex: MachineVertex) Tuple[Tuple[int, int], Tuple[MachineVertex, int | None, int | None]][source]

Get the non-virtual chip coordinates, the vertex, and processor or link to follow to get to the vertex.

Parameters:

vertex

Returns:

the (x,y) coordinates of the target vertex mapped to a tuple of the vertex, core and link. One of core or link is provided the other is None

pacman.utilities.algorithm_utilities.routing_tree module

An explicit representation of a routing tree in a machine.

This representation of a route explicitly describes a tree-structure and the complete path taken by a route. This is used during place and route in preference to a set of RoutingEntry tuples since it is more easily verified and more accurately represents the problem at hand.

Based on https://github.com/project-rig/rig/blob/master/rig/place_and_route/routing_tree.py

class pacman.utilities.algorithm_utilities.routing_tree.RoutingTree(chip: Tuple[int, int], label: str | None = None)[source]

Bases: object

Explicitly defines a multicast route through a SpiNNaker machine.

Each instance represents a single hop in a route and recursively refers to following steps.

Parameters:

chip – The chip the route is currently passing through.

append_child(child: Tuple[int, RoutingTree | MachineVertex]) None[source]

Adds the child to the tree

No check is done to see if it already exists.

property children: Iterable[Tuple[int, RoutingTree | MachineVertex]]

A iterable of the next steps in the route represented by a (route, object) tuple.

Note

Up until Rig 1.5.1, this structure used sets to store children. This was changed to lists since sets incur a large memory overhead and in practice the set-like behaviour of the list of children is not useful.

The object indicates the intended destination of this step in the route. It may be one of:

  • RoutingTree representing the continuation of the routing tree after following a given link.

  • A vertex (i.e. some other Python object) when the route terminates at the supplied vertex.

Note

The direction may be None and so additional logic may be required to determine what core to target to reach the vertex.

property chip: Tuple[int, int]

The chip the route is currently passing through.

property is_leaf: bool

Detect if this is a leaf node, which is one with no children.

property label: str | None

The label value provided to the init (if applicable).

remove_child(child: Tuple[int, RoutingTree | MachineVertex]) None[source]

Removes a child which must have been in the tree

traverse() Iterable[Tuple[int | None, Tuple[int, int], Set[int]]][source]

Traverse the tree yielding the direction taken to a node, the coordinates of that node and the directions leading from the Node.

Returns:

A sequence of (direction, (x, y), set(route)) describing the route taken. At each step, we have the direction taken to reach a Node in the tree, the (x, y) coordinate of that Node and routes leading to children of the Node.

Module contents