spinn_machine package

Submodules

spinn_machine.chip module

class spinn_machine.chip.Chip(x, y, processors, router, sdram, nearest_ethernet_x, nearest_ethernet_y, ip_address=None, virtual=False, tag_ids=None)[source]

Bases: object

Represents a SpiNNaker chip with a number of cores, an amount of SDRAM shared between the cores, and a router. The chip is iterable over the processors, yielding (processor_id, processor) where:

  • processor_id is the ID of a processor
  • processor is the processor with processor_id
Parameters:
  • x (int) – the x-coordinate of the chip’s position in the two-dimensional grid of chips
  • y (int) – the y-coordinate of the chip’s position in the two-dimensional grid of chips
  • processors (iterable(Processor)) – an iterable of processor objects
  • router (Router) – a router for the chip
  • sdram (SDRAM) – an SDRAM for the chip
  • ip_address (str) – the IP address of the chip or None if no Ethernet attached
  • virtual (bool) – boolean which defines if this chip is a virtual one
  • tag_ids (iterable(int) or None) – IDs to identify the chip for SDP can be empty to define no tags or None to allocate tag automatically based on if there is an ip_address
  • nearest_ethernet_x (int or None) – the nearest Ethernet x coordinate
  • nearest_ethernet_y (int or None) – the nearest Ethernet y coordinate
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If processors contains any two processors with the same processor_id

DEFAULT_PROCESSORS = {0: [CPU: id=0, clock_speed=200 MHz, monitor=True], 1: [CPU: id=1, clock_speed=200 MHz, monitor=False], 2: [CPU: id=2, clock_speed=200 MHz, monitor=False], 3: [CPU: id=3, clock_speed=200 MHz, monitor=False], 4: [CPU: id=4, clock_speed=200 MHz, monitor=False], 5: [CPU: id=5, clock_speed=200 MHz, monitor=False], 6: [CPU: id=6, clock_speed=200 MHz, monitor=False], 7: [CPU: id=7, clock_speed=200 MHz, monitor=False], 8: [CPU: id=8, clock_speed=200 MHz, monitor=False], 9: [CPU: id=9, clock_speed=200 MHz, monitor=False], 10: [CPU: id=10, clock_speed=200 MHz, monitor=False], 11: [CPU: id=11, clock_speed=200 MHz, monitor=False], 12: [CPU: id=12, clock_speed=200 MHz, monitor=False], 13: [CPU: id=13, clock_speed=200 MHz, monitor=False], 14: [CPU: id=14, clock_speed=200 MHz, monitor=False], 15: [CPU: id=15, clock_speed=200 MHz, monitor=False], 16: [CPU: id=16, clock_speed=200 MHz, monitor=False], 17: [CPU: id=17, clock_speed=200 MHz, monitor=False]}
IPTAG_IDS = OrderedSet([1, 2, 3, 4, 5, 6, 7])
static default_processors()[source]
get_first_none_monitor_processor()[source]

Get the first processor in the list which is not a monitor core

Returns:a processor
get_processor_with_id(processor_id)[source]

Return the processor with the specified ID or None if the processor does not exist.

Parameters:processor_id (int) – the ID of the processor to return
Returns:the processor with the specified ID, or None if no such processor
Return type:Processor
Raises:None – does not raise any known exceptions
ip_address

The IP address of the chip

Returns:IP address of the chip, or None if there is no Ethernet connected to the chip
Return type:str
Raises:None – does not raise any known exceptions
is_processor_with_id(processor_id)[source]

Determines if a processor with the given ID exists in the chip. Also implemented as __contains__(processor_id)

Parameters:processor_id (int) – the processor ID to check for
Returns:Whether the processor with the given ID exists
Return type:bool
Raises:None – does not raise any known exceptions
n_processors

The total number of processors

n_user_processors

The total number of processors that are not monitors

nearest_ethernet_x

The x coordinate of the nearest Ethernet chip

Returns:the x coordinate of the nearest Ethernet chip
Return type:int
Raises:None – does not raise any known exceptions
nearest_ethernet_y

The y coordinate of the nearest Ethernet chip

Returns:the y coordinate of the nearest Ethernet chip
Return type:int
Raises:None – does not raise any known exceptions
processors

An iterable of available processors

Returns:iterable of processors
Return type:iterable(Processor)
Raises:None – does not raise any known exceptions
router

The router object associated with the chip

Returns:router associated with the chip
Return type:Router
Raises:None – does not raise any known exceptions
sdram

The SDRAM associated with the chip

Returns:SDRAM associated with the chip
Return type:SDRAM
Raises:None – does not raise any known exceptions
tag_ids

The tag IDs supported by this chip

Returns:the set of IDs.
Raises:None – this method does not raise any exception
virtual

Boolean which defines if the chip is virtual or not

Returns:if the chip is virtual
Return type:boolean
Raises:None – this method does not raise any known exceptions
x

The x-coordinate of the chip in the two-dimensional grid of chips

Returns:the x-coordinate of the chip
Return type:int
Raises:None – does not raise any known exceptions
y

The y-coordinate of the chip in the two-dimensional grid of chips

Returns:the y-coordinate of the chip
Return type:int
Raises:None – does not raise any known exceptions

spinn_machine.core_subset module

class spinn_machine.core_subset.CoreSubset(x, y, processor_ids)[source]

Bases: object

Represents a subset of the cores on a SpiNNaker chip.

Parameters:
  • x (int) – The x-coordinate of the chip
  • y (int) – The y-coordinate of the chip
  • processor_ids (iterable(int)) – The processor IDs on the chip
add_processor(processor_id)[source]

Adds a processor ID to this subset

Parameters:processor_id (int) – A processor ID
Returns:Nothing is returned
Return type:None
intersect(other)[source]

Returns a new CoreSubset which is an intersect of this and the other.

Parameters:other (spinn_machine.CoreSubset) – A second CoreSubset with possibly overlapping cores
Returns:A new CoreSubset with any overlap
Return type:spinn_machine.CoreSubset
processor_ids

The subset of processor IDs on the chip

Returns:An iterable of processor IDs
Return type:iterable(int)
x

The x-coordinate of the chip

Returns:The x-coordinate
Return type:int
y

The y-coordinate of the chip

Returns:The y-coordinate
Return type:int

spinn_machine.core_subsets module

class spinn_machine.core_subsets.CoreSubsets(core_subsets=None)[source]

Bases: object

Represents a group of CoreSubsets, with a maximum of one per SpiNNaker chip.

Parameters:core_subsets (iterable(CoreSubset)) – The cores for each desired chip
add_core_subset(core_subset)[source]

Add a core subset to the set

Parameters:core_subset (spinn_machine.CoreSubset) – The core subset to add
Return type:None
add_core_subsets(core_subsets)[source]

Merges a core subsets into this one.

Parameters:core_subsets – the core subsets to add
Return type:None
add_processor(x, y, processor_id)[source]

Add a processor on a given chip to the set.

Parameters:
  • x (int) – The x-coordinate of the chip
  • y (int) – The y-coordinate of the chip
  • processor_id (int) – A processor ID
Return type:

None

core_subsets

The one-per-chip subsets.

Returns:Iterable of core subsets
Return type:iterable(spinn_machine.CoreSubset)
get_core_subset_for_chip(x, y)[source]

Get the core subset for a chip.

Parameters:
  • x (int) – The x-coordinate of a chip
  • y (int) – The y-coordinate of a chip
Returns:

The core subset of a chip, which will be empty if not added

Return type:

CoreSubset

intersect(other)[source]

Returns a new CoreSubsets which is an intersect of this and the other.

Parameters:other (spinn_machine.CoreSubsets) – A second CoreSubsets with possibly overlapping cores
Returns:A new CoreSubsets with any overlap
Return type:spinn_machine.CoreSubsets
is_chip(x, y)[source]

Determine if the chip with coordinates (x, y) is in the subset

Parameters:
  • x (int) – The x-coordinate of a chip
  • y (int) – The y-coordinate of a chip
Returns:

True if the chip with coordinates (x, y) is in the subset

Return type:

bool

is_core(x, y, processor_id)[source]

Determine if there is a chip with coordinates (x, y) in the subset, which has a core with the given ID in the subset

Parameters:
  • x (int) – The x-coordinate of a chip
  • y (int) – The y-coordinate of a chip
  • processor_id (int) – The ID of a core
Returns:

Whether there is a chip with coordinates (x, y) in the subset, which has a core with the given ID in the subset

values()[source]

spinn_machine.exceptions module

exception spinn_machine.exceptions.SpinnMachineAlreadyExistsException(item, value)[source]

Bases: spinn_machine.exceptions.SpinnMachineException

Indicates that something already exists of which there can only be one

Parameters:
  • item (str) – The item of which there is already one of
  • value (str) – The value of the item
item

The item of which there is already one

value

The value of the item

exception spinn_machine.exceptions.SpinnMachineException[source]

Bases: Exception

A generic exception which all other exceptions extend

exception spinn_machine.exceptions.SpinnMachineInvalidParameterException(parameter, value, problem)[source]

Bases: spinn_machine.exceptions.SpinnMachineException

Indicates that there is a problem with a parameter value

Parameters:
  • parameter (str) – The name of the parameter that has an invalid value
  • value (str) – The value of the parameter that is invalid
  • problem (str) – The reason for the exception
parameter

The name of the parameter

problem

The problem with the setting of the parameter

value

The value of the parameter

spinn_machine.fixed_route_entry module

class spinn_machine.fixed_route_entry.FixedRouteEntry(processor_ids, link_ids)[source]

Bases: object

Describes an entry in a SpiNNaker chip’s fixed route routing table.

The destination link IDs

Returns:An iterable of link IDs
Return type:iterable(int)
processor_ids

The destination processor IDs

Returns:An iterable of processor IDs
Return type:iterable(int)

spinn_machine.full_wrap_machine module

class spinn_machine.full_wrap_machine.FullWrapMachine(width, height, chips=None, origin=None)[source]

Bases: spinn_machine.machine.Machine

Creates a fully wrapped machine.

Parameters:
  • width – The width of the machine excluding any virtual chips
  • height – The height of the machine excluding any virtual chips
  • chips (iterable of Chip) – An iterable of chips in the machine
  • origin – Extra information about how this mnachine was created to be used in the str method. Example “Virtual” or “Json”
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If any two chips have the same x and y coordinates

get_chips_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the actual chips on the board with this ethernet. Including the Ethernet chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the chips on this board.

get_down_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y) coordinates of the down chips on the board with this ethernet.

Note the Ethernet chip itself can not be missing if validated

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the (x, y) of the down chips on this board.

get_existing_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y)s of actual chips on the board with this ethernet. Including the Ethernet chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the (x,y)s of chips on this board.

get_global_xy(local_x, local_y, ethernet_x, ethernet_y)[source]

Converts the local x and y coordinates into global x,y coordinates, under the assumption that they are on the board with local 0,0 at ethernet_x, ethernet_y

This method does take wrap-arounds into consideration.

GIGO: This method does not check if input parameters make sense, nor does it check if there is a chip at the resulting global x,y

Parameters:
  • local_x – A valid local x coordinate for a chip
  • local_y – A valid local y coordinate for a chip
  • ethernet_x – The global ethernet x for the board the chip is on
  • ethernet_y – The global ethernet y for the board the chip is on
Returns:

global (x,y) coordinates of the chip

get_local_xy(chip)[source]

Converts the x and y coordinates into the local coordinates on the board as if the ethernet was at position 0,0

This method does take wrap-arounds into consideration.

This method assumes that chip is on the machine or is a copy of a chip on the machine

Parameters:chip – A Chip in the machine
Returns:Local (x, y) coordinates.
get_vector(source, destination)[source]

Get mathematical shortest vector (x, y, z) from source to destination

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a none wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

Use the same algorithm as vector_length using the best x, y pair as minimize(x, y, 0)

Parameters:
  • source ((int, int)) – (x,y) coordinates of the source chip
  • destination – (x,y) coordinates of the destination chip
Returns:

get_vector_length(source, destination)[source]

Get the mathematical length of the shortest vector (x, y, z) from source to destination

Use the same algorithm as vector to find the best x, y pair but then is optimised to directly calculate length

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a none wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

On full wrap-around machines (before minization) the vectors can have any of the 4 combinations of possitive and negative x and y The possitive one is: destination - source % dimension The negative one is: possitive - dimension If source is less than dimension the negative one is the wrap around If destination is greater than source the possitive one wraps

One no wrap or part wrap boards the x/y that does not wrap is just destination - source

The length of vectors where both x and y have the same sign will be max(abs(x), abs(y)) As the z direction can be used in minization The length of vectors where x and y have opposite signs will be abs(x) and abs(y) as these are alread minimum so z is not used.

GIGO: This method does not check if input parameters make sense,

Parameters:
  • source ((int, int)) – (x,y) coordinates of the source chip
  • destination – (x,y) coordinates of the destination chip
Returns:

The distantance in steps

get_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the potential x,y locations of all the chips on the board with this ethernet. Including the Ethernet chip itself.

Wrap-arounds are handled as appropriate.

Note: This method does not check if the chip actually exists as is intended to be called to create the chips.

Warning: GIGO! This methods assumes that ethernet_x and ethernet_y are the local 0,0 of an existing board, within the width and height of the machine.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the (x, y) coordinates of all the potential chips on this board.

multiple_48_chip_boards()[source]

Checks that the width and height correspond to the expected size for a multi-board machine made up of more than one 48 chip board.

The assumption is that any size machine can be supported but that only ones with an expected 48 chip board size can have more than one ethernet chip.

Returns:True if this machine can have multiple 48 chip boards
wrap

String to represent the type of wrap.

Returns:Short string for type of wrap

Get the potential x,y location of the chip reached over this link.

Wrap-arounds are handled as appropriate.

Note: This method does not check if either chip source or destination actually exists as is intended to be called to create the links.

It is the callers responsibility to check the validity of this call before making it or the validity of the result.

Warning: GIGO! This methods assumes that x and y are within the width and height of the machine, and that the link goes to another chip on the machine.

On machine without full wrap-around it is possible that this method generates x,y values that fall outside of the legal values including negative values, x = width or y = height.

Parameters:
  • x – The x coordinate of a chip that will exist on the machine
  • y – The y coordinate of a chip that will exist on the machine
  • link – The link to another chip that could exist on the machine
Returns:

x and y coordinates of the chip over that link if it is valid or some fictional x,y if not.

spinn_machine.horizontal_wrap_machine module

class spinn_machine.horizontal_wrap_machine.HorizontalWrapMachine(width, height, chips=None, origin=None)[source]

Bases: spinn_machine.machine.Machine

Creates a horizontally wrapped machine.

Parameters:
  • width – The width of the machine excluding any virtual chips
  • height – The height of the machine excluding any virtual chips
  • chips (iterable of Chip) – An iterable of chips in the machine
  • origin – Extra information about how this mnachine was created to be used in the str method. Example “Virtual” or “Json”
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If any two chips have the same x and y coordinates

get_chips_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the actual chips on the board with this ethernet. Including the Ethernet chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the chips on this board.

get_down_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y) coordinates of the down chips on the board with this ethernet.

Note the Ethernet chip itself can not be missing if validated

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the (x, y) of the down chips on this board.

get_existing_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y)s of actual chips on the board with this ethernet. Including the Ethernet chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the (x,y)s of chips on this board.

get_global_xy(local_x, local_y, ethernet_x, ethernet_y)[source]

Converts the local x and y coordinates into global x,y coordinates, under the assumption that they are on the board with local 0,0 at ethernet_x, ethernet_y

This method does take wrap-arounds into consideration.

GIGO: This method does not check if input parameters make sense, nor does it check if there is a chip at the resulting global x,y

Parameters:
  • local_x – A valid local x coordinate for a chip
  • local_y – A valid local y coordinate for a chip
  • ethernet_x – The global ethernet x for the board the chip is on
  • ethernet_y – The global ethernet y for the board the chip is on
Returns:

global (x,y) coordinates of the chip

get_local_xy(chip)[source]

Converts the x and y coordinates into the local coordinates on the board as if the ethernet was at position 0,0

This method does take wrap-arounds into consideration.

This method assumes that chip is on the machine or is a copy of a chip on the machine

Parameters:chip – A Chip in the machine
Returns:Local (x, y) coordinates.
get_vector(source, destination)[source]

Get mathematical shortest vector (x, y, z) from source to destination

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a none wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

Use the same algorithm as vector_length using the best x, y pair as minimize(x, y, 0)

Parameters:
  • source ((int, int)) – (x,y) coordinates of the source chip
  • destination – (x,y) coordinates of the destination chip
Returns:

get_vector_length(source, destination)[source]

Get the mathematical length of the shortest vector (x, y, z) from source to destination

Use the same algorithm as vector to find the best x, y pair but then is optimised to directly calculate length

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a none wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

On full wrap-around machines (before minization) the vectors can have any of the 4 combinations of possitive and negative x and y The possitive one is: destination - source % dimension The negative one is: possitive - dimension If source is less than dimension the negative one is the wrap around If destination is greater than source the possitive one wraps

One no wrap or part wrap boards the x/y that does not wrap is just destination - source

The length of vectors where both x and y have the same sign will be max(abs(x), abs(y)) As the z direction can be used in minization The length of vectors where x and y have opposite signs will be abs(x) and abs(y) as these are alread minimum so z is not used.

GIGO: This method does not check if input parameters make sense,

Parameters:
  • source ((int, int)) – (x,y) coordinates of the source chip
  • destination – (x,y) coordinates of the destination chip
Returns:

The distantance in steps

get_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the potential x,y locations of all the chips on the board with this ethernet. Including the Ethernet chip itself.

Wrap-arounds are handled as appropriate.

Note: This method does not check if the chip actually exists as is intended to be called to create the chips.

Warning: GIGO! This methods assumes that ethernet_x and ethernet_y are the local 0,0 of an existing board, within the width and height of the machine.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the (x, y) coordinates of all the potential chips on this board.

multiple_48_chip_boards()[source]

Checks that the width and height correspond to the expected size for a multi-board machine made up of more than one 48 chip board.

The assumption is that any size machine can be supported but that only ones with an expected 48 chip board size can have more than one ethernet chip.

Returns:True if this machine can have multiple 48 chip boards
wrap

String to represent the type of wrap.

Returns:Short string for type of wrap

Get the potential x,y location of the chip reached over this link.

Wrap-arounds are handled as appropriate.

Note: This method does not check if either chip source or destination actually exists as is intended to be called to create the links.

It is the callers responsibility to check the validity of this call before making it or the validity of the result.

Warning: GIGO! This methods assumes that x and y are within the width and height of the machine, and that the link goes to another chip on the machine.

On machine without full wrap-around it is possible that this method generates x,y values that fall outside of the legal values including negative values, x = width or y = height.

Parameters:
  • x – The x coordinate of a chip that will exist on the machine
  • y – The y coordinate of a chip that will exist on the machine
  • link – The link to another chip that could exist on the machine
Returns:

x and y coordinates of the chip over that link if it is valid or some fictional x,y if not.

spinn_machine.json_machine module

spinn_machine.json_machine.machine_from_json(j_machine)[source]
Parameters:j_machine (dict in format returned by json.load or a str representing a path to the json file) – json description of the machine
spinn_machine.json_machine.to_json(machine)[source]

Runs the code to write the machine in Java readable JSON.

Parameters:machine (spinn_machine.machine.Machine) – Machine to convert
spinn_machine.json_machine.to_json_path(machine, file_path)[source]

Runs the code to write the machine in Java readable JSON.

Parameters:

spinn_machine.machine module

class spinn_machine.machine.Machine(width, height, chips=None, origin=None)[source]

Bases: object

A representation of a SpiNNaker Machine with a number of Chips. Machine is also iterable, providing ((x, y), chip) where:

  • x is the x-coordinate of a chip
  • y is the y-coordinate of a chip
  • chip is the chip with the given x, y coordinates

Creates an abstract machine that must be superclassed by wrap type.

Use machine_fatcory methods to determine the correct machine class

Parameters:
  • width – The width of the machine excluding any virtual chips
  • height – The height of the machine excluding any virtual chips
  • chips (iterable of Chip) – An iterable of chips in the machine
  • origin – Extra information about how this machine was created to be used in the str method. Example “Virtual” or “Json”
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If any two chips have the same x and y coordinates

BOARD_48_CHIPS = [(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7)]
BOARD_VERSION_FOR_48_CHIPS = [4, 5]
BOARD_VERSION_FOR_4_CHIPS = [2, 3]
MAX_BANDWIDTH_PER_ETHERNET_CONNECTED_CHIP = 2560
MAX_CHIPS_PER_48_BOARD = 48
MAX_CHIPS_PER_4_CHIP_BOARD = 4
MAX_CHIP_X_ID_ON_ONE_BOARD = 7
MAX_CHIP_Y_ID_ON_ONE_BOARD = 7
MAX_CORES_PER_CHIP = 18
SIZE_X_OF_ONE_BOARD = 8
SIZE_Y_OF_ONE_BOARD = 8
add_chip(chip)[source]

Add a chip to the machine

Parameters:chip (Chip) – The chip to add to the machine
Returns:Nothing is returned
Return type:None
Raises:spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If a chip with the same x and y coordinates already exists
add_chips(chips)[source]

Add some chips to the machine

Parameters:chips (iterable(Chip)) – an iterable of chips
Returns:Nothing is returned
Return type:None
Raises:spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If a chip with the same x and y coordinates as one being added already exists

Add FPGA links that are on a given machine depending on the version of the board.

Parameters:version_no – which version of board to use

Add SpiNNaker links that are on a given machine depending on the version of the board.

Parameters:version_no – which version of board to use
add_virtual_chip(chip)[source]
boot_chip

The chip used to boot the machine

Return type:~py:class:spinn_machine.Chip
chip_coordinates

An iterable of chip coordinates in the machine

Returns:An iterable of chip coordinates
Return type:iterable(int,int)
chips

An iterable of chips in the machine

Returns:An iterable of chips
Return type:iterable(Chip)
Raises:None – does not raise any known exceptions

Get a string detailing the number of cores and links

Return type:str
ethernet_connected_chips

The chips in the machine that have an Ethernet connection

Returns:An iterable of chips
Return type:iterable of Chip
get_chip_at(x, y)[source]

Get the chip at a specific (x, y) location. Also implemented as __getitem__((x, y))

Parameters:
  • x (int) – the x-coordinate of the requested chip
  • y (int) – the y-coordinate of the requested chip
Returns:

the chip at the specified location, or None if no such chip

Return type:

Chip

Raises:

None – does not raise any known exceptions

get_chips_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the actual chips on the board with this ethernet. Including the Ethernet chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the chips on this board.

Get the number of cores and links from the machine

Links are assumed to be bidirectional so the total links counted is half of the unidirectional links found.

Spinnaker and fpga links are not included.

Returns:tuple of (n_cores, n_links)
Return type:tuple(int,int)
get_down_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y) coordinates of the down chips on the board with this ethernet.

Note the Ethernet chip itself can not be missing if validated

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the (x, y) of the down chips on this board.

get_existing_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y)s of actual chips on the board with this ethernet. Including the Ethernet chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the (x,y)s of chips on this board.

get_existing_xys_on_board(chip)[source]

Get the chips that are on the same board as the given chip

Parameters:chip – The chip to find other chips on the same board as
Returns:An iterable of (x, y) coordinates of chips on the same board
Return type:iterable(tuple(int,int))

Get an FPGA link data item that corresponds to the FPGA and FPGA link for a given board address.

Parameters:
Return type:

FPGALinkData

Returns:

the given FPGA link object or None if no such link

get_global_xy(local_x, local_y, ethernet_x, ethernet_y)[source]

Converts the local x and y coordinates into global x,y coordinates, under the assumption that they are on the board with local 0,0 at ethernet_x, ethernet_y

This method does take wrap-arounds into consideration.

GIGO: This method does not check if input parameters make sense, nor does it check if there is a chip at the resulting global x,y

Parameters:
  • local_x – A valid local x coordinate for a chip
  • local_y – A valid local y coordinate for a chip
  • ethernet_x – The global ethernet x for the board the chip is on
  • ethernet_y – The global ethernet y for the board the chip is on
Returns:

global (x,y) coordinates of the chip

get_local_xy(chip)[source]

Converts the x and y coordinates into the local coordinates on the board as if the ethernet was at position 0,0

This method does take wrap-arounds into consideration.

This method assumes that chip is on the machine or is a copy of a chip on the machine

Parameters:chip – A Chip in the machine
Returns:Local (x, y) coordinates.

Get a SpiNNaker link with a given ID

Parameters:
  • spinnaker_link_id (int) – The ID of the link
  • board_address (str or None) – the board address that this SpiNNaker link is associated with
Returns:

The SpiNNaker link data or None if no link

Return type:

SpinnakerLinkData

get_vector(source, destination)[source]

Get mathematical shortest vector (x, y, z) from source to destination

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a none wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

Use the same algorithm as vector_length using the best x, y pair as minimize(x, y, 0)

Parameters:
  • source ((int, int)) – (x,y) coordinates of the source chip
  • destination – (x,y) coordinates of the destination chip
Returns:

get_vector_length(source, destination)[source]

Get the mathematical length of the shortest vector (x, y, z) from source to destination

Use the same algorithm as vector to find the best x, y pair but then is optimised to directly calculate length

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a none wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

On full wrap-around machines (before minization) the vectors can have any of the 4 combinations of possitive and negative x and y The possitive one is: destination - source % dimension The negative one is: possitive - dimension If source is less than dimension the negative one is the wrap around If destination is greater than source the possitive one wraps

One no wrap or part wrap boards the x/y that does not wrap is just destination - source

The length of vectors where both x and y have the same sign will be max(abs(x), abs(y)) As the z direction can be used in minization The length of vectors where x and y have opposite signs will be abs(x) and abs(y) as these are alread minimum so z is not used.

GIGO: This method does not check if input parameters make sense,

Parameters:
  • source ((int, int)) – (x,y) coordinates of the source chip
  • destination – (x,y) coordinates of the destination chip
Returns:

The distantance in steps

get_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the potential x,y locations of all the chips on the board with this ethernet. Including the Ethernet chip itself.

Wrap-arounds are handled as appropriate.

Note: This method does not check if the chip actually exists as is intended to be called to create the chips.

Warning: GIGO! This methods assumes that ethernet_x and ethernet_y are the local 0,0 of an existing board, within the width and height of the machine.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the (x, y) coordinates of all the potential chips on this board.

height

The height to the machine ignoring virtual chips

Returns:The height to the machine ignoring virtual chips
Return type:int
is_chip_at(x, y)[source]

Determine if a chip exists at the given coordinates. Also implemented as __contains__((x, y))

Parameters:
  • x (int) – x location of the chip to test for existence
  • y (int) – y location of the chip to test for existence
Returns:

True if the chip exists, False otherwise

Return type:

bool

Raises:

None – does not raise any known exceptions

Determine if a link exists at the given coordinates

Parameters:
  • x (int) – The x location of the chip to test the link of
  • y (int) – The y location of the chip to test the link of
  • link (int) – The link to test the existence of
local_xys

Provides a list of local (x,y) values for a perfect board on this machine.

Local (x,y)s never include wrap-arounds.

Note: no check is done to see if any board in the machine actually has a chip with this local x, y

Returns:a list of (x,y) coordinates
max_chip_x

The maximum x-coordinate of any chip in the board

Returns:The maximum x-coordinate
Return type:int
max_chip_y

The maximum y-coordinate of any chip in the board

Returns:The maximum y-coordinate
Return type:int
maximum_user_cores_on_chip

The maximum number of user cores on any chip

multiple_48_chip_boards()[source]

Checks that the width and height correspond to the expected size for a multi-board machine made up of more than one 48 chip board.

The assumption is that any size machine can be supported but that only ones with an expected 48 chip board size can have more than one ethernet chip.

Returns:True if this machine can have multiple 48 chip boards
n_chips

The set of SpiNNaker links in the machine

Returns:An iterable of SpiNNaker links
Return type:iterable of SpinnakerLinkData
total_available_user_cores

The total number of cores on the machine which are not monitor cores

Returns:total
Return type:int
total_cores

The total number of cores on the machine, including monitors

Returns:total
Return type:int
unreachable_incoming_chips()[source]

Detects chips that are not reachable from any of their neighbours

Current implementation does NOT deal with group of unreachable chips

Returns:List (hopefully empty) if the (x,y) cooridinates of unreachable chips.
unreachable_incoming_local_chips()[source]

Detects chips that are not reachable from any of their LOCAL neighbours

Current implementation does NOT deal with group of unreachable chips

Returns:List (hopefully empty) if the (x,y) cooridinates of unreachable chips.
unreachable_outgoing_chips()[source]

Detects chips that can not reach any of their neighbours

Current implementation does NOT deal with group of unreachable chips

Returns:List (hopefully empty) if the (x,y) cooridinates of unreachable chips.
unreachable_outgoing_local_chips()[source]

Detects chips that can not reach any of their LOCAL neighbours

Current implementation does NOT deal with group of unreachable chips

Returns:List (hopefully empty) if the (x,y) cooridinates of unreachable chips.
validate()[source]

Validates the machine and raises an exception in unexpected conditions.

Assumes that at the time this is called all chips are on the board.

This allows the checks to be avoided when creating a virtual machine (Except of course in testing)

An Error is raised if there is a chip with a x outside of the range 0 to width -1 (except for virtual ones) An Error is raised if there is a chip with a y outside of the range 0 to height -1 (except for virtual ones) An Error is raise if there is no chip at the declared ethernet x and y An Error is raised if an ethernet chip is not at a local 0,0 An Error is raised if there is no ethernet chip is at 0,0 An Error is raised if this is a unexpected multiple board situation

virtual_chips
width

The width to the machine ignoring virtual chips

Returns:The width to the machine ignoring virtual chips
Return type:int
wrap

String to represent the type of wrap.

Returns:Short string for type of wrap

Get the potential x,y location of the chip reached over this link.

Wrap-arounds are handled as appropriate.

Note: This method does not check if either chip source or destination actually exists as is intended to be called to create the links.

It is the callers responsibility to check the validity of this call before making it or the validity of the result.

Warning: GIGO! This methods assumes that x and y are within the width and height of the machine, and that the link goes to another chip on the machine.

On machine without full wrap-around it is possible that this method generates x,y values that fall outside of the legal values including negative values, x = width or y = height.

Parameters:
  • x – The x coordinate of a chip that will exist on the machine
  • y – The y coordinate of a chip that will exist on the machine
  • link – The link to another chip that could exist on the machine
Returns:

x and y coordinates of the chip over that link if it is valid or some fictional x,y if not.

spinn_machine.machine_factory module

spinn_machine.machine_factory.machine_from_chips(chips)[source]

Create a machine with the assumed wrap-around based on the sizes.

The size of the machine is calculated from the list of chips.

Parameters:chips – Full list of all chips on this machine. Or at least a list which includes a chip with the highest X and one with the highest Y (excluding any virtual chips)
Returns:A subclass of Machine
spinn_machine.machine_factory.machine_from_size(width, height, chips=None, origin=None)[source]

Create a machine with the assumed wrap-around based on the sizes.

This could include a machine with no wrap-arounds, only vertical ones, only horizontal ones or both.

Note: If the sizes do not match the ones for a known wrap-around machine, no wrap-arounds is assumed.

Parameters:
  • width – The width of the machine excluding any virtual chips
  • height – The height of the machine excluding any virtual chips
  • chips – Any chips to be added.
  • origin – Extra information about how this machine was created to be used in the str method. Example “Virtual” or “Json”
Returns:

A subclass of Machine

spinn_machine.machine_factory.machine_repair(original, repair_machine=False, removed_chips=[])[source]

Remove chips that can’t be reached or that can’t reach other chips due to missing links

Also Reomve and one way links
Parameters:
  • original – the original machine
  • repair_machine (bool) – A flag to say if the machine requires unexpected repairs. It True the unexpected repairs are logged and then done If false will raise an exception if the machine needs an unexpected repair
  • removed_chips – List of chips (x and y cooridinates) that have been removed while the machine was being created. Oneway links to these chip are expected repairs so always done and never logged
:raises:SpinnMachineException if repair_machine is false and an unexpected
repair is needed.
Returns:Either the original machine or a repaired replacement

spinn_machine.multicast_routing_entry module

class spinn_machine.multicast_routing_entry.MulticastRoutingEntry(routing_entry_key, mask, processor_ids=None, link_ids=None, defaultable=False, spinnaker_route=None)[source]

Bases: object

Represents an entry in a SpiNNaker chip’s multicast routing table

Parameters:
  • routing_entry_key (int) – The routing key_combo
  • mask (int) – The route key_combo mask
  • processor_ids (iterable(int)) – The destination processor IDs
  • link_ids (iterable(int)) – The destination link IDs
  • defaultable (bool) – if this entry is defaultable (it receives packets from its directly opposite route position)
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException

  • If processor_ids contains the same ID more than once
  • If link_ids contains the same ID more than once

defaultable

Whether this entry is a defaultable entry

Returns:the bool that represents if a entry is defaultable or not
Return type:bool

The destination link IDs

Returns:An iterable of link IDs
Return type:iterable(int)
mask

The routing mask

Returns:The routing mask
Return type:int
merge(other_entry)[source]

Merges together two multicast routing entries. The entry to merge must have the same key and mask. The merge will join the processor IDs and link IDs from both the entries. This could be used to add a new destination to an existing route in a routing table. It is also possible to use the add (+) operator or the or (|) operator with the same effect.

Parameters:other_entry (MulticastRoutingEntry) – The multicast entry to merge with this entry
Returns:A new multicast routing entry with merged destinations
Return type:MulticastRoutingEntry
Raises:spinn_machine.exceptions.SpinnMachineInvalidParameterException – If the key and mask of the other entry do not match
processor_ids

The destination processor IDs

Returns:An iterable of processor IDs
Return type:iterable(int)
routing_entry_key

The routing key

Returns:The routing key
Return type:int
spinnaker_route

spinn_machine.no_wrap_machine module

class spinn_machine.no_wrap_machine.NoWrapMachine(width, height, chips=None, origin=None)[source]

Bases: spinn_machine.machine.Machine

Creates an machine without wrap-arounds.

Parameters:
  • width – The width of the machine excluding any virtual chips
  • height – The height of the machine excluding any virtual chips
  • chips (iterable of Chip) – An iterable of chips in the machine
  • origin – Extra information about how this mnachine was created to be used in the str method. Example “Virtual” or “Json”
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If any two chips have the same x and y coordinates

get_chips_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the actual chips on the board with this ethernet. Including the Ethernet chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the chips on this board.

get_down_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y) coordinates of the down chips on the board with this ethernet.

Note the Ethernet chip itself can not be missing if validated

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the (x, y) of the down chips on this board.

get_existing_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y)s of actual chips on the board with this ethernet. Including the Ethernet chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the (x,y)s of chips on this board.

get_global_xy(local_x, local_y, ethernet_x, ethernet_y)[source]

Converts the local x and y coordinates into global x,y coordinates, under the assumption that they are on the board with local 0,0 at ethernet_x, ethernet_y

This method does take wrap-arounds into consideration.

GIGO: This method does not check if input parameters make sense, nor does it check if there is a chip at the resulting global x,y

Parameters:
  • local_x – A valid local x coordinate for a chip
  • local_y – A valid local y coordinate for a chip
  • ethernet_x – The global ethernet x for the board the chip is on
  • ethernet_y – The global ethernet y for the board the chip is on
Returns:

global (x,y) coordinates of the chip

get_local_xy(chip)[source]

Converts the x and y coordinates into the local coordinates on the board as if the ethernet was at position 0,0

This method does take wrap-arounds into consideration.

This method assumes that chip is on the machine or is a copy of a chip on the machine

Parameters:chip – A Chip in the machine
Returns:Local (x, y) coordinates.
get_vector(source, destination)[source]

Get mathematical shortest vector (x, y, z) from source to destination

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a none wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

Use the same algorithm as vector_length using the best x, y pair as minimize(x, y, 0)

Parameters:
  • source ((int, int)) – (x,y) coordinates of the source chip
  • destination – (x,y) coordinates of the destination chip
Returns:

get_vector_length(source, destination)[source]

Get the mathematical length of the shortest vector (x, y, z) from source to destination

Use the same algorithm as vector to find the best x, y pair but then is optimised to directly calculate length

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a none wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

On full wrap-around machines (before minization) the vectors can have any of the 4 combinations of possitive and negative x and y The possitive one is: destination - source % dimension The negative one is: possitive - dimension If source is less than dimension the negative one is the wrap around If destination is greater than source the possitive one wraps

One no wrap or part wrap boards the x/y that does not wrap is just destination - source

The length of vectors where both x and y have the same sign will be max(abs(x), abs(y)) As the z direction can be used in minization The length of vectors where x and y have opposite signs will be abs(x) and abs(y) as these are alread minimum so z is not used.

GIGO: This method does not check if input parameters make sense,

Parameters:
  • source ((int, int)) – (x,y) coordinates of the source chip
  • destination – (x,y) coordinates of the destination chip
Returns:

The distantance in steps

get_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the potential x,y locations of all the chips on the board with this ethernet. Including the Ethernet chip itself.

Wrap-arounds are handled as appropriate.

Note: This method does not check if the chip actually exists as is intended to be called to create the chips.

Warning: GIGO! This methods assumes that ethernet_x and ethernet_y are the local 0,0 of an existing board, within the width and height of the machine.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the (x, y) coordinates of all the potential chips on this board.

multiple_48_chip_boards()[source]

Checks that the width and height correspond to the expected size for a multi-board machine made up of more than one 48 chip board.

The assumption is that any size machine can be supported but that only ones with an expected 48 chip board size can have more than one ethernet chip.

Returns:True if this machine can have multiple 48 chip boards
wrap

String to represent the type of wrap.

Returns:Short string for type of wrap

Get the potential x,y location of the chip reached over this link.

Wrap-arounds are handled as appropriate.

Note: This method does not check if either chip source or destination actually exists as is intended to be called to create the links.

It is the callers responsibility to check the validity of this call before making it or the validity of the result.

Warning: GIGO! This methods assumes that x and y are within the width and height of the machine, and that the link goes to another chip on the machine.

On machine without full wrap-around it is possible that this method generates x,y values that fall outside of the legal values including negative values, x = width or y = height.

Parameters:
  • x – The x coordinate of a chip that will exist on the machine
  • y – The y coordinate of a chip that will exist on the machine
  • link – The link to another chip that could exist on the machine
Returns:

x and y coordinates of the chip over that link if it is valid or some fictional x,y if not.

spinn_machine.processor module

class spinn_machine.processor.Processor(processor_id, clock_speed=200000000, is_monitor=False, dtcm_available=65536)[source]

Bases: object

A processor object included in a SpiNNaker chip

Parameters:
  • processor_id (int) – ID of the processor in the chip
  • clock_speed (int) – The number of CPU cycles per second of the processor
  • is_monitor (bool) – Determines if the processor is considered the monitor processor, and so should not be otherwise allocated
  • dtcm_available (int) – Data Tightly Coupled Memory available
Raises:

spinn_machine.exceptions.SpinnMachineInvalidParameterException – If the clock speed is negative

CLOCK_SPEED = 200000000
DTCM_AVAILABLE = 65536
clock_speed

The clock speed of the processor in cycles per second

Returns:The clock speed in cycles per second
Return type:int
clone_as_system_processor()[source]

Creates a clone of this processor but changing it to a system processor.

Returns:A new Processor with the same properties INCLUDING the ID except now set as a System processor
Return type:Processor
cpu_cycles_available

The number of CPU cycles available from this processor per ms

Returns:the number of CPU cycles available on this processor
Return type:int
dtcm_available

The amount of DTCM available on this processor

Returns:the amount of DTCM available on this processor
Return type:int
static factory(processor_id, is_monitor=False)[source]
is_monitor

Determines if the processor is the monitor, and therefore not to be allocated

Warning

Currently rejection processors are also marked as monitors.

Returns:True if the processor is the monitor, False otherwise
Return type:bool
processor_id

The ID of the processor

Returns:ID of the processor
Return type:int

spinn_machine.router module

class spinn_machine.router.Router(links, emergency_routing_enabled=False, clock_speed=157286400, n_available_multicast_entries=1024)[source]

Bases: object

Represents a router of a chip, with a set of available links. The router is iterable over the links, providing (source_link_id, link) where:

  • source_link_id is the ID of a link
  • link is the link with ID source_link_id
Parameters:
  • links (iterable(Link)) – iterable of links
  • emergency_routing_enabled (bool) – Determines if the router emergency routing is operating
  • clock_speed (int) – The router clock speed in cycles per second
  • n_available_multicast_entries (int) – The number of entries available in the routing table
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If any two links have the same source_link_id

MAX_CORES_PER_ROUTER = 18
ROUTER_DEFAULT_AVAILABLE_ENTRIES = 1024
ROUTER_DEFAULT_CLOCK_SPEED = 157286400

Add a link to the router of the chip

Parameters:link (spinn_machine.Link) – The link to be added
Returns:Nothing is returned
Return type:None
Raises:spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If another link already exists with the same source_link_id
clock_speed

The clock speed of the router in cycles per second

Returns:The clock speed in cycles per second
Return type:int
Raises:None – does not raise any known exceptions
static convert_routing_table_entry_to_spinnaker_route(routing_table_entry)[source]

Convert a routing table entry represented in software to a binary routing table entry usable on the machine

Parameters:routing_table_entry (MulticastRoutingEntry) – The entry to convert
Return type:int
static convert_spinnaker_route_to_routing_ids(route)[source]

Convert a binary routing table entry usable on the machine to lists of route IDs usable in a routing table entry represented in software.

Parameters:route (int) – The routing table entry
Returns:The list of processor IDs, and the list of link IDs.
Return type:tuple(list(int), list(int))
emergency_routing_enabled

Indicator of whether emergency routing is enabled

Returns:True if emergency routing is enabled, False otherwise
Return type:bool
Raises:None – does not raise any known exceptions

Get the link with the given ID, or None if no such link. Also implemented as __getitem__(source_link_id)

Parameters:source_link_id (int) – The ID of the link to find
Returns:The link, or None if no such link
Return type:Link
Raises:None – No known exceptions are raised
get_neighbouring_chips_coords()[source]

Utility method to convert links into x and y coordinates

Returns:iterable list of destination coordinates in x and y dict
Return type:iterable(dict(str,int))

Determine if there is a link with ID source_link_id. Also implemented as __contains__(source_link_id)

Parameters:source_link_id (int) – The ID of the link to find
Returns:True if there is a link with the given ID, False otherwise
Return type:bool
Raises:None – No known exceptions are raised

The available links of this router

Returns:an iterable of available links
Return type:iterable(Link)
Raises:None – does not raise any known exceptions
n_available_multicast_entries

The number of available multicast entries in the routing tables

Returns:The number of available entries
Return type:int
Raises:None – does not raise any known exceptions
static opposite(link_id)[source]

Given a valid link_id this method returns its opposite.

GIGO: this method assumes the input is valid. No verfication is done

Parameters:link_id – A valid link_id
Returns:The link_id for the opposite direction

spinn_machine.sdram module

class spinn_machine.sdram.SDRAM(size=122683392)[source]

Bases: object

Represents the properties of the SDRAM of a chip in the machine

Parameters:size (int) – the space available in SDRAM
DEFAULT_SDRAM_BYTES = 122683392
max_sdram_found = 0
size

The SDRAM available for user applications

Returns:The space available in bytes
Return type:int

spinn_machine.spinnaker_triad_geometry module

class spinn_machine.spinnaker_triad_geometry.SpiNNakerTriadGeometry(triad_width, triad_height, roots, centre)[source]

Bases: object

Geometry of a “triad” of SpiNNaker boards

The geometry is defined by the arguments to the constructor; the standard arrangement can be obtained from get_spinn5_geometry

Note that the geometry defines what a Triad is in terms of the dimensions of a triad and where the Ethernet chips occur in the triad

Parameters:
  • triad_width (int) – width of a triad in chips
  • triad_height (int) – height of a triad in chips
  • roots (list of (int, int)) – locations of the Ethernet connected chips
  • centre ((float, float)) – the distance from each Ethernet chip to the centre of the hexagon
get_ethernet_chip_coordinates(x, y, width, height, root_x=0, root_y=0)[source]

Get the coordinates of a chip’s local Ethernet connected chip according to this triad geometry object

Warning

local_eth_coord() will always produce the coordinates of the Ethernet-connected SpiNNaker chip on the same SpiNN-5 board as the supplied chip. This chip may not actually be working.

Parameters:
  • x (int) – x-coordinate of the chip to find the nearest Ethernet of
  • y (int) – y-coordinate of the chip to find the nearest Ethernet of
  • width (int) – width of the SpiNNaker machine (must be a multiple of the triad width of this geometry)
  • height (int) – height of the SpiNNaker machine (must be a multiple of the triad height of this geometry)
  • root_x (int) – x-coordinate of the boot chip (default 0, 0)
  • root_y (int) – y-coordinate of the boot chip (default 0, 0)
Returns:

The coordinates of the closest Ethernet chip

Return type:

(int, int)

get_local_chip_coordinate(x, y, root_x=0, root_y=0)[source]

Get the coordinates of a chip on its board of a multi-board system relative to the Ethernet chip of the board.

Note

This function assumes the system is constructed from SpiNN-5 boards

Parameters:
  • x (int) – The x-coordinate of the chip to find the location of
  • y (int) – The y-coordinate of the chip to find the location of
  • root_x (int) – The x-coordinate of the boot chip (default 0, 0)
  • root_y (int) – The y-coordinate of the boot chip (default 0, 0)
Returns:

the coordinates of the chip relative to its board

Return type:

(int, int)

get_potential_ethernet_chips(width, height)[source]

Get the coordinates of chips that should be Ethernet chips

Parameters:
  • width – The width of the machine to find the chips in
  • height – The height of the machine to find the chips in
static get_spinn5_geometry()[source]

Get the geometry object for a SpiNN-5 arrangement of boards

Returns:a SpiNNakerTriadGeometry object.
spinn5_triad_geometry = None

spinn_machine.vertical_wrap_machine module

class spinn_machine.vertical_wrap_machine.VerticalWrapMachine(width, height, chips=None, origin=None)[source]

Bases: spinn_machine.machine.Machine

Creates a vertically wrapped machine.

Parameters:
  • width – The width of the machine excluding any virtual chips
  • height – The height of the machine excluding any virtual chips
  • chips (iterable of Chip) – An iterable of chips in the machine
  • origin – Extra information about how this mnachine was created to be used in the str method. Example “Virtual” or “Json”
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If any two chips have the same x and y coordinates

get_chips_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the actual chips on the board with this ethernet. Including the Ethernet chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the chips on this board.

get_down_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y) coordinates of the down chips on the board with this ethernet.

Note the Ethernet chip itself can not be missing if validated

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the (x, y) of the down chips on this board.

get_existing_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y)s of actual chips on the board with this ethernet. Including the Ethernet chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the (x,y)s of chips on this board.

get_global_xy(local_x, local_y, ethernet_x, ethernet_y)[source]

Converts the local x and y coordinates into global x,y coordinates, under the assumption that they are on the board with local 0,0 at ethernet_x, ethernet_y

This method does take wrap-arounds into consideration.

GIGO: This method does not check if input parameters make sense, nor does it check if there is a chip at the resulting global x,y

Parameters:
  • local_x – A valid local x coordinate for a chip
  • local_y – A valid local y coordinate for a chip
  • ethernet_x – The global ethernet x for the board the chip is on
  • ethernet_y – The global ethernet y for the board the chip is on
Returns:

global (x,y) coordinates of the chip

get_local_xy(chip)[source]

Converts the x and y coordinates into the local coordinates on the board as if the ethernet was at position 0,0

This method does take wrap-arounds into consideration.

This method assumes that chip is on the machine or is a copy of a chip on the machine

Parameters:chip – A Chip in the machine
Returns:Local (x, y) coordinates.
get_vector(source, destination)[source]

Get mathematical shortest vector (x, y, z) from source to destination

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a none wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

Use the same algorithm as vector_length using the best x, y pair as minimize(x, y, 0)

Parameters:
  • source ((int, int)) – (x,y) coordinates of the source chip
  • destination – (x,y) coordinates of the destination chip
Returns:

get_vector_length(source, destination)[source]

Get the mathematical length of the shortest vector (x, y, z) from source to destination

Use the same algorithm as vector to find the best x, y pair but then is optimised to directly calculate length

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a none wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

On full wrap-around machines (before minization) the vectors can have any of the 4 combinations of possitive and negative x and y The possitive one is: destination - source % dimension The negative one is: possitive - dimension If source is less than dimension the negative one is the wrap around If destination is greater than source the possitive one wraps

One no wrap or part wrap boards the x/y that does not wrap is just destination - source

The length of vectors where both x and y have the same sign will be max(abs(x), abs(y)) As the z direction can be used in minization The length of vectors where x and y have opposite signs will be abs(x) and abs(y) as these are alread minimum so z is not used.

GIGO: This method does not check if input parameters make sense,

Parameters:
  • source ((int, int)) – (x,y) coordinates of the source chip
  • destination – (x,y) coordinates of the destination chip
Returns:

The distantance in steps

get_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the potential x,y locations of all the chips on the board with this ethernet. Including the Ethernet chip itself.

Wrap-arounds are handled as appropriate.

Note: This method does not check if the chip actually exists as is intended to be called to create the chips.

Warning: GIGO! This methods assumes that ethernet_x and ethernet_y are the local 0,0 of an existing board, within the width and height of the machine.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the (x, y) coordinates of all the potential chips on this board.

multiple_48_chip_boards()[source]

Checks that the width and height correspond to the expected size for a multi-board machine made up of more than one 48 chip board.

The assumption is that any size machine can be supported but that only ones with an expected 48 chip board size can have more than one ethernet chip.

Returns:True if this machine can have multiple 48 chip boards
wrap

String to represent the type of wrap.

Returns:Short string for type of wrap

Get the potential x,y location of the chip reached over this link.

Wrap-arounds are handled as appropriate.

Note: This method does not check if either chip source or destination actually exists as is intended to be called to create the links.

It is the callers responsibility to check the validity of this call before making it or the validity of the result.

Warning: GIGO! This methods assumes that x and y are within the width and height of the machine, and that the link goes to another chip on the machine.

On machine without full wrap-around it is possible that this method generates x,y values that fall outside of the legal values including negative values, x = width or y = height.

Parameters:
  • x – The x coordinate of a chip that will exist on the machine
  • y – The y coordinate of a chip that will exist on the machine
  • link – The link to another chip that could exist on the machine
Returns:

x and y coordinates of the chip over that link if it is valid or some fictional x,y if not.

spinn_machine.virtual_machine module

spinn_machine.virtual_machine.virtual_machine(width=None, height=None, with_wrap_arounds=None, version=None, n_cpus_per_chip=18, with_monitors=True, sdram_per_chip=122683392, down_chips=None, down_cores=None, down_links=None, router_entries_per_chip=1024, validate=True)[source]
Parameters:
  • width (int) – the width of the virtual machine in chips
  • height (int) – the height of the virtual machine in chips
  • with_wrap_arounds (bool) –

    bool defining if wrap around links exist If set a board with the requested wrap around is created regardless of the board size.

    In None the wrap around will be auto detected by machine_factory

    Note: Use either with_wrap_arounds or version but not both

  • version (int) – the version ID of a board; if None, a machine is created with the correct dimensions, otherwise the machine will be a single board of the given version.
  • n_cpus_per_chip (int) – The number of CPUs to put on each chip
  • with_monitors (bool) – True if CPU 0 should be marked as a monitor
  • sdram_per_chip (int or None) – The amount of SDRAM to give to each chip
  • router_entries_per_chip (int) – the number of entries to each router
  • validate (bool) – if True will call the machine validate function
spinn_machine.virtual_machine.virtual_submachine(machine, ethernet_chip)[source]

Creates a virtual machine based off a real machine but just with the system resources of a single board (identified by its ethernet chip).

Parameters:
  • machine – The machine to create the virtual machine from. May be a virtual machine. May be a single-board machine.
  • ethernet_chip – The chip that can talk to the board’s ethernet.

Module contents

An abstraction of a SpiNNaker Machine. The main functionality isprovided by spinn_machine.Machine.

Functional Requirements

  • Create a machine which represents the current state of a machine, in terms of the available chips, cores on the chips, SDRAM available, routable links between chips and available routing entries.

  • Create a machine which represents an abstract ideal machine.

    • There can only be one chip in the machine with given x, y coordinates
    • There can only be one processor in each chip with a given processor ID
    • There can only be one link in the router of each chip with a given ID
  • Add a chip to a given machine to represent an external device.

    • A chip with the same x, y coordinates must not already exist in the machine
  • Add a link to a router of a given chip to represent a connection to an external device.

    • A link with the given ID must not already exist in the chip
  • Create a representation of a multicast routing entry to be shared between modules that deal with routing entries.

Use Cases

  • Machine is returned as a representation of the current state of a machine.
  • VirtualMachine is used as an outline of a machine on which a simulation will be run, e.g., for placement of executables and/or finding routes between placed executables.
  • Machine is extended to add a virtual Chip on the machine representing an external peripheral connected to the machine directly via a link from a chip, so that routes can be directed to and from the external peripheral.
  • MulticastRoutingEntry is returned in a list of entries, which indicate the current set of routing entries within a multicast routing table on a chip on the machine.
  • MulticastRoutingEntry is sent in a list of routing entries to set up routing on a chip on the machine.
class spinn_machine.Chip(x, y, processors, router, sdram, nearest_ethernet_x, nearest_ethernet_y, ip_address=None, virtual=False, tag_ids=None)[source]

Bases: object

Represents a SpiNNaker chip with a number of cores, an amount of SDRAM shared between the cores, and a router. The chip is iterable over the processors, yielding (processor_id, processor) where:

  • processor_id is the ID of a processor
  • processor is the processor with processor_id
Parameters:
  • x (int) – the x-coordinate of the chip’s position in the two-dimensional grid of chips
  • y (int) – the y-coordinate of the chip’s position in the two-dimensional grid of chips
  • processors (iterable(Processor)) – an iterable of processor objects
  • router (Router) – a router for the chip
  • sdram (SDRAM) – an SDRAM for the chip
  • ip_address (str) – the IP address of the chip or None if no Ethernet attached
  • virtual (bool) – boolean which defines if this chip is a virtual one
  • tag_ids (iterable(int) or None) – IDs to identify the chip for SDP can be empty to define no tags or None to allocate tag automatically based on if there is an ip_address
  • nearest_ethernet_x (int or None) – the nearest Ethernet x coordinate
  • nearest_ethernet_y (int or None) – the nearest Ethernet y coordinate
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If processors contains any two processors with the same processor_id

DEFAULT_PROCESSORS = {0: [CPU: id=0, clock_speed=200 MHz, monitor=True], 1: [CPU: id=1, clock_speed=200 MHz, monitor=False], 2: [CPU: id=2, clock_speed=200 MHz, monitor=False], 3: [CPU: id=3, clock_speed=200 MHz, monitor=False], 4: [CPU: id=4, clock_speed=200 MHz, monitor=False], 5: [CPU: id=5, clock_speed=200 MHz, monitor=False], 6: [CPU: id=6, clock_speed=200 MHz, monitor=False], 7: [CPU: id=7, clock_speed=200 MHz, monitor=False], 8: [CPU: id=8, clock_speed=200 MHz, monitor=False], 9: [CPU: id=9, clock_speed=200 MHz, monitor=False], 10: [CPU: id=10, clock_speed=200 MHz, monitor=False], 11: [CPU: id=11, clock_speed=200 MHz, monitor=False], 12: [CPU: id=12, clock_speed=200 MHz, monitor=False], 13: [CPU: id=13, clock_speed=200 MHz, monitor=False], 14: [CPU: id=14, clock_speed=200 MHz, monitor=False], 15: [CPU: id=15, clock_speed=200 MHz, monitor=False], 16: [CPU: id=16, clock_speed=200 MHz, monitor=False], 17: [CPU: id=17, clock_speed=200 MHz, monitor=False]}
IPTAG_IDS = OrderedSet([1, 2, 3, 4, 5, 6, 7])
static default_processors()[source]
get_first_none_monitor_processor()[source]

Get the first processor in the list which is not a monitor core

Returns:a processor
get_processor_with_id(processor_id)[source]

Return the processor with the specified ID or None if the processor does not exist.

Parameters:processor_id (int) – the ID of the processor to return
Returns:the processor with the specified ID, or None if no such processor
Return type:Processor
Raises:None – does not raise any known exceptions
ip_address

The IP address of the chip

Returns:IP address of the chip, or None if there is no Ethernet connected to the chip
Return type:str
Raises:None – does not raise any known exceptions
is_processor_with_id(processor_id)[source]

Determines if a processor with the given ID exists in the chip. Also implemented as __contains__(processor_id)

Parameters:processor_id (int) – the processor ID to check for
Returns:Whether the processor with the given ID exists
Return type:bool
Raises:None – does not raise any known exceptions
n_processors

The total number of processors

n_user_processors

The total number of processors that are not monitors

nearest_ethernet_x

The x coordinate of the nearest Ethernet chip

Returns:the x coordinate of the nearest Ethernet chip
Return type:int
Raises:None – does not raise any known exceptions
nearest_ethernet_y

The y coordinate of the nearest Ethernet chip

Returns:the y coordinate of the nearest Ethernet chip
Return type:int
Raises:None – does not raise any known exceptions
processors

An iterable of available processors

Returns:iterable of processors
Return type:iterable(Processor)
Raises:None – does not raise any known exceptions
router

The router object associated with the chip

Returns:router associated with the chip
Return type:Router
Raises:None – does not raise any known exceptions
sdram

The SDRAM associated with the chip

Returns:SDRAM associated with the chip
Return type:SDRAM
Raises:None – does not raise any known exceptions
tag_ids

The tag IDs supported by this chip

Returns:the set of IDs.
Raises:None – this method does not raise any exception
virtual

Boolean which defines if the chip is virtual or not

Returns:if the chip is virtual
Return type:boolean
Raises:None – this method does not raise any known exceptions
x

The x-coordinate of the chip in the two-dimensional grid of chips

Returns:the x-coordinate of the chip
Return type:int
Raises:None – does not raise any known exceptions
y

The y-coordinate of the chip in the two-dimensional grid of chips

Returns:the y-coordinate of the chip
Return type:int
Raises:None – does not raise any known exceptions
class spinn_machine.CoreSubset(x, y, processor_ids)[source]

Bases: object

Represents a subset of the cores on a SpiNNaker chip.

Parameters:
  • x (int) – The x-coordinate of the chip
  • y (int) – The y-coordinate of the chip
  • processor_ids (iterable(int)) – The processor IDs on the chip
add_processor(processor_id)[source]

Adds a processor ID to this subset

Parameters:processor_id (int) – A processor ID
Returns:Nothing is returned
Return type:None
intersect(other)[source]

Returns a new CoreSubset which is an intersect of this and the other.

Parameters:other (spinn_machine.CoreSubset) – A second CoreSubset with possibly overlapping cores
Returns:A new CoreSubset with any overlap
Return type:spinn_machine.CoreSubset
processor_ids

The subset of processor IDs on the chip

Returns:An iterable of processor IDs
Return type:iterable(int)
x

The x-coordinate of the chip

Returns:The x-coordinate
Return type:int
y

The y-coordinate of the chip

Returns:The y-coordinate
Return type:int
class spinn_machine.CoreSubsets(core_subsets=None)[source]

Bases: object

Represents a group of CoreSubsets, with a maximum of one per SpiNNaker chip.

Parameters:core_subsets (iterable(CoreSubset)) – The cores for each desired chip
add_core_subset(core_subset)[source]

Add a core subset to the set

Parameters:core_subset (spinn_machine.CoreSubset) – The core subset to add
Return type:None
add_core_subsets(core_subsets)[source]

Merges a core subsets into this one.

Parameters:core_subsets – the core subsets to add
Return type:None
add_processor(x, y, processor_id)[source]

Add a processor on a given chip to the set.

Parameters:
  • x (int) – The x-coordinate of the chip
  • y (int) – The y-coordinate of the chip
  • processor_id (int) – A processor ID
Return type:

None

core_subsets

The one-per-chip subsets.

Returns:Iterable of core subsets
Return type:iterable(spinn_machine.CoreSubset)
get_core_subset_for_chip(x, y)[source]

Get the core subset for a chip.

Parameters:
  • x (int) – The x-coordinate of a chip
  • y (int) – The y-coordinate of a chip
Returns:

The core subset of a chip, which will be empty if not added

Return type:

CoreSubset

intersect(other)[source]

Returns a new CoreSubsets which is an intersect of this and the other.

Parameters:other (spinn_machine.CoreSubsets) – A second CoreSubsets with possibly overlapping cores
Returns:A new CoreSubsets with any overlap
Return type:spinn_machine.CoreSubsets
is_chip(x, y)[source]

Determine if the chip with coordinates (x, y) is in the subset

Parameters:
  • x (int) – The x-coordinate of a chip
  • y (int) – The y-coordinate of a chip
Returns:

True if the chip with coordinates (x, y) is in the subset

Return type:

bool

is_core(x, y, processor_id)[source]

Determine if there is a chip with coordinates (x, y) in the subset, which has a core with the given ID in the subset

Parameters:
  • x (int) – The x-coordinate of a chip
  • y (int) – The y-coordinate of a chip
  • processor_id (int) – The ID of a core
Returns:

Whether there is a chip with coordinates (x, y) in the subset, which has a core with the given ID in the subset

values()[source]
class spinn_machine.FixedRouteEntry(processor_ids, link_ids)[source]

Bases: object

Describes an entry in a SpiNNaker chip’s fixed route routing table.

The destination link IDs

Returns:An iterable of link IDs
Return type:iterable(int)
processor_ids

The destination processor IDs

Returns:An iterable of processor IDs
Return type:iterable(int)

Bases: object

Represents a directional link between SpiNNaker chips in the machine

Parameters:
  • source_x (int) – The x-coordinate of the source chip of the link
  • source_y (int) – The y-coordinate of the source chip of the link
  • source_link_id (int) – The ID of the link in the source chip
  • destination_x (int) – The x-coordinate of the destination chip of the link
  • destination_y (int) – The y-coordinate of the destination chip of the link
Raises:

None – No known exceptions are raised

destination_x

The x-coordinate of the destination chip of this link

Returns:The x-coordinate
Return type:int
destination_y

The y-coordinate of the destination chip of this link

Returns:The y-coordinate
Return type:int

The ID of the link on the source chip

Returns:The link ID
Return type:int
source_x

The x-coordinate of the source chip of this link

Returns:The x-coordinate
Return type:int
source_y

The y-coordinate of the source chip of this link

Returns:The y-coordinate
Return type:int
class spinn_machine.Machine(width, height, chips=None, origin=None)[source]

Bases: object

A representation of a SpiNNaker Machine with a number of Chips. Machine is also iterable, providing ((x, y), chip) where:

  • x is the x-coordinate of a chip
  • y is the y-coordinate of a chip
  • chip is the chip with the given x, y coordinates

Creates an abstract machine that must be superclassed by wrap type.

Use machine_fatcory methods to determine the correct machine class

Parameters:
  • width – The width of the machine excluding any virtual chips
  • height – The height of the machine excluding any virtual chips
  • chips (iterable of Chip) – An iterable of chips in the machine
  • origin – Extra information about how this machine was created to be used in the str method. Example “Virtual” or “Json”
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If any two chips have the same x and y coordinates

BOARD_48_CHIPS = [(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7)]
BOARD_VERSION_FOR_48_CHIPS = [4, 5]
BOARD_VERSION_FOR_4_CHIPS = [2, 3]
MAX_BANDWIDTH_PER_ETHERNET_CONNECTED_CHIP = 2560
MAX_CHIPS_PER_48_BOARD = 48
MAX_CHIPS_PER_4_CHIP_BOARD = 4
MAX_CHIP_X_ID_ON_ONE_BOARD = 7
MAX_CHIP_Y_ID_ON_ONE_BOARD = 7
MAX_CORES_PER_CHIP = 18
SIZE_X_OF_ONE_BOARD = 8
SIZE_Y_OF_ONE_BOARD = 8
add_chip(chip)[source]

Add a chip to the machine

Parameters:chip (Chip) – The chip to add to the machine
Returns:Nothing is returned
Return type:None
Raises:spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If a chip with the same x and y coordinates already exists
add_chips(chips)[source]

Add some chips to the machine

Parameters:chips (iterable(Chip)) – an iterable of chips
Returns:Nothing is returned
Return type:None
Raises:spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If a chip with the same x and y coordinates as one being added already exists

Add FPGA links that are on a given machine depending on the version of the board.

Parameters:version_no – which version of board to use

Add SpiNNaker links that are on a given machine depending on the version of the board.

Parameters:version_no – which version of board to use
add_virtual_chip(chip)[source]
boot_chip

The chip used to boot the machine

Return type:~py:class:spinn_machine.Chip
chip_coordinates

An iterable of chip coordinates in the machine

Returns:An iterable of chip coordinates
Return type:iterable(int,int)
chips

An iterable of chips in the machine

Returns:An iterable of chips
Return type:iterable(Chip)
Raises:None – does not raise any known exceptions

Get a string detailing the number of cores and links

Return type:str
ethernet_connected_chips

The chips in the machine that have an Ethernet connection

Returns:An iterable of chips
Return type:iterable of Chip
get_chip_at(x, y)[source]

Get the chip at a specific (x, y) location. Also implemented as __getitem__((x, y))

Parameters:
  • x (int) – the x-coordinate of the requested chip
  • y (int) – the y-coordinate of the requested chip
Returns:

the chip at the specified location, or None if no such chip

Return type:

Chip

Raises:

None – does not raise any known exceptions

get_chips_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the actual chips on the board with this ethernet. Including the Ethernet chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the chips on this board.

Get the number of cores and links from the machine

Links are assumed to be bidirectional so the total links counted is half of the unidirectional links found.

Spinnaker and fpga links are not included.

Returns:tuple of (n_cores, n_links)
Return type:tuple(int,int)
get_down_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y) coordinates of the down chips on the board with this ethernet.

Note the Ethernet chip itself can not be missing if validated

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the (x, y) of the down chips on this board.

get_existing_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y)s of actual chips on the board with this ethernet. Including the Ethernet chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the (x,y)s of chips on this board.

get_existing_xys_on_board(chip)[source]

Get the chips that are on the same board as the given chip

Parameters:chip – The chip to find other chips on the same board as
Returns:An iterable of (x, y) coordinates of chips on the same board
Return type:iterable(tuple(int,int))

Get an FPGA link data item that corresponds to the FPGA and FPGA link for a given board address.

Parameters:
Return type:

FPGALinkData

Returns:

the given FPGA link object or None if no such link

get_global_xy(local_x, local_y, ethernet_x, ethernet_y)[source]

Converts the local x and y coordinates into global x,y coordinates, under the assumption that they are on the board with local 0,0 at ethernet_x, ethernet_y

This method does take wrap-arounds into consideration.

GIGO: This method does not check if input parameters make sense, nor does it check if there is a chip at the resulting global x,y

Parameters:
  • local_x – A valid local x coordinate for a chip
  • local_y – A valid local y coordinate for a chip
  • ethernet_x – The global ethernet x for the board the chip is on
  • ethernet_y – The global ethernet y for the board the chip is on
Returns:

global (x,y) coordinates of the chip

get_local_xy(chip)[source]

Converts the x and y coordinates into the local coordinates on the board as if the ethernet was at position 0,0

This method does take wrap-arounds into consideration.

This method assumes that chip is on the machine or is a copy of a chip on the machine

Parameters:chip – A Chip in the machine
Returns:Local (x, y) coordinates.

Get a SpiNNaker link with a given ID

Parameters:
  • spinnaker_link_id (int) – The ID of the link
  • board_address (str or None) – the board address that this SpiNNaker link is associated with
Returns:

The SpiNNaker link data or None if no link

Return type:

SpinnakerLinkData

get_vector(source, destination)[source]

Get mathematical shortest vector (x, y, z) from source to destination

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a none wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

Use the same algorithm as vector_length using the best x, y pair as minimize(x, y, 0)

Parameters:
  • source ((int, int)) – (x,y) coordinates of the source chip
  • destination – (x,y) coordinates of the destination chip
Returns:

get_vector_length(source, destination)[source]

Get the mathematical length of the shortest vector (x, y, z) from source to destination

Use the same algorithm as vector to find the best x, y pair but then is optimised to directly calculate length

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a none wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

On full wrap-around machines (before minization) the vectors can have any of the 4 combinations of possitive and negative x and y The possitive one is: destination - source % dimension The negative one is: possitive - dimension If source is less than dimension the negative one is the wrap around If destination is greater than source the possitive one wraps

One no wrap or part wrap boards the x/y that does not wrap is just destination - source

The length of vectors where both x and y have the same sign will be max(abs(x), abs(y)) As the z direction can be used in minization The length of vectors where x and y have opposite signs will be abs(x) and abs(y) as these are alread minimum so z is not used.

GIGO: This method does not check if input parameters make sense,

Parameters:
  • source ((int, int)) – (x,y) coordinates of the source chip
  • destination – (x,y) coordinates of the destination chip
Returns:

The distantance in steps

get_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the potential x,y locations of all the chips on the board with this ethernet. Including the Ethernet chip itself.

Wrap-arounds are handled as appropriate.

Note: This method does not check if the chip actually exists as is intended to be called to create the chips.

Warning: GIGO! This methods assumes that ethernet_x and ethernet_y are the local 0,0 of an existing board, within the width and height of the machine.

Parameters:
  • ethernet_x – The x coordinate of a (local 0,0) legal ethernet chip
  • ethernet_y – The y coordinate of a (local 0,0) legal ethernet chip
Returns:

Yields the (x, y) coordinates of all the potential chips on this board.

height

The height to the machine ignoring virtual chips

Returns:The height to the machine ignoring virtual chips
Return type:int
is_chip_at(x, y)[source]

Determine if a chip exists at the given coordinates. Also implemented as __contains__((x, y))

Parameters:
  • x (int) – x location of the chip to test for existence
  • y (int) – y location of the chip to test for existence
Returns:

True if the chip exists, False otherwise

Return type:

bool

Raises:

None – does not raise any known exceptions

Determine if a link exists at the given coordinates

Parameters:
  • x (int) – The x location of the chip to test the link of
  • y (int) – The y location of the chip to test the link of
  • link (int) – The link to test the existence of
local_xys

Provides a list of local (x,y) values for a perfect board on this machine.

Local (x,y)s never include wrap-arounds.

Note: no check is done to see if any board in the machine actually has a chip with this local x, y

Returns:a list of (x,y) coordinates
max_chip_x

The maximum x-coordinate of any chip in the board

Returns:The maximum x-coordinate
Return type:int
max_chip_y

The maximum y-coordinate of any chip in the board

Returns:The maximum y-coordinate
Return type:int
maximum_user_cores_on_chip

The maximum number of user cores on any chip

multiple_48_chip_boards()[source]

Checks that the width and height correspond to the expected size for a multi-board machine made up of more than one 48 chip board.

The assumption is that any size machine can be supported but that only ones with an expected 48 chip board size can have more than one ethernet chip.

Returns:True if this machine can have multiple 48 chip boards
n_chips

The set of SpiNNaker links in the machine

Returns:An iterable of SpiNNaker links
Return type:iterable of SpinnakerLinkData
total_available_user_cores

The total number of cores on the machine which are not monitor cores

Returns:total
Return type:int
total_cores

The total number of cores on the machine, including monitors

Returns:total
Return type:int
unreachable_incoming_chips()[source]

Detects chips that are not reachable from any of their neighbours

Current implementation does NOT deal with group of unreachable chips

Returns:List (hopefully empty) if the (x,y) cooridinates of unreachable chips.
unreachable_incoming_local_chips()[source]

Detects chips that are not reachable from any of their LOCAL neighbours

Current implementation does NOT deal with group of unreachable chips

Returns:List (hopefully empty) if the (x,y) cooridinates of unreachable chips.
unreachable_outgoing_chips()[source]

Detects chips that can not reach any of their neighbours

Current implementation does NOT deal with group of unreachable chips

Returns:List (hopefully empty) if the (x,y) cooridinates of unreachable chips.
unreachable_outgoing_local_chips()[source]

Detects chips that can not reach any of their LOCAL neighbours

Current implementation does NOT deal with group of unreachable chips

Returns:List (hopefully empty) if the (x,y) cooridinates of unreachable chips.
validate()[source]

Validates the machine and raises an exception in unexpected conditions.

Assumes that at the time this is called all chips are on the board.

This allows the checks to be avoided when creating a virtual machine (Except of course in testing)

An Error is raised if there is a chip with a x outside of the range 0 to width -1 (except for virtual ones) An Error is raised if there is a chip with a y outside of the range 0 to height -1 (except for virtual ones) An Error is raise if there is no chip at the declared ethernet x and y An Error is raised if an ethernet chip is not at a local 0,0 An Error is raised if there is no ethernet chip is at 0,0 An Error is raised if this is a unexpected multiple board situation

virtual_chips
width

The width to the machine ignoring virtual chips

Returns:The width to the machine ignoring virtual chips
Return type:int
wrap

String to represent the type of wrap.

Returns:Short string for type of wrap

Get the potential x,y location of the chip reached over this link.

Wrap-arounds are handled as appropriate.

Note: This method does not check if either chip source or destination actually exists as is intended to be called to create the links.

It is the callers responsibility to check the validity of this call before making it or the validity of the result.

Warning: GIGO! This methods assumes that x and y are within the width and height of the machine, and that the link goes to another chip on the machine.

On machine without full wrap-around it is possible that this method generates x,y values that fall outside of the legal values including negative values, x = width or y = height.

Parameters:
  • x – The x coordinate of a chip that will exist on the machine
  • y – The y coordinate of a chip that will exist on the machine
  • link – The link to another chip that could exist on the machine
Returns:

x and y coordinates of the chip over that link if it is valid or some fictional x,y if not.

class spinn_machine.MulticastRoutingEntry(routing_entry_key, mask, processor_ids=None, link_ids=None, defaultable=False, spinnaker_route=None)[source]

Bases: object

Represents an entry in a SpiNNaker chip’s multicast routing table

Parameters:
  • routing_entry_key (int) – The routing key_combo
  • mask (int) – The route key_combo mask
  • processor_ids (iterable(int)) – The destination processor IDs
  • link_ids (iterable(int)) – The destination link IDs
  • defaultable (bool) – if this entry is defaultable (it receives packets from its directly opposite route position)
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException

  • If processor_ids contains the same ID more than once
  • If link_ids contains the same ID more than once

defaultable

Whether this entry is a defaultable entry

Returns:the bool that represents if a entry is defaultable or not
Return type:bool

The destination link IDs

Returns:An iterable of link IDs
Return type:iterable(int)
mask

The routing mask

Returns:The routing mask
Return type:int
merge(other_entry)[source]

Merges together two multicast routing entries. The entry to merge must have the same key and mask. The merge will join the processor IDs and link IDs from both the entries. This could be used to add a new destination to an existing route in a routing table. It is also possible to use the add (+) operator or the or (|) operator with the same effect.

Parameters:other_entry (MulticastRoutingEntry) – The multicast entry to merge with this entry
Returns:A new multicast routing entry with merged destinations
Return type:MulticastRoutingEntry
Raises:spinn_machine.exceptions.SpinnMachineInvalidParameterException – If the key and mask of the other entry do not match
processor_ids

The destination processor IDs

Returns:An iterable of processor IDs
Return type:iterable(int)
routing_entry_key

The routing key

Returns:The routing key
Return type:int
spinnaker_route
class spinn_machine.Processor(processor_id, clock_speed=200000000, is_monitor=False, dtcm_available=65536)[source]

Bases: object

A processor object included in a SpiNNaker chip

Parameters:
  • processor_id (int) – ID of the processor in the chip
  • clock_speed (int) – The number of CPU cycles per second of the processor
  • is_monitor (bool) – Determines if the processor is considered the monitor processor, and so should not be otherwise allocated
  • dtcm_available (int) – Data Tightly Coupled Memory available
Raises:

spinn_machine.exceptions.SpinnMachineInvalidParameterException – If the clock speed is negative

CLOCK_SPEED = 200000000
DTCM_AVAILABLE = 65536
clock_speed

The clock speed of the processor in cycles per second

Returns:The clock speed in cycles per second
Return type:int
clone_as_system_processor()[source]

Creates a clone of this processor but changing it to a system processor.

Returns:A new Processor with the same properties INCLUDING the ID except now set as a System processor
Return type:Processor
cpu_cycles_available

The number of CPU cycles available from this processor per ms

Returns:the number of CPU cycles available on this processor
Return type:int
dtcm_available

The amount of DTCM available on this processor

Returns:the amount of DTCM available on this processor
Return type:int
static factory(processor_id, is_monitor=False)[source]
is_monitor

Determines if the processor is the monitor, and therefore not to be allocated

Warning

Currently rejection processors are also marked as monitors.

Returns:True if the processor is the monitor, False otherwise
Return type:bool
processor_id

The ID of the processor

Returns:ID of the processor
Return type:int
class spinn_machine.Router(links, emergency_routing_enabled=False, clock_speed=157286400, n_available_multicast_entries=1024)[source]

Bases: object

Represents a router of a chip, with a set of available links. The router is iterable over the links, providing (source_link_id, link) where:

  • source_link_id is the ID of a link
  • link is the link with ID source_link_id
Parameters:
  • links (iterable(Link)) – iterable of links
  • emergency_routing_enabled (bool) – Determines if the router emergency routing is operating
  • clock_speed (int) – The router clock speed in cycles per second
  • n_available_multicast_entries (int) – The number of entries available in the routing table
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If any two links have the same source_link_id

MAX_CORES_PER_ROUTER = 18
ROUTER_DEFAULT_AVAILABLE_ENTRIES = 1024
ROUTER_DEFAULT_CLOCK_SPEED = 157286400

Add a link to the router of the chip

Parameters:link (spinn_machine.Link) – The link to be added
Returns:Nothing is returned
Return type:None
Raises:spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If another link already exists with the same source_link_id
clock_speed

The clock speed of the router in cycles per second

Returns:The clock speed in cycles per second
Return type:int
Raises:None – does not raise any known exceptions
static convert_routing_table_entry_to_spinnaker_route(routing_table_entry)[source]

Convert a routing table entry represented in software to a binary routing table entry usable on the machine

Parameters:routing_table_entry (MulticastRoutingEntry) – The entry to convert
Return type:int
static convert_spinnaker_route_to_routing_ids(route)[source]

Convert a binary routing table entry usable on the machine to lists of route IDs usable in a routing table entry represented in software.

Parameters:route (int) – The routing table entry
Returns:The list of processor IDs, and the list of link IDs.
Return type:tuple(list(int), list(int))
emergency_routing_enabled

Indicator of whether emergency routing is enabled

Returns:True if emergency routing is enabled, False otherwise
Return type:bool
Raises:None – does not raise any known exceptions

Get the link with the given ID, or None if no such link. Also implemented as __getitem__(source_link_id)

Parameters:source_link_id (int) – The ID of the link to find
Returns:The link, or None if no such link
Return type:Link
Raises:None – No known exceptions are raised
get_neighbouring_chips_coords()[source]

Utility method to convert links into x and y coordinates

Returns:iterable list of destination coordinates in x and y dict
Return type:iterable(dict(str,int))

Determine if there is a link with ID source_link_id. Also implemented as __contains__(source_link_id)

Parameters:source_link_id (int) – The ID of the link to find
Returns:True if there is a link with the given ID, False otherwise
Return type:bool
Raises:None – No known exceptions are raised

The available links of this router

Returns:an iterable of available links
Return type:iterable(Link)
Raises:None – does not raise any known exceptions
n_available_multicast_entries

The number of available multicast entries in the routing tables

Returns:The number of available entries
Return type:int
Raises:None – does not raise any known exceptions
static opposite(link_id)[source]

Given a valid link_id this method returns its opposite.

GIGO: this method assumes the input is valid. No verfication is done

Parameters:link_id – A valid link_id
Returns:The link_id for the opposite direction
class spinn_machine.SDRAM(size=122683392)[source]

Bases: object

Represents the properties of the SDRAM of a chip in the machine

Parameters:size (int) – the space available in SDRAM
DEFAULT_SDRAM_BYTES = 122683392
max_sdram_found = 0
size

The SDRAM available for user applications

Returns:The space available in bytes
Return type:int
class spinn_machine.SpiNNakerTriadGeometry(triad_width, triad_height, roots, centre)[source]

Bases: object

Geometry of a “triad” of SpiNNaker boards

The geometry is defined by the arguments to the constructor; the standard arrangement can be obtained from get_spinn5_geometry

Note that the geometry defines what a Triad is in terms of the dimensions of a triad and where the Ethernet chips occur in the triad

Parameters:
  • triad_width (int) – width of a triad in chips
  • triad_height (int) – height of a triad in chips
  • roots (list of (int, int)) – locations of the Ethernet connected chips
  • centre ((float, float)) – the distance from each Ethernet chip to the centre of the hexagon
get_ethernet_chip_coordinates(x, y, width, height, root_x=0, root_y=0)[source]

Get the coordinates of a chip’s local Ethernet connected chip according to this triad geometry object

Warning

local_eth_coord() will always produce the coordinates of the Ethernet-connected SpiNNaker chip on the same SpiNN-5 board as the supplied chip. This chip may not actually be working.

Parameters:
  • x (int) – x-coordinate of the chip to find the nearest Ethernet of
  • y (int) – y-coordinate of the chip to find the nearest Ethernet of
  • width (int) – width of the SpiNNaker machine (must be a multiple of the triad width of this geometry)
  • height (int) – height of the SpiNNaker machine (must be a multiple of the triad height of this geometry)
  • root_x (int) – x-coordinate of the boot chip (default 0, 0)
  • root_y (int) – y-coordinate of the boot chip (default 0, 0)
Returns:

The coordinates of the closest Ethernet chip

Return type:

(int, int)

get_local_chip_coordinate(x, y, root_x=0, root_y=0)[source]

Get the coordinates of a chip on its board of a multi-board system relative to the Ethernet chip of the board.

Note

This function assumes the system is constructed from SpiNN-5 boards

Parameters:
  • x (int) – The x-coordinate of the chip to find the location of
  • y (int) – The y-coordinate of the chip to find the location of
  • root_x (int) – The x-coordinate of the boot chip (default 0, 0)
  • root_y (int) – The y-coordinate of the boot chip (default 0, 0)
Returns:

the coordinates of the chip relative to its board

Return type:

(int, int)

get_potential_ethernet_chips(width, height)[source]

Get the coordinates of chips that should be Ethernet chips

Parameters:
  • width – The width of the machine to find the chips in
  • height – The height of the machine to find the chips in
static get_spinn5_geometry()[source]

Get the geometry object for a SpiNN-5 arrangement of boards

Returns:a SpiNNakerTriadGeometry object.
spinn5_triad_geometry = None
spinn_machine.virtual_machine(width=None, height=None, with_wrap_arounds=None, version=None, n_cpus_per_chip=18, with_monitors=True, sdram_per_chip=122683392, down_chips=None, down_cores=None, down_links=None, router_entries_per_chip=1024, validate=True)[source]
Parameters:
  • width (int) – the width of the virtual machine in chips
  • height (int) – the height of the virtual machine in chips
  • with_wrap_arounds (bool) –

    bool defining if wrap around links exist If set a board with the requested wrap around is created regardless of the board size.

    In None the wrap around will be auto detected by machine_factory

    Note: Use either with_wrap_arounds or version but not both

  • version (int) – the version ID of a board; if None, a machine is created with the correct dimensions, otherwise the machine will be a single board of the given version.
  • n_cpus_per_chip (int) – The number of CPUs to put on each chip
  • with_monitors (bool) – True if CPU 0 should be marked as a monitor
  • sdram_per_chip (int or None) – The amount of SDRAM to give to each chip
  • router_entries_per_chip (int) – the number of entries to each router
  • validate (bool) – if True will call the machine validate function
spinn_machine.virtual_submachine(machine, ethernet_chip)[source]

Creates a virtual machine based off a real machine but just with the system resources of a single board (identified by its ethernet chip).

Parameters:
  • machine – The machine to create the virtual machine from. May be a virtual machine. May be a single-board machine.
  • ethernet_chip – The chip that can talk to the board’s ethernet.
spinn_machine.machine_from_chips(chips)[source]

Create a machine with the assumed wrap-around based on the sizes.

The size of the machine is calculated from the list of chips.

Parameters:chips – Full list of all chips on this machine. Or at least a list which includes a chip with the highest X and one with the highest Y (excluding any virtual chips)
Returns:A subclass of Machine
spinn_machine.machine_from_size(width, height, chips=None, origin=None)[source]

Create a machine with the assumed wrap-around based on the sizes.

This could include a machine with no wrap-arounds, only vertical ones, only horizontal ones or both.

Note: If the sizes do not match the ones for a known wrap-around machine, no wrap-arounds is assumed.

Parameters:
  • width – The width of the machine excluding any virtual chips
  • height – The height of the machine excluding any virtual chips
  • chips – Any chips to be added.
  • origin – Extra information about how this machine was created to be used in the str method. Example “Virtual” or “Json”
Returns:

A subclass of Machine