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 (ApplicationVertex) – The vertex to get the slices of

Returns:

The slices

Return type:

list(Slice)

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 (ApplicationVertex) – The vertex to get the slices of

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 (MulticastRoutingEntry)

Return type:

str

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.

Return type:

list(ApplicationEdgePartition)

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 (tuple(int,int,int)) – (x, y, z) The vector which the path should cover.

  • start (tuple(int,int)) –

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

    Note

    This is a 2D coordinate.

Returns:

min route

Return type:

list(tuple(int,tuple(int, int)))

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 (list(tuple(int,int))) – A vector made up of a list of (dimension, magnitude), where dimensions are x=0, y=1, z=diagonal=2

  • start (tuple(int,int)) – The x, y coordinates of the start

Returns:

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

Return type:

list(tuple(int,tuple(int, int)))

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

vertex (MachineVertex)

Return type:

Chip

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

vertex (MachineVertex)

Return type:

tuple(int,int)

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 (MachineVertex)

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

Return type:

tuple(tuple(int, int), tuple(MachineVertex, int, None)) or tuple(tuple(int, int), tuple(MachineVertex, None, int))

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 (tuple(int,int)) – The chip the route is currently passing through.

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

child (tuple(int, RoutingTree or MachineVertex))

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.

Return type:

iterable(tuple(int, RoutingTree or MachineVertex))

property chip: Tuple[int, int]

The chip the route is currently passing through.

Return type:

tuple(int,int)

property is_leaf: bool

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

property label: str | None

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

Return type:

str or None

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

child (tuple(int, RoutingTree or MachineVertex))

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.

Return type:

iterable(tuple(int, tuple(int,int), set(int)))

Module contents