rig.geometry
: Machine geometry utility functions¶
General-purpose SpiNNaker-related geometry functions.
-
rig.geometry.
to_xyz
(xy)[source]¶ Convert a two-tuple (x, y) coordinate into an (x, y, 0) coordinate.
-
rig.geometry.
shortest_mesh_path_length
(source, destination)[source]¶ Get the length of a shortest path from source to destination without using wrap-around links.
Parameters: - source : (x, y, z)
- destination : (x, y, z)
Returns: - int
-
rig.geometry.
shortest_mesh_path
(source, destination)[source]¶ Calculate the shortest vector from source to destination without using wrap-around links.
Parameters: - source : (x, y, z)
- destination : (x, y, z)
Returns: - (x, y, z)
-
rig.geometry.
shortest_torus_path_length
(source, destination, width, height)[source]¶ Get the length of a shortest path from source to destination using wrap-around links.
See http://jhnet.co.uk/articles/torus_paths for an explanation of how this method works.
Parameters: - source : (x, y, z)
- destination : (x, y, z)
- width : int
- height : int
Returns: - int
-
rig.geometry.
shortest_torus_path
(source, destination, width, height)[source]¶ Calculate the shortest vector from source to destination using wrap-around links.
See http://jhnet.co.uk/articles/torus_paths for an explanation of how this method works.
Note that when multiple shortest paths exist, one will be chosen at random with uniform probability.
Parameters: - source : (x, y, z)
- destination : (x, y, z)
- width : int
- height : int
Returns: - (x, y, z)
-
rig.geometry.
concentric_hexagons
(radius, start=(0, 0))[source]¶ A generator which produces coordinates of concentric rings of hexagons.
Parameters: - radius : int
Number of layers to produce (0 is just one hexagon)
- start : (x, y)
The coordinate of the central hexagon.
-
rig.geometry.
standard_system_dimensions
(num_boards)[source]¶ Calculate the standard network dimensions (in chips) for a full torus system with the specified number of SpiNN-5 boards.
Returns: - (w, h)
Width and height of the network in chips.
Standard SpiNNaker systems are constructed as squarely as possible given the number of boards available. When a square system cannot be made, the function prefers wider systems over taller systems.
Raises: - ValueError
If the number of boards is not a multiple of three.
-
rig.geometry.
spinn5_eth_coords
(width, height, root_x=0, root_y=0)[source]¶ Generate a list of board coordinates with Ethernet connectivity in a SpiNNaker machine.
Specifically, generates the coordinates for the Ethernet connected chips of SpiNN-5 boards arranged in a standard torus topology.
Warning
In general, applications should use
rig.machine_control.MachineController.get_system_info
andethernet_connected_chips()
to gather the coordinates of Ethernet connected chips which are actually functioning. For example:>> from rig.machine_control import MachineController >> mc = MachineController("my-machine") >> si = mc.get_system_info() >> print(list(si.ethernet_connected_chips())) [((0, 0), "1.2.3.4"), ((4, 8), "1.2.3.5"), ((8, 4), "1.2.3.6")]
Parameters: - width, height : int
Width and height of the system in chips.
- root_x, root_y : int
The coordinates of the root chip (i.e. the chip used to boot the machine), e.g. from
rig.machine_control.MachineController.root_chip
.
-
rig.geometry.
spinn5_local_eth_coord
(x, y, w, h, root_x=0, root_y=0)[source]¶ Get the coordinates of a chip’s local ethernet connected chip.
Returns the coordinates of the ethernet connected chip on the same board as the supplied chip.
Note
This function assumes the system is constructed from SpiNN-5 boards
Warning
In general, applications should interrogate the machine to determine which Ethernet connected chip is considered ‘local’ to a particular SpiNNaker chip, e.g. using
rig.machine_control.MachineController.get_system_info
:>> from rig.machine_control import MachineController >> mc = MachineController("my-machine") >> si = mc.get_system_info() >> print(si[(3, 2)].local_ethernet_chip) (0, 0)
spinn5_local_eth_coord()
will always produce the coordinates of the Ethernet-connected SpiNNaker chip on the same SpiNN-5 board as the supplied chip. In future versions of the low-level system software, some other method of choosing local Ethernet connected chips may be used.Parameters: - x, y : int
Chip whose coordinates are of interest.
- w, h : int
Width and height of the system in chips.
- root_x, root_y : int
The coordinates of the root chip (i.e. the chip used to boot the machine), e.g. from
rig.machine_control.MachineController.root_chip
.
-
rig.geometry.
SPINN5_ETH_OFFSET
= array([[[ 0, 0], [-1, 0], [-2, 0], [-3, 0], [-4, 0], [-1, -4], [-2, -4], [-3, -4], [-4, -4], [-5, -4], [-6, -4], [-7, -4]], [[ 0, -1], [-1, -1], [-2, -1], [-3, -1], [-4, -1], [-5, -1], [-2, -5], [-3, -5], [-4, -5], [-5, -5], [-6, -5], [-7, -5]], [[ 0, -2], [-1, -2], [-2, -2], [-3, -2], [-4, -2], [-5, -2], [-6, -2], [-3, -6], [-4, -6], [-5, -6], [-6, -6], [-7, -6]], [[ 0, -3], [-1, -3], [-2, -3], [-3, -3], [-4, -3], [-5, -3], [-6, -3], [-7, -3], [-4, -7], [-5, -7], [-6, -7], [-7, -7]], [[-4, 0], [-1, -4], [-2, -4], [-3, -4], [-4, -4], [-5, -4], [-6, -4], [-7, -4], [ 0, 0], [-1, 0], [-2, 0], [-3, 0]], [[-4, -1], [-5, -1], [-2, -5], [-3, -5], [-4, -5], [-5, -5], [-6, -5], [-7, -5], [ 0, -1], [-1, -1], [-2, -1], [-3, -1]], [[-4, -2], [-5, -2], [-6, -2], [-3, -6], [-4, -6], [-5, -6], [-6, -6], [-7, -6], [ 0, -2], [-1, -2], [-2, -2], [-3, -2]], [[-4, -3], [-5, -3], [-6, -3], [-7, -3], [-4, -7], [-5, -7], [-6, -7], [-7, -7], [ 0, -3], [-1, -3], [-2, -3], [-3, -3]], [[-4, -4], [-5, -4], [-6, -4], [-7, -4], [ 0, 0], [-1, 0], [-2, 0], [-3, 0], [-4, 0], [-1, -4], [-2, -4], [-3, -4]], [[-4, -5], [-5, -5], [-6, -5], [-7, -5], [ 0, -1], [-1, -1], [-2, -1], [-3, -1], [-4, -1], [-5, -1], [-2, -5], [-3, -5]], [[-4, -6], [-5, -6], [-6, -6], [-7, -6], [ 0, -2], [-1, -2], [-2, -2], [-3, -2], [-4, -2], [-5, -2], [-6, -2], [-3, -6]], [[-4, -7], [-5, -7], [-6, -7], [-7, -7], [ 0, -3], [-1, -3], [-2, -3], [-3, -3], [-4, -3], [-5, -3], [-6, -3], [-7, -3]]])¶ SpiNN-5 ethernet connected chip lookup.
Used by
spinn5_local_eth_coord()
. Given an x and y chip position modulo 12, return the offset of the board’s bottom-left chip from the chip’s position.Note: the order of indexes:
SPINN5_ETH_OFFSET[y][x]
!
-
rig.geometry.
spinn5_chip_coord
(x, y, root_x=0, root_y=0)[source]¶ Get the coordinates of a chip on its board.
Given the coordinates of a chip in a multi-board system, calculates the coordinates of the chip within its board.
Note
This function assumes the system is constructed from SpiNN-5 boards
Parameters: - x, y : int
The coordinates of the chip of interest
- root_x, root_y : int
The coordinates of the root chip (i.e. the chip used to boot the machine), e.g. from
rig.machine_control.MachineController.root_chip
.
-
rig.geometry.
spinn5_fpga_link
(x, y, link, root_x=0, root_y=0)[source]¶ Get the identity of the FPGA link which corresponds with the supplied link.
Note
This function assumes the system is constructed from SpiNN-5 boards whose FPGAs are loaded with the SpI/O ‘spinnaker_fpgas’ image.
Parameters: - x, y : int
The chip whose link is of interest.
- link :
Link
The link of interest.
- root_x, root_y : int
The coordinates of the root chip (i.e. the chip used to boot the machine), e.g. from
rig.machine_control.MachineController.root_chip
.
Returns: - (fpga_num, link_num) or None
If not None, the link supplied passes through an FPGA link. The returned tuple indicates the FPGA responsible for the sending-side of the link.
fpga_num is the number (0, 1 or 2) of the FPGA responsible for the link.
link_num indicates which of the sixteen SpiNNaker links (0 to 15) into an FPGA is being used. Links 0-7 are typically handled by S-ATA link 0 and 8-15 are handled by S-ATA link 1.
Returns None if the supplied link does not pass through an FPGA.
-
rig.geometry.
SPINN5_FPGA_LINKS
= {(0, 0, <Links.west: 3>): (1, 1), (0, 0, <Links.south_west: 4>): (1, 0), (0, 0, <Links.south: 5>): (0, 15), (0, 1, <Links.west: 3>): (1, 3), (0, 1, <Links.south_west: 4>): (1, 2), (0, 2, <Links.west: 3>): (1, 5), (0, 2, <Links.south_west: 4>): (1, 4), (0, 3, <Links.north: 2>): (1, 8), (0, 3, <Links.west: 3>): (1, 7), (0, 3, <Links.south_west: 4>): (1, 6), (1, 0, <Links.south_west: 4>): (0, 14), (1, 0, <Links.south: 5>): (0, 13), (1, 4, <Links.north: 2>): (1, 10), (1, 4, <Links.west: 3>): (1, 9), (2, 0, <Links.south_west: 4>): (0, 12), (2, 0, <Links.south: 5>): (0, 11), (2, 5, <Links.north: 2>): (1, 12), (2, 5, <Links.west: 3>): (1, 11), (3, 0, <Links.south_west: 4>): (0, 10), (3, 0, <Links.south: 5>): (0, 9), (3, 6, <Links.north: 2>): (1, 14), (3, 6, <Links.west: 3>): (1, 13), (4, 0, <Links.east: 0>): (0, 6), (4, 0, <Links.south_west: 4>): (0, 8), (4, 0, <Links.south: 5>): (0, 7), (4, 7, <Links.north_east: 1>): (2, 1), (4, 7, <Links.north: 2>): (2, 0), (4, 7, <Links.west: 3>): (1, 15), (5, 1, <Links.east: 0>): (0, 4), (5, 1, <Links.south: 5>): (0, 5), (5, 7, <Links.north_east: 1>): (2, 3), (5, 7, <Links.north: 2>): (2, 2), (6, 2, <Links.east: 0>): (0, 2), (6, 2, <Links.south: 5>): (0, 3), (6, 7, <Links.north_east: 1>): (2, 5), (6, 7, <Links.north: 2>): (2, 4), (7, 3, <Links.east: 0>): (0, 0), (7, 3, <Links.north_east: 1>): (2, 15), (7, 3, <Links.south: 5>): (0, 1), (7, 4, <Links.east: 0>): (2, 14), (7, 4, <Links.north_east: 1>): (2, 13), (7, 5, <Links.east: 0>): (2, 12), (7, 5, <Links.north_east: 1>): (2, 11), (7, 6, <Links.east: 0>): (2, 10), (7, 6, <Links.north_east: 1>): (2, 9), (7, 7, <Links.east: 0>): (2, 8), (7, 7, <Links.north_east: 1>): (2, 7), (7, 7, <Links.north: 2>): (2, 6)}¶ FPGA link IDs for each link leaving a SpiNN-5 board.
Format:
{(x, y, link): (fpga_num, link_num), ...}
Used by
spinn5_fpga_link()
.